protected void updateState(World worldIn, BlockPos pos, IBlockState state) { if (!worldIn.isBlockTickPending(pos, this)) { int i = this.calculateOutput(worldIn, pos, state); TileEntity tileentity = worldIn.getTileEntity(pos); int j = tileentity instanceof TileEntityComparator ? ((TileEntityComparator)tileentity).getOutputSignal() : 0; if (i != j || this.isPowered(state) != this.shouldBePowered(worldIn, pos, state)) { if (this.isFacingTowardsRepeater(worldIn, pos, state)) { worldIn.updateBlockTick(pos, this, 2, -1); } else { worldIn.updateBlockTick(pos, this, 2, 0); } } } }
private void onStateChange(World worldIn, BlockPos pos, IBlockState state) { int i = this.calculateOutput(worldIn, pos, state); TileEntity tileentity = worldIn.getTileEntity(pos); int j = 0; if (tileentity instanceof TileEntityComparator) { TileEntityComparator tileentitycomparator = (TileEntityComparator)tileentity; j = tileentitycomparator.getOutputSignal(); tileentitycomparator.setOutputSignal(i); } if (j != i || state.getValue(MODE) == BlockRedstoneComparator.Mode.COMPARE) { boolean flag1 = this.shouldBePowered(worldIn, pos, state); boolean flag = this.isPowered(state); if (flag && !flag1) { worldIn.setBlockState(pos, state.withProperty(POWERED, Boolean.valueOf(false)), 2); } else if (!flag && flag1) { worldIn.setBlockState(pos, state.withProperty(POWERED, Boolean.valueOf(true)), 2); } this.notifyNeighbors(worldIn, pos, state); } }
protected int getActiveSignal(IBlockAccess worldIn, BlockPos pos, IBlockState state) { TileEntity tileentity = worldIn.getTileEntity(pos); return tileentity instanceof TileEntityComparator ? ((TileEntityComparator)tileentity).getOutputSignal() : 0; }
/** * Returns a new instance of a block's tile entity class. Called on placing the block. */ public TileEntity createNewTileEntity(World worldIn, int meta) { return new TileEntityComparator(); }
public TileEntityComparator func_149971_e(IBlockAccess p_149971_1_, int p_149971_2_, int p_149971_3_, int p_149971_4_) { return (TileEntityComparator)p_149971_1_.getTileEntity(p_149971_2_, p_149971_3_, p_149971_4_); }
/** * Returns a new instance of a block's tile entity class. Called on placing the block. */ public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) { return new TileEntityComparator(); }
private static void registerVanillaTileEntityHandlers() { registerTileEntityHandler(TileEntityComparator.class, ComparatorHandler.class); }
@Override public Class<?> getTargetClass() { return TileEntityComparator.class; }
@ScriptCallable(returnTypes = ReturnType.NUMBER, description = "Get the strength of the output signal") public int getOutputSignal(TileEntityComparator comparator) { return comparator.getOutputSignal(); }
public TileEntityComparator getTileEntityComparator(IBlockAccess p_149971_1_, int p_149971_2_, int p_149971_3_, int p_149971_4_) { return (TileEntityComparator)p_149971_1_.getTileEntity(p_149971_2_, p_149971_3_, p_149971_4_); }
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) { return new TileEntityComparator(); }
public TileEntityComparator func_96475_a_(IBlockAccess p_96475_1_, int p_96475_2_, int p_96475_3_, int p_96475_4_) { return (TileEntityComparator)p_96475_1_.func_72796_p(p_96475_2_, p_96475_3_, p_96475_4_); }
public TileEntity func_72274_a(World p_72274_1_) { return new TileEntityComparator(); }
/** * Returns the blockTileEntity at given coordinates. */ public TileEntityComparator getTileEntityComparator(IBlockAccess par1IBlockAccess, int par2, int par3, int par4) { return (TileEntityComparator)par1IBlockAccess.getBlockTileEntity(par2, par3, par4); }