/** * Tries to load any block's TileEntity if it exists. Will not create the TileEntity when used in a render thread with the correct IBlockAccess. Will not * cause chunk loads. * */ public static @Nullable TileEntity getAnyTileEntitySafe(@Nonnull IBlockAccess world, @Nonnull BlockPos pos) { return getAnyTileEntitySafe(world, pos, TileEntity.class); }
protected boolean isSilent(@Nonnull IBlockAccess worldIn, @Nonnull BlockPos pos) { TileEntity te = BlockEnder.getAnyTileEntitySafe(worldIn, pos); if (te instanceof TilePaintedPressurePlate) { return ((TilePaintedPressurePlate) te).isSilent(); } return false; }
@Override public int getFlammability(@Nonnull IBlockAccess world, @Nonnull BlockPos pos, @Nonnull EnumFacing face) { TileEntity te = BlockEnder.getAnyTileEntitySafe(world, pos); if (te instanceof TilePaintedPressurePlate) { return EnumPressurePlateType.WOOD == ((TilePaintedPressurePlate) te).getType() ? 20 : 0; } return 0; }
protected EnumFacing getRotation(@Nonnull IBlockAccess world, @Nonnull BlockPos pos) { TileEntity te = BlockEnder.getAnyTileEntitySafe(world, pos); if (te instanceof TilePaintedPressurePlate) { return ((TilePaintedPressurePlate) te).getRotation(); } return EnumFacing.NORTH; }
@Override public int getFireSpreadSpeed(@Nonnull IBlockAccess world, @Nonnull BlockPos pos, @Nonnull EnumFacing face) { TileEntity te = BlockEnder.getAnyTileEntitySafe(world, pos); if (te instanceof TilePaintedPressurePlate) { return EnumPressurePlateType.WOOD == ((TilePaintedPressurePlate) te).getType() ? 5 : 0; } return 0; }
protected EnumPressurePlateType getType(@Nonnull IBlockAccess worldIn, @Nonnull BlockPos pos) { TileEntity te = BlockEnder.getAnyTileEntitySafe(worldIn, pos); if (te instanceof TilePaintedPressurePlate) { return ((TilePaintedPressurePlate) te).getType(); } return EnumPressurePlateType.WOOD; }
/** * Gets the paint source from a block that exists in the world. Will return null if the block is not painted. */ default @Nullable IBlockState getPaintSource(@Nonnull IBlockState state, @Nonnull IBlockAccess world, @Nonnull BlockPos pos) { IPaintable.IPaintableTileEntity te = BlockEnder.getAnyTileEntitySafe(world, pos, IPaintable.IPaintableTileEntity.class); if (te != null) { return te.getPaintSource(); } return null; }
protected CapturedMob getMobType(@Nonnull IBlockAccess worldIn, @Nonnull BlockPos pos) { TileEntity te = BlockEnder.getAnyTileEntitySafe(worldIn, pos); if (te instanceof TilePaintedPressurePlate) { return ((TilePaintedPressurePlate) te).getMobType(); } return null; }
public void getChargers(@Nonnull World world, @Nonnull BlockPos pos, @Nonnull Collection<IWirelessCharger> res) { final Collection<BlockPos> chargers = getChargersForWorld(world); for (Iterator<BlockPos> iterator = chargers.iterator(); iterator.hasNext();) { BlockPos chargerPos = iterator.next(); IWirelessCharger charger = chargerPos != null ? BlockEnder.getAnyTileEntitySafe(world, chargerPos, IWirelessCharger.class) : null; if (charger != null) { if (charger.getRange().contains(pos)) { res.add(charger); } } else { iterator.remove(); changeCount++; } } }
public IBlockState getPaintSource2(@Nonnull IBlockState state, @Nonnull IBlockAccess world, @Nonnull BlockPos pos) { if (isDouble()) { TileEntity te = BlockEnder.getAnyTileEntitySafe(world, pos); if (te instanceof TileEntityTwicePaintedBlock) { return ((TileEntityTwicePaintedBlock) te).getPaintSource2(); } return null; } else { return getPaintSource(state, world, pos); } }
protected int getMetaForStack(@Nonnull IBlockAccess worldIn, @Nonnull BlockPos pos) { TileEntity te = BlockEnder.getAnyTileEntitySafe(worldIn, pos); if (te instanceof TilePaintedPressurePlate) { return EnumPressurePlateType.getMetaFromType(((TilePaintedPressurePlate) te).getType(), ((TilePaintedPressurePlate) te).isSilent()); } return 0; }
@Override public int getLightValue(@Nonnull IBlockState bs, @Nonnull IBlockAccess world, @Nonnull BlockPos pos) { TileTank tank = BlockEnder.getAnyTileEntitySafe(world, pos, TileTank.class); if (tank != null) { FluidStack stack = tank.tank.getFluid(); return stack == null || stack.amount <= 0 ? 0 : stack.getFluid().getLuminosity(stack); } return super.getLightValue(bs, world, pos); }
@Override public IBlockState getPaintSource(@Nonnull IBlockState state, @Nonnull IBlockAccess world, @Nonnull BlockPos pos) { TileEntity te = BlockEnder.getAnyTileEntitySafe(world, pos); if (te instanceof IPaintable.IPaintableTileEntity) { IBlockState paintSource = ((IPaintableTileEntity) te).getPaintSource(); if (paintSource != null) { return paintSource; } } return defaultPaints.get(getType(world, pos).ordinal()); }
private void calculateFillLevel() { if (world != null && pos != null) { TileEntity tileEntity = BlockEnder.getAnyTileEntitySafe(world, pos); if (!(tileEntity instanceof TileCapBank)) { localFillLevel = 0; return; } ICapBankNetwork network = ((TileCapBank) tileEntity).getNetwork(); if (!(network instanceof CapBankClientNetwork)) { localFillLevel = 0; return; } ((CapBankClientNetwork) network).requestPowerUpdate(((TileCapBank) tileEntity), 20); double ratio = Math.min(((CapBankClientNetwork) network).getEnergyStoredRatio(), 1); localFillLevel = Math.max(0, Math.min(ratio * (height * 16 - 6) - myOffset * 16, 13) + 3); } }
@Override public void apply(@Nonnull EnumFacing face) { BlockPos neighbor = pos.offset(face); TileEntity tile = getAnyTileEntitySafe(world, neighbor); if (!(tile instanceof TileCapBank) && !(tile instanceof IConduitBundle)) { IPowerInterface eh = PowerHandlerUtil.getPowerInterface(tile, face.getOpposite()); if (eh != null) { sides.put(face, eh); return; } eh = PowerHandlerUtil.getPowerInterface(tile, EnumFacing.DOWN); if (eh != null) { sides.put(face, eh); return; } } } });
public @Nullable TileTelePad findTelepad() { for (BlockPos check : new CubicBlockIterator(getBounds())) { TileTelePad result = BlockEnder.getAnyTileEntitySafe(getWorld(), NullHelper.first(check, pos), TileTelePad.class); if (result != null) { return result.getMaster(); } } return null; }
@Override protected int computeRedstoneStrength(@Nonnull World worldIn, @Nonnull BlockPos pos) { TileEntity te = BlockEnder.getAnyTileEntitySafe(worldIn, pos); if (te instanceof TilePaintedPressurePlate) { EnumPressurePlateType type = ((TilePaintedPressurePlate) te).getType(); return type.getCountingMode() .count(worldIn.getEntitiesWithinAABB(type.getSearchClass(), PRESSURE_AABB.offset(pos), type.getPredicate(getMobType(worldIn, pos)))); } else { return getRedstoneStrength(worldIn.getBlockState(pos)); } }
@Override public IMessage doTeleport(@Nonnull BlockPos telepad, int targetID, boolean initiateTeleport) { final TileDialingDevice dialer = getTileEntity(); if (dialer != null && dialer.getEnergy().canUseEnergy(CapacitorKey.DIALING_DEVICE_POWER_USE_TELEPORT)) { TileTelePad tp = BlockEnder.getAnyTileEntitySafe(dialer.getWorld(), telepad, TileTelePad.class); if (tp != null) { ArrayList<TelepadTarget> targets = dialer.getTargets(); if (targetID >= 0 && targetID < targets.size()) { tp.setTarget(targets.get(targetID)); if (initiateTeleport) { tp.teleportAll(); dialer.getEnergy().useEnergy(CapacitorKey.DIALING_DEVICE_POWER_USE_TELEPORT); } } return new PacketSetTarget(tp, tp.getTarget()); } } return null; }
TileEntity tileEntity = BlockEnder.getAnyTileEntitySafe(world, other); if (!(tileEntity instanceof TileCapBank) || ((TileCapBank) tileEntity).getDisplayType(face) != InfoDisplayType.LEVEL_BAR) { break; TileEntity tileEntity = BlockEnder.getAnyTileEntitySafe(world, other); if (!(tileEntity instanceof TileCapBank) || ((TileCapBank) tileEntity).getDisplayType(face) != InfoDisplayType.LEVEL_BAR) { break;
TileEntity tileEntity = blockState.getBlock() instanceof ITEProxy ? ((ITEProxy) blockState.getBlock()).getParent(world, NullHelper.notnull(hitData.getPos(), "hitData.getPos()"), blockState) : BlockEnder.getAnyTileEntitySafe(world, NullHelper.notnull(hitData.getPos(), "hitData.getPos()/2")); if (tileEntity != null) { EioBox eiobox = new EioBox(probeInfo);