/** * The <b>localized</b> title of this config screen */ protected String getTitle() { return EnderCore.lang.localize("config.title"); }
/** * Returns the {@link Scheduler} instance for the current side. * * @see #schedule(int, Runnable) * * @return The {@link Scheduler} instance. */ public static Scheduler instance() { return EnderCore.proxy.getScheduler(); }
/** * Call this with an interval (in ticks) to find out if the current tick is the one you want to do some work. This is staggered so the work of different TEs * is stretched out over time. * * @see #shouldDoWorkThisTick(int, int) If you need to offset work ticks */ protected boolean shouldDoWorkThisTick(int interval) { return shouldDoWorkThisTick(interval, 0); }
/** * Localizes the string passed, first appending the prefix stored in this instance of the class. * * @param unloc * The unlocalized string. * * @return A localized string. */ public @Nonnull String localize(@Nonnull String unloc) { return localizeExact(addPrefix(unloc)); }
/** * Checks if the passed string (plus the prefix) has a localization mapped. * * @param unloc * The unlocalized suffix * @return True if there is a localization mapped, false otherwise. */ public boolean canLocalize(@Nonnull String unloc) { return canLocalizeExact(addPrefix(unloc)); }
@Override public final void update() { if (!hasWorld() || isInvalid() || !world.isBlockLoaded(getPos()) || world.getTileEntity(getPos()) != this) { // we can get ticked after being removed from the world, ignore this return; } if (ConfigHandler.allowExternalTickSpeedup || world.getTotalWorldTime() != lastUpdate) { lastUpdate = world.getTotalWorldTime(); doUpdate(); sendProgressIf(); } }
@Override public @Nonnull String getLocalizedName() { return EnderIO.lang.localizeExact(unlocalizedName + ".name"); }
@Override @Nonnull public String getUnlocalizedName() { return EnderIOMachines.lang.addPrefix("block_powered_spawner.note." + langStr); }
@Override public final void onBlockPlacedBy(@Nonnull World worldIn, @Nonnull BlockPos pos, @Nonnull IBlockState state, @Nonnull EntityLivingBase placer, @Nonnull ItemStack stack) { onBlockPlaced(worldIn, pos, state, placer, stack); T te = getTileEntity(worldIn, pos); if (te != null) { te.readCustomNBT(stack); onBlockPlaced(worldIn, pos, state, placer, te); } }
@Override public final @Nonnull BlockFaceShape getBlockFaceShape(@Nonnull IBlockAccess worldIn, @Nonnull IBlockState state, @Nonnull BlockPos pos, @Nonnull EnumFacing face) { if (shape != null) { T te = getTileEntitySafe(worldIn, pos); if (te != null) { return shape.getBlockFaceShape(worldIn, state, pos, face, te); } else { return shape.getBlockFaceShape(worldIn, state, pos, face); } } return super.getBlockFaceShape(worldIn, state, pos, face); }
protected boolean shouldDoWorkThisTick(@Nonnull World world, @Nonnull BlockPos pos, int interval) { T te = getTileEntity(world, pos); if (te == null) { return world.getTotalWorldTime() % interval == 0; } else { return te.shouldDoWorkThisTick(interval); } }
@Override public @Nonnull List<String> getTooltipLines() { return EnderIOMachines.lang.localizeAll(unlocTooltips); }
default @Nonnull BlockFaceShape getBlockFaceShape(@Nonnull IBlockAccess worldIn, @Nonnull IBlockState state, @Nonnull BlockPos pos, @Nonnull EnumFacing face, @Nonnull T te) { return getBlockFaceShape(worldIn, state, pos, face); } }
@Handler public class ClientHandler { private static int ticksElapsed; public static int getTicksElapsed() { return ticksElapsed; } @SubscribeEvent public static void onClientTick(@Nonnull ClientTickEvent event) { if (event.phase == Phase.END) { ticksElapsed++; } } private ClientHandler() { } }
@Override public void setGhostSlotContents(int slot, @Nonnull ItemStack stack, int realsize) { if (te instanceof TileEntityBase) { ((TileEntityBase) te).setGhostSlotContents(slot, stack, realsize); } }
/** * Splits the localized text on "|" into a String[]. * * @param unloc * The unlocalized string. * @param args * The args to format the localized text with. * @return A localized list of strings. */ public @Nonnull String[] localizeList(@Nonnull String unloc, @Nonnull String... args) { return splitList(localize(unloc, (Object[]) args)); }
public static @Nonnull String getDisplayNameForEntity(@Nonnull String mobName) { return EnderIO.lang.localizeExact("entity." + mobName + ".name"); }
protected boolean shouldDoWorkThisTick(@Nonnull World world, @Nonnull BlockPos pos, int interval, int offset) { T te = getTileEntity(world, pos); if (te == null) { return (world.getTotalWorldTime() + offset) % interval == 0; } else { return te.shouldDoWorkThisTick(interval, offset); } }
@Handler public class FluidSpawnHandler { @SubscribeEvent public static void onEntitySpawn(LivingSpawnEvent.CheckSpawn evt) { if (evt.getResult() != Result.DENY && EntitySpawnPlacementRegistry .getPlacementForEntity(evt.getEntity().getClass()) == EntityLiving.SpawnPlacementType.IN_WATER && evt.getWorld().getBlockState(evt.getEntityLiving().getPosition()).getBlock() instanceof BlockFluidEnder) { evt.setResult(Result.DENY); } return; } private FluidSpawnHandler() { } }