More blockstates

This commit is contained in:
Vincent Lee committed 2015-11-26 12:03:33 -06:00
1 parent a40a443607
commit bf81e002e8
28 files changed
+256 -312

No files matched your search

@@ -14,6 +14,7 @@ import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
@@ -26,6 +27,7 @@ import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import vazkii.botania.api.lexicon.ILexiconable;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.api.state.BotaniaStateProps;
import vazkii.botania.client.core.helper.IconHelper;
import vazkii.botania.common.block.tile.TileSimpleInventory;
import vazkii.botania.common.block.tile.TileSparkChanger;
@@ -44,10 +46,25 @@ public class BlockSparkChanger extends BlockModContainer implements ILexiconable
setResistance(10.0F);
setStepSound(soundTypeStone);
setUnlocalizedName(LibBlockNames.SPARK_CHANGER);
setDefaultState(blockState.getBaseState().withProperty(BotaniaStateProps.POWERED, true));
random = new Random();
}
@Override
public BlockState createBlockState() {
return new BlockState(this, BotaniaStateProps.POWERED);
}
@Override
public int getMetaFromState(IBlockState state) {
return ((Boolean) state.getValue(BotaniaStateProps.POWERED)) ? 8 : 0;
}
@Override
public IBlockState getStateFromMeta(int meta) {
return getDefaultState().withProperty(BotaniaStateProps.POWERED, meta == 8);
}
@Override
public boolean isFullCube() {
return false;
@@ -66,14 +83,13 @@ public class BlockSparkChanger extends BlockModContainer implements ILexiconable
@Override
public void onNeighborBlockChange(World world, BlockPos pos, IBlockState state, Block block) {
boolean power = world.isBlockIndirectlyGettingPowered(pos) > 0 || world.isBlockIndirectlyGettingPowered(pos.up()) > 0;
int meta = world.getBlockMetadata(x, y, z);
boolean powered = (meta & 8) != 0;
boolean powered = ((Boolean) state.getValue(BotaniaStateProps.POWERED));
if(power && !powered) {
((TileSparkChanger) world.getTileEntity(pos)).doSwap();
world.setBlockMetadataWithNotify(x, y, z, meta | 8, 4);
world.setBlockState(pos, state.withProperty(BotaniaStateProps.POWERED, true), 4);
} else if(!power && powered)
world.setBlockMetadataWithNotify(x, y, z, meta & -9, 4);
world.setBlockState(pos, state.withProperty(BotaniaStateProps.POWERED, false), 4);
}
@Override