@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; }
@Override public void enforceValidity() throws InvalidRecipeConfigException { if (!isValid()) { Log.warn("Could not find an entity for '" + name + "'"); Log.warn("Available entities are:"); for (CapturedMob possible : CapturedMob.getAllSouls()) { Log.warn(" -> " + possible.getEntityName() + " (" + possible.getDisplayName() + ")"); } throw new InvalidRecipeConfigException("Could not find an entity for '" + name + "'"); } }
public @Nullable Entity getEntity(@Nullable World world, boolean clone) { return getEntity(world, null, null, clone); }
@Override public String toString() { return "CapturedMob [" + "entityId=" + entityId + ", " + (customName != null ? "customName=" + customName + ", " : "") + (entityNbt != null ? "entityNbt=" + entityNbt + ", " : "") + "getDisplayName()=" + getDisplayName() + ", getHealth()=" + getHealth() + ", getMaxHealth()=" + getMaxHealth() + ", " + (getColor() != null ? "getColor()=" + getColor() + ", " : "") + (getFluidName() != null ? "getFluidName()=" + getFluidName() : "") + "]"; }
public static @Nullable CapturedMob create(@Nullable NBTTagCompound nbt) { if (nbt != null && containsSoul(nbt)) { return new CapturedMob(nbt); } else { return null; } }
@Override public void getIngredients(@Nonnull IIngredients ingredients) { final ItemStack outputStack = recipe.getOutputStack(); final List<ResourceLocation> supportedSouls = recipe.getSupportedSouls(); final ItemStack inputStack = recipe.getInputStack(); final List<ItemStack> inputItemList = new NNList<>(); if (Prep.isValid(inputStack)) { inputItemList.add(inputStack); if (itemBrokenSpawner.getItem() == inputStack.getItem()) { // a Broken Spawner on the input side always means "any kind of", so put any kind of broken spawner into the input list. Skip the same type as the // output, that would be a wasteful NOP recipe CapturedMob resultMob = CapturedMob.create(outputStack); for (CapturedMob soul : CapturedMob.getAllSouls()) { if (resultMob == null || !resultMob.isSameType(soul)) { inputItemList.add(soul.toStack(itemBrokenSpawner.getItemNN(), 0, 1)); } } } } NNList<CapturedMob> souls = CapturedMob.getSouls(supportedSouls); final List<ItemStack> soulStacks = new ArrayList<ItemStack>(); final List<ItemStack> outputs = new ArrayList<ItemStack>(); for (CapturedMob soul : souls) { soulStacks.add(soul.toStack(itemSoulVial.getItemNN(), 1, 1)); outputs.add(recipe.getOutputStack(inputStack, soul)); } ingredients.setInputLists(ItemStack.class, new NNList<List<ItemStack>>(soulStacks, inputItemList)); ingredients.setOutputLists(ItemStack.class, new NNList<List<ItemStack>>(Collections.singletonList(new ItemStack(itemSoulVial.getItemNN())), outputs)); ingredients.setInput(EnergyIngredient.class, new EnergyIngredient(recipe.getEnergyRequired())); }
@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 @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 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()); } }
if (CapturedMob.containsSoul(item) && !isCreative) { return false; CapturedMob capturedMob = CapturedMob.create(entity); if (capturedMob == null) { if (entity instanceof EntityPlayer) { player.sendMessage(Lang.SOUL_VIAL_DENIED_PLAYER.toChatServer()); } else if (CapturedMob.isBlacklisted(entity)) { player.sendMessage(Lang.SOUL_VIAL_DENIED_AALISTED.toChatServer()); ItemStack capturedMobVessel = capturedMob.toStack(this, 1, 1);
@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())); }
@Override public void readCustomNBT(@Nonnull ItemStack stack) { super.readCustomNBT(stack); capturedMob = CapturedMob.create(stack); }
@Override public boolean doApply(@Nonnull ItemStack input) { return CapturedMob.containsSoul(input); } };
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 void register(@Nonnull String recipeName) { if (isValid() && isActive()) { for (Entity entity : entities) { if (entity.isDefault()) { PoweredSpawnerRecipeRegistry.getInstance().setDefaultCostMultiplier(entity.getCostMultiplier()); PoweredSpawnerRecipeRegistry.getInstance().setAllowUnconfiguredMobs(!entity.isDisabled()); } else if (entity.isBoss()) { CapturedMob.setBossesBlacklisted(!entity.isSoulvial()); } else { if (entity.isDisabled()) { PoweredSpawnerRecipeRegistry.getInstance().addToBlacklist(entity.getMob().getEntityName()); } else { PoweredSpawnerRecipeRegistry.getInstance().addEntityCost(entity.getMob().getEntityName(), entity.getCostMultiplier()); } if (entity.isClone()) { CapturedMob.addToUnspawnableList(entity.getMob().getEntityName()); } if (!entity.isSoulvial()) { CapturedMob.addToBlackList(entity.getMob().getEntityName()); } } } } }
EnumFacing enumfacing = source.getBlockState().getValue(BlockDispenser.FACING); CapturedMob capturedMob = CapturedMob.create(stack); if (capturedMob.spawn(source.getWorld(), source.getBlockPos().offset(enumfacing).down(), EnumFacing.UP, true)) { stack.shrink(1); secondaryResult = new ItemStack(ItemSoulVial.this); new AxisAlignedBB(source.getBlockPos().offset(enumfacing)), EntitySelectors.NOT_SPECTATING)) { if (!(entity instanceof IEntityOwnable) || ((IEntityOwnable) entity).getOwnerId() == null) { capturedMob = CapturedMob.create(entity); if (capturedMob != null) { entity.setDead(); if (entity.isDead) { stack.shrink(1); secondaryResult = capturedMob.toStack(ItemSoulVial.this, 1, 1); break;
@Override public void getSubItems(@Nonnull CreativeTabs tab, @Nonnull NonNullList<ItemStack> list) { if (tab == getCreativeTab()) { super.getSubItems(tab, list); } else if (tab == EnderIOTab.tabEnderIOMobs) { for (CapturedMob capturedMob : CapturedMob.getAllSouls()) { list.add(capturedMob.toStack(this, 1, 1)); } } }
@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) }; }
public ResourceLocation getEntityName() { return capturedMob != null ? capturedMob.getEntityName() : null; }