public static @Nonnull EnderIO getInstance() { return NullHelper.notnullF(instance, "instance is missing"); }
public static @Nullable IItemHandler getExternalInventory(@Nonnull TileEntity tile, @Nonnull EnumFacing face) { return tile.getCapability(NullHelper.notnullF(ITEM_HANDLER_CAPABILITY, "Capability<IItemHandler> is missing"), face); }
private static boolean isSoulBound(@Nonnull ItemStack item) { return EnchantmentHelper.getEnchantmentLevel(NullHelper.notnullF(SOULBOUND, "Soulbound went unbound"), item) > 0; }
@Override public void fromBytes(ByteBuf buf) { super.fromBytes(buf); cmd = buf.readByte() & 255; value = buf.readInt(); stack = NullHelper.notnullF(ByteBufUtils.readItemStack(buf), "readItemStack returned null"); }
private static @Nonnull AspectList getAspects(@Nonnull String ore) { List<ItemStack> ores = OreDictionary.getOres(ore); return ores.isEmpty() ? new AspectList() : getAspects(NullHelper.notnullF(ores.get(0), "oreDict " + ore + " has null stack")); }
@Override public @Nonnull ItemStack apply(@Nonnull ItemStack stack, @Nonnull Random rand, @Nonnull LootContext context) { if (Prep.isValid(stack)) { IEnergyStorage capability = stack.getCapability(NullHelper.notnullF(CapabilityEnergy.ENERGY, "Forge ran out of energy"), null); if (capability != null) { int maxEnergyStored = capability.getMaxEnergyStored(); int realEnergy = (int) (maxEnergyStored * .1 + maxEnergyStored * .5 * rand.nextFloat()); while (realEnergy > 0) { realEnergy -= Math.max(1, capability.receiveEnergy(realEnergy, false)); } } } return stack; }
@Override public boolean canDisplace(IBlockAccess world, BlockPos pos) { IBlockState bs = NullHelper.notnullF(world, "canDisplace() called without world") .getBlockState(NullHelper.notnullF(pos, "canDisplace() called without pos")); if (bs.getMaterial().isLiquid()) { return false; } return super.canDisplace(world, pos); }
@Override public boolean displaceIfPossible(World world, BlockPos pos) { IBlockState bs = NullHelper.notnullF(world, "displaceIfPossible() called without world") .getBlockState(NullHelper.notnullF(pos, "displaceIfPossible() called without pos")); if (bs.getMaterial().isLiquid()) { return false; } return super.displaceIfPossible(world, pos); }
public void addCoolant(String fluidName, float degreesCoolingPerMB) { addCoolant(NullHelper.notnullF(FluidRegistry.getFluid(fluidName), "Invalid fluid " + fluidName), degreesCoolingPerMB); }
public void addFuel(String fluidName, int powerPerCycleRF, int totalBurnTime) { addFuel(NullHelper.notnullF(FluidRegistry.getFluid(fluidName), "Invalid fluid " + fluidName), powerPerCycleRF, totalBurnTime); }
@SubscribeEvent public static void registerRegistry(@Nonnull EnderIOLifecycleEvent.PreInit event) { MinecraftForge.EVENT_BUS.post(new RegisterModObject(NAME, NullHelper.notnullF(REGISTRY, "RegistryBuilder.create()"))); }
public static @Nonnull NNList<ResourceLocation> getAllRegisteredMobNames() { NNList<ResourceLocation> result = new NNList<ResourceLocation>(); for (ResourceLocation entityName : EntityList.getEntityNameList()) { final Class<? extends Entity> clazz = EntityList.getClass(NullHelper.notnullF(entityName, "EntityList.getEntityNameList()")); if (clazz != null && EntityLiving.class.isAssignableFrom(clazz)) { result.add(entityName); } } return result; }
@SubscribeEvent public static void onPlayerTick(TickEvent.PlayerTickEvent event) { if (event.side == Side.CLIENT || event.phase != TickEvent.Phase.END || event.player.isSpectator()) { return; } instance.chargePlayersItems(NullHelper.notnullF(event.player, "TickEvent.PlayerTickEvent without player")); }
public static @Nonnull NNList<ItemStack> getAllBuckets() { NNList<ItemStack> result = new NNList<>(); for (Fluid fluid : FluidRegistry.getBucketFluids()) { result.add(getBucket(NullHelper.notnullF(fluid, "FluidRegistry.getBucketFluids() has null fluid"))); } return result; }
private @Nonnull IBakedModel getDefaults() { if (defaults == null) { try { defaults = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getModelManager().getMissingModel(); } catch (Throwable t) { } } return NullHelper.notnullF(defaults, "missing model is missing"); }
public void writeCommon(@Nonnull String name, @Nonnull NBTTagCompound nbtRoot) { NBTTagCompound tankRoot = new NBTTagCompound(); writeToNBT(tankRoot); if (restriction != null) { tankRoot.setString("FluidRestriction", NullHelper.notnullF(restriction.getName(), "encountered fluid with null name")); } tankRoot.setInteger("Capacity", capacity); nbtRoot.setTag(name, tankRoot); }
@SubscribeEvent(priority = EventPriority.LOW) public static void registerAddonBlocks(@Nonnull RegistryEvent.Register<Block> event) { for (ModContainer modContainer : Loader.instance().getModList()) { Object mod = modContainer.getMod(); if (mod instanceof IEnderIOAddon) { ((IEnderIOAddon) mod).injectBlocks(NullHelper.notnullF(event.getRegistry(), "RegistryEvent.Register<Block>.getRegistry()")); } } }
@SideOnly(Side.CLIENT) @SubscribeEvent public static void handleFovUpdate(@Nonnull FOVUpdateEvent evt) { if (ignoreFovEvent) { return; } EntityPlayer player = NullHelper.notnullF(evt.getEntity(), "FOVUpdateEvent has no player"); if (clearModifiers(player)) { // set the same as vanilla does without our speed buff evt.setNewfov(getVanillaFovModifier(player)); setModifiers(player); } }
@SubscribeEvent public void onAchievement(AdvancementEvent event) { final @Nonnull Advancement advancement = NullHelper.notnullF(event.getAdvancement(), "AdvancementEvent.getAdvancement()"); DisplayInfo display = advancement.getDisplay(); if (ConfigHandler.betterAchievements && !event.getEntity().world.isRemote && display != null && display.shouldAnnounceToChat()) { event.getEntityPlayer().getEntityData().setInteger("fireworksLeft", 9); event.getEntityPlayer().getEntityData().setBoolean("fireworkDelay", false); } }
@SubscribeEvent(priority = EventPriority.LOWEST) public void onArrowNock(ArrowNockEvent event) { ItemStack stack = event.getBow(); if (EnchantmentHelper.getEnchantmentLevel(Enchantments.INFINITY, stack) > 0) { event.getEntityPlayer().setActiveHand(NullHelper.notnullF(event.getHand(), "null hand in ArrowNockEvent event")); event.setAction(new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack)); } } }