@Override public @Nonnull String apply(@Nullable ItemStack itemStack) { if (itemStack == null) { throw new NullPointerException("You want me to return something Nonnull for a null ItemStack? F.U."); } CapturedMob capturedMob = CapturedMob.create(itemStack); if (capturedMob != null) { return capturedMob.getDisplayName(); } return ""; }
@Override public void readCustomNBT(@Nonnull ItemStack stack) { super.readCustomNBT(stack); capturedMob = CapturedMob.create(stack); }
@Override public Object readResolve() throws InvalidRecipeConfigException { if (name == null || name.trim().isEmpty()) { mob = null; return this; } mob = CapturedMob.create(new ResourceLocation(name.trim())); return this; }
@Override @Nullable public CapturedMob read(Registry registry, Set<NBTAction> phase, NBTTagCompound nbt, Type type, String name, @Nullable CapturedMob object) throws IllegalArgumentException, IllegalAccessException, InstantiationException, NoHandlerFoundException { if (nbt.hasKey(name)) { return CapturedMob.create(nbt.getCompoundTag(name)); } return null; }
@Override public boolean doesItemPassFilter(@Nullable IItemHandler inv, @Nonnull ItemStack item) { if (CapturedMob.containsSoul(item)) { CapturedMob input = CapturedMob.create(item); for (CapturedMob mob : souls) { if (mob.isSameType(input)) { return !blacklist; } } } return blacklist; }
public @Nonnull ItemStack createVesselWithEntity(Entity entity) { CapturedMob capturedMob = CapturedMob.create(entity); if (capturedMob == null) { return Prep.getEmpty(); } return capturedMob.toStack(this, 1, 1); }
public @Nonnull ItemStack createVesselWithEntityStub(ResourceLocation entityId) { CapturedMob capturedMob = CapturedMob.create(entityId); if (capturedMob == null) { return Prep.getEmpty(); } return capturedMob.toStack(this, 1, 1); }
@Override @SideOnly(Side.CLIENT) public void addInformation(@Nonnull ItemStack stack, @Nullable World worldIn, @Nonnull List<String> tooltip, @Nonnull ITooltipFlag flagIn) { super.addInformation(stack, worldIn, tooltip, flagIn); CapturedMob capturedMob = CapturedMob.create(stack); if (capturedMob != null) { tooltip.add(Lang.PRESSURE_PLATE_TUNED.get(capturedMob.getDisplayName())); } }
@Override public void addCommonEntries(@Nonnull ItemStack itemstack, @Nullable EntityPlayer entityplayer, @Nonnull List<String> list, boolean flag) { CapturedMob mob = CapturedMob.create(itemstack); if (mob != null) { list.add(mob.getDisplayName()); list.add(Lang.TOOLTIP_SPAWNER_COST.get(LangPower.FLOAT_NF.format(PoweredSpawnerRecipeRegistry.getInstance().getCostMultiplierFor(mob.getEntityName())))); } else { list.add(Lang.SPAWNER_EMPTY.get()); } }
protected boolean isMobInFilter(EntityLivingBase entity) { for (int i = slotDefinition.minInputSlot; i <= slotDefinition.maxInputSlot; i++) { CapturedMob mob = CapturedMob.create(getStackInSlot(i)); if (mob != null && mob.isSameType(entity)) { return true; } } return false; }
@Override public @Nonnull NNList<CapturedMob> getEntities() { NNList<CapturedMob> result = new NNList<>(); for (int i = slotDefinition.minInputSlot; i <= slotDefinition.maxInputSlot; i++) { CapturedMob mob = CapturedMob.create(getStackInSlot(i)); if (mob != null) { result.add(mob); } } return result; }
@Override @Nullable public CapturedMob getEntity() { return CapturedMob.create(getInventory().getSlot(SLOT.VIAL).get()); }
public static @Nonnull NNList<CapturedMob> getSouls(List<ResourceLocation> list) { NNList<CapturedMob> result = new NNList<CapturedMob>(); for (ResourceLocation mobName : list) { CapturedMob soul = create(mobName); if (soul != null && !DRAGON.equals(mobName)) { result.add(soul); } } return result; }
@Override @SideOnly(Side.CLIENT) public void addInformation(@Nonnull ItemStack stack, @Nullable World worldIn, @Nonnull List<String> tooltip, @Nonnull ITooltipFlag flagIn) { super.addInformation(stack, worldIn, tooltip, flagIn); CapturedMob mob = CapturedMob.create(stack); if (mob != null) { tooltip.add(mob.getDisplayName()); } if (!SpecialTooltipHandler.showAdvancedTooltips()) { SpecialTooltipHandler.addShowDetailsTooltip(tooltip); } else { SpecialTooltipHandler.addDetailedTooltipFromResources(tooltip, stack); } }
@Override public void onBlockPlacedBy(@Nonnull World worldIn, @Nonnull BlockPos pos, @Nonnull IBlockState state, @Nonnull EntityLivingBase placer, @Nonnull ItemStack stack) { setTypeFromMeta(worldIn, pos, stack.getMetadata()); setPaintSource(state, worldIn, pos, PaintUtil.getSourceBlock(stack)); setRotation(worldIn, pos, EnumFacing.fromAngle(placer.rotationYaw)); setMobType(worldIn, pos, CapturedMob.create(stack)); if (!worldIn.isRemote) { worldIn.notifyBlockUpdate(pos, state, state, 3); } }
@SuppressWarnings("null") @Override public void getSubItems(@Nonnull CreativeTabs tab, @Nonnull NonNullList<ItemStack> list) { if (tab == getCreativeTab()) { list.add(CapturedMob.create(new ResourceLocation("minecraft", "chicken")).toStack(this, 0, 1)); } else if (tab == EnderIOTab.tabEnderIOMobs) { for (CapturedMob capturedMob : CapturedMob.getAllSouls()) { list.add(capturedMob.toStack(this, 0, 1)); } } }
@Override public boolean isValidInput(@Nonnull RecipeLevel machineLevel, @Nonnull MachineRecipeInput input) { if (!RecipeLevel.IGNORE.canMake(machineLevel)) { return false; } if (Prep.isInvalid(input.item)) { return false; } int slot = input.slotNumber; ItemStack item = input.item; if (slot == 0) { CapturedMob mobType = CapturedMob.create(item); return mobType != null && item.getItem() == itemSoulVial.getItem() && isValidInputSoul(mobType); } if (slot == 1) { return isValidInputItem(item); } return false; }
@Override public @Nonnull ResultStack[] getCompletedResult(long nextSeed, float chanceMultiplier, @Nonnull NNList<MachineRecipeInput> inputs) { CapturedMob mobType = null; ItemStack inputItem = null; for (MachineRecipeInput input : inputs) { if (input != null && input.slotNumber == 0 && CapturedMob.containsSoul(input.item)) { mobType = CapturedMob.create(input.item); } else if (input != null && input.slotNumber == 1 && isValidInputItem(input.item)) { inputItem = input.item; } } if (mobType == null || !isValidInputSoul(mobType) || inputItem == null) { return new ResultStack[0]; } ItemStack resultStack = getOutputStack(inputItem, mobType); ItemStack soulVessel = new ItemStack(itemSoulVial.getItemNN()); return new ResultStack[] { new ResultStack(soulVessel), new ResultStack(resultStack) }; }
@SideOnly(Side.CLIENT) public static void doItemOverlayIntoGUI(@Nonnull ItemStack stack, int xPosition, int yPosition) { if (EnderIO.proxy.getClientPlayer().isSneaking() || Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) { CapturedMob capturedMob = CapturedMob.create(stack); if (capturedMob != null) { String name = capturedMob.getDisplayName(); int idx = (int) ((EnderIO.proxy.getTickCount() / 4) % name.length()); name = (name + " " + name).substring(idx, idx + 3); FontRenderer fr = Minecraft.getMinecraft().getRenderManager().getFontRenderer(); GlStateManager.disableLighting(); GlStateManager.disableDepth(); GlStateManager.disableBlend(); GlStateManager.enableBlend(); fr.drawStringWithShadow(name, xPosition + 8 - fr.getStringWidth(name) / 2, yPosition + 5, 0xFF0030B0); GlStateManager.enableLighting(); GlStateManager.enableDepth(); GlStateManager.enableBlend(); } } }
@SubscribeEvent public void handleAnvilEvent(AnvilUpdateEvent evt) { if (Prep.isInvalid(evt.getLeft()) || evt.getLeft().getCount() != 1 || evt.getLeft().getItem() != block_powered_spawner.getItem()) { return; } if (Prep.isInvalid(evt.getRight()) || evt.getRight().getCount() != 1 || evt.getRight().getItem() != ModObject.itemBrokenSpawner.getItem()) { return; } CapturedMob spawnerType = CapturedMob.create(evt.getRight()); if (spawnerType == null || isBlackListed(spawnerType.getEntityName())) { return; } evt.setCost(SpawnerConfig.powerSpawnerAddSpawnerCost.get()); evt.setOutput(evt.getLeft().copy()); evt.getOutput().setTagCompound(spawnerType.toNbt(evt.getOutput().getTagCompound())); }