Made coal and oil generator not randomly appear on even though they're not

This commit is contained in:
Ellpeck 2016-06-11 16:26:51 +02:00
parent 3f00973f28
commit 3dbc31e264
6 changed files with 15 additions and 50 deletions

View file

@ -37,8 +37,6 @@ import java.util.Random;
public class BlockCoalGenerator extends BlockContainerBase{ public class BlockCoalGenerator extends BlockContainerBase{
private static final PropertyInteger META = PropertyInteger.create("meta", 0, 1);
public BlockCoalGenerator(String name){ public BlockCoalGenerator(String name){
super(Material.ROCK, name); super(Material.ROCK, name);
this.setHarvestLevel("pickaxe", 0); this.setHarvestLevel("pickaxe", 0);
@ -57,14 +55,15 @@ public class BlockCoalGenerator extends BlockContainerBase{
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random rand){ public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random rand){
int meta = PosUtil.getMetadata(state); TileEntity tile = world.getTileEntity(pos);
if(tile instanceof TileEntityCoalGenerator){
if(meta == 1){ if(((TileEntityCoalGenerator)tile).currentBurnTime > 0){
for(int i = 0; i < 5; i++){ for(int i = 0; i < 5; i++){
world.spawnParticle(ClientProxy.bulletForMyValentine ? EnumParticleTypes.HEART : EnumParticleTypes.SMOKE_NORMAL, (double)pos.getX()+0.5F, (double)pos.getY()+1.0F, (double)pos.getZ()+0.5F, 0.0D, 0.0D, 0.0D); world.spawnParticle(ClientProxy.bulletForMyValentine ? EnumParticleTypes.HEART : EnumParticleTypes.SMOKE_NORMAL, (double)pos.getX()+0.5F, (double)pos.getY()+1.0F, (double)pos.getZ()+0.5F, 0.0D, 0.0D, 0.0D);
} }
} }
} }
}
@Override @Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack stack, EnumFacing par6, float par7, float par8, float par9){ public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack stack, EnumFacing par6, float par7, float par8, float par9){
@ -83,11 +82,6 @@ public class BlockCoalGenerator extends BlockContainerBase{
return EnumRarity.RARE; return EnumRarity.RARE;
} }
@Override
protected PropertyInteger getMetaProperty(){
return META;
}
@Override @Override
public void breakBlock(World world, BlockPos pos, IBlockState state){ public void breakBlock(World world, BlockPos pos, IBlockState state){
this.dropInventory(world, pos); this.dropInventory(world, pos);

View file

@ -15,6 +15,7 @@ import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase; import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler; import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
import de.ellpeck.actuallyadditions.mod.proxy.ClientProxy; import de.ellpeck.actuallyadditions.mod.proxy.ClientProxy;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityCoalGenerator;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityOilGenerator; import de.ellpeck.actuallyadditions.mod.tile.TileEntityOilGenerator;
import de.ellpeck.actuallyadditions.mod.util.PosUtil; import de.ellpeck.actuallyadditions.mod.util.PosUtil;
import net.minecraft.block.SoundType; import net.minecraft.block.SoundType;
@ -37,8 +38,6 @@ import java.util.Random;
public class BlockOilGenerator extends BlockContainerBase{ public class BlockOilGenerator extends BlockContainerBase{
private static final PropertyInteger META = PropertyInteger.create("meta", 0, 1);
public BlockOilGenerator(String name){ public BlockOilGenerator(String name){
super(Material.ROCK, name); super(Material.ROCK, name);
this.setHarvestLevel("pickaxe", 0); this.setHarvestLevel("pickaxe", 0);
@ -57,12 +56,15 @@ public class BlockOilGenerator extends BlockContainerBase{
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random rand){ public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random rand){
if(PosUtil.getMetadata(state) == 1){ TileEntity tile = world.getTileEntity(pos);
if(tile instanceof TileEntityOilGenerator){
if(((TileEntityOilGenerator)tile).currentBurnTime > 0){
for(int i = 0; i < 5; i++){ for(int i = 0; i < 5; i++){
world.spawnParticle(ClientProxy.bulletForMyValentine ? EnumParticleTypes.HEART : EnumParticleTypes.SMOKE_NORMAL, (double)pos.getX()+0.5F, (double)pos.getY()+1.0F, (double)pos.getZ()+0.5F, 0.0D, 0.0D, 0.0D); world.spawnParticle(ClientProxy.bulletForMyValentine ? EnumParticleTypes.HEART : EnumParticleTypes.SMOKE_NORMAL, (double)pos.getX()+0.5F, (double)pos.getY()+1.0F, (double)pos.getZ()+0.5F, 0.0D, 0.0D, 0.0D);
} }
} }
} }
}
@Override @Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack stack, EnumFacing par6, float par7, float par8, float par9){ public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack stack, EnumFacing par6, float par7, float par8, float par9){
@ -83,11 +85,6 @@ public class BlockOilGenerator extends BlockContainerBase{
return EnumRarity.RARE; return EnumRarity.RARE;
} }
@Override
protected PropertyInteger getMetaProperty(){
return META;
}
@Override @Override
public void breakBlock(World world, BlockPos pos, IBlockState state){ public void breakBlock(World world, BlockPos pos, IBlockState state){
this.dropInventory(world, pos); this.dropInventory(world, pos);

View file

@ -89,15 +89,6 @@ public class TileEntityCoalGenerator extends TileEntityInventoryBase implements
if(flag != this.currentBurnTime > 0){ if(flag != this.currentBurnTime > 0){
this.markDirty(); this.markDirty();
int meta = PosUtil.getMetadata(this.getPos(), this.worldObj);
if(meta == 1){
if(!(this.currentBurnTime <= 0 && this.slots[0] != null && TileEntityFurnace.getItemBurnTime(this.slots[0]) > 0 && this.storage.getEnergyStored() < this.storage.getMaxEnergyStored())){
PosUtil.setMetadata(this.pos, this.worldObj, 0, 2);
}
}
else{
PosUtil.setMetadata(this.pos, this.worldObj, 1, 2);
}
} }
if((this.storage.getEnergyStored() != this.lastEnergy || this.currentBurnTime != this.lastCurrentBurnTime || this.lastBurnTime != this.maxBurnTime) && this.sendUpdateWithInterval()){ if((this.storage.getEnergyStored() != this.lastEnergy || this.currentBurnTime != this.lastCurrentBurnTime || this.lastBurnTime != this.maxBurnTime) && this.sendUpdateWithInterval()){

View file

@ -105,15 +105,6 @@ public class TileEntityOilGenerator extends TileEntityBase implements IEnergyPro
if(flag != this.currentBurnTime > 0){ if(flag != this.currentBurnTime > 0){
this.markDirty(); this.markDirty();
int meta = PosUtil.getMetadata(this.pos, this.worldObj);
if(meta == 1){
if(!(ENERGY_PRODUCED*BURN_TIME <= this.storage.getMaxEnergyStored()-this.storage.getEnergyStored() && this.currentBurnTime <= 0 && this.tank.getFluidAmount() >= fuelUsed)){
PosUtil.setMetadata(this.pos, this.worldObj, 0, 2);
}
}
else{
PosUtil.setMetadata(this.pos, this.worldObj, 1, 2);
}
} }
if((this.storage.getEnergyStored() != this.lastEnergy || this.tank.getFluidAmount() != this.lastTank || this.lastBurnTime != this.currentBurnTime) && this.sendUpdateWithInterval()){ if((this.storage.getEnergyStored() != this.lastEnergy || this.tank.getFluidAmount() != this.lastTank || this.lastBurnTime != this.currentBurnTime) && this.sendUpdateWithInterval()){

View file

@ -11,10 +11,6 @@
}, },
"variants": { "variants": {
"normal": [{}], "normal": [{}],
"inventory": [{}], "inventory": [{}]
"meta": {
"0": {},
"1": {}
}
} }
} }

View file

@ -11,10 +11,6 @@
}, },
"variants": { "variants": {
"normal": [{}], "normal": [{}],
"inventory": [{}], "inventory": [{}]
"meta": {
"0": {},
"1": {}
}
} }
} }