private void init(@Nonnull IModObject modObject) { SmartModelAttacher.registerNoProps(this); PaintRegistry.registerModel("pressure_plate_up", new ResourceLocation("minecraft", "block/stone_pressure_plate_up"), PaintRegistry.PaintMode.ALL_TEXTURES); PaintRegistry.registerModel("pressure_plate_down", new ResourceLocation("minecraft", "block/stone_pressure_plate_down"), PaintRegistry.PaintMode.ALL_TEXTURES); PaintRegistry.registerModel("pressure_plate_inventory", new ResourceLocation("minecraft", "block/stone_pressure_plate_up"), PaintRegistry.PaintMode.ALL_TEXTURES); defaultPaints.set(EnumPressurePlateType.WOOD.ordinal(), Blocks.WOODEN_PRESSURE_PLATE.getDefaultState()); defaultPaints.set(EnumPressurePlateType.STONE.ordinal(), Blocks.STONE_PRESSURE_PLATE.getDefaultState()); defaultPaints.set(EnumPressurePlateType.IRON.ordinal(), Blocks.HEAVY_WEIGHTED_PRESSURE_PLATE.getDefaultState()); defaultPaints.set(EnumPressurePlateType.GOLD.ordinal(), Blocks.LIGHT_WEIGHTED_PRESSURE_PLATE.getDefaultState()); defaultPaints.set(EnumPressurePlateType.DARKSTEEL.ordinal(), getDefaultState().withProperty(BlockPressurePlateWeighted.POWER, 1)); defaultPaints.set(EnumPressurePlateType.SOULARIUM.ordinal(), getDefaultState().withProperty(BlockPressurePlateWeighted.POWER, 2)); defaultPaints.set(EnumPressurePlateType.TUNED.ordinal(), getDefaultState().withProperty(BlockPressurePlateWeighted.POWER, 3)); }
public BlockPaintedPressurePlate(@Nonnull IModObject modObject) { super(Material.IRON); this.setDefaultState(this.blockState.getBaseState().withProperty(BlockPressurePlateWeighted.POWER, 0)); setCreativeTab(EnderIOTab.tabEnderIO); modObject.apply(this); setSoundType(SoundType.WOOD); }
@Override public @Nonnull IBlockState getExtendedState(@Nonnull IBlockState state, @Nonnull IBlockAccess world, @Nonnull BlockPos pos) { IBlockStateWrapper blockStateWrapper = new BlockStateWrapperBase(state, world, pos, this); blockStateWrapper.addCacheKey(getPaintSource(state, world, pos)).addCacheKey(getRotation(world, pos)) .addCacheKey(state.getValue(BlockPressurePlateWeighted.POWER) > 0); blockStateWrapper.bakeModel(); return blockStateWrapper; }
@SideOnly(Side.CLIENT) private IBakedModel mapRender(IBlockState state, @Nullable IBlockState paint, EnumFacing facing) { ModelRotation rot; switch (facing) { case EAST: rot = ModelRotation.X0_Y90; break; case NORTH: rot = null; break; case SOUTH: rot = ModelRotation.X0_Y180; break; case WEST: rot = ModelRotation.X0_Y270; break; default: return null; } if (state.getValue(BlockPressurePlateWeighted.POWER) > 0) { return PaintRegistry.getModel(IBakedModel.class, "pressure_plate_down", paint, rot); } else { return PaintRegistry.getModel(IBakedModel.class, "pressure_plate_up", paint, rot); } }
@Override public @Nonnull IBlockState getStateFromMeta(int meta) { return this.getDefaultState().withProperty(BlockPressurePlateWeighted.POWER, meta); }
@Override public int getMetaFromState(@Nonnull IBlockState state) { return state.getValue(BlockPressurePlateWeighted.POWER); }
@Override protected @Nonnull BlockStateContainer createBlockState() { return new BlockStateContainer(this, new IProperty[] { BlockPressurePlateWeighted.POWER }); }
@Override protected int getRedstoneStrength(@Nonnull IBlockState state) { return state.getValue(BlockPressurePlateWeighted.POWER); }
@Override protected @Nonnull IBlockState setRedstoneStrength(@Nonnull IBlockState state, int strength) { return state.withProperty(BlockPressurePlateWeighted.POWER, strength); }