- 54
- 0
Здравствуйте форумчане, у меня проблемка.
При зажигании костра одним игроком , другие игроки не видят что он зажег.
Вот код:
Прошу подсказать в чем проблемка, заранее спасибо.
При зажигании костра одним игроком , другие игроки не видят что он зажег.
Вот код:
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int metadata, float what, float these, float are) {
TileEntity tileEntity = world.getTileEntity(x, y, z);
if(tileEntity.getWorldObj() != null) {
if(player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() == LDItems.item_match) {
if(player.getCurrentEquippedItem().getItemDamage() == player.getCurrentEquippedItem().getMaxDamage()) {
--player.getCurrentEquippedItem().stackSize;
} else {
player.getCurrentEquippedItem().getItem().setDamage(player.getCurrentEquippedItem(), player.getCurrentEquippedItem().getItemDamage() + 1);
}
if(!((LDTileEntityBlockBonfire)tileEntity).getIsBurning()) {
((LDTileEntityBlockBonfire)tileEntity).setIsBurning(true);
this.setLightLevel(1.0F);
this.setLightOpacity(5);
return true;
} else {
((LDTileEntityBlockBonfire)tileEntity).setIsBurning(false);
this.setLightLevel(0.0F);
this.setLightOpacity(0);
return true;
}
} else {
((LDTileEntityBlockBonfire)tileEntity).setIsBurning(false);
this.setLightLevel(0.0F);
this.setLightOpacity(0);
return true;
}
} else {
return false;
}
}
public void updateTick(World par1World, int x, int y, int z, Random random) {
TileEntity tileEntity = par1World.getTileEntity(x, y, z);
if(tileEntity.getWorldObj() != null && ((LDTileEntityBlockBonfire)tileEntity).getIsBurning()) {
((LDTileEntityBlockBonfire)tileEntity).setIsBurning(false);
this.setLightLevel(0.0F);
this.setLightOpacity(0);
}
}
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World par1World, int x, int y, int z, Random random) {
TileEntity tileEntity = par1World.getTileEntity(x, y, z);
if(tileEntity.getWorldObj() != null && ((LDTileEntityBlockBonfire)tileEntity).getIsBurning()) {
par1World.spawnParticle("flame", (double)((float)x + 0.5F), (double)((float)y + 0.5F), (double)((float)z + 0.5F), 0.0D, 0.0D, 0.0D);
par1World.spawnParticle("flame", (double)((float)x + 0.7F), (double)((float)y + 0.4F), (double)((float)z + 0.7F), 0.0D, 0.0D, 0.0D);
par1World.spawnParticle("flame", (double)((float)x + 0.4F), (double)((float)y + 0.4F), (double)((float)z + 0.4F), 0.0D, 0.0D, 0.0D);
par1World.spawnParticle("flame", (double)((float)x + 0.4F), (double)((float)y + 0.4F), (double)((float)z + 0.7F), 0.0D, 0.0D, 0.0D);
par1World.spawnParticle("flame", (double)((float)x + 0.7F), (double)((float)y + 0.4F), (double)((float)z + 0.4F), 0.0D, 0.0D, 0.0D);
par1World.spawnParticle("smoke", (double)((float)x + 0.5F), (double)((float)y + 0.75F), (double)((float)z + 0.5F), 0.0D, 0.0D, 0.0D);
par1World.spawnParticle("largesmoke", (double)((float)x + 0.5F), (double)((float)y + 0.85F), (double)((float)z + 0.5F), 0.0D, 0.0D, 0.0D);
}
}
public void onEntityCollidedWithBlock(World par1World, int x, int y, int z, Entity par5Entity) {
TileEntity tileEntity = par1World.getTileEntity(x, y, z);
if(tileEntity.getWorldObj() != null && ((LDTileEntityBlockBonfire)tileEntity).getIsBurning()) {
par5Entity.attackEntityFrom(DamageSource.inFire, 1.0F);
}
}
public TileEntity createNewTileEntity(World arg0, int arg1) {
return new LDTileEntityBlockBonfire();
}
TileEntity tileEntity = world.getTileEntity(x, y, z);
if(tileEntity.getWorldObj() != null) {
if(player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() == LDItems.item_match) {
if(player.getCurrentEquippedItem().getItemDamage() == player.getCurrentEquippedItem().getMaxDamage()) {
--player.getCurrentEquippedItem().stackSize;
} else {
player.getCurrentEquippedItem().getItem().setDamage(player.getCurrentEquippedItem(), player.getCurrentEquippedItem().getItemDamage() + 1);
}
if(!((LDTileEntityBlockBonfire)tileEntity).getIsBurning()) {
((LDTileEntityBlockBonfire)tileEntity).setIsBurning(true);
this.setLightLevel(1.0F);
this.setLightOpacity(5);
return true;
} else {
((LDTileEntityBlockBonfire)tileEntity).setIsBurning(false);
this.setLightLevel(0.0F);
this.setLightOpacity(0);
return true;
}
} else {
((LDTileEntityBlockBonfire)tileEntity).setIsBurning(false);
this.setLightLevel(0.0F);
this.setLightOpacity(0);
return true;
}
} else {
return false;
}
}
public void updateTick(World par1World, int x, int y, int z, Random random) {
TileEntity tileEntity = par1World.getTileEntity(x, y, z);
if(tileEntity.getWorldObj() != null && ((LDTileEntityBlockBonfire)tileEntity).getIsBurning()) {
((LDTileEntityBlockBonfire)tileEntity).setIsBurning(false);
this.setLightLevel(0.0F);
this.setLightOpacity(0);
}
}
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World par1World, int x, int y, int z, Random random) {
TileEntity tileEntity = par1World.getTileEntity(x, y, z);
if(tileEntity.getWorldObj() != null && ((LDTileEntityBlockBonfire)tileEntity).getIsBurning()) {
par1World.spawnParticle("flame", (double)((float)x + 0.5F), (double)((float)y + 0.5F), (double)((float)z + 0.5F), 0.0D, 0.0D, 0.0D);
par1World.spawnParticle("flame", (double)((float)x + 0.7F), (double)((float)y + 0.4F), (double)((float)z + 0.7F), 0.0D, 0.0D, 0.0D);
par1World.spawnParticle("flame", (double)((float)x + 0.4F), (double)((float)y + 0.4F), (double)((float)z + 0.4F), 0.0D, 0.0D, 0.0D);
par1World.spawnParticle("flame", (double)((float)x + 0.4F), (double)((float)y + 0.4F), (double)((float)z + 0.7F), 0.0D, 0.0D, 0.0D);
par1World.spawnParticle("flame", (double)((float)x + 0.7F), (double)((float)y + 0.4F), (double)((float)z + 0.4F), 0.0D, 0.0D, 0.0D);
par1World.spawnParticle("smoke", (double)((float)x + 0.5F), (double)((float)y + 0.75F), (double)((float)z + 0.5F), 0.0D, 0.0D, 0.0D);
par1World.spawnParticle("largesmoke", (double)((float)x + 0.5F), (double)((float)y + 0.85F), (double)((float)z + 0.5F), 0.0D, 0.0D, 0.0D);
}
}
public void onEntityCollidedWithBlock(World par1World, int x, int y, int z, Entity par5Entity) {
TileEntity tileEntity = par1World.getTileEntity(x, y, z);
if(tileEntity.getWorldObj() != null && ((LDTileEntityBlockBonfire)tileEntity).getIsBurning()) {
par5Entity.attackEntityFrom(DamageSource.inFire, 1.0F);
}
}
public TileEntity createNewTileEntity(World arg0, int arg1) {
return new LDTileEntityBlockBonfire();
}
public class LDTileEntityBlockBonfire extends TileEntity {
public boolean burning;
public void readFromNBT(NBTTagCompound par1NBTTagCompound) {
this.burning = par1NBTTagCompound.getBoolean("burning");
}
public void writeToNBT(NBTTagCompound par1NBTTagCompound) {
par1NBTTagCompound.setBoolean("fireTicks", this.burning);
}
public boolean setIsBurning(boolean time) {
return this.burning = time;
}
public boolean getIsBurning() {
return this.burning;
}
}
public boolean burning;
public void readFromNBT(NBTTagCompound par1NBTTagCompound) {
this.burning = par1NBTTagCompound.getBoolean("burning");
}
public void writeToNBT(NBTTagCompound par1NBTTagCompound) {
par1NBTTagCompound.setBoolean("fireTicks", this.burning);
}
public boolean setIsBurning(boolean time) {
return this.burning = time;
}
public boolean getIsBurning() {
return this.burning;
}
}