From b8161d00cf10f55a28cc39a7b393d24003ac3c74 Mon Sep 17 00:00:00 2001 From: Hubry Date: Sun, 2 Dec 2018 20:46:39 +0100 Subject: [PATCH 01/31] Fix Lexica rotating item config not swapping usable items in recipes --- .../botania/common/lexicon/page/PagePetalRecipe.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/vazkii/botania/common/lexicon/page/PagePetalRecipe.java b/src/main/java/vazkii/botania/common/lexicon/page/PagePetalRecipe.java index b74a79368..530098c02 100644 --- a/src/main/java/vazkii/botania/common/lexicon/page/PagePetalRecipe.java +++ b/src/main/java/vazkii/botania/common/lexicon/page/PagePetalRecipe.java @@ -41,9 +41,9 @@ public class PagePetalRecipe extends PageRecipe { private static final ResourceLocation petalOverlay = new ResourceLocation(LibResources.GUI_PETAL_OVERLAY); - final List recipes; - int ticksElapsed = 0; - int recipeAt = 0; + private final List recipes; + private int ticksElapsed = 0; + private int recipeAt = 0; public PagePetalRecipe(String unlocalizedName, List recipes) { super(unlocalizedName); @@ -72,14 +72,14 @@ public class PagePetalRecipe extends PageRecipe { List inputs = recipe.getInputs(); int degreePerInput = (int) (360F / inputs.size()); float currentDegree = ConfigHandler.lexiconRotatingItems ? GuiScreen.isShiftKeyDown() ? ticksElapsed : ticksElapsed + ClientTickHandler.partialTicks : 0; - float baseDegree = currentDegree; - + int inputIndex = ticksElapsed / 40; + for(Object obj : inputs) { Object input = obj; if(input instanceof String) { NonNullList list = OreDictionary.getOres((String) input); int size = list.size(); - input = list.get(size - (int) (baseDegree / 40) % size - 1); + input = list.get(size - inputIndex % size - 1); } renderItemAtAngle(gui, currentDegree, (ItemStack) input); From 718f266521baed1a5217cd0059ed66fb63e124eb Mon Sep 17 00:00:00 2001 From: Hubry Date: Mon, 3 Dec 2018 21:45:19 +0100 Subject: [PATCH 02/31] Give the red string container a dummy item handler when not bound Fixes #2790 --- .../block/tile/string/TileRedStringContainer.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringContainer.java b/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringContainer.java index 5db4f9678..c7a8cac51 100644 --- a/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringContainer.java +++ b/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringContainer.java @@ -15,6 +15,7 @@ import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.items.CapabilityItemHandler; +import net.minecraftforge.items.wrapper.EmptyHandler; import javax.annotation.Nonnull; import java.util.Arrays; @@ -31,19 +32,19 @@ public class TileRedStringContainer extends TileRedString { @Override public boolean hasCapability(@Nonnull Capability cap, EnumFacing side) { - if(cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY - && getTileAtBinding() != null - && getTileAtBinding().hasCapability(cap, side)) + if(cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) return true; return super.hasCapability(cap, side); } @Override public T getCapability(@Nonnull Capability cap, EnumFacing side) { - if(cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY - && getTileAtBinding() != null - && getTileAtBinding().hasCapability(cap, side)) - return getTileAtBinding().getCapability(cap, side); + if(cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { + if(getTileAtBinding() != null && getTileAtBinding().hasCapability(cap, side)) { + return getTileAtBinding().getCapability(cap, side); + } + return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(EmptyHandler.INSTANCE); + } return super.getCapability(cap, side); } From 047e572ed1ff208253ca52f8234b26c9bb2e5316 Mon Sep 17 00:00:00 2001 From: Vasco Lavos Date: Mon, 21 Jan 2019 13:43:25 +0000 Subject: [PATCH 03/31] Update contributors.properties --- contributors.properties | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/contributors.properties b/contributors.properties index fb5ac7299..aa96569d4 100644 --- a/contributors.properties +++ b/contributors.properties @@ -124,7 +124,7 @@ lifeofchrome=4 stylzm=vinculotus yepidoodles=3 generrosity=2 -nooblybear=agricarnation +nooblybear=spectrolus 3ddy=sweet_alexum nekosoul241=arcanerose hubry=5 @@ -156,3 +156,4 @@ _neotron_=9 taciturasa=6 nachog2003=9 ewsmith=rafflowsia +attifyon=1 From b9e169fff1100328592d9d0f96116081232ea0ea Mon Sep 17 00:00:00 2001 From: Vasco Lavos Date: Tue, 29 Jan 2019 11:58:51 +0000 Subject: [PATCH 04/31] Update contributors.properties --- contributors.properties | 2 ++ 1 file changed, 2 insertions(+) diff --git a/contributors.properties b/contributors.properties index aa96569d4..ee149cfa7 100644 --- a/contributors.properties +++ b/contributors.properties @@ -157,3 +157,5 @@ taciturasa=6 nachog2003=9 ewsmith=rafflowsia attifyon=1 +sarkasaa=spectrolus +ellpeck=spectrolus From cff5edcd21781119a4eaac201b2183579ff7c861 Mon Sep 17 00:00:00 2001 From: Hubry Date: Fri, 1 Feb 2019 17:44:00 +0100 Subject: [PATCH 05/31] Make magnet ring respect pickup delays and tweak blacklist (#2799) * Items with pickup delay >40 ticks will be ignored * Ignore AE2 seeds with their changed name * Make the blacklist actually usable and not crash when added to with IMC --- .../common/item/equipment/bauble/ItemMagnetRing.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemMagnetRing.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemMagnetRing.java index 6f2c1f607..1a6be9bc2 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemMagnetRing.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemMagnetRing.java @@ -12,7 +12,7 @@ package vazkii.botania.common.item.equipment.bauble; import baubles.api.BaubleType; import baubles.api.BaublesApi; -import com.google.common.collect.ImmutableList; +import com.google.common.collect.Lists; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityItem; import net.minecraft.item.Item; @@ -41,7 +41,7 @@ public class ItemMagnetRing extends ItemBauble { private static final String TAG_COOLDOWN = "cooldown"; - private static final List BLACKLIST = ImmutableList.of(new ResourceLocation("appliedenergistics2", "item.ItemCrystalSeed")); + private static final List BLACKLIST = Lists.newArrayList(new ResourceLocation("appliedenergistics2", "crystal_seed")); private final int range; @@ -105,7 +105,7 @@ public class ItemMagnetRing extends ItemBauble { } private boolean canPullItem(EntityItem item) { - if(item.isDead || SubTileSolegnolia.hasSolegnoliaAround(item)) + if(item.isDead || item.pickupDelay >= 40 || SubTileSolegnolia.hasSolegnoliaAround(item)) return false; ItemStack stack = item.getItem(); From f41de4afe4379aa8fe6cbebba6d50996679fa3f0 Mon Sep 17 00:00:00 2001 From: Hubry Date: Fri, 4 Jan 2019 13:01:22 +0100 Subject: [PATCH 06/31] Clean up JEI plugin warnings, add wrappers for a few recipe types --- .gitignore | 1 + .../integration/jei/JEIBotaniaPlugin.java | 28 ++- .../jei/brewery/BreweryRecipeCategory.java | 14 +- .../jei/brewery/BreweryRecipeWrapper.java | 11 +- .../crafting/AncientWillRecipeWrapper.java | 100 ++++++++++ .../crafting/CompositeLensRecipeWrapper.java | 81 ++++++++ .../SpecialFloatingFlowerWrapper.java | 49 +++-- .../TerraPickTippingRecipeWrapper.java | 41 ++++ .../elventrade/ElvenTradeRecipeCategory.java | 19 +- .../elventrade/ElvenTradeRecipeWrapper.java | 6 +- .../jei/manapool/ManaPoolRecipeCategory.java | 22 +-- .../jei/manapool/ManaPoolRecipeWrapper.java | 5 +- .../orechid/OrechidIgnemRecipeCategory.java | 183 +++++++++--------- .../orechid/OrechidIgnemRecipeWrapper.java | 64 +++--- .../jei/orechid/OrechidRecipeCategory.java | 183 +++++++++--------- .../jei/orechid/OrechidRecipeWrapper.java | 149 +++++++------- .../PetalApothecaryRecipeCategory.java | 14 +- .../PetalApothecaryRecipeWrapper.java | 6 +- .../puredaisy/PureDaisyRecipeCategory.java | 20 +- .../jei/puredaisy/PureDaisyRecipeWrapper.java | 9 +- .../runicaltar/RunicAltarRecipeCategory.java | 20 +- .../runicaltar/RunicAltarRecipeWrapper.java | 6 +- .../item/block/ItemBlockSpecialFlower.java | 1 + 23 files changed, 638 insertions(+), 394 deletions(-) create mode 100644 src/main/java/vazkii/botania/client/integration/jei/crafting/AncientWillRecipeWrapper.java create mode 100644 src/main/java/vazkii/botania/client/integration/jei/crafting/CompositeLensRecipeWrapper.java create mode 100644 src/main/java/vazkii/botania/client/integration/jei/crafting/TerraPickTippingRecipeWrapper.java diff --git a/.gitignore b/.gitignore index 518ba98a2..dbf79e44d 100644 --- a/.gitignore +++ b/.gitignore @@ -23,6 +23,7 @@ Thumbs.db /*.ipr /*.iws /*.iml +/classes ## Private Stuffs /private.properties diff --git a/src/main/java/vazkii/botania/client/integration/jei/JEIBotaniaPlugin.java b/src/main/java/vazkii/botania/client/integration/jei/JEIBotaniaPlugin.java index 01e82ce52..f4bc554f4 100644 --- a/src/main/java/vazkii/botania/client/integration/jei/JEIBotaniaPlugin.java +++ b/src/main/java/vazkii/botania/client/integration/jei/JEIBotaniaPlugin.java @@ -11,10 +11,12 @@ package vazkii.botania.client.integration.jei; import mezz.jei.api.IJeiRuntime; import mezz.jei.api.IModPlugin; import mezz.jei.api.IModRegistry; +import mezz.jei.api.IRecipeRegistry; import mezz.jei.api.IRecipesGui; import mezz.jei.api.ISubtypeRegistry; import mezz.jei.api.JEIPlugin; import mezz.jei.api.recipe.IRecipeCategoryRegistration; +import mezz.jei.api.recipe.IRecipeWrapper; import mezz.jei.api.recipe.VanillaRecipeCategoryUid; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.inventory.GuiContainer; @@ -35,7 +37,10 @@ import vazkii.botania.client.core.handler.CorporeaInputHandler; import vazkii.botania.client.gui.crafting.ContainerCraftingHalo; import vazkii.botania.client.integration.jei.brewery.BreweryRecipeCategory; import vazkii.botania.client.integration.jei.brewery.BreweryRecipeWrapper; +import vazkii.botania.client.integration.jei.crafting.AncientWillRecipeWrapper; +import vazkii.botania.client.integration.jei.crafting.CompositeLensRecipeWrapper; import vazkii.botania.client.integration.jei.crafting.SpecialFloatingFlowerWrapper; +import vazkii.botania.client.integration.jei.crafting.TerraPickTippingRecipeWrapper; import vazkii.botania.client.integration.jei.elventrade.ElvenTradeRecipeCategory; import vazkii.botania.client.integration.jei.elventrade.ElvenTradeRecipeWrapper; import vazkii.botania.client.integration.jei.manapool.ManaPoolRecipeCategory; @@ -51,12 +56,16 @@ import vazkii.botania.client.integration.jei.puredaisy.PureDaisyRecipeWrapper; import vazkii.botania.client.integration.jei.runicaltar.RunicAltarRecipeCategory; import vazkii.botania.client.integration.jei.runicaltar.RunicAltarRecipeWrapper; import vazkii.botania.common.block.ModBlocks; +import vazkii.botania.common.crafting.recipe.AncientWillRecipe; +import vazkii.botania.common.crafting.recipe.CompositeLensRecipe; import vazkii.botania.common.crafting.recipe.SpecialFloatingFlowerRecipe; +import vazkii.botania.common.crafting.recipe.TerraPickTippingRecipe; import vazkii.botania.common.item.ModItems; import vazkii.botania.common.item.block.ItemBlockSpecialFlower; import vazkii.botania.common.item.brew.ItemBrewBase; import javax.annotation.Nonnull; +import java.util.List; import java.util.stream.Collectors; import static vazkii.botania.common.lib.LibBlockNames.SUBTILE_ORECHID; @@ -104,8 +113,12 @@ public class JEIBotaniaPlugin implements IModPlugin { registry.handleRecipes(RecipePetals.class, PetalApothecaryRecipeWrapper::new, PetalApothecaryRecipeCategory.UID); registry.handleRecipes(RecipeElvenTrade.class, ElvenTradeRecipeWrapper::new, ElvenTradeRecipeCategory.UID); registry.handleRecipes(RecipeManaInfusion.class, ManaPoolRecipeWrapper::new, ManaPoolRecipeCategory.UID); + registry.handleRecipes(SpecialFloatingFlowerRecipe.class, SpecialFloatingFlowerWrapper::new, VanillaRecipeCategoryUid.CRAFTING); - + registry.handleRecipes(AncientWillRecipe.class, AncientWillRecipeWrapper::new, VanillaRecipeCategoryUid.CRAFTING); + registry.handleRecipes(TerraPickTippingRecipe.class, TerraPickTippingRecipeWrapper::new, VanillaRecipeCategoryUid.CRAFTING); + registry.handleRecipes(CompositeLensRecipe.class, r -> new CompositeLensRecipeWrapper(), VanillaRecipeCategoryUid.CRAFTING); + registry.addRecipes(BotaniaAPI.brewRecipes, BreweryRecipeCategory.UID); registry.addRecipes(BotaniaAPI.pureDaisyRecipes, PureDaisyRecipeCategory.UID); registry.addRecipes(BotaniaAPI.petalRecipes, PetalApothecaryRecipeCategory.UID); @@ -159,6 +172,19 @@ public class JEIBotaniaPlugin implements IModPlugin { @Override public void onRuntimeAvailable(IJeiRuntime jeiRuntime) { + IRecipeRegistry recipeRegistry = jeiRuntime.getRecipeRegistry(); + for(RecipeElvenTrade recipe : BotaniaAPI.elvenTradeRecipes) { + List inputs = recipe.getInputs(); + List outputs = recipe.getOutputs(); + if(inputs.size() == 1 && outputs.size() == 1 && inputs.get(0) instanceof ItemStack + && ItemStack.areItemStacksEqual((ItemStack) inputs.get(0), outputs.get(0))) { + IRecipeWrapper wrapper = recipeRegistry.getRecipeWrapper(recipe, ElvenTradeRecipeCategory.UID); + if(wrapper != null) { + recipeRegistry.hideRecipe(wrapper, ElvenTradeRecipeCategory.UID); + } + } + } + CorporeaInputHandler.jeiPanelSupplier = () -> { Object o = jeiRuntime.getIngredientListOverlay().getIngredientUnderMouse(); diff --git a/src/main/java/vazkii/botania/client/integration/jei/brewery/BreweryRecipeCategory.java b/src/main/java/vazkii/botania/client/integration/jei/brewery/BreweryRecipeCategory.java index 30d6dc8c6..a6dc10ee8 100644 --- a/src/main/java/vazkii/botania/client/integration/jei/brewery/BreweryRecipeCategory.java +++ b/src/main/java/vazkii/botania/client/integration/jei/brewery/BreweryRecipeCategory.java @@ -13,9 +13,9 @@ import mezz.jei.api.gui.IDrawable; import mezz.jei.api.gui.IDrawableStatic; import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.ingredients.IIngredients; +import mezz.jei.api.ingredients.VanillaTypes; import mezz.jei.api.recipe.IFocus; import mezz.jei.api.recipe.IRecipeCategory; -import mezz.jei.api.recipe.IRecipeWrapper; import net.minecraft.client.resources.I18n; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; @@ -25,7 +25,7 @@ import javax.annotation.Nonnull; import java.util.Collections; import java.util.List; -public class BreweryRecipeCategory implements IRecipeCategory { +public class BreweryRecipeCategory implements IRecipeCategory { public static final String UID = "botania.brewery"; private final IDrawableStatic background; @@ -33,7 +33,7 @@ public class BreweryRecipeCategory implements IRecipeCategory { public BreweryRecipeCategory(IGuiHelper guiHelper) { ResourceLocation location = new ResourceLocation("botania", "textures/gui/neiBrewery.png"); - background = guiHelper.createDrawable(location, 0, 0, 166, 65, 0, 0, 0, 0); + background = guiHelper.createDrawable(location, 0, 0, 166, 65); localizedName = I18n.format("botania.nei.brewery"); } @@ -62,12 +62,10 @@ public class BreweryRecipeCategory implements IRecipeCategory { } @Override - public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull IRecipeWrapper recipeWrapper, @Nonnull IIngredients ingredients) { - if(!(recipeWrapper instanceof BreweryRecipeWrapper)) - return; + public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull BreweryRecipeWrapper recipeWrapper, @Nonnull IIngredients ingredients) { - List> inputs = ingredients.getInputs(ItemStack.class); - List> outputs = ingredients.getOutputs(ItemStack.class); + List> inputs = ingredients.getInputs(VanillaTypes.ITEM); + List> outputs = ingredients.getOutputs(VanillaTypes.ITEM); IFocus focus = recipeLayout.getFocus(); recipeLayout.getItemStacks().init(0, true, 39, 41); diff --git a/src/main/java/vazkii/botania/client/integration/jei/brewery/BreweryRecipeWrapper.java b/src/main/java/vazkii/botania/client/integration/jei/brewery/BreweryRecipeWrapper.java index 9c502c189..30bce5f02 100644 --- a/src/main/java/vazkii/botania/client/integration/jei/brewery/BreweryRecipeWrapper.java +++ b/src/main/java/vazkii/botania/client/integration/jei/brewery/BreweryRecipeWrapper.java @@ -10,6 +10,7 @@ package vazkii.botania.client.integration.jei.brewery; import com.google.common.collect.ImmutableList; import mezz.jei.api.ingredients.IIngredients; +import mezz.jei.api.ingredients.VanillaTypes; import mezz.jei.api.recipe.IRecipeWrapper; import net.minecraft.item.ItemStack; import net.minecraftforge.oredict.OreDictionary; @@ -24,8 +25,8 @@ public class BreweryRecipeWrapper implements IRecipeWrapper { private final List> input; private final List output; - - private static final List inputs = Arrays.asList(new ItemStack(ModItems.vial), + + private static final List inputs = Arrays.asList(new ItemStack(ModItems.vial), new ItemStack(ModItems.vial, 1, 1), new ItemStack(ModItems.incenseStick), new ItemStack(ModItems.bloodPendant)); public BreweryRecipeWrapper(RecipeBrew recipeBrew) { @@ -41,7 +42,7 @@ public class BreweryRecipeWrapper implements IRecipeWrapper { } } inputBuilder.add(containers.build()); - + for(Object o : recipeBrew.getInputs()) { if(o instanceof ItemStack) { inputBuilder.add(ImmutableList.of((ItemStack) o)); @@ -57,7 +58,7 @@ public class BreweryRecipeWrapper implements IRecipeWrapper { @Override public void getIngredients(@Nonnull IIngredients ingredients) { - ingredients.setInputLists(ItemStack.class, input); - ingredients.setOutputLists(ItemStack.class, ImmutableList.of(output)); + ingredients.setInputLists(VanillaTypes.ITEM, input); + ingredients.setOutputLists(VanillaTypes.ITEM, ImmutableList.of(output)); } } diff --git a/src/main/java/vazkii/botania/client/integration/jei/crafting/AncientWillRecipeWrapper.java b/src/main/java/vazkii/botania/client/integration/jei/crafting/AncientWillRecipeWrapper.java new file mode 100644 index 000000000..5167ca139 --- /dev/null +++ b/src/main/java/vazkii/botania/client/integration/jei/crafting/AncientWillRecipeWrapper.java @@ -0,0 +1,100 @@ +package vazkii.botania.client.integration.jei.crafting; + +import com.google.common.collect.ImmutableList; +import mezz.jei.api.gui.IGuiItemStackGroup; +import mezz.jei.api.gui.IRecipeLayout; +import mezz.jei.api.ingredients.IIngredients; +import mezz.jei.api.ingredients.VanillaTypes; +import mezz.jei.api.recipe.IFocus; +import mezz.jei.api.recipe.wrapper.ICustomCraftingRecipeWrapper; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; +import vazkii.botania.api.item.IAncientWillContainer; +import vazkii.botania.common.Botania; +import vazkii.botania.common.crafting.recipe.AncientWillRecipe; +import vazkii.botania.common.item.ModItems; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import java.util.List; + +public class AncientWillRecipeWrapper implements ICustomCraftingRecipeWrapper { + private final ResourceLocation name; + private final List> inputs; + private final List output; + + public AncientWillRecipeWrapper(AncientWillRecipe recipe) { + this.name = recipe.getRegistryName(); + + ImmutableList.Builder> builder = ImmutableList.builder(); + ImmutableList.Builder helmets = ImmutableList.builder(); + ImmutableList.Builder wills = ImmutableList.builder(); + helmets.add(new ItemStack(ModItems.terrasteelHelm)); + if(Botania.thaumcraftLoaded) { + helmets.add(new ItemStack(ModItems.terrasteelHelmRevealing)); + } + for(int i = 0; i < 6; i++) { + wills.add(new ItemStack(ModItems.ancientWill, 1, i)); + } + + output = helmets.build(); + builder.add(output); + builder.add(wills.build()); + inputs = builder.build(); + } + + @Override + public void getIngredients(@Nonnull IIngredients ingredients) { + ingredients.setInputLists(VanillaTypes.ITEM, inputs); + ingredients.setOutputLists(VanillaTypes.ITEM, ImmutableList.of(output)); + } + + @Nullable + @Override + public ResourceLocation getRegistryName() { + return name; + } + + @Override + public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull IIngredients ingredients) { + IFocus focus = recipeLayout.getFocus(); + IGuiItemStackGroup group = recipeLayout.getItemStacks(); + group.set(ingredients); + + if(focus != null) { + ItemStack focused = (ItemStack) focus.getValue(); + + if(focus.getMode() == IFocus.Mode.INPUT && focused.getItem() == ModItems.ancientWill) { + group.set(2, new ItemStack(ModItems.ancientWill, 1, focused.getMetadata())); + group.set(0, getHelmetsWithWill(focused.getMetadata())); + } else if(focused.getItem() instanceof IAncientWillContainer) { //helmet + group.set(1, new ItemStack(focused.getItem())); + group.set(0, getWillsOnHelmet(focused.getItem())); + } + } + } + + private List getHelmetsWithWill(int meta) { + ImmutableList.Builder builder = ImmutableList.builder(); + for(ItemStack itemStack : output) { + ItemStack toAdd = itemStack.copy(); + ((IAncientWillContainer) toAdd.getItem()).addAncientWill(toAdd, meta); + builder.add(toAdd); + } + return builder.build(); + } + + private List getWillsOnHelmet(Item item) { + if(item instanceof IAncientWillContainer) { + ImmutableList.Builder builder = ImmutableList.builder(); + for(int i = 0; i < 6; i++) { + ItemStack stack = new ItemStack(item); + ((IAncientWillContainer) item).addAncientWill(stack, i); + builder.add(stack); + } + return builder.build(); + } + return ImmutableList.of(); + } +} diff --git a/src/main/java/vazkii/botania/client/integration/jei/crafting/CompositeLensRecipeWrapper.java b/src/main/java/vazkii/botania/client/integration/jei/crafting/CompositeLensRecipeWrapper.java new file mode 100644 index 000000000..3a3003dcd --- /dev/null +++ b/src/main/java/vazkii/botania/client/integration/jei/crafting/CompositeLensRecipeWrapper.java @@ -0,0 +1,81 @@ +package vazkii.botania.client.integration.jei.crafting; + +import com.google.common.collect.ImmutableList; +import mezz.jei.api.gui.IRecipeLayout; +import mezz.jei.api.ingredients.IIngredients; +import mezz.jei.api.ingredients.VanillaTypes; +import mezz.jei.api.recipe.wrapper.ICustomCraftingRecipeWrapper; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.util.NonNullList; +import vazkii.botania.common.item.ModItems; +import vazkii.botania.common.item.lens.ItemLens; + +import javax.annotation.Nonnull; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +public class CompositeLensRecipeWrapper implements ICustomCraftingRecipeWrapper { + private final List> inputs; + private static final List lenses; + + static { + NonNullList allLenses = NonNullList.create(); + ItemLens lens = (ItemLens) ModItems.lens; + lens.getSubItems(CreativeTabs.SEARCH, allLenses); + lenses = ImmutableList.copyOf(allLenses.stream().filter(stack -> !lens.isControlLens(stack)).filter(lens::isCombinable).collect(Collectors.toList())); + } + + public CompositeLensRecipeWrapper() { + inputs = ImmutableList.of(lenses, ImmutableList.of(new ItemStack(Items.SLIME_BALL)), lenses); + } + + @Override + public void getIngredients(@Nonnull IIngredients ingredients) { + ingredients.setInputLists(VanillaTypes.ITEM, inputs); + } + + @Override + public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull IIngredients ingredients) { + recipeLayout.getItemStacks().set(ingredients); + recipeLayout.setShapeless(); + if(recipeLayout.getFocus() != null) { + ItemStack stack = (ItemStack) recipeLayout.getFocus().getValue(); + if(stack.getItem() == ModItems.lens) { + setLenses(recipeLayout, stack.getMetadata(), stack.getMetadata()); + return; + } + } + setLenses(recipeLayout, 1, ItemLens.SUBTYPES - 1); + } + + private void setLenses(IRecipeLayout recipeLayout, int start, int end) { + List firstInput = new ArrayList<>(); + List secondInput = new ArrayList<>(); + List outputs = new ArrayList<>(); + + if(end >= ItemLens.SUBTYPES) + end = ItemLens.SUBTYPES - 1; + + for(int i = start; i <= end; i++) { + ItemStack firstLens = new ItemStack(ModItems.lens, 1, i); + for(ItemStack secondLens : lenses) { + if(secondLens.getMetadata() == i) + continue; + + if(((ItemLens) ModItems.lens).canCombineLenses(firstLens, secondLens)) { + firstInput.add(firstLens); + secondInput.add(secondLens); + outputs.add(((ItemLens) ModItems.lens).setCompositeLens(firstLens.copy(), secondLens)); + } + } + + } + recipeLayout.getItemStacks().set(1, firstInput); + recipeLayout.getItemStacks().set(3, secondInput); + recipeLayout.getItemStacks().set(0, outputs); + } + +} diff --git a/src/main/java/vazkii/botania/client/integration/jei/crafting/SpecialFloatingFlowerWrapper.java b/src/main/java/vazkii/botania/client/integration/jei/crafting/SpecialFloatingFlowerWrapper.java index 47b16eec1..648f4f8d0 100644 --- a/src/main/java/vazkii/botania/client/integration/jei/crafting/SpecialFloatingFlowerWrapper.java +++ b/src/main/java/vazkii/botania/client/integration/jei/crafting/SpecialFloatingFlowerWrapper.java @@ -2,34 +2,45 @@ package vazkii.botania.client.integration.jei.crafting; import com.google.common.collect.ImmutableList; import mezz.jei.api.ingredients.IIngredients; -import mezz.jei.api.recipe.IRecipeWrapper; +import mezz.jei.api.ingredients.VanillaTypes; +import mezz.jei.api.recipe.wrapper.ICraftingRecipeWrapper; import net.minecraft.item.EnumDyeColor; import net.minecraft.item.ItemStack; -import vazkii.botania.api.BotaniaAPI; +import net.minecraft.util.ResourceLocation; import vazkii.botania.common.block.ModBlocks; import vazkii.botania.common.crafting.recipe.SpecialFloatingFlowerRecipe; import vazkii.botania.common.item.block.ItemBlockSpecialFlower; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; import java.util.ArrayList; import java.util.List; -public class SpecialFloatingFlowerWrapper implements IRecipeWrapper { - private final List> inputs = new ArrayList<>(); - private final ItemStack output; +public class SpecialFloatingFlowerWrapper implements ICraftingRecipeWrapper { + private final List> inputs = new ArrayList<>(); + private final ItemStack output; + private final ResourceLocation name; - public SpecialFloatingFlowerWrapper(SpecialFloatingFlowerRecipe recipe) { - inputs.add(ImmutableList.of(ItemBlockSpecialFlower.ofType(recipe.type))); - List normalFloaters = new ArrayList<>(); - for (EnumDyeColor color : EnumDyeColor.values()) { - normalFloaters.add(new ItemStack(ModBlocks.floatingFlower, 1, color.getMetadata())); - } - inputs.add(normalFloaters); - output = ItemBlockSpecialFlower.ofType(new ItemStack(ModBlocks.floatingSpecialFlower), recipe.type); - } + public SpecialFloatingFlowerWrapper(SpecialFloatingFlowerRecipe recipe) { + name = recipe.getRegistryName(); + inputs.add(ImmutableList.of(ItemBlockSpecialFlower.ofType(recipe.type))); + List normalFloaters = new ArrayList<>(); + for(EnumDyeColor color : EnumDyeColor.values()) { + normalFloaters.add(new ItemStack(ModBlocks.floatingFlower, 1, color.getMetadata())); + } + inputs.add(normalFloaters); + output = ItemBlockSpecialFlower.ofType(new ItemStack(ModBlocks.floatingSpecialFlower), recipe.type); + } - @Override - public void getIngredients(IIngredients ingredients) { - ingredients.setInputLists(ItemStack.class, inputs); - ingredients.setOutput(ItemStack.class, output); - } + @Override + public void getIngredients(@Nonnull IIngredients ingredients) { + ingredients.setInputLists(VanillaTypes.ITEM, inputs); + ingredients.setOutput(VanillaTypes.ITEM, output); + } + + @Nullable + @Override + public ResourceLocation getRegistryName() { + return name; + } } diff --git a/src/main/java/vazkii/botania/client/integration/jei/crafting/TerraPickTippingRecipeWrapper.java b/src/main/java/vazkii/botania/client/integration/jei/crafting/TerraPickTippingRecipeWrapper.java new file mode 100644 index 000000000..053b1d43c --- /dev/null +++ b/src/main/java/vazkii/botania/client/integration/jei/crafting/TerraPickTippingRecipeWrapper.java @@ -0,0 +1,41 @@ +package vazkii.botania.client.integration.jei.crafting; + +import com.google.common.collect.ImmutableList; +import mezz.jei.api.ingredients.IIngredients; +import mezz.jei.api.ingredients.VanillaTypes; +import mezz.jei.api.recipe.wrapper.ICraftingRecipeWrapper; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; +import vazkii.botania.common.crafting.recipe.TerraPickTippingRecipe; +import vazkii.botania.common.item.ModItems; +import vazkii.botania.common.item.equipment.tool.terrasteel.ItemTerraPick; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import java.util.List; + +public class TerraPickTippingRecipeWrapper implements ICraftingRecipeWrapper { + private final List> inputs; + private final ItemStack output; + private final ResourceLocation name; + + public TerraPickTippingRecipeWrapper(TerraPickTippingRecipe recipe) { + inputs = ImmutableList.of(ImmutableList.of(new ItemStack(ModItems.terraPick)), ImmutableList.of(new ItemStack(ModItems.elementiumPick))); + output = new ItemStack(ModItems.terraPick); + ItemTerraPick.setTipped(output); + + this.name = recipe.getRegistryName(); + } + + @Override + public void getIngredients(@Nonnull IIngredients ingredients) { + ingredients.setInputLists(VanillaTypes.ITEM, inputs); + ingredients.setOutput(VanillaTypes.ITEM, output); + } + + @Nullable + @Override + public ResourceLocation getRegistryName() { + return name; + } +} diff --git a/src/main/java/vazkii/botania/client/integration/jei/elventrade/ElvenTradeRecipeCategory.java b/src/main/java/vazkii/botania/client/integration/jei/elventrade/ElvenTradeRecipeCategory.java index a1ae05674..81c1c9c62 100644 --- a/src/main/java/vazkii/botania/client/integration/jei/elventrade/ElvenTradeRecipeCategory.java +++ b/src/main/java/vazkii/botania/client/integration/jei/elventrade/ElvenTradeRecipeCategory.java @@ -12,8 +12,8 @@ import mezz.jei.api.IGuiHelper; import mezz.jei.api.gui.IDrawable; import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.ingredients.IIngredients; +import mezz.jei.api.ingredients.VanillaTypes; import mezz.jei.api.recipe.IRecipeCategory; -import mezz.jei.api.recipe.IRecipeWrapper; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.BufferBuilder; import net.minecraft.client.renderer.GlStateManager; @@ -29,11 +29,9 @@ import vazkii.botania.client.core.handler.MiscellaneousIcons; import vazkii.botania.common.lib.LibMisc; import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import java.util.ArrayList; import java.util.List; -public class ElvenTradeRecipeCategory implements IRecipeCategory { +public class ElvenTradeRecipeCategory implements IRecipeCategory { public static final String UID = "botania.elvenTrade"; private final String localizedName; @@ -89,20 +87,17 @@ public class ElvenTradeRecipeCategory implements IRecipeCategory { } @Override - public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull IRecipeWrapper recipeWrapper, @Nonnull IIngredients ingredients) { - if(!(recipeWrapper instanceof ElvenTradeRecipeWrapper)) - return; - + public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull ElvenTradeRecipeWrapper recipeWrapper, @Nonnull IIngredients ingredients) { int index = 0, posX = 42; - for(List o : ingredients.getInputs(ItemStack.class)) { + for(List o : ingredients.getInputs(VanillaTypes.ITEM)) { recipeLayout.getItemStacks().init(index, true, posX, 0); recipeLayout.getItemStacks().set(index, o); index++; posX += 18; } - for (int i = 0; i < ingredients.getOutputs(ItemStack.class).size(); i++) { - List stacks = ingredients.getOutputs(ItemStack.class).get(i); + for(int i = 0; i < ingredients.getOutputs(VanillaTypes.ITEM).size(); i++) { + List stacks = ingredients.getOutputs(VanillaTypes.ITEM).get(i); recipeLayout.getItemStacks().init(index + i, false, 93 + i % 2 * 20, 41 + i / 2 * 20); recipeLayout.getItemStacks().set(index + i, stacks); } @@ -113,5 +108,5 @@ public class ElvenTradeRecipeCategory implements IRecipeCategory { public String getModName() { return LibMisc.MOD_NAME; } - + } diff --git a/src/main/java/vazkii/botania/client/integration/jei/elventrade/ElvenTradeRecipeWrapper.java b/src/main/java/vazkii/botania/client/integration/jei/elventrade/ElvenTradeRecipeWrapper.java index d00ccf37e..160e308a3 100644 --- a/src/main/java/vazkii/botania/client/integration/jei/elventrade/ElvenTradeRecipeWrapper.java +++ b/src/main/java/vazkii/botania/client/integration/jei/elventrade/ElvenTradeRecipeWrapper.java @@ -10,6 +10,7 @@ package vazkii.botania.client.integration.jei.elventrade; import com.google.common.collect.ImmutableList; import mezz.jei.api.ingredients.IIngredients; +import mezz.jei.api.ingredients.VanillaTypes; import mezz.jei.api.recipe.IRecipeWrapper; import net.minecraft.client.Minecraft; import net.minecraft.item.ItemStack; @@ -24,7 +25,6 @@ public class ElvenTradeRecipeWrapper implements IRecipeWrapper { private final List> input; private final List outputs; - @SuppressWarnings("unchecked") public ElvenTradeRecipeWrapper(RecipeElvenTrade recipe) { ImmutableList.Builder> builder = ImmutableList.builder(); for(Object o : recipe.getInputs()) { @@ -41,7 +41,7 @@ public class ElvenTradeRecipeWrapper implements IRecipeWrapper { @Override public void getIngredients(@Nonnull IIngredients ingredients) { - ingredients.setInputLists(ItemStack.class, input); - ingredients.setOutputs(ItemStack.class, outputs); + ingredients.setInputLists(VanillaTypes.ITEM, input); + ingredients.setOutputs(VanillaTypes.ITEM, outputs); } } diff --git a/src/main/java/vazkii/botania/client/integration/jei/manapool/ManaPoolRecipeCategory.java b/src/main/java/vazkii/botania/client/integration/jei/manapool/ManaPoolRecipeCategory.java index fda764fc6..d91bb0524 100644 --- a/src/main/java/vazkii/botania/client/integration/jei/manapool/ManaPoolRecipeCategory.java +++ b/src/main/java/vazkii/botania/client/integration/jei/manapool/ManaPoolRecipeCategory.java @@ -12,8 +12,8 @@ import mezz.jei.api.IGuiHelper; import mezz.jei.api.gui.IDrawable; import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.ingredients.IIngredients; +import mezz.jei.api.ingredients.VanillaTypes; import mezz.jei.api.recipe.IRecipeCategory; -import mezz.jei.api.recipe.IRecipeWrapper; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.resources.I18n; @@ -28,7 +28,7 @@ import javax.annotation.Nullable; import java.util.ArrayList; import java.util.List; -public class ManaPoolRecipeCategory implements IRecipeCategory { +public class ManaPoolRecipeCategory implements IRecipeCategory { public static final String UID = "botania.manaPool"; private final IDrawable background; @@ -78,21 +78,18 @@ public class ManaPoolRecipeCategory implements IRecipeCategory { } @Override - public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull IRecipeWrapper recipeWrapper, @Nonnull IIngredients ingredients) { - if(!(recipeWrapper instanceof ManaPoolRecipeWrapper)) - return; - + public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull ManaPoolRecipeWrapper recipeWrapper, @Nonnull IIngredients ingredients) { int index = 0; recipeLayout.getItemStacks().init(index, true, 40, 12); - recipeLayout.getItemStacks().set(index, ingredients.getInputs(ItemStack.class).get(0)); + recipeLayout.getItemStacks().set(index, ingredients.getInputs(VanillaTypes.ITEM).get(0)); index++; - if(ingredients.getInputs(ItemStack.class).size() > 1) { + if(ingredients.getInputs(VanillaTypes.ITEM).size() > 1) { // Has catalyst recipeLayout.getItemStacks().init(index, true, 20, 12); - recipeLayout.getItemStacks().set(index, ingredients.getInputs(ItemStack.class).get(1)); + recipeLayout.getItemStacks().set(index, ingredients.getInputs(VanillaTypes.ITEM).get(1)); index++; } @@ -101,12 +98,13 @@ public class ManaPoolRecipeCategory implements IRecipeCategory { index++; recipeLayout.getItemStacks().init(index, false, 99, 12); - recipeLayout.getItemStacks().set(index, ingredients.getOutputs(ItemStack.class).get(0)); + recipeLayout.getItemStacks().set(index, ingredients.getOutputs(VanillaTypes.ITEM).get(0)); } + @Nonnull @Override - public List getTooltipStrings(int mouseX, int mouseY) { - return new ArrayList(); + public List getTooltipStrings(int mouseX, int mouseY) { + return new ArrayList<>(); } @Nonnull diff --git a/src/main/java/vazkii/botania/client/integration/jei/manapool/ManaPoolRecipeWrapper.java b/src/main/java/vazkii/botania/client/integration/jei/manapool/ManaPoolRecipeWrapper.java index 18d36461c..d0cb9be1e 100644 --- a/src/main/java/vazkii/botania/client/integration/jei/manapool/ManaPoolRecipeWrapper.java +++ b/src/main/java/vazkii/botania/client/integration/jei/manapool/ManaPoolRecipeWrapper.java @@ -10,6 +10,7 @@ package vazkii.botania.client.integration.jei.manapool; import com.google.common.collect.ImmutableList; import mezz.jei.api.ingredients.IIngredients; +import mezz.jei.api.ingredients.VanillaTypes; import mezz.jei.api.recipe.IRecipeWrapper; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; @@ -54,8 +55,8 @@ public class ManaPoolRecipeWrapper implements IRecipeWrapper { @Override public void getIngredients(@Nonnull IIngredients ingredients) { - ingredients.setInputLists(ItemStack.class, input); - ingredients.setOutput(ItemStack.class, output); + ingredients.setInputLists(VanillaTypes.ITEM, input); + ingredients.setOutput(VanillaTypes.ITEM, output); } @Override diff --git a/src/main/java/vazkii/botania/client/integration/jei/orechid/OrechidIgnemRecipeCategory.java b/src/main/java/vazkii/botania/client/integration/jei/orechid/OrechidIgnemRecipeCategory.java index 95ed99e5d..1f586543d 100644 --- a/src/main/java/vazkii/botania/client/integration/jei/orechid/OrechidIgnemRecipeCategory.java +++ b/src/main/java/vazkii/botania/client/integration/jei/orechid/OrechidIgnemRecipeCategory.java @@ -1,92 +1,91 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: - * https://github.com/Vazkii/Botania - *

- * Botania is Open Source and distributed under the - * Botania License: http://botaniamod.net/license.php - */ -package vazkii.botania.client.integration.jei.orechid; - -import mezz.jei.api.IGuiHelper; -import mezz.jei.api.gui.IDrawable; -import mezz.jei.api.gui.IDrawableStatic; -import mezz.jei.api.gui.IGuiItemStackGroup; -import mezz.jei.api.gui.IRecipeLayout; -import mezz.jei.api.ingredients.IIngredients; -import mezz.jei.api.recipe.IRecipeCategory; -import mezz.jei.api.recipe.IRecipeWrapper; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.resources.I18n; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; -import vazkii.botania.common.item.block.ItemBlockSpecialFlower; -import vazkii.botania.common.lib.LibBlockNames; -import vazkii.botania.common.lib.LibMisc; - -import javax.annotation.Nonnull; - -public class OrechidIgnemRecipeCategory implements IRecipeCategory { - - public static final String UID = "botania.orechid_ignem"; - private final IDrawableStatic background; - private final String localizedName; - private final IDrawableStatic overlay; - - public OrechidIgnemRecipeCategory(IGuiHelper guiHelper) { - background = guiHelper.createBlankDrawable(168, 64); - localizedName = I18n.format("botania.nei.orechidIgnem"); - overlay = guiHelper.createDrawable(new ResourceLocation("botania", "textures/gui/pureDaisyOverlay.png"), - 0, 0, 64, 46); - } - - @Nonnull - @Override - public String getUid() { - return UID; - } - - @Nonnull - @Override - public String getTitle() { - return localizedName; - } - - @Nonnull - @Override - public IDrawable getBackground() { - return background; - } - - - @Override - public void setRecipe(IRecipeLayout recipeLayout, IRecipeWrapper recipeWrapper, IIngredients ingredients) { - final IGuiItemStackGroup itemStacks = recipeLayout.getItemStacks(); - - itemStacks.init(0, true, 40, 12); - itemStacks.set(0, ingredients.getInputs(ItemStack.class).get(0)); - - itemStacks.init(1, true, 70, 12); - itemStacks.set(1, ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_ORECHID_IGNEM)); - - itemStacks.init(2, true, 99, 12); - itemStacks.set(2, ingredients.getOutputs(ItemStack.class).get(0)); - } - - @Override - public void drawExtras(@Nonnull Minecraft minecraft) { - GlStateManager.enableAlpha(); - GlStateManager.enableBlend(); - overlay.draw(minecraft, 48, 0); - GlStateManager.disableBlend(); - GlStateManager.disableAlpha(); - } - - @Nonnull - @Override - public String getModName() { - return LibMisc.MOD_NAME; - } - -} +/** + * This class was created by . It's distributed as + * part of the Botania Mod. Get the Source Code in github: + * https://github.com/Vazkii/Botania + *

+ * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php + */ +package vazkii.botania.client.integration.jei.orechid; + +import mezz.jei.api.IGuiHelper; +import mezz.jei.api.gui.IDrawable; +import mezz.jei.api.gui.IDrawableStatic; +import mezz.jei.api.gui.IGuiItemStackGroup; +import mezz.jei.api.gui.IRecipeLayout; +import mezz.jei.api.ingredients.IIngredients; +import mezz.jei.api.ingredients.VanillaTypes; +import mezz.jei.api.recipe.IRecipeCategory; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.resources.I18n; +import net.minecraft.util.ResourceLocation; +import vazkii.botania.common.item.block.ItemBlockSpecialFlower; +import vazkii.botania.common.lib.LibBlockNames; +import vazkii.botania.common.lib.LibMisc; + +import javax.annotation.Nonnull; + +public class OrechidIgnemRecipeCategory implements IRecipeCategory { + + public static final String UID = "botania.orechid_ignem"; + private final IDrawableStatic background; + private final String localizedName; + private final IDrawableStatic overlay; + + public OrechidIgnemRecipeCategory(IGuiHelper guiHelper) { + background = guiHelper.createBlankDrawable(168, 64); + localizedName = I18n.format("botania.nei.orechidIgnem"); + overlay = guiHelper.createDrawable(new ResourceLocation("botania", "textures/gui/pureDaisyOverlay.png"), + 0, 0, 64, 46); + } + + @Nonnull + @Override + public String getUid() { + return UID; + } + + @Nonnull + @Override + public String getTitle() { + return localizedName; + } + + @Nonnull + @Override + public IDrawable getBackground() { + return background; + } + + + @Override + public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull OrechidIgnemRecipeWrapper recipeWrapper, @Nonnull IIngredients ingredients) { + final IGuiItemStackGroup itemStacks = recipeLayout.getItemStacks(); + + itemStacks.init(0, true, 40, 12); + itemStacks.set(0, ingredients.getInputs(VanillaTypes.ITEM).get(0)); + + itemStacks.init(1, true, 70, 12); + itemStacks.set(1, ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_ORECHID_IGNEM)); + + itemStacks.init(2, true, 99, 12); + itemStacks.set(2, ingredients.getOutputs(VanillaTypes.ITEM).get(0)); + } + + @Override + public void drawExtras(@Nonnull Minecraft minecraft) { + GlStateManager.enableAlpha(); + GlStateManager.enableBlend(); + overlay.draw(minecraft, 48, 0); + GlStateManager.disableBlend(); + GlStateManager.disableAlpha(); + } + + @Nonnull + @Override + public String getModName() { + return LibMisc.MOD_NAME; + } + +} diff --git a/src/main/java/vazkii/botania/client/integration/jei/orechid/OrechidIgnemRecipeWrapper.java b/src/main/java/vazkii/botania/client/integration/jei/orechid/OrechidIgnemRecipeWrapper.java index 617bf00e8..5367862d3 100644 --- a/src/main/java/vazkii/botania/client/integration/jei/orechid/OrechidIgnemRecipeWrapper.java +++ b/src/main/java/vazkii/botania/client/integration/jei/orechid/OrechidIgnemRecipeWrapper.java @@ -1,32 +1,32 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: - * https://github.com/Vazkii/Botania - *

- * Botania is Open Source and distributed under the - * Botania License: http://botaniamod.net/license.php - */ -package vazkii.botania.client.integration.jei.orechid; - -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import vazkii.botania.api.BotaniaAPI; - -import java.util.Map; - -public class OrechidIgnemRecipeWrapper extends OrechidRecipeWrapper { - - public OrechidIgnemRecipeWrapper(Map.Entry entry) { - super(entry); - } - - @Override - protected ItemStack getInputStack() { - return new ItemStack(Blocks.NETHERRACK, 64); - } - - public Map getOreWeights() { - return BotaniaAPI.oreWeightsNether; - } - -} +/** + * This class was created by . It's distributed as + * part of the Botania Mod. Get the Source Code in github: + * https://github.com/Vazkii/Botania + *

+ * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php + */ +package vazkii.botania.client.integration.jei.orechid; + +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import vazkii.botania.api.BotaniaAPI; + +import java.util.Map; + +public class OrechidIgnemRecipeWrapper extends OrechidRecipeWrapper { + + public OrechidIgnemRecipeWrapper(Map.Entry entry) { + super(entry); + } + + @Override + protected ItemStack getInputStack() { + return new ItemStack(Blocks.NETHERRACK, 64); + } + + public Map getOreWeights() { + return BotaniaAPI.oreWeightsNether; + } + +} diff --git a/src/main/java/vazkii/botania/client/integration/jei/orechid/OrechidRecipeCategory.java b/src/main/java/vazkii/botania/client/integration/jei/orechid/OrechidRecipeCategory.java index 49e7526c2..653344e18 100644 --- a/src/main/java/vazkii/botania/client/integration/jei/orechid/OrechidRecipeCategory.java +++ b/src/main/java/vazkii/botania/client/integration/jei/orechid/OrechidRecipeCategory.java @@ -1,92 +1,91 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: - * https://github.com/Vazkii/Botania - *

- * Botania is Open Source and distributed under the - * Botania License: http://botaniamod.net/license.php - */ -package vazkii.botania.client.integration.jei.orechid; - -import mezz.jei.api.IGuiHelper; -import mezz.jei.api.gui.IDrawable; -import mezz.jei.api.gui.IDrawableStatic; -import mezz.jei.api.gui.IGuiItemStackGroup; -import mezz.jei.api.gui.IRecipeLayout; -import mezz.jei.api.ingredients.IIngredients; -import mezz.jei.api.recipe.IRecipeCategory; -import mezz.jei.api.recipe.IRecipeWrapper; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.resources.I18n; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; -import vazkii.botania.common.item.block.ItemBlockSpecialFlower; -import vazkii.botania.common.lib.LibBlockNames; -import vazkii.botania.common.lib.LibMisc; - -import javax.annotation.Nonnull; - -public class OrechidRecipeCategory implements IRecipeCategory { - - public static final String UID = "botania.orechid"; - private final IDrawableStatic background; - private final String localizedName; - private final IDrawableStatic overlay; - - public OrechidRecipeCategory(IGuiHelper guiHelper) { - background = guiHelper.createBlankDrawable(168, 64); - localizedName = I18n.format("botania.nei.orechid"); - overlay = guiHelper.createDrawable(new ResourceLocation("botania", "textures/gui/pureDaisyOverlay.png"), - 0, 0, 64, 46); - } - - @Nonnull - @Override - public String getUid() { - return UID; - } - - @Nonnull - @Override - public String getTitle() { - return localizedName; - } - - @Nonnull - @Override - public IDrawable getBackground() { - return background; - } - - - @Override - public void setRecipe(IRecipeLayout recipeLayout, IRecipeWrapper recipeWrapper, IIngredients ingredients) { - final IGuiItemStackGroup itemStacks = recipeLayout.getItemStacks(); - - itemStacks.init(0, true, 40, 12); - itemStacks.set(0, ingredients.getInputs(ItemStack.class).get(0)); - - itemStacks.init(1, true, 70, 12); - itemStacks.set(1, ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_ORECHID)); - - itemStacks.init(2, true, 99, 12); - itemStacks.set(2, ingredients.getOutputs(ItemStack.class).get(0)); - } - - @Override - public void drawExtras(@Nonnull Minecraft minecraft) { - GlStateManager.enableAlpha(); - GlStateManager.enableBlend(); - overlay.draw(minecraft, 48, 0); - GlStateManager.disableBlend(); - GlStateManager.disableAlpha(); - } - - @Nonnull - @Override - public String getModName() { - return LibMisc.MOD_NAME; - } - -} +/** + * This class was created by . It's distributed as + * part of the Botania Mod. Get the Source Code in github: + * https://github.com/Vazkii/Botania + *

+ * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php + */ +package vazkii.botania.client.integration.jei.orechid; + +import mezz.jei.api.IGuiHelper; +import mezz.jei.api.gui.IDrawable; +import mezz.jei.api.gui.IDrawableStatic; +import mezz.jei.api.gui.IGuiItemStackGroup; +import mezz.jei.api.gui.IRecipeLayout; +import mezz.jei.api.ingredients.IIngredients; +import mezz.jei.api.ingredients.VanillaTypes; +import mezz.jei.api.recipe.IRecipeCategory; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.resources.I18n; +import net.minecraft.util.ResourceLocation; +import vazkii.botania.common.item.block.ItemBlockSpecialFlower; +import vazkii.botania.common.lib.LibBlockNames; +import vazkii.botania.common.lib.LibMisc; + +import javax.annotation.Nonnull; + +public class OrechidRecipeCategory implements IRecipeCategory { + + public static final String UID = "botania.orechid"; + private final IDrawableStatic background; + private final String localizedName; + private final IDrawableStatic overlay; + + public OrechidRecipeCategory(IGuiHelper guiHelper) { + background = guiHelper.createBlankDrawable(168, 64); + localizedName = I18n.format("botania.nei.orechid"); + overlay = guiHelper.createDrawable(new ResourceLocation("botania", "textures/gui/pureDaisyOverlay.png"), + 0, 0, 64, 46); + } + + @Nonnull + @Override + public String getUid() { + return UID; + } + + @Nonnull + @Override + public String getTitle() { + return localizedName; + } + + @Nonnull + @Override + public IDrawable getBackground() { + return background; + } + + + @Override + public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull OrechidRecipeWrapper recipeWrapper, @Nonnull IIngredients ingredients) { + final IGuiItemStackGroup itemStacks = recipeLayout.getItemStacks(); + + itemStacks.init(0, true, 40, 12); + itemStacks.set(0, ingredients.getInputs(VanillaTypes.ITEM).get(0)); + + itemStacks.init(1, true, 70, 12); + itemStacks.set(1, ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_ORECHID)); + + itemStacks.init(2, true, 99, 12); + itemStacks.set(2, ingredients.getOutputs(VanillaTypes.ITEM).get(0)); + } + + @Override + public void drawExtras(@Nonnull Minecraft minecraft) { + GlStateManager.enableAlpha(); + GlStateManager.enableBlend(); + overlay.draw(minecraft, 48, 0); + GlStateManager.disableBlend(); + GlStateManager.disableAlpha(); + } + + @Nonnull + @Override + public String getModName() { + return LibMisc.MOD_NAME; + } + +} diff --git a/src/main/java/vazkii/botania/client/integration/jei/orechid/OrechidRecipeWrapper.java b/src/main/java/vazkii/botania/client/integration/jei/orechid/OrechidRecipeWrapper.java index cac565660..498a8dfd7 100644 --- a/src/main/java/vazkii/botania/client/integration/jei/orechid/OrechidRecipeWrapper.java +++ b/src/main/java/vazkii/botania/client/integration/jei/orechid/OrechidRecipeWrapper.java @@ -1,74 +1,75 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: - * https://github.com/Vazkii/Botania - *

- * Botania is Open Source and distributed under the - * Botania License: http://botaniamod.net/license.php - */ -package vazkii.botania.client.integration.jei.orechid; - -import mezz.jei.api.ingredients.IIngredients; -import mezz.jei.api.ingredients.VanillaTypes; -import mezz.jei.api.recipe.IRecipeWrapper; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemStack; -import net.minecraftforge.oredict.OreDictionary; -import vazkii.botania.api.BotaniaAPI; - -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -import static vazkii.botania.client.integration.jei.JEIBotaniaPlugin.doesOreExist; - -public class OrechidRecipeWrapper implements IRecipeWrapper, Comparable { - - private final int weight; - private final List> outputStacks; - - protected ItemStack getInputStack() { - return new ItemStack(Blocks.STONE, 64); - } - - public OrechidRecipeWrapper(Map.Entry entry) { - this.weight = entry.getValue(); - - final int amount = Math.max(1, Math.round((float) weight * 64 / getTotalOreWeight())); - - // Shouldn't ever return an empty list since the ore weight - // list is filtered to only have ores with ItemBlocks - List stackList = OreDictionary.getOres(entry.getKey()).stream() - .filter(s -> s.getItem() instanceof ItemBlock) - .map(ItemStack::copy) - .collect(Collectors.toList()); - - stackList.forEach(s -> s.setCount(amount)); - - outputStacks = Collections.singletonList(stackList); - } - - public Map getOreWeights() { - return BotaniaAPI.oreWeights; - } - - private float getTotalOreWeight() { - return (getOreWeights().entrySet().stream() - .filter(e -> doesOreExist(e.getKey())) - .map(Map.Entry::getValue) - .reduce(Integer::sum)).orElse(weight * 64 * 64); - } - - @Override - public void getIngredients(IIngredients ingredients) { - ingredients.setInput(VanillaTypes.ITEM, getInputStack()); - ingredients.setOutputLists(VanillaTypes.ITEM, outputStacks); - } - - @Override - public int compareTo(OrechidRecipeWrapper o) { - return Integer.compare(o.weight, weight); - } -} +/** + * This class was created by . It's distributed as + * part of the Botania Mod. Get the Source Code in github: + * https://github.com/Vazkii/Botania + *

+ * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php + */ +package vazkii.botania.client.integration.jei.orechid; + +import mezz.jei.api.ingredients.IIngredients; +import mezz.jei.api.ingredients.VanillaTypes; +import mezz.jei.api.recipe.IRecipeWrapper; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraftforge.oredict.OreDictionary; +import vazkii.botania.api.BotaniaAPI; + +import javax.annotation.Nonnull; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +import static vazkii.botania.client.integration.jei.JEIBotaniaPlugin.doesOreExist; + +public class OrechidRecipeWrapper implements IRecipeWrapper, Comparable { + + private final int weight; + private final List> outputStacks; + + protected ItemStack getInputStack() { + return new ItemStack(Blocks.STONE, 64); + } + + public OrechidRecipeWrapper(Map.Entry entry) { + this.weight = entry.getValue(); + + final int amount = Math.max(1, Math.round((float) weight * 64 / getTotalOreWeight())); + + // Shouldn't ever return an empty list since the ore weight + // list is filtered to only have ores with ItemBlocks + List stackList = OreDictionary.getOres(entry.getKey()).stream() + .filter(s -> s.getItem() instanceof ItemBlock) + .map(ItemStack::copy) + .collect(Collectors.toList()); + + stackList.forEach(s -> s.setCount(amount)); + + outputStacks = Collections.singletonList(stackList); + } + + public Map getOreWeights() { + return BotaniaAPI.oreWeights; + } + + private float getTotalOreWeight() { + return (getOreWeights().entrySet().stream() + .filter(e -> doesOreExist(e.getKey())) + .map(Map.Entry::getValue) + .reduce(Integer::sum)).orElse(weight * 64 * 64); + } + + @Override + public void getIngredients(@Nonnull IIngredients ingredients) { + ingredients.setInput(VanillaTypes.ITEM, getInputStack()); + ingredients.setOutputLists(VanillaTypes.ITEM, outputStacks); + } + + @Override + public int compareTo(@Nonnull OrechidRecipeWrapper o) { + return Integer.compare(o.weight, weight); + } +} diff --git a/src/main/java/vazkii/botania/client/integration/jei/petalapothecary/PetalApothecaryRecipeCategory.java b/src/main/java/vazkii/botania/client/integration/jei/petalapothecary/PetalApothecaryRecipeCategory.java index ddf0ee744..84dc0dfef 100644 --- a/src/main/java/vazkii/botania/client/integration/jei/petalapothecary/PetalApothecaryRecipeCategory.java +++ b/src/main/java/vazkii/botania/client/integration/jei/petalapothecary/PetalApothecaryRecipeCategory.java @@ -13,6 +13,7 @@ import mezz.jei.api.gui.IDrawable; import mezz.jei.api.gui.IDrawableStatic; import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.ingredients.IIngredients; +import mezz.jei.api.ingredients.VanillaTypes; import mezz.jei.api.recipe.IRecipeCategory; import mezz.jei.api.recipe.IRecipeWrapper; import net.minecraft.client.Minecraft; @@ -29,7 +30,7 @@ import java.awt.Point; import java.util.ArrayList; import java.util.List; -public class PetalApothecaryRecipeCategory implements IRecipeCategory { +public class PetalApothecaryRecipeCategory implements IRecipeCategory { public static final String UID = "botania.petals"; private final IDrawableStatic background; @@ -71,18 +72,15 @@ public class PetalApothecaryRecipeCategory implements IRecipeCategory { } @Override - public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull IRecipeWrapper recipeWrapper, @Nonnull IIngredients ingredients) { - if(!(recipeWrapper instanceof PetalApothecaryRecipeWrapper)) - return; - + public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull PetalApothecaryRecipeWrapper recipeWrapper, @Nonnull IIngredients ingredients) { recipeLayout.getItemStacks().init(0, true, 64, 52); recipeLayout.getItemStacks().set(0, new ItemStack(ModBlocks.altar)); int index = 1; - double angleBetweenEach = 360.0 / ingredients.getInputs(ItemStack.class).size(); + double angleBetweenEach = 360.0 / ingredients.getInputs(VanillaTypes.ITEM).size(); Point point = new Point(64, 20), center = new Point(64, 52); - for(List o : ingredients.getInputs(ItemStack.class)) { + for(List o : ingredients.getInputs(VanillaTypes.ITEM)) { recipeLayout.getItemStacks().init(index, true, point.x, point.y); recipeLayout.getItemStacks().set(index, o); index += 1; @@ -90,7 +88,7 @@ public class PetalApothecaryRecipeCategory implements IRecipeCategory { } recipeLayout.getItemStacks().init(index, false, 103, 17); - recipeLayout.getItemStacks().set(index, ingredients.getOutputs(ItemStack.class).get(0)); + recipeLayout.getItemStacks().set(index, ingredients.getOutputs(VanillaTypes.ITEM).get(0)); } private Point rotatePointAbout(Point in, Point about, double degrees) { diff --git a/src/main/java/vazkii/botania/client/integration/jei/petalapothecary/PetalApothecaryRecipeWrapper.java b/src/main/java/vazkii/botania/client/integration/jei/petalapothecary/PetalApothecaryRecipeWrapper.java index 05eab87a4..425da04cd 100644 --- a/src/main/java/vazkii/botania/client/integration/jei/petalapothecary/PetalApothecaryRecipeWrapper.java +++ b/src/main/java/vazkii/botania/client/integration/jei/petalapothecary/PetalApothecaryRecipeWrapper.java @@ -10,8 +10,8 @@ package vazkii.botania.client.integration.jei.petalapothecary; import com.google.common.collect.ImmutableList; import mezz.jei.api.ingredients.IIngredients; +import mezz.jei.api.ingredients.VanillaTypes; import mezz.jei.api.recipe.IRecipeWrapper; -import net.minecraft.client.Minecraft; import net.minecraft.item.ItemStack; import net.minecraftforge.oredict.OreDictionary; import vazkii.botania.api.recipe.RecipePetals; @@ -40,8 +40,8 @@ public class PetalApothecaryRecipeWrapper implements IRecipeWrapper { @Override public void getIngredients(@Nonnull IIngredients ingredients) { - ingredients.setInputLists(ItemStack.class, input); - ingredients.setOutput(ItemStack.class, output); + ingredients.setInputLists(VanillaTypes.ITEM, input); + ingredients.setOutput(VanillaTypes.ITEM, output); } } diff --git a/src/main/java/vazkii/botania/client/integration/jei/puredaisy/PureDaisyRecipeCategory.java b/src/main/java/vazkii/botania/client/integration/jei/puredaisy/PureDaisyRecipeCategory.java index c14b7277b..361d3317e 100644 --- a/src/main/java/vazkii/botania/client/integration/jei/puredaisy/PureDaisyRecipeCategory.java +++ b/src/main/java/vazkii/botania/client/integration/jei/puredaisy/PureDaisyRecipeCategory.java @@ -12,6 +12,7 @@ import mezz.jei.api.IGuiHelper; import mezz.jei.api.gui.IDrawable; import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.ingredients.IIngredients; +import mezz.jei.api.ingredients.VanillaTypes; import mezz.jei.api.recipe.IRecipeCategory; import mezz.jei.api.recipe.IRecipeWrapper; import net.minecraft.client.Minecraft; @@ -29,7 +30,7 @@ import javax.annotation.Nullable; import java.util.ArrayList; import java.util.List; -public class PureDaisyRecipeCategory implements IRecipeCategory { +public class PureDaisyRecipeCategory implements IRecipeCategory { public static final String UID = "botania.pureDaisy"; private final IDrawable background; @@ -71,19 +72,16 @@ public class PureDaisyRecipeCategory implements IRecipeCategory { } @Override - public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull IRecipeWrapper recipeWrapper, @Nonnull IIngredients ingredients) { - if(!(recipeWrapper instanceof PureDaisyRecipeWrapper)) - return; - - boolean inputFluid = !ingredients.getInputs(FluidStack.class).isEmpty(); - boolean outputFluid = !ingredients.getOutputs(FluidStack.class).isEmpty(); + public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull PureDaisyRecipeWrapper recipeWrapper, @Nonnull IIngredients ingredients) { + boolean inputFluid = !ingredients.getInputs(VanillaTypes.FLUID).isEmpty(); + boolean outputFluid = !ingredients.getOutputs(VanillaTypes.FLUID).isEmpty(); if(inputFluid) { recipeLayout.getFluidStacks().init(0, true, 40, 12, 16, 16, 1000, false, null); - recipeLayout.getFluidStacks().set(0, ingredients.getInputs(FluidStack.class).get(0)); + recipeLayout.getFluidStacks().set(0, ingredients.getInputs(VanillaTypes.FLUID).get(0)); } else { recipeLayout.getItemStacks().init(0, true, 40, 12); - recipeLayout.getItemStacks().set(0, ingredients.getInputs(ItemStack.class).get(0)); + recipeLayout.getItemStacks().set(0, ingredients.getInputs(VanillaTypes.ITEM).get(0)); } recipeLayout.getItemStacks().init(1, true, 70, 12); @@ -91,10 +89,10 @@ public class PureDaisyRecipeCategory implements IRecipeCategory { if(outputFluid) { recipeLayout.getFluidStacks().init(2, false, 99, 12, 16, 16, 1000, false, null); - recipeLayout.getFluidStacks().set(2, ingredients.getOutputs(FluidStack.class).get(0)); + recipeLayout.getFluidStacks().set(2, ingredients.getOutputs(VanillaTypes.FLUID).get(0)); } else { recipeLayout.getItemStacks().init(2, false, 99, 12); - recipeLayout.getItemStacks().set(2, ingredients.getOutputs(ItemStack.class).get(0)); + recipeLayout.getItemStacks().set(2, ingredients.getOutputs(VanillaTypes.ITEM).get(0)); } } diff --git a/src/main/java/vazkii/botania/client/integration/jei/puredaisy/PureDaisyRecipeWrapper.java b/src/main/java/vazkii/botania/client/integration/jei/puredaisy/PureDaisyRecipeWrapper.java index aa48aadec..28583c235 100644 --- a/src/main/java/vazkii/botania/client/integration/jei/puredaisy/PureDaisyRecipeWrapper.java +++ b/src/main/java/vazkii/botania/client/integration/jei/puredaisy/PureDaisyRecipeWrapper.java @@ -10,6 +10,7 @@ package vazkii.botania.client.integration.jei.puredaisy; import com.google.common.collect.ImmutableList; import mezz.jei.api.ingredients.IIngredients; +import mezz.jei.api.ingredients.VanillaTypes; import mezz.jei.api.recipe.IRecipeWrapper; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; @@ -54,18 +55,18 @@ public class PureDaisyRecipeWrapper implements IRecipeWrapper { @Override public void getIngredients(@Nonnull IIngredients ingredients) { - ingredients.setInputs(ItemStack.class, inputs); + ingredients.setInputs(VanillaTypes.ITEM, inputs); if (fluidInput != null) { - ingredients.setInput(FluidStack.class, fluidInput); + ingredients.setInput(VanillaTypes.FLUID, fluidInput); } if (!output.isEmpty()) { - ingredients.setOutput(ItemStack.class, output); + ingredients.setOutput(VanillaTypes.ITEM, output); } if (fluidOutput != null) { - ingredients.setOutput(FluidStack.class, fluidOutput); + ingredients.setOutput(VanillaTypes.FLUID, fluidOutput); } } diff --git a/src/main/java/vazkii/botania/client/integration/jei/runicaltar/RunicAltarRecipeCategory.java b/src/main/java/vazkii/botania/client/integration/jei/runicaltar/RunicAltarRecipeCategory.java index 433097f60..c1cf04905 100644 --- a/src/main/java/vazkii/botania/client/integration/jei/runicaltar/RunicAltarRecipeCategory.java +++ b/src/main/java/vazkii/botania/client/integration/jei/runicaltar/RunicAltarRecipeCategory.java @@ -12,8 +12,8 @@ import mezz.jei.api.IGuiHelper; import mezz.jei.api.gui.IDrawable; import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.ingredients.IIngredients; +import mezz.jei.api.ingredients.VanillaTypes; import mezz.jei.api.recipe.IRecipeCategory; -import mezz.jei.api.recipe.IRecipeWrapper; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.resources.I18n; @@ -23,12 +23,10 @@ import vazkii.botania.common.block.ModBlocks; import vazkii.botania.common.lib.LibMisc; import javax.annotation.Nonnull; -import javax.annotation.Nullable; import java.awt.Point; -import java.util.ArrayList; import java.util.List; -public class RunicAltarRecipeCategory implements IRecipeCategory { +public class RunicAltarRecipeCategory implements IRecipeCategory { public static final String UID = "botania.runicAltar"; private final IDrawable background; @@ -70,19 +68,15 @@ public class RunicAltarRecipeCategory implements IRecipeCategory { } @Override - public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull IRecipeWrapper recipeWrapper, @Nonnull IIngredients ingredients) { - if(!(recipeWrapper instanceof RunicAltarRecipeWrapper)) - return; - RunicAltarRecipeWrapper wrapper = (RunicAltarRecipeWrapper) recipeWrapper; - + public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull RunicAltarRecipeWrapper recipeWrapper, @Nonnull IIngredients ingredients) { recipeLayout.getItemStacks().init(0, true, 64, 52); recipeLayout.getItemStacks().set(0, new ItemStack(ModBlocks.runeAltar)); int index = 1; - double angleBetweenEach = 360.0 / ingredients.getInputs(ItemStack.class).size(); + double angleBetweenEach = 360.0 / ingredients.getInputs(VanillaTypes.ITEM).size(); Point point = new Point(64, 20), center = new Point(64, 52); - for(List o : ingredients.getInputs(ItemStack.class)) { + for(List o : ingredients.getInputs(VanillaTypes.ITEM)) { recipeLayout.getItemStacks().init(index, true, point.x, point.y); recipeLayout.getItemStacks().set(index, o); index += 1; @@ -90,7 +84,7 @@ public class RunicAltarRecipeCategory implements IRecipeCategory { } recipeLayout.getItemStacks().init(index, false, 103, 17); - recipeLayout.getItemStacks().set(index, ingredients.getOutputs(ItemStack.class).get(0)); + recipeLayout.getItemStacks().set(index, ingredients.getOutputs(VanillaTypes.ITEM).get(0)); } @@ -106,5 +100,5 @@ public class RunicAltarRecipeCategory implements IRecipeCategory { public String getModName() { return LibMisc.MOD_NAME; } - + } diff --git a/src/main/java/vazkii/botania/client/integration/jei/runicaltar/RunicAltarRecipeWrapper.java b/src/main/java/vazkii/botania/client/integration/jei/runicaltar/RunicAltarRecipeWrapper.java index d6d691c89..56c85735f 100644 --- a/src/main/java/vazkii/botania/client/integration/jei/runicaltar/RunicAltarRecipeWrapper.java +++ b/src/main/java/vazkii/botania/client/integration/jei/runicaltar/RunicAltarRecipeWrapper.java @@ -10,6 +10,7 @@ package vazkii.botania.client.integration.jei.runicaltar; import com.google.common.collect.ImmutableList; import mezz.jei.api.ingredients.IIngredients; +import mezz.jei.api.ingredients.VanillaTypes; import mezz.jei.api.recipe.IRecipeWrapper; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.GlStateManager; @@ -28,7 +29,6 @@ public class RunicAltarRecipeWrapper implements IRecipeWrapper { private final ItemStack output; private final int manaUsage; - @SuppressWarnings("unchecked") public RunicAltarRecipeWrapper(RecipeRuneAltar recipe) { ImmutableList.Builder> builder = ImmutableList.builder(); for(Object o : recipe.getInputs()) { @@ -46,8 +46,8 @@ public class RunicAltarRecipeWrapper implements IRecipeWrapper { @Override public void getIngredients(@Nonnull IIngredients ingredients) { - ingredients.setInputLists(ItemStack.class, input); - ingredients.setOutput(ItemStack.class, output); + ingredients.setInputLists(VanillaTypes.ITEM, input); + ingredients.setOutput(VanillaTypes.ITEM, output); } @Override diff --git a/src/main/java/vazkii/botania/common/item/block/ItemBlockSpecialFlower.java b/src/main/java/vazkii/botania/common/item/block/ItemBlockSpecialFlower.java index 7afd9c650..6a2e904af 100644 --- a/src/main/java/vazkii/botania/common/item/block/ItemBlockSpecialFlower.java +++ b/src/main/java/vazkii/botania/common/item/block/ItemBlockSpecialFlower.java @@ -114,6 +114,7 @@ public class ItemBlockSpecialFlower extends ItemBlockMod implements IRecipeKeyPr return LibMisc.MOD_ID; } + @Nonnull public static String getType(ItemStack stack) { return stack.hasTagCompound() ? ItemNBTHelper.getString(stack, SubTileEntity.TAG_TYPE, "") : ""; } From 25cfc0734928c11d691f872bf43dc1d67f6bb3a7 Mon Sep 17 00:00:00 2001 From: Vincent Lee Date: Fri, 1 Feb 2019 16:28:15 -0600 Subject: [PATCH 07/31] Fix mana prism automation changes not causing spreaders to recalculate, closes #2837 --- .../vazkii/botania/common/block/mana/BlockPrism.java | 6 +----- .../botania/common/block/tile/mana/TilePrism.java | 10 ++++++++++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/main/java/vazkii/botania/common/block/mana/BlockPrism.java b/src/main/java/vazkii/botania/common/block/mana/BlockPrism.java index b8d7b9c60..543d72ebe 100644 --- a/src/main/java/vazkii/botania/common/block/mana/BlockPrism.java +++ b/src/main/java/vazkii/botania/common/block/mana/BlockPrism.java @@ -122,13 +122,9 @@ public class BlockPrism extends BlockMod implements IManaTrigger, ILexiconable, player.setHeldItem(hand, ItemStack.EMPTY); prism.getItemHandler().setStackInSlot(0, heldItem.copy()); - prism.markDirty(); - world.setBlockState(pos, state.withProperty(BotaniaStateProps.HAS_LENS, true), 1 | 2); } else if(!lens.isEmpty()) { ItemHandlerHelper.giveItemToPlayer(player, lens); prism.getItemHandler().setStackInSlot(0, ItemStack.EMPTY); - prism.markDirty(); - world.setBlockState(pos, state.withProperty(BotaniaStateProps.HAS_LENS, false), 1 | 2); } return true; @@ -170,7 +166,7 @@ public class BlockPrism extends BlockMod implements IManaTrigger, ILexiconable, @Override public void onBurstCollision(IManaBurst burst, World world, BlockPos pos) { TileEntity tile = world.getTileEntity(pos); - if(tile != null && tile instanceof TilePrism) + if(tile instanceof TilePrism) ((TilePrism) tile).onBurstCollision(burst); } diff --git a/src/main/java/vazkii/botania/common/block/tile/mana/TilePrism.java b/src/main/java/vazkii/botania/common/block/tile/mana/TilePrism.java index 349d2aa58..2067ec366 100644 --- a/src/main/java/vazkii/botania/common/block/tile/mana/TilePrism.java +++ b/src/main/java/vazkii/botania/common/block/tile/mana/TilePrism.java @@ -10,6 +10,7 @@ */ package vazkii.botania.common.block.tile.mana; +import net.minecraft.block.state.IBlockState; import net.minecraft.entity.Entity; import net.minecraft.item.ItemStack; import vazkii.botania.api.internal.IManaBurst; @@ -18,6 +19,7 @@ import vazkii.botania.api.mana.BurstProperties; import vazkii.botania.api.mana.ILens; import vazkii.botania.api.mana.ITinyPlanetExcempt; import vazkii.botania.api.state.BotaniaStateProps; +import vazkii.botania.common.block.ModBlocks; import vazkii.botania.common.block.tile.TileSimpleInventory; import javax.annotation.Nonnull; @@ -72,6 +74,14 @@ public class TilePrism extends TileSimpleInventory { public void markDirty() { super.markDirty(); VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this); + if(world != null && !world.isRemote) { + IBlockState state = world.getBlockState(pos); + boolean hasLens = !itemHandler.getStackInSlot(0).isEmpty(); + if (state.getBlock() != ModBlocks.prism || state.getValue(BotaniaStateProps.HAS_LENS) != hasLens) { + IBlockState base = state.getBlock() == ModBlocks.prism ? state : ModBlocks.prism.getDefaultState(); + world.setBlockState(pos, base.withProperty(BotaniaStateProps.HAS_LENS, hasLens)); + } + } } } From 7577ac8511c038c11795a7effb80b8b60cdfdff5 Mon Sep 17 00:00:00 2001 From: Vincent Lee Date: Fri, 1 Feb 2019 16:43:00 -0600 Subject: [PATCH 08/31] Fix #2836 --- .../vazkii/botania/common/crafting/recipe/SpellClothRecipe.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/vazkii/botania/common/crafting/recipe/SpellClothRecipe.java b/src/main/java/vazkii/botania/common/crafting/recipe/SpellClothRecipe.java index c77b3804c..3368353ce 100644 --- a/src/main/java/vazkii/botania/common/crafting/recipe/SpellClothRecipe.java +++ b/src/main/java/vazkii/botania/common/crafting/recipe/SpellClothRecipe.java @@ -54,7 +54,7 @@ public class SpellClothRecipe extends IForgeRegistryEntry.Impl implemen ItemStack stackToDisenchant = ItemStack.EMPTY; for(int i = 0; i < var1.getSizeInventory(); i++) { ItemStack stack = var1.getStackInSlot(i); - if(!stack.isEmpty() && stack.isItemEnchanted()) { + if(!stack.isEmpty() && stack.isItemEnchanted() && stack.getItem() != ModItems.spellCloth) { stackToDisenchant = stack.copy(); stackToDisenchant.setCount(1); break; From 464fe133c7930d6ede3df76f750e2e2af07d6ba7 Mon Sep 17 00:00:00 2001 From: Vincent Lee Date: Sat, 2 Feb 2019 01:25:39 -0600 Subject: [PATCH 09/31] Fix redstring spoofer not affecting vinculotus, closes #2835 --- .../subtile/functional/SubTileVinculotus.java | 41 ++++++++++++------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileVinculotus.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileVinculotus.java index 521862367..4d6f96acf 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileVinculotus.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileVinculotus.java @@ -11,10 +11,13 @@ package vazkii.botania.common.block.subtile.functional; import net.minecraft.entity.monster.EntityEnderman; +import net.minecraft.util.math.BlockPos; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.living.EnderTeleportEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import org.apache.commons.lang3.tuple.ImmutablePair; +import org.apache.commons.lang3.tuple.Pair; import vazkii.botania.api.lexicon.LexiconEntry; import vazkii.botania.api.subtile.RadiusDescriptor; import vazkii.botania.api.subtile.SubTileFunctional; @@ -25,21 +28,26 @@ import vazkii.botania.common.lib.LibMisc; import java.util.ArrayList; import java.util.Collections; import java.util.List; +import java.util.Map; import java.util.Set; import java.util.WeakHashMap; @Mod.EventBusSubscriber(modid = LibMisc.MOD_ID) public class SubTileVinculotus extends SubTileFunctional { - public static final Set existingFlowers = Collections.newSetFromMap(new WeakHashMap<>()); + // Must store position since red string spoofers are only active during onUpdate + // But our main logic runs outside, in the event handler + public static final Map existingFlowers = new WeakHashMap<>(); private static final int RANGE = 64; @Override public void onUpdate() { super.onUpdate(); - if(!supertile.getWorld().isRemote && !existingFlowers.contains(this)) { - existingFlowers.add(this); + if(!supertile.getWorld().isRemote) { + BlockPos pos = existingFlowers.get(this); + if (pos == null || !pos.equals(getPos())) + existingFlowers.put(this, getPos()); } } @@ -73,25 +81,30 @@ public class SubTileVinculotus extends SubTileFunctional { int cost = 50; if(event.getEntityLiving() instanceof EntityEnderman) { - List possibleFlowers = new ArrayList<>(); - for(SubTileVinculotus flower : existingFlowers) { - if(flower.redstoneSignal > 0 || flower.mana <= cost || flower.supertile.getWorld() != event.getEntityLiving().world || flower.supertile.getWorld().getTileEntity(flower.supertile.getPos()) != flower.supertile) + List> possibleFlowers = new ArrayList<>(); + for(Map.Entry e : existingFlowers.entrySet()) { + SubTileVinculotus flower = e.getKey(); + BlockPos activePos = e.getValue(); + + if(flower == null || flower.redstoneSignal > 0 || flower.mana <= cost || flower.supertile.getWorld() != event.getEntityLiving().world || flower.supertile.getWorld().getTileEntity(flower.supertile.getPos()) != flower.supertile) continue; - double x = flower.supertile.getPos().getX() + 0.5; - double y = flower.supertile.getPos().getY() + 1.5; - double z = flower.supertile.getPos().getZ() + 0.5; + double x = activePos.getX() + 0.5; + double y = activePos.getY() + 1.5; + double z = activePos.getZ() + 0.5; if(MathHelper.pointDistanceSpace(x, y, z, event.getTargetX(), event.getTargetY(), event.getTargetZ()) < RANGE) - possibleFlowers.add(flower); + possibleFlowers.add(ImmutablePair.of(flower, activePos)); } if(!possibleFlowers.isEmpty()) { - SubTileVinculotus flower = possibleFlowers.get(event.getEntityLiving().world.rand.nextInt(possibleFlowers.size())); + Pair p = possibleFlowers.get(event.getEntityLiving().world.rand.nextInt(possibleFlowers.size())); + SubTileVinculotus flower = p.getLeft(); + BlockPos activePos = p.getRight(); - double x = flower.supertile.getPos().getX() + 0.5; - double y = flower.supertile.getPos().getY() + 1.5; - double z = flower.supertile.getPos().getZ() + 0.5; + double x = activePos.getX() + 0.5; + double y = activePos.getY() + 1.5; + double z = activePos.getZ() + 0.5; event.setTargetX(x + Math.random() * 3 - 1); event.setTargetY(y); From cae9a83ddfbfa964074baca63ce8068aa858a5dd Mon Sep 17 00:00:00 2001 From: Vincent Lee Date: Sat, 2 Feb 2019 16:26:56 -0600 Subject: [PATCH 10/31] Fall through when enchanter creation fails. Closes #2840 --- src/main/java/vazkii/botania/common/item/ItemTwigWand.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/vazkii/botania/common/item/ItemTwigWand.java b/src/main/java/vazkii/botania/common/item/ItemTwigWand.java index e48f7ec5b..5b7e90f48 100644 --- a/src/main/java/vazkii/botania/common/item/ItemTwigWand.java +++ b/src/main/java/vazkii/botania/common/item/ItemTwigWand.java @@ -142,8 +142,6 @@ public class ItemTwigWand extends Item16Colors implements ICoordBoundItem { return EnumActionResult.SUCCESS; } - - return EnumActionResult.PASS; } if(block instanceof IWandable) { From 47ce2fd12b0658cf24cfadf3e5d8ccd316a2a017 Mon Sep 17 00:00:00 2001 From: Vasco Lavos Date: Sun, 3 Feb 2019 12:45:51 +0000 Subject: [PATCH 11/31] Update contributors.properties --- contributors.properties | 3 +++ 1 file changed, 3 insertions(+) diff --git a/contributors.properties b/contributors.properties index ee149cfa7..8cb4e329f 100644 --- a/contributors.properties +++ b/contributors.properties @@ -159,3 +159,6 @@ ewsmith=rafflowsia attifyon=1 sarkasaa=spectrolus ellpeck=spectrolus +mecharm=14 +studkid=3 +brannie17=puredaisy From 3ffd9aed49d222ce8f8ad62a504dd6ed862de32d Mon Sep 17 00:00:00 2001 From: Vasco Lavos Date: Sun, 3 Feb 2019 13:59:43 +0000 Subject: [PATCH 12/31] Update ItemItemFinder.java --- .../botania/common/item/equipment/bauble/ItemItemFinder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemItemFinder.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemItemFinder.java index b80787ef7..17ebaca70 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemItemFinder.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemItemFinder.java @@ -191,7 +191,7 @@ public class ItemItemFinder extends ItemBauble implements IBaubleRender { } private boolean scanInventory(IItemHandler inv, ItemStack pstack) { - if(pstack.isEmpty()) + if(pstack.isEmpty() || inv == null) return false; for(int l = 0; l < inv.getSlots(); l++) { From 164fe6b45ebf9966385c4a3c679a99c39ef58cf0 Mon Sep 17 00:00:00 2001 From: Vasco Lavos Date: Mon, 4 Feb 2019 17:57:12 +0000 Subject: [PATCH 13/31] buildy --- build.properties | 4 ++-- version/1.12.2.txt | 2 +- web/changelog.txt | 17 +++++++++++++++++ web/versions.ini | 3 ++- 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/build.properties b/build.properties index c93bdf6db..a858d8f12 100644 --- a/build.properties +++ b/build.properties @@ -1,5 +1,5 @@ # -#Fri Nov 30 05:12:11 GMT 2018 +#Sun Feb 03 18:19:36 GMT 2019 mod_name=Botania cf_meta_version=1.12.2 forge_version=14.23.5.2768 @@ -7,5 +7,5 @@ dir_repo=./ mc_mappings=stable_39 version=r1.10 dir_output=../Build Output/Botania/ +build_number=360 mc_version=1.12.2 -build_number=359 diff --git a/version/1.12.2.txt b/version/1.12.2.txt index 4987fba71..0d5eae487 100644 --- a/version/1.12.2.txt +++ b/version/1.12.2.txt @@ -1 +1 @@ -r1.10-358 \ No newline at end of file +r1.10-359 \ No newline at end of file diff --git a/web/changelog.txt b/web/changelog.txt index ce01e9c38..c71000c40 100644 --- a/web/changelog.txt +++ b/web/changelog.txt @@ -1,3 +1,20 @@ +r1.10 359 +*Fix Lexica rotating item config not swapping usable items in recipes (Hubry) +*Fix mana prism automation changes not causing spreaders to recalculate +*Fix redirection lenses having phantom lens functionality as well (Hubry) +*Fixed a bunch of typos (trunksbomb) +*Fixed a dupe with spellbinding cloth +*Fixed botania shears not dropping apples and saplings +*Fixed Corporea Sparks not staying on Red Stringed Containers (Hubry) +*Fixed crafted flowers entering back the petal apothecary (quat) +*Fixed ender air bottles not being acquirable in custom end dimensions +*Fixed force relays not being bindable to lapis blocks +*Fixed spellbinding cloth deleting items +*Fixed the botanical brewery destroying invalid brew containers +*Fixed the red stringed spoofer not affecting the vinculotus +*Fixed the worldshaper's sextant being able to softlock the game if you look far enough +*Improved the detection for the heisei dream and the diva charm +*Made magnet ring respect pickup delays and tweak blacklist (Hubry) r1.10 358 *Added an Offline Mode config. (Hubry) *All Garden of Glass features now depend on the GoG mod being loaded, rather than the GoG world type. diff --git a/web/versions.ini b/web/versions.ini index 0a23ab87d..07ab7cc98 100644 --- a/web/versions.ini +++ b/web/versions.ini @@ -309,4 +309,5 @@ r1.10-354=1.12.2 r1.10-355=1.12.2 r1.10-356=1.12.2 r1.10-357=1.12.2 -r1.10-358=1.12.2 \ No newline at end of file +r1.10-358=1.12.2 +r1.10-359=1.12.2 \ No newline at end of file From 1feadf2835b81730b28d18865c15c256186de2ea Mon Sep 17 00:00:00 2001 From: Vincent Lee Date: Mon, 4 Feb 2019 14:16:48 -0600 Subject: [PATCH 14/31] Fix #2841 --- .../item/equipment/tool/manasteel/ItemManasteelShears.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/vazkii/botania/common/item/equipment/tool/manasteel/ItemManasteelShears.java b/src/main/java/vazkii/botania/common/item/equipment/tool/manasteel/ItemManasteelShears.java index 5a2c585ad..1d719cf0b 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/tool/manasteel/ItemManasteelShears.java +++ b/src/main/java/vazkii/botania/common/item/equipment/tool/manasteel/ItemManasteelShears.java @@ -17,6 +17,7 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; import net.minecraft.init.Enchantments; import net.minecraft.item.ItemShears; import net.minecraft.item.ItemStack; @@ -111,6 +112,7 @@ public class ItemManasteelShears extends ItemShears implements IManaUsingItem, I ToolCommons.damageItem(itemstack, 1, player, MANA_PER_DAMAGE); player.addStat(StatList.getBlockStats(block), 1); + player.world.setBlockState(pos, Blocks.AIR.getDefaultState(), 11); return true; } } From f84e09eda3aac39914663069c29de1ad666f237e Mon Sep 17 00:00:00 2001 From: Vincent Lee Date: Tue, 5 Feb 2019 23:44:01 -0600 Subject: [PATCH 15/31] Fix cloaks blocking admin-damage like /kill --- .../botania/common/item/equipment/bauble/ItemHolyCloak.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemHolyCloak.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemHolyCloak.java index 3378c5f0e..66f53a878 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemHolyCloak.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemHolyCloak.java @@ -56,7 +56,7 @@ public class ItemHolyCloak extends ItemBauble implements IBaubleRender { @SubscribeEvent public void onPlayerDamage(LivingHurtEvent event) { - if(event.getEntityLiving() instanceof EntityPlayer) { + if(event.getEntityLiving() instanceof EntityPlayer && !event.getSource().canHarmInCreative()) { EntityPlayer player = (EntityPlayer) event.getEntityLiving(); ItemStack belt = BaublesApi.getBaublesHandler(player).getStackInSlot(5); if(!belt.isEmpty() && belt.getItem() instanceof ItemHolyCloak && !isInEffect(belt)) { From cd558910d9eb4a9116ec6d7b5a184d9d886870ab Mon Sep 17 00:00:00 2001 From: quat Date: Tue, 12 Feb 2019 00:30:02 -0500 Subject: [PATCH 16/31] Change how NBT matching works, now it's faster and works better with nested tags --- .../botania/api/recipe/RecipePetals.java | 15 ++------ .../common/core/helper/ItemNBTHelper.java | 35 +++++++++++++++++++ 2 files changed, 37 insertions(+), 13 deletions(-) diff --git a/src/main/java/vazkii/botania/api/recipe/RecipePetals.java b/src/main/java/vazkii/botania/api/recipe/RecipePetals.java index 9e8bccf66..ce1b26735 100644 --- a/src/main/java/vazkii/botania/api/recipe/RecipePetals.java +++ b/src/main/java/vazkii/botania/api/recipe/RecipePetals.java @@ -15,6 +15,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.items.IItemHandler; import net.minecraftforge.oredict.OreDictionary; +import vazkii.botania.common.core.helper.ItemNBTHelper; import java.util.ArrayList; import java.util.List; @@ -79,19 +80,7 @@ public class RecipePetals { } private boolean compareStacks(ItemStack recipe, ItemStack supplied) { - if(recipe.getItem() == supplied.getItem() && recipe.getItemDamage() == supplied.getItemDamage()) { - //check that the user supplied nbt tag is a superset of the recipe item nbt tag - //if the recipe doesn't have an NBT tag, the user supplied one doesn't matter, it is a superset - if(!recipe.hasTagCompound()) return true; - //if the recipe does have an NBT tag but the user supplied doesn't, also no way it's a superset - if(!supplied.hasTagCompound()) return false; - - NBTTagCompound mergedNBT = supplied.getTagCompound().copy(); - mergedNBT.merge(recipe.getTagCompound()); - return supplied.getTagCompound().equals(mergedNBT); - } - - return false; + return recipe.getItem() == supplied.getItem() && recipe.getItemDamage() == supplied.getItemDamage() && ItemNBTHelper.isTagSubset(recipe.getTagCompound(), supplied.getTagCompound()); } public List getInputs() { diff --git a/src/main/java/vazkii/botania/common/core/helper/ItemNBTHelper.java b/src/main/java/vazkii/botania/common/core/helper/ItemNBTHelper.java index 14e427de7..569a65e87 100644 --- a/src/main/java/vazkii/botania/common/core/helper/ItemNBTHelper.java +++ b/src/main/java/vazkii/botania/common/core/helper/ItemNBTHelper.java @@ -14,9 +14,12 @@ package vazkii.botania.common.core.helper; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; +import javax.annotation.Nullable; + public final class ItemNBTHelper { private static final int[] EMPTY_INT_ARRAY = new int[0]; @@ -132,4 +135,36 @@ public final class ItemNBTHelper { return verifyExistance(stack, tag) ? getNBT(stack).getTagList(tag, objtype) : nullifyOnFail ? null : new NBTTagList(); } + /** + * Checks that one tag is a subset of another - that is, it's ok if the superset has more NBT keys than the subset, but the subset has to have at least all the same keys as the superset, and the values of the keys that *are* shared between the two must match. + * + * This is useful when, e.g. matching NBT tags in recipes. + */ + public static boolean isTagSubset(@Nullable NBTTagCompound subset, @Nullable NBTTagCompound superset) { + //an empty set is a subset of everything + if(subset == null || subset.isEmpty()) return true; + //an empty set is a superset of only another empty set (which was already checked above) + if(superset == null || superset.isEmpty()) return false; + //a subset can't be bigger than its superset + if(subset.getKeySet().size() > superset.getKeySet().size()) return false; + + //it's not an easy case, so we actually have to check the contents of each tag + for(String key : superset.getKeySet()) { + //it's ok if the subset is missing a key from the superset + if(!subset.hasKey(key)) continue; + + NBTBase supersetEntry = superset.getTag(key); + NBTBase subsetEntry = subset.getTag(key); + + //if a value is present on both tags, but they do not match, fail + if(supersetEntry instanceof NBTTagCompound && subsetEntry instanceof NBTTagCompound) { + //recurse into tag compounds (this properly compares nested tag compounds) + if(!isTagSubset((NBTTagCompound) subsetEntry, (NBTTagCompound) supersetEntry)) return false; + } else { + if(!supersetEntry.equals(subsetEntry)) return false; + } + } + + return true; + } } From 16a02f59f81d603664921c573c2dcaa69534f27f Mon Sep 17 00:00:00 2001 From: quat Date: Tue, 12 Feb 2019 00:53:47 -0500 Subject: [PATCH 17/31] Flip hopperhocks --- .../common/block/subtile/functional/SubTileHopperhock.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileHopperhock.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileHopperhock.java index e438227b4..8d3b978a4 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileHopperhock.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileHopperhock.java @@ -79,7 +79,7 @@ public class SubTileHopperhock extends SubTileFunctional { for(EnumFacing dir : EnumFacing.VALUES) { BlockPos pos_ = pos.offset(dir); - InvWithLocation inv = InventoryHelper.getInventoryWithLocation(supertile.getWorld(), pos_, dir); + InvWithLocation inv = InventoryHelper.getInventoryWithLocation(supertile.getWorld(), pos_, dir.getOpposite()); if(inv != null) { List filter = getFilterForInventory(pos_, true); boolean canAccept = canAcceptItem(stack, filter, filterType); From b40a99bd9cf989fa832401eabdfde52bf8157367 Mon Sep 17 00:00:00 2001 From: quat Date: Tue, 12 Feb 2019 01:12:25 -0500 Subject: [PATCH 18/31] Fix vine balls placing budded/invalid vines. Closes #2819 --- .../java/vazkii/botania/common/entity/EntityVineBall.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/vazkii/botania/common/entity/EntityVineBall.java b/src/main/java/vazkii/botania/common/entity/EntityVineBall.java index d4e5e11e9..67a3f88d9 100644 --- a/src/main/java/vazkii/botania/common/entity/EntityVineBall.java +++ b/src/main/java/vazkii/botania/common/entity/EntityVineBall.java @@ -28,6 +28,7 @@ import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; +import vazkii.botania.common.block.BlockSolidVines; import vazkii.botania.common.block.ModBlocks; import vazkii.botania.common.item.ModItems; @@ -73,11 +74,16 @@ public class EntityVineBall extends EntityThrowable { if(dir != null && dir.getAxis() != EnumFacing.Axis.Y) { BlockPos pos = var1.getBlockPos().offset(dir); + boolean first = true; while(pos.getY() > 0) { IBlockState state = world.getBlockState(pos); Block block = state.getBlock(); if(block.isAir(state, world, pos)) { IBlockState stateSet = ModBlocks.solidVines.getDefaultState().withProperty(propMap.get(dir.getOpposite()), true); + + if(first && !((BlockSolidVines)ModBlocks.solidVines).canAttachTo(world, pos, dir)) break; + first = false; + world.setBlockState(pos, stateSet, 1 | 2); world.playEvent(2001, pos, Block.getStateId(stateSet)); pos = pos.down(); From c5a874d4ea86d47f87aa4ab88f11d615b5c0a469 Mon Sep 17 00:00:00 2001 From: quat Date: Tue, 12 Feb 2019 01:34:29 -0500 Subject: [PATCH 19/31] Pumpkins and melons can grow on special grass --- src/main/java/vazkii/botania/common/block/BlockAltGrass.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/vazkii/botania/common/block/BlockAltGrass.java b/src/main/java/vazkii/botania/common/block/BlockAltGrass.java index 70f1b1fbe..624344a06 100644 --- a/src/main/java/vazkii/botania/common/block/BlockAltGrass.java +++ b/src/main/java/vazkii/botania/common/block/BlockAltGrass.java @@ -11,6 +11,7 @@ package vazkii.botania.common.block; import net.minecraft.block.BlockDirt; +import net.minecraft.block.BlockStem; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.block.state.BlockStateContainer; @@ -111,7 +112,7 @@ public class BlockAltGrass extends BlockMod implements ILexiconable { @Override public boolean canSustainPlant(@Nonnull IBlockState state, @Nonnull IBlockAccess world, BlockPos pos, @Nonnull EnumFacing direction, IPlantable plantable) { EnumPlantType type = plantable.getPlantType(world, pos.down()); - return type == EnumPlantType.Plains || type == EnumPlantType.Beach; + return type == EnumPlantType.Plains || type == EnumPlantType.Beach || plantable instanceof BlockStem; } @SideOnly(Side.CLIENT) From 666ed3f6ac4d34b1d2f637566d0636d67f460dc0 Mon Sep 17 00:00:00 2001 From: quat Date: Tue, 12 Feb 2019 01:51:26 -0500 Subject: [PATCH 20/31] You can now use your mother on special grasses --- .../botania/common/block/BlockAltGrass.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/main/java/vazkii/botania/common/block/BlockAltGrass.java b/src/main/java/vazkii/botania/common/block/BlockAltGrass.java index 624344a06..a28e2a600 100644 --- a/src/main/java/vazkii/botania/common/block/BlockAltGrass.java +++ b/src/main/java/vazkii/botania/common/block/BlockAltGrass.java @@ -20,8 +20,10 @@ import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.Item; +import net.minecraft.item.ItemHoe; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumFacing; +import net.minecraft.util.EnumHand; import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.NonNullList; import net.minecraft.util.math.BlockPos; @@ -81,7 +83,19 @@ public class BlockAltGrass extends BlockMod implements ILexiconable { for(int i = 0; i < 6; i++) list.add(new ItemStack(this, 1, i)); } - + + @Override + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { + ItemStack held = player.getHeldItem(hand); + if(held.getItem() instanceof ItemHoe && world.isAirBlock(pos.up())) { + held.damageItem(1, player); + world.setBlockState(pos, Blocks.FARMLAND.getDefaultState(), 1 | 2); + return true; + } + + return false; + } + @Override public void updateTick(World world, BlockPos pos, IBlockState state, Random rand) { if(!world.isRemote && state.getBlock() == this && world.getLight(pos.up()) >= 9) { From f33a5675adba03fb079fbaededa990b2347223e2 Mon Sep 17 00:00:00 2001 From: quat Date: Tue, 12 Feb 2019 02:16:08 -0500 Subject: [PATCH 21/31] Fix crafting petal blocks out of mushrooms --- src/main/resources/assets/botania/recipes/petalblock_0.json | 3 ++- src/main/resources/assets/botania/recipes/petalblock_1.json | 3 ++- src/main/resources/assets/botania/recipes/petalblock_10.json | 3 ++- src/main/resources/assets/botania/recipes/petalblock_11.json | 3 ++- src/main/resources/assets/botania/recipes/petalblock_12.json | 3 ++- src/main/resources/assets/botania/recipes/petalblock_13.json | 3 ++- src/main/resources/assets/botania/recipes/petalblock_14.json | 3 ++- src/main/resources/assets/botania/recipes/petalblock_15.json | 3 ++- src/main/resources/assets/botania/recipes/petalblock_2.json | 3 ++- src/main/resources/assets/botania/recipes/petalblock_3.json | 3 ++- src/main/resources/assets/botania/recipes/petalblock_4.json | 3 ++- src/main/resources/assets/botania/recipes/petalblock_5.json | 3 ++- src/main/resources/assets/botania/recipes/petalblock_6.json | 3 ++- src/main/resources/assets/botania/recipes/petalblock_7.json | 3 ++- src/main/resources/assets/botania/recipes/petalblock_8.json | 3 ++- src/main/resources/assets/botania/recipes/petalblock_9.json | 3 ++- 16 files changed, 32 insertions(+), 16 deletions(-) diff --git a/src/main/resources/assets/botania/recipes/petalblock_0.json b/src/main/resources/assets/botania/recipes/petalblock_0.json index 049ba764a..62a9ccb99 100644 --- a/src/main/resources/assets/botania/recipes/petalblock_0.json +++ b/src/main/resources/assets/botania/recipes/petalblock_0.json @@ -12,7 +12,8 @@ "group": "botania:petalblock", "key": { "P": { - "item": "#PETALWHITE" + "item": "botania:petal", + "data": 0 } } } \ No newline at end of file diff --git a/src/main/resources/assets/botania/recipes/petalblock_1.json b/src/main/resources/assets/botania/recipes/petalblock_1.json index 8977df4ad..662547ea5 100644 --- a/src/main/resources/assets/botania/recipes/petalblock_1.json +++ b/src/main/resources/assets/botania/recipes/petalblock_1.json @@ -12,7 +12,8 @@ "group": "botania:petalblock", "key": { "P": { - "item": "#PETALORANGE" + "item": "botania:petal", + "data": 1 } } } \ No newline at end of file diff --git a/src/main/resources/assets/botania/recipes/petalblock_10.json b/src/main/resources/assets/botania/recipes/petalblock_10.json index 40542d250..02dbe778c 100644 --- a/src/main/resources/assets/botania/recipes/petalblock_10.json +++ b/src/main/resources/assets/botania/recipes/petalblock_10.json @@ -12,7 +12,8 @@ "group": "botania:petalblock", "key": { "P": { - "item": "#PETALPURPLE" + "item": "botania:petal", + "data": 10 } } } \ No newline at end of file diff --git a/src/main/resources/assets/botania/recipes/petalblock_11.json b/src/main/resources/assets/botania/recipes/petalblock_11.json index d1363e300..163e882a8 100644 --- a/src/main/resources/assets/botania/recipes/petalblock_11.json +++ b/src/main/resources/assets/botania/recipes/petalblock_11.json @@ -12,7 +12,8 @@ "group": "botania:petalblock", "key": { "P": { - "item": "#PETALBLUE" + "item": "botania:petal", + "data": 11 } } } \ No newline at end of file diff --git a/src/main/resources/assets/botania/recipes/petalblock_12.json b/src/main/resources/assets/botania/recipes/petalblock_12.json index eb31b746b..e6c1fffa2 100644 --- a/src/main/resources/assets/botania/recipes/petalblock_12.json +++ b/src/main/resources/assets/botania/recipes/petalblock_12.json @@ -12,7 +12,8 @@ "group": "botania:petalblock", "key": { "P": { - "item": "#PETALBROWN" + "item": "botania:petal", + "data": 12 } } } \ No newline at end of file diff --git a/src/main/resources/assets/botania/recipes/petalblock_13.json b/src/main/resources/assets/botania/recipes/petalblock_13.json index 5cf1afaa2..d4253bda7 100644 --- a/src/main/resources/assets/botania/recipes/petalblock_13.json +++ b/src/main/resources/assets/botania/recipes/petalblock_13.json @@ -12,7 +12,8 @@ "group": "botania:petalblock", "key": { "P": { - "item": "#PETALGREEN" + "item": "botania:petal", + "data": 13 } } } \ No newline at end of file diff --git a/src/main/resources/assets/botania/recipes/petalblock_14.json b/src/main/resources/assets/botania/recipes/petalblock_14.json index 8ccd22dff..c55c00358 100644 --- a/src/main/resources/assets/botania/recipes/petalblock_14.json +++ b/src/main/resources/assets/botania/recipes/petalblock_14.json @@ -12,7 +12,8 @@ "group": "botania:petalblock", "key": { "P": { - "item": "#PETALRED" + "item": "botania:petal", + "data": 14 } } } \ No newline at end of file diff --git a/src/main/resources/assets/botania/recipes/petalblock_15.json b/src/main/resources/assets/botania/recipes/petalblock_15.json index 85f7c20e6..16847d552 100644 --- a/src/main/resources/assets/botania/recipes/petalblock_15.json +++ b/src/main/resources/assets/botania/recipes/petalblock_15.json @@ -12,7 +12,8 @@ "group": "botania:petalblock", "key": { "P": { - "item": "#PETALBLACK" + "item": "botania:petal", + "data": 15 } } } \ No newline at end of file diff --git a/src/main/resources/assets/botania/recipes/petalblock_2.json b/src/main/resources/assets/botania/recipes/petalblock_2.json index 6cceebc31..ada7854fa 100644 --- a/src/main/resources/assets/botania/recipes/petalblock_2.json +++ b/src/main/resources/assets/botania/recipes/petalblock_2.json @@ -12,7 +12,8 @@ "group": "botania:petalblock", "key": { "P": { - "item": "#PETALMAGENTA" + "item": "botania:petal", + "data": 2 } } } \ No newline at end of file diff --git a/src/main/resources/assets/botania/recipes/petalblock_3.json b/src/main/resources/assets/botania/recipes/petalblock_3.json index b6b0adf63..a62d8ee05 100644 --- a/src/main/resources/assets/botania/recipes/petalblock_3.json +++ b/src/main/resources/assets/botania/recipes/petalblock_3.json @@ -12,7 +12,8 @@ "group": "botania:petalblock", "key": { "P": { - "item": "#PETALLIGHTBLUE" + "item": "botania:petal", + "data": 3 } } } \ No newline at end of file diff --git a/src/main/resources/assets/botania/recipes/petalblock_4.json b/src/main/resources/assets/botania/recipes/petalblock_4.json index e61a0410f..f5032151d 100644 --- a/src/main/resources/assets/botania/recipes/petalblock_4.json +++ b/src/main/resources/assets/botania/recipes/petalblock_4.json @@ -12,7 +12,8 @@ "group": "botania:petalblock", "key": { "P": { - "item": "#PETALYELLOW" + "item": "botania:petal", + "data": 4 } } } \ No newline at end of file diff --git a/src/main/resources/assets/botania/recipes/petalblock_5.json b/src/main/resources/assets/botania/recipes/petalblock_5.json index 1203e4857..1b5580bfa 100644 --- a/src/main/resources/assets/botania/recipes/petalblock_5.json +++ b/src/main/resources/assets/botania/recipes/petalblock_5.json @@ -12,7 +12,8 @@ "group": "botania:petalblock", "key": { "P": { - "item": "#PETALLIME" + "item": "botania:petal", + "data": 5 } } } \ No newline at end of file diff --git a/src/main/resources/assets/botania/recipes/petalblock_6.json b/src/main/resources/assets/botania/recipes/petalblock_6.json index ee41a07ac..9f0cd1753 100644 --- a/src/main/resources/assets/botania/recipes/petalblock_6.json +++ b/src/main/resources/assets/botania/recipes/petalblock_6.json @@ -12,7 +12,8 @@ "group": "botania:petalblock", "key": { "P": { - "item": "#PETALPINK" + "item": "botania:petal", + "data": 6 } } } \ No newline at end of file diff --git a/src/main/resources/assets/botania/recipes/petalblock_7.json b/src/main/resources/assets/botania/recipes/petalblock_7.json index b36cca901..6c3760350 100644 --- a/src/main/resources/assets/botania/recipes/petalblock_7.json +++ b/src/main/resources/assets/botania/recipes/petalblock_7.json @@ -12,7 +12,8 @@ "group": "botania:petalblock", "key": { "P": { - "item": "#PETALGRAY" + "item": "botania:petal", + "data": 7 } } } \ No newline at end of file diff --git a/src/main/resources/assets/botania/recipes/petalblock_8.json b/src/main/resources/assets/botania/recipes/petalblock_8.json index 4327e322c..e6bd6215d 100644 --- a/src/main/resources/assets/botania/recipes/petalblock_8.json +++ b/src/main/resources/assets/botania/recipes/petalblock_8.json @@ -12,7 +12,8 @@ "group": "botania:petalblock", "key": { "P": { - "item": "#PETALLIGHTGRAY" + "item": "botania:petal", + "data": 8 } } } \ No newline at end of file diff --git a/src/main/resources/assets/botania/recipes/petalblock_9.json b/src/main/resources/assets/botania/recipes/petalblock_9.json index fa3a05eac..a32a8019a 100644 --- a/src/main/resources/assets/botania/recipes/petalblock_9.json +++ b/src/main/resources/assets/botania/recipes/petalblock_9.json @@ -12,7 +12,8 @@ "group": "botania:petalblock", "key": { "P": { - "item": "#PETALCYAN" + "item": "botania:petal", + "data": 9 } } } \ No newline at end of file From 9df180a6a11e7bc542ea0e400def64d5f5307754 Mon Sep 17 00:00:00 2001 From: Hubry Date: Tue, 12 Feb 2019 20:12:27 +0100 Subject: [PATCH 22/31] Fix crash on moving static model floating flowers with Quark TE pistons --- .../vazkii/botania/client/model/FloatingFlowerModel.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/vazkii/botania/client/model/FloatingFlowerModel.java b/src/main/java/vazkii/botania/client/model/FloatingFlowerModel.java index 2aa9b0ec9..25b9f80e5 100644 --- a/src/main/java/vazkii/botania/client/model/FloatingFlowerModel.java +++ b/src/main/java/vazkii/botania/client/model/FloatingFlowerModel.java @@ -105,6 +105,11 @@ public class FloatingFlowerModel implements IBakedModel { private CompositeBakedModel getModel(IFloatingFlower.IslandType islandType, String identifier) { ModelManager modelManager = Minecraft.getMinecraft().getRenderItem().getItemModelMesher().getModelManager(); + if(islandType == null) // This and the next one can be null if obtained from a non-extended state + islandType = IFloatingFlower.IslandType.GRASS; + if(identifier == null) + identifier = ""; + if(CACHE.contains(islandType, identifier)) { return CACHE.get(islandType, identifier); } else { From 2986240b74f8a56ca7c13a3f7b6334da6b3d6f43 Mon Sep 17 00:00:00 2001 From: Hubry Date: Tue, 12 Feb 2019 20:13:28 +0100 Subject: [PATCH 23/31] Fix static model flowers not showing pasture seed effects on apply --- .../common/block/tile/TileFloatingFlower.java | 13 ++++++++++++- .../block/tile/TileFloatingSpecialFlower.java | 13 ++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/main/java/vazkii/botania/common/block/tile/TileFloatingFlower.java b/src/main/java/vazkii/botania/common/block/tile/TileFloatingFlower.java index 32ffb8f81..3ad41e2e4 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileFloatingFlower.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileFloatingFlower.java @@ -13,6 +13,8 @@ package vazkii.botania.common.block.tile; import net.minecraft.item.EnumDyeColor; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.play.server.SPacketUpdateTileEntity; import vazkii.botania.api.item.IFloatingFlower; import vazkii.botania.api.state.BotaniaStateProps; import vazkii.botania.common.block.ModBlocks; @@ -21,7 +23,7 @@ public class TileFloatingFlower extends TileMod implements IFloatingFlower { public static final String TAG_ISLAND_TYPE = "islandType"; public static ItemStack forcedStack = ItemStack.EMPTY; - IslandType type = IslandType.GRASS; + private IslandType type = IslandType.GRASS; @Override public ItemStack getDisplayStack() { @@ -35,6 +37,15 @@ public class TileFloatingFlower extends TileMod implements IFloatingFlower { return new ItemStack(ModBlocks.shinyFlower, 1, color.getMetadata()); } + @Override + public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity packet) { + IslandType oldType = getIslandType(); + super.onDataPacket(net, packet); + if(oldType != getIslandType()) { + world.markBlockRangeForRenderUpdate(pos, pos); + } + } + @Override public IslandType getIslandType() { return type; diff --git a/src/main/java/vazkii/botania/common/block/tile/TileFloatingSpecialFlower.java b/src/main/java/vazkii/botania/common/block/tile/TileFloatingSpecialFlower.java index fbe247919..862680eff 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileFloatingSpecialFlower.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileFloatingSpecialFlower.java @@ -12,13 +12,15 @@ package vazkii.botania.common.block.tile; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.play.server.SPacketUpdateTileEntity; import vazkii.botania.api.item.IFloatingFlower; import vazkii.botania.common.item.block.ItemBlockSpecialFlower; public class TileFloatingSpecialFlower extends TileSpecialFlower implements IFloatingFlower { public static final String TAG_ISLAND_TYPE = "islandType"; - IslandType type = IslandType.GRASS; + private IslandType type = IslandType.GRASS; @Override public boolean isOnSpecialSoil() { @@ -46,6 +48,15 @@ public class TileFloatingSpecialFlower extends TileSpecialFlower implements IFlo cmp.setString(TAG_ISLAND_TYPE, type.toString()); } + @Override + public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity packet) { + IslandType oldType = getIslandType(); + super.onDataPacket(net, packet); + if(oldType != getIslandType()) { + world.markBlockRangeForRenderUpdate(pos, pos); + } + } + @Override public void readPacketNBT(NBTTagCompound cmp) { super.readPacketNBT(cmp); From 5b0521382cc09df0b0d9a3a1d6631b61dcb31b35 Mon Sep 17 00:00:00 2001 From: ZaBi94 Date: Tue, 19 Feb 2019 20:16:36 +0100 Subject: [PATCH 24/31] Get worn ring with method provided by baubles API Allows compatibility with Bring Me The Rings --- .../item/equipment/bauble/ItemDodgeRing.java | 11 ++++----- .../tool/terrasteel/ItemTerraPick.java | 2 +- .../common/item/relic/ItemLokiRing.java | 24 ++++++++----------- .../common/item/relic/ItemOdinRing.java | 14 +++++------ .../common/item/relic/ItemThorRing.java | 13 ++++------ .../botania/common/network/PacketDodge.java | 13 ++++------ 6 files changed, 31 insertions(+), 46 deletions(-) diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemDodgeRing.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemDodgeRing.java index 4f81b8483..0add6407e 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemDodgeRing.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemDodgeRing.java @@ -20,8 +20,6 @@ import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.math.MathHelper; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.InputEvent.KeyInputEvent; @@ -31,6 +29,7 @@ import net.minecraftforge.items.IItemHandler; import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.common.core.helper.ItemNBTHelper; import vazkii.botania.common.core.helper.Vector3; +import vazkii.botania.common.item.ModItems; import vazkii.botania.common.lib.LibItemNames; import vazkii.botania.common.lib.LibMisc; import vazkii.botania.common.network.PacketDodge; @@ -55,13 +54,11 @@ public class ItemDodgeRing extends ItemBauble { Minecraft mc = Minecraft.getMinecraft(); IItemHandler baublesInv = BaublesApi.getBaublesHandler(mc.player); - ItemStack ringStack = baublesInv.getStackInSlot(1); - if(ringStack.isEmpty() || !(ringStack.getItem() instanceof ItemDodgeRing)) { - ringStack = baublesInv.getStackInSlot(2); - if(ringStack.isEmpty() || !(ringStack.getItem() instanceof ItemDodgeRing)) + int slot = BaublesApi.isBaubleEquipped(mc.player, ModItems.dodgeRing); + if(slot < 0) { return; } - + ItemStack ringStack = baublesInv.getStackInSlot(slot); if(ItemNBTHelper.getInt(ringStack, TAG_DODGE_COOLDOWN, 0) > 0) return; diff --git a/src/main/java/vazkii/botania/common/item/equipment/tool/terrasteel/ItemTerraPick.java b/src/main/java/vazkii/botania/common/item/equipment/tool/terrasteel/ItemTerraPick.java index 4e87627ab..4e4c064ad 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/tool/terrasteel/ItemTerraPick.java +++ b/src/main/java/vazkii/botania/common/item/equipment/tool/terrasteel/ItemTerraPick.java @@ -170,7 +170,7 @@ public class ItemTerraPick extends ItemManasteelPick implements IManaItem, ISequ int fortune = EnchantmentHelper.getEnchantmentLevel(Enchantments.FORTUNE, stack); boolean silk = EnchantmentHelper.getEnchantmentLevel(Enchantments.SILK_TOUCH, stack) > 0; - boolean thor = ItemThorRing.getThorRing(player) != null; + boolean thor = !ItemThorRing.getThorRing(player).isEmpty(); boolean doX = thor || side.getXOffset() == 0; boolean doY = thor || side.getYOffset() == 0; boolean doZ = thor || side.getZOffset() == 0; diff --git a/src/main/java/vazkii/botania/common/item/relic/ItemLokiRing.java b/src/main/java/vazkii/botania/common/item/relic/ItemLokiRing.java index 36e2dcee1..b3e76b41b 100644 --- a/src/main/java/vazkii/botania/common/item/relic/ItemLokiRing.java +++ b/src/main/java/vazkii/botania/common/item/relic/ItemLokiRing.java @@ -10,15 +10,17 @@ */ package vazkii.botania.common.item.relic; +import java.util.ArrayList; +import java.util.List; + +import com.google.common.collect.ImmutableList; + import baubles.api.BaubleType; import baubles.api.BaublesApi; -import com.google.common.collect.ImmutableList; import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; -import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Enchantments; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -27,7 +29,6 @@ import net.minecraft.util.EnumFacing; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; -import net.minecraft.world.World; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; @@ -45,10 +46,6 @@ import vazkii.botania.common.item.equipment.tool.ToolCommons; import vazkii.botania.common.lib.LibItemNames; import vazkii.botania.common.lib.LibMisc; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - @Mod.EventBusSubscriber(modid = LibMisc.MOD_ID) public class ItemLokiRing extends ItemRelicBauble implements IWireframeCoordinateListProvider, IManaUsingItem { @@ -198,14 +195,13 @@ public class ItemLokiRing extends ItemRelicBauble implements IWireframeCoordinat private static ItemStack getLokiRing(EntityPlayer player) { IItemHandler baubles = BaublesApi.getBaublesHandler(player); - ItemStack stack1 = baubles.getStackInSlot(1); - ItemStack stack2 = baubles.getStackInSlot(2); - return isLokiRing(stack1) ? stack1 : isLokiRing(stack2) ? stack2 : ItemStack.EMPTY; + int slot = BaublesApi.isBaubleEquipped(player, ModItems.lokiRing); + if (slot < 0) { + return ItemStack.EMPTY; + } + return baubles.getStackInSlot(slot); } - private static boolean isLokiRing(ItemStack stack) { - return !stack.isEmpty() && stack.getItem() == ModItems.lokiRing; - } private static BlockPos getOriginPos(ItemStack stack) { int x = ItemNBTHelper.getInt(stack, TAG_X_ORIGIN, 0); diff --git a/src/main/java/vazkii/botania/common/item/relic/ItemOdinRing.java b/src/main/java/vazkii/botania/common/item/relic/ItemOdinRing.java index 5010934b7..d3b7fd616 100644 --- a/src/main/java/vazkii/botania/common/item/relic/ItemOdinRing.java +++ b/src/main/java/vazkii/botania/common/item/relic/ItemOdinRing.java @@ -64,7 +64,7 @@ public class ItemOdinRing extends ItemRelicBauble { public static void onPlayerAttacked(LivingAttackEvent event) { if(event.getEntityLiving() instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) event.getEntityLiving(); - if(getOdinRing(player) != null && damageNegations.contains(event.getSource().damageType)) + if(!getOdinRing(player).isEmpty() && damageNegations.contains(event.getSource().damageType)) event.setCanceled(true); } } @@ -76,13 +76,11 @@ public class ItemOdinRing extends ItemRelicBauble { public static ItemStack getOdinRing(EntityPlayer player) { IItemHandler baubles = BaublesApi.getBaublesHandler(player); - ItemStack stack1 = baubles.getStackInSlot(1); - ItemStack stack2 = baubles.getStackInSlot(2); - return isOdinRing(stack1) ? stack1 : isOdinRing(stack2) ? stack2 : null; - } - - private static boolean isOdinRing(ItemStack stack) { - return !stack.isEmpty() && stack.getItem() == ModItems.odinRing; + int slot = BaublesApi.isBaubleEquipped(player, ModItems.odinRing); + if (slot < 0) { + return ItemStack.EMPTY; + } + return baubles.getStackInSlot(slot); } @Override diff --git a/src/main/java/vazkii/botania/common/item/relic/ItemThorRing.java b/src/main/java/vazkii/botania/common/item/relic/ItemThorRing.java index 6c1455139..82d7bc85e 100644 --- a/src/main/java/vazkii/botania/common/item/relic/ItemThorRing.java +++ b/src/main/java/vazkii/botania/common/item/relic/ItemThorRing.java @@ -38,13 +38,10 @@ public class ItemThorRing extends ItemRelicBauble { public static ItemStack getThorRing(EntityPlayer player) { IItemHandler baubles = BaublesApi.getBaublesHandler(player); - ItemStack stack1 = baubles.getStackInSlot(1); - ItemStack stack2 = baubles.getStackInSlot(2); - return isThorRing(stack1) ? stack1 : isThorRing(stack2) ? stack2 : null; + int slot = BaublesApi.isBaubleEquipped(player, ModItems.thorRing); + if (slot < 0) { + return ItemStack.EMPTY; + } + return baubles.getStackInSlot(slot); } - - private static boolean isThorRing(ItemStack stack) { - return !stack.isEmpty() && stack.getItem() == ModItems.thorRing; - } - } diff --git a/src/main/java/vazkii/botania/common/network/PacketDodge.java b/src/main/java/vazkii/botania/common/network/PacketDodge.java index 9684bbcc1..5c6636d22 100644 --- a/src/main/java/vazkii/botania/common/network/PacketDodge.java +++ b/src/main/java/vazkii/botania/common/network/PacketDodge.java @@ -15,7 +15,6 @@ import io.netty.buffer.ByteBuf; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; import net.minecraft.util.SoundCategory; -import net.minecraft.util.text.TextComponentString; import net.minecraft.util.text.TextComponentTranslation; import net.minecraftforge.fml.common.network.simpleimpl.IMessage; import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; @@ -23,6 +22,7 @@ import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; import net.minecraftforge.items.IItemHandler; import vazkii.botania.common.core.handler.ModSounds; import vazkii.botania.common.core.helper.ItemNBTHelper; +import vazkii.botania.common.item.ModItems; import vazkii.botania.common.item.equipment.bauble.ItemDodgeRing; public class PacketDodge implements IMessage { @@ -40,16 +40,13 @@ public class PacketDodge implements IMessage { EntityPlayerMP player = ctx.getServerHandler().player; player.server.addScheduledTask(() -> { player.world.playSound(null, player.posX, player.posY, player.posZ, ModSounds.dash, SoundCategory.PLAYERS, 1F, 1F); - IItemHandler baublesInv = BaublesApi.getBaublesHandler(player); - ItemStack ringStack = baublesInv.getStackInSlot(1); - if(ringStack.isEmpty() || !(ringStack.getItem() instanceof ItemDodgeRing)) { - ringStack = baublesInv.getStackInSlot(2); - if(ringStack.isEmpty() || !(ringStack.getItem() instanceof ItemDodgeRing)) - ctx.getServerHandler().disconnect(new TextComponentTranslation("botaniamisc.invalidDodge")); + int slot = BaublesApi.isBaubleEquipped(player, ModItems.dodgeRing); + if(slot < 0) { + ctx.getServerHandler().disconnect(new TextComponentTranslation("botaniamisc.invalidDodge")); return; } - + ItemStack ringStack = baublesInv.getStackInSlot(slot); player.addExhaustion(0.3F); ItemNBTHelper.setInt(ringStack, ItemDodgeRing.TAG_DODGE_COOLDOWN, ItemDodgeRing.MAX_CD); }); From 5e7a55ed5852f1997c73902357f9842cd417be28 Mon Sep 17 00:00:00 2001 From: Vasco Lavos Date: Tue, 19 Feb 2019 20:24:38 +0000 Subject: [PATCH 25/31] build --- build.properties | 4 ++-- version/1.12.2.txt | 2 +- web/changelog.txt | 11 +++++++++++ web/versions.ini | 3 ++- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/build.properties b/build.properties index a858d8f12..5e598177a 100644 --- a/build.properties +++ b/build.properties @@ -1,5 +1,5 @@ # -#Sun Feb 03 18:19:36 GMT 2019 +#Tue Feb 19 20:11:12 GMT 2019 mod_name=Botania cf_meta_version=1.12.2 forge_version=14.23.5.2768 @@ -7,5 +7,5 @@ dir_repo=./ mc_mappings=stable_39 version=r1.10 dir_output=../Build Output/Botania/ -build_number=360 mc_version=1.12.2 +build_number=361 diff --git a/version/1.12.2.txt b/version/1.12.2.txt index 0d5eae487..d3b362fd0 100644 --- a/version/1.12.2.txt +++ b/version/1.12.2.txt @@ -1 +1 @@ -r1.10-359 \ No newline at end of file +r1.10-360 \ No newline at end of file diff --git a/web/changelog.txt b/web/changelog.txt index c71000c40..a0f884573 100644 --- a/web/changelog.txt +++ b/web/changelog.txt @@ -1,3 +1,14 @@ +r1.10 360 +*Fixed a crash on moving floating flowers with the static model config with quark's pistons. (Hubry) +*Fixed a dupe with shears. +*Fixed cloaks blocking /kill damage +*Fixed floating flowers with the static model config not showing special grass types. (Hubry) +*Fixed hoes not being usable on special grasses. (quat) +*Fixed hopperhocks pulling from the wrong sides. (quat) +*Fixed mushrooms being usable to craft petal blocks. (quat) +*Fixed pumpkins and melons not growing on special grasses. (quat) +*Fixed vine balls placing invalid vines. (quat) +*Made NBT matching faster and work better. (quat) r1.10 359 *Fix Lexica rotating item config not swapping usable items in recipes (Hubry) *Fix mana prism automation changes not causing spreaders to recalculate diff --git a/web/versions.ini b/web/versions.ini index 07ab7cc98..1b5d6304d 100644 --- a/web/versions.ini +++ b/web/versions.ini @@ -310,4 +310,5 @@ r1.10-355=1.12.2 r1.10-356=1.12.2 r1.10-357=1.12.2 r1.10-358=1.12.2 -r1.10-359=1.12.2 \ No newline at end of file +r1.10-359=1.12.2 +r1.10-360=1.12.2 \ No newline at end of file From 404f18604b6ba81429ffad566b76895bbf3cbb8b Mon Sep 17 00:00:00 2001 From: Vincent Lee Date: Wed, 20 Feb 2019 23:15:00 -0600 Subject: [PATCH 26/31] Fix placeholders being overwritten by crafty crate. Closes #2858 --- .../java/vazkii/botania/common/block/tile/TileCraftCrate.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/vazkii/botania/common/block/tile/TileCraftCrate.java b/src/main/java/vazkii/botania/common/block/tile/TileCraftCrate.java index 4400fb1da..106af51f6 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileCraftCrate.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileCraftCrate.java @@ -144,7 +144,9 @@ public class TileCraftCrate extends TileOpenCrate { List remainders = recipe.getRemainingItems(craft); for(int i = 0; i < craft.getSizeInventory(); i++) { - itemHandler.setStackInSlot(i, remainders.get(i)); + ItemStack s = remainders.get(i); + if(!s.isEmpty()) + itemHandler.setStackInSlot(i, s); } return true; } From c1841ff5ddb3716e382f3123339fd714675a752a Mon Sep 17 00:00:00 2001 From: Hubry Date: Thu, 21 Feb 2019 12:59:03 +0100 Subject: [PATCH 27/31] Fix corporea interceptor causing wrong count on index requests If the interceptor triggered a funnel making a request on the same network it would've overwritten the request counts with last funnel's --- .../java/vazkii/botania/api/corporea/CorporeaHelper.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/vazkii/botania/api/corporea/CorporeaHelper.java b/src/main/java/vazkii/botania/api/corporea/CorporeaHelper.java index cfe70ecf3..3befd4e33 100644 --- a/src/main/java/vazkii/botania/api/corporea/CorporeaHelper.java +++ b/src/main/java/vazkii/botania/api/corporea/CorporeaHelper.java @@ -194,12 +194,12 @@ public final class CorporeaHelper { } } - lastRequestMatches = request.foundItems; - lastRequestExtractions = request.extractedItems; - for(ICorporeaInterceptor interceptor : interceptors.keySet()) interceptor.interceptRequestLast(matcher, itemCount, interceptors.get(interceptor), spark, stacks, inventories, doit); + lastRequestMatches = request.foundItems; + lastRequestExtractions = request.extractedItems; + return stacks; } From a559131772116ae2081c92441a7ffe85e9eea234 Mon Sep 17 00:00:00 2001 From: quaternary Date: Fri, 22 Feb 2019 01:48:03 -0500 Subject: [PATCH 28/31] Gaia fixes and anticheese stuff (#2853) * No sleeping through the fight! * Far stricter arena check * Some cleanups * Change the way GG teleportation works + happier to break blocks * Simplify teleportation logic. * Basically just picks a point somewhere in the arena and goes there. * Doesn't take collision boxes etc into consideration. * This fixes the "double carpet" exploit. * GG is now super happy to break blocks. * Will break blocks in the path of a teleport. * Will break blocks around it every tick. * A new API method is added to add immune blocks (such as the pylons). * Fix #2824 by always spawning traps at the arena height * Fix regression where the gg considered players in spec mode * Fix landmines better * Fix block break position lol --- .../java/vazkii/botania/api/BotaniaAPI.java | 13 +- .../java/vazkii/botania/api/package-info.java | 2 +- .../botania/common/block/BlockPylon.java | 4 +- .../common/core/handler/SleepingHandler.java | 25 ++ .../common/entity/EntityDoppleganger.java | 424 ++++++++---------- 5 files changed, 220 insertions(+), 248 deletions(-) create mode 100644 src/main/java/vazkii/botania/common/core/handler/SleepingHandler.java diff --git a/src/main/java/vazkii/botania/api/BotaniaAPI.java b/src/main/java/vazkii/botania/api/BotaniaAPI.java index cee71196e..8f8ac7812 100644 --- a/src/main/java/vazkii/botania/api/BotaniaAPI.java +++ b/src/main/java/vazkii/botania/api/BotaniaAPI.java @@ -29,7 +29,6 @@ import net.minecraft.item.Item; import net.minecraft.item.Item.ToolMaterial; import net.minecraft.item.ItemArmor.ArmorMaterial; import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipe; import net.minecraft.util.text.TextFormatting; import net.minecraftforge.common.util.EnumHelper; import net.minecraftforge.fml.common.Loader; @@ -56,8 +55,8 @@ import vazkii.botania.api.wiki.SimpleWikiProvider; import vazkii.botania.api.wiki.WikiHooks; import java.util.ArrayList; -import java.util.Collections; import java.util.HashMap; +import java.util.HashSet; import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.List; @@ -97,8 +96,9 @@ public final class BotaniaAPI { public static final Map> paintableBlocks = new LinkedHashMap<>(); public static final Set magnetBlacklist = new LinkedHashSet<>(); public static final Set> gravityRodBlacklist = new LinkedHashSet<>(); - - + + public static final Set gaiaBreakBlacklist = new HashSet<>(); + public static final ArmorMaterial manasteelArmorMaterial = EnumHelper.addArmorMaterial("MANASTEEL", "manasteel", 16, new int[] { 2, 5, 6, 2 }, 18, SoundEvents.ITEM_ARMOR_EQUIP_IRON, 0); public static final ToolMaterial manasteelToolMaterial = EnumHelper.addToolMaterial("MANASTEEL", 3, 300, 6.2F, 2F, 20); @@ -243,6 +243,8 @@ public final class BotaniaAPI { registerSemiDisposableBlock("stoneBasalt"); // Vanilla registerSemiDisposableBlock("stoneDiorite"); // Vanilla registerSemiDisposableBlock("stoneGranite"); // Vanilla + + blacklistBlockFromGaiaGuardian(Blocks.BEACON); } /** @@ -667,4 +669,7 @@ public final class BotaniaAPI { return "bm_" + block.getTranslationKey() + "@" + meta; } + public static void blacklistBlockFromGaiaGuardian(Block block) { + gaiaBreakBlacklist.add(block); + } } diff --git a/src/main/java/vazkii/botania/api/package-info.java b/src/main/java/vazkii/botania/api/package-info.java index 5e7cc4872..1d08d4ba2 100644 --- a/src/main/java/vazkii/botania/api/package-info.java +++ b/src/main/java/vazkii/botania/api/package-info.java @@ -1,4 +1,4 @@ -@API(owner = "Botania", apiVersion = "92", provides = "BotaniaAPI") +@API(owner = "Botania", apiVersion = "93", provides = "BotaniaAPI") package vazkii.botania.api; import net.minecraftforge.fml.common.API; diff --git a/src/main/java/vazkii/botania/common/block/BlockPylon.java b/src/main/java/vazkii/botania/common/block/BlockPylon.java index 6ef94e53f..468093352 100644 --- a/src/main/java/vazkii/botania/common/block/BlockPylon.java +++ b/src/main/java/vazkii/botania/common/block/BlockPylon.java @@ -17,7 +17,6 @@ import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumBlockRenderType; @@ -27,11 +26,11 @@ import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -import net.minecraftforge.client.ForgeHooksClient; import net.minecraftforge.fml.common.Optional; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import thaumcraft.api.crafting.IInfusionStabiliser; +import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.lexicon.ILexiconable; import vazkii.botania.api.lexicon.LexiconEntry; import vazkii.botania.api.state.BotaniaStateProps; @@ -55,6 +54,7 @@ public class BlockPylon extends BlockMod implements ILexiconable, IInfusionStabi setSoundType(SoundType.METAL); setLightLevel(0.5F); setDefaultState(blockState.getBaseState().withProperty(BotaniaStateProps.PYLON_VARIANT, PylonVariant.MANA)); + BotaniaAPI.blacklistBlockFromGaiaGuardian(this); } @Nonnull diff --git a/src/main/java/vazkii/botania/common/core/handler/SleepingHandler.java b/src/main/java/vazkii/botania/common/core/handler/SleepingHandler.java new file mode 100644 index 000000000..1d0baca22 --- /dev/null +++ b/src/main/java/vazkii/botania/common/core/handler/SleepingHandler.java @@ -0,0 +1,25 @@ +package vazkii.botania.common.core.handler; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.world.World; +import net.minecraftforge.event.entity.player.PlayerSleepInBedEvent; +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import vazkii.botania.common.entity.EntityDoppleganger; +import vazkii.botania.common.lib.LibMisc; + +@Mod.EventBusSubscriber(modid = LibMisc.MOD_ID) +public final class SleepingHandler { + + private SleepingHandler() {} + + @SubscribeEvent + public static void trySleep(PlayerSleepInBedEvent event) { + World world = event.getEntityPlayer().world; + for(EntityDoppleganger guardian : world.getEntities(EntityDoppleganger.class, e -> true)) { + if(guardian.getPlayersAround().contains(event.getEntityPlayer())) { + event.setResult(EntityPlayer.SleepResult.NOT_SAFE); + } + } + } +} diff --git a/src/main/java/vazkii/botania/common/entity/EntityDoppleganger.java b/src/main/java/vazkii/botania/common/entity/EntityDoppleganger.java index 23ebf6e59..f70758a6f 100644 --- a/src/main/java/vazkii/botania/common/entity/EntityDoppleganger.java +++ b/src/main/java/vazkii/botania/common/entity/EntityDoppleganger.java @@ -45,6 +45,7 @@ import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.tileentity.TileEntityBeacon; import net.minecraft.util.DamageSource; +import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.ResourceLocation; import net.minecraft.util.SoundCategory; @@ -66,6 +67,7 @@ import net.minecraftforge.fml.common.registry.IEntityAdditionalSpawnData; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import org.lwjgl.opengl.ARBShaderObjects; +import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.boss.IBotaniaBoss; import vazkii.botania.api.internal.ShaderCallback; import vazkii.botania.api.lexicon.multiblock.Multiblock; @@ -90,8 +92,10 @@ import javax.annotation.Nonnull; import java.awt.Rectangle; import java.util.ArrayList; import java.util.Arrays; +import java.util.HashSet; import java.util.List; import java.util.Random; +import java.util.Set; import java.util.UUID; import java.util.regex.Pattern; import java.util.stream.Collectors; @@ -99,6 +103,8 @@ import java.util.stream.Collectors; public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss, IEntityAdditionalSpawnData { public static final float ARENA_RANGE = 12F; + public static final int ARENA_HEIGHT = 5; + private static final int SPAWN_TICKS = 160; private static final float MAX_HP = 320F; @@ -128,8 +134,8 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss, IE }; private static final List CHEATY_BLOCKS = Arrays.asList( - new ResourceLocation("openblocks", "beartrap"), - new ResourceLocation("thaumictinkerer", "magnet") + new ResourceLocation("openblocks", "beartrap"), + new ResourceLocation("thaumictinkerer", "magnet") ); private boolean spawnLandmines = false; @@ -173,43 +179,53 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss, IE } public static boolean spawn(EntityPlayer player, ItemStack stack, World world, BlockPos pos, boolean hard) { - if(world.getTileEntity(pos) instanceof TileEntityBeacon && isTruePlayer(player)) { - if(world.getDifficulty() == EnumDifficulty.PEACEFUL) { + //initial checks + if( + !(world.getTileEntity(pos) instanceof TileEntityBeacon) || + !isTruePlayer(player) || + countGaiaGuardiansAround(world, pos) > 0 + ) + return false; + + //check difficulty + if(world.getDifficulty() == EnumDifficulty.PEACEFUL) { + if(!world.isRemote) + player.sendMessage(new TextComponentTranslation("botaniamisc.peacefulNoob").setStyle(new Style().setColor(TextFormatting.RED))); + return false; + } + + //check pylons + for(BlockPos coords : PYLON_LOCATIONS) { + BlockPos pos_ = pos.add(coords); + + IBlockState state = world.getBlockState(pos_); + if(state.getBlock() != ModBlocks.pylon || state.getValue(BotaniaStateProps.PYLON_VARIANT) != PylonVariant.GAIA) { if(!world.isRemote) - player.sendMessage(new TextComponentTranslation("botaniamisc.peacefulNoob").setStyle(new Style().setColor(TextFormatting.RED))); + player.sendMessage(new TextComponentTranslation("botaniamisc.needsCatalysts").setStyle(new Style().setColor(TextFormatting.RED))); return false; } + } - for(BlockPos coords : PYLON_LOCATIONS) { - BlockPos pos_ = pos.add(coords); + //check arena shape + List invalidArenaBlocks = checkArena(world, pos); + if(!invalidArenaBlocks.isEmpty()) { + if(world.isRemote) { + Botania.proxy.setWispFXDepthTest(false); + for(BlockPos pos_ : invalidArenaBlocks) + Botania.proxy.wispFX(pos_.getX() + 0.5, pos_.getY() + 0.5, pos_.getZ() + 0.5, 1F, 0.2F, 0.2F, 0.5F, 0F, 8); + Botania.proxy.setWispFXDepthTest(true); + } else { + PacketHandler.sendTo((EntityPlayerMP) player, + new PacketBotaniaEffect(PacketBotaniaEffect.EffectType.ARENA_INDICATOR, pos.getX(), pos.getY(), pos.getZ())); - IBlockState state = world.getBlockState(pos_); - Block blockat = state.getBlock(); - if(blockat != ModBlocks.pylon || state.getValue(BotaniaStateProps.PYLON_VARIANT) != PylonVariant.GAIA) { - if(!world.isRemote) - player.sendMessage(new TextComponentTranslation("botaniamisc.needsCatalysts").setStyle(new Style().setColor(TextFormatting.RED))); - return false; - } + player.sendMessage(new TextComponentTranslation("botaniamisc.badArena").setStyle(new Style().setColor(TextFormatting.RED))); } - if(!hasProperArena(world, pos)) { - if(!world.isRemote) { - PacketHandler.sendTo((EntityPlayerMP) player, - new PacketBotaniaEffect(PacketBotaniaEffect.EffectType.ARENA_INDICATOR, pos.getX(), pos.getY(), pos.getZ())); - - player.sendMessage(new TextComponentTranslation("botaniamisc.badArena").setStyle(new Style().setColor(TextFormatting.RED))); - } - - return false; - } - - int guardians = getGaiaGuardiansAround(world, pos); - if(guardians > 0) - return false; - - if(world.isRemote) - return true; + return false; + } + //all checks ok, spawn the boss + if(!world.isRemote) { stack.shrink(1); EntityDoppleganger e = new EntityDoppleganger(world); @@ -220,72 +236,46 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss, IE e.mobSpawnTicks = MOB_SPAWN_TICKS; e.hardMode = hard; - int playerCount = (int) e.getPlayersAround().stream().filter(EntityDoppleganger::isTruePlayer).count(); + int playerCount = e.getPlayersAround().size(); e.playerCount = playerCount; e.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(MAX_HP * playerCount); - if (hard) + if(hard) e.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.ARMOR).setBaseValue(15); e.playSound(SoundEvents.ENTITY_ENDERDRAGON_GROWL, 10F, 0.1F); e.onInitialSpawn(world.getDifficultyForLocation(new BlockPos(e)), null); world.spawnEntity(e); - return true; } - - return false; + + return true; } - private static boolean hasProperArena(World world, BlockPos startPos) { + private static List checkArena(World world, BlockPos beaconPos) { List trippedPositions = new ArrayList<>(); - boolean tripped = false; - - int heightCheck = 3; - int heightMin = 2; int range = (int) Math.ceil(ARENA_RANGE); - for(int i = -range; i < range + 1; i++) - for(int j = -range; j < range + 1; j++) { - if(Math.abs(i) == 4 && Math.abs(j) == 4 || vazkii.botania.common.core.helper.MathHelper.pointDistancePlane(i, j, 0, 0) > ARENA_RANGE) + BlockPos pos; + + for(int x = -range; x <= range; x++) + for(int z = -range; z <= range; z++) { + if(Math.abs(x) == 4 && Math.abs(z) == 4 || vazkii.botania.common.core.helper.MathHelper.pointDistancePlane(x, z, 0, 0) > ARENA_RANGE) continue; // Ignore pylons and out of circle - int air = 0; + for(int y = -1; y <= ARENA_HEIGHT; y++) { + if(x == 0 && y == 0 && z == 0) + continue; //this is the beacon - yCheck: { - BlockPos pos = null; - int trippedColumn = 0; + pos = beaconPos.add(x, y, z); - for(int k = heightCheck + heightMin; k >= -heightCheck; k--) { - pos = startPos.add(i, k, j); - boolean isAir = world.getBlockState(pos).getCollisionBoundingBox(world, pos) == null; - if(isAir) - air++; - else { - if(air >= 2) - break yCheck; - else if(trippedColumn < 2) { - trippedPositions.add(pos); - trippedColumn++; - } - air = 0; - } - } + boolean expectedBlockHere = y == -1; //the floor + boolean isBlockHere = world.getBlockState(pos).getCollisionBoundingBox(world, pos) != null; - if(trippedColumn == 0) + if(expectedBlockHere != isBlockHere) { trippedPositions.add(pos); - - tripped = true; + } } } - if(tripped) { - Botania.proxy.setWispFXDepthTest(false); - for(BlockPos pos : trippedPositions) - Botania.proxy.wispFX(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, 1F, 0.2F, 0.2F, 0.5F, 0F, 8); - Botania.proxy.setWispFXDepthTest(true); - - return false; - } - - return true; + return trippedPositions; } @Override @@ -313,35 +303,35 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss, IE } @Override - public void writeEntityToNBT(NBTTagCompound par1nbtTagCompound) { - super.writeEntityToNBT(par1nbtTagCompound); - par1nbtTagCompound.setInteger(TAG_INVUL_TIME, getInvulTime()); - par1nbtTagCompound.setBoolean(TAG_AGGRO, aggro); - par1nbtTagCompound.setInteger(TAG_MOB_SPAWN_TICKS, mobSpawnTicks); + public void writeEntityToNBT(NBTTagCompound cmp) { + super.writeEntityToNBT(cmp); + cmp.setInteger(TAG_INVUL_TIME, getInvulTime()); + cmp.setBoolean(TAG_AGGRO, aggro); + cmp.setInteger(TAG_MOB_SPAWN_TICKS, mobSpawnTicks); - par1nbtTagCompound.setInteger(TAG_SOURCE_X, source.getX()); - par1nbtTagCompound.setInteger(TAG_SOURCE_Y, source.getY()); - par1nbtTagCompound.setInteger(TAG_SOURCE_Z, source.getZ()); + cmp.setInteger(TAG_SOURCE_X, source.getX()); + cmp.setInteger(TAG_SOURCE_Y, source.getY()); + cmp.setInteger(TAG_SOURCE_Z, source.getZ()); - par1nbtTagCompound.setBoolean(TAG_HARD_MODE, hardMode); - par1nbtTagCompound.setInteger(TAG_PLAYER_COUNT, playerCount); + cmp.setBoolean(TAG_HARD_MODE, hardMode); + cmp.setInteger(TAG_PLAYER_COUNT, playerCount); } @Override - public void readEntityFromNBT(NBTTagCompound par1nbtTagCompound) { - super.readEntityFromNBT(par1nbtTagCompound); - setInvulTime(par1nbtTagCompound.getInteger(TAG_INVUL_TIME)); - aggro = par1nbtTagCompound.getBoolean(TAG_AGGRO); - mobSpawnTicks = par1nbtTagCompound.getInteger(TAG_MOB_SPAWN_TICKS); + public void readEntityFromNBT(NBTTagCompound cmp) { + super.readEntityFromNBT(cmp); + setInvulTime(cmp.getInteger(TAG_INVUL_TIME)); + aggro = cmp.getBoolean(TAG_AGGRO); + mobSpawnTicks = cmp.getInteger(TAG_MOB_SPAWN_TICKS); - int x = par1nbtTagCompound.getInteger(TAG_SOURCE_X); - int y = par1nbtTagCompound.getInteger(TAG_SOURCE_Y); - int z = par1nbtTagCompound.getInteger(TAG_SOURCE_Z); + int x = cmp.getInteger(TAG_SOURCE_X); + int y = cmp.getInteger(TAG_SOURCE_Y); + int z = cmp.getInteger(TAG_SOURCE_Z); source = new BlockPos(x, y, z); - hardMode = par1nbtTagCompound.getBoolean(TAG_HARD_MODE); - if(par1nbtTagCompound.hasKey(TAG_PLAYER_COUNT)) - playerCount = par1nbtTagCompound.getInteger(TAG_PLAYER_COUNT); + hardMode = cmp.getBoolean(TAG_HARD_MODE); + if(cmp.hasKey(TAG_PLAYER_COUNT)) + playerCount = cmp.getInteger(TAG_PLAYER_COUNT); else playerCount = 1; if (this.hasCustomName()) { @@ -395,10 +385,10 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss, IE } @Override - protected void damageEntity(@Nonnull DamageSource par1DamageSource, float par2) { - super.damageEntity(par1DamageSource, par2); + protected void damageEntity(@Nonnull DamageSource source, float par2) { + super.damageEntity(source, par2); - Entity attacker = par1DamageSource.getImmediateSource(); + Entity attacker = source.getImmediateSource(); if(attacker != null) { Vector3 thisVector = Vector3.fromEntityCenter(this); Vector3 playerVector = Vector3.fromEntityCenter(attacker); @@ -447,8 +437,7 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss, IE } @Override - protected void dropLoot(boolean wasRecentlyHit, int lootingModifier, @Nonnull DamageSource source) - { + protected void dropLoot(boolean wasRecentlyHit, int lootingModifier, @Nonnull DamageSource source) { // Save true killer, they get extra loot if (wasRecentlyHit && source.getTrueSource() instanceof EntityPlayer) { trueKiller = (EntityPlayer) source.getTrueSource(); @@ -494,12 +483,12 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss, IE super.setDead(); } - private List getPlayersAround() { + public List getPlayersAround() { float range = 15F; - return world.getEntitiesWithinAABB(EntityPlayer.class, new AxisAlignedBB(source.getX() + 0.5 - range, source.getY() + 0.5 - range, source.getZ() + 0.5 - range, source.getX() + 0.5 + range, source.getY() + 0.5 + range, source.getZ() + 0.5 + range)); + return world.getEntitiesWithinAABB(EntityPlayer.class, new AxisAlignedBB(source.getX() + 0.5 - range, source.getY() + 0.5 - range, source.getZ() + 0.5 - range, source.getX() + 0.5 + range, source.getY() + 0.5 + range, source.getZ() + 0.5 + range), player -> isTruePlayer(player) && !player.isSpectator()); } - private static int getGaiaGuardiansAround(World world, BlockPos source) { + private static int countGaiaGuardiansAround(World world, BlockPos source) { float range = 15F; List l = world.getEntitiesWithinAABB(EntityDoppleganger.class, new AxisAlignedBB(source.getX() + 0.5 - range, source.getY() + 0.5 - range, source.getZ() + 0.5 - range, source.getX() + 0.5 + range, source.getY() + 0.5 + range, source.getZ() + 0.5 + range)); return l.size(); @@ -545,20 +534,31 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss, IE } } - private void smashCheatyBlocks() { - int radius = 1; - int posXInt = MathHelper.floor(posX); - int posYInt = MathHelper.floor(posY); - int posZInt = MathHelper.floor(posZ); - for(int i = -radius; i < radius + 1; i++) - for(int j = -radius; j < radius + 1; j++) - for(int k = -radius; k < radius + 1; k++) { - int xp = posXInt + i; - int yp = posYInt + j; - int zp = posZInt + k; - BlockPos posp = new BlockPos(xp, yp, zp); - if(isCheatyBlock(world, posp)) { - world.destroyBlock(posp, true); + private void smashBlocksAround(int centerX, int centerY, int centerZ, int radius) { + for(int dx = -radius; dx <= radius; dx++) + for(int dy = -radius; dy <= radius + 1; dy++) + for(int dz = -radius; dz <= radius; dz++) { + int x = centerX + dx; + int y = centerY + dy; + int z = centerZ + dz; + + BlockPos pos = new BlockPos(x, y, z); + IBlockState state = world.getBlockState(pos); + Block block = state.getBlock(); + + if(state.getBlockHardness(world, pos) == -1) continue; + + if(CHEATY_BLOCKS.contains(block.getRegistryName())) { + world.destroyBlock(pos, true); + } else { + //don't break blacklisted blocks + if(BotaniaAPI.gaiaBreakBlacklist.contains(block)) continue; + //don't break the floor + if(y == source.getY() - 1) continue; + //don't break blocks in pylon columns + if(Math.abs(source.getX() - x) == 4 && Math.abs(source.getZ() - z) == 4) continue; + + world.destroyBlock(pos, true); } } } @@ -646,11 +646,11 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss, IE int invul = getInvulTime(); - if (world.isRemote) { + if(world.isRemote) { particles(); EntityPlayer player = Botania.proxy.getClientPlayer(); if(getPlayersAround().contains(player)) - player.capabilities.isFlying = player.capabilities.isFlying && player.capabilities.isCreativeMode; + player.capabilities.isFlying &= player.capabilities.isCreativeMode; return; } @@ -662,7 +662,7 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss, IE if(world.getDifficulty() == EnumDifficulty.PEACEFUL) setDead(); - smashCheatyBlocks(); + smashBlocksAround(MathHelper.floor(posX), MathHelper.floor(posY), MathHelper.floor(posZ), 1); List players = getPlayersAround(); @@ -677,9 +677,12 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss, IE } } + //also see SleepingHandler + if(player.isPlayerSleeping()) player.wakeUpPlayer(true, true, false); + clearPotions(player); keepInsideArena(player); - player.capabilities.isFlying = player.capabilities.isFlying && player.capabilities.isCreativeMode; + player.capabilities.isFlying &= player.capabilities.isCreativeMode; } } @@ -731,18 +734,14 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss, IE tpDelay--; if(tpDelay == 0 && getHealth() > 0) { - int tries = 0; - while(!teleportRandomly() && tries < 50) - tries++; - if(tries >= 50) - teleportTo(source.getX() + 0.5, source.getY() + 1.6, source.getZ() + 0.5); + teleportRandomly(); if(spawnLandmines) { int count = dying && hardMode ? 7 : 6; for(int i = 0; i < count; i++) { int x = source.getX() - 10 + rand.nextInt(20); + int y = (int) players.get(rand.nextInt(players.size())).posY; int z = source.getZ() - 10 + rand.nextInt(20); - int y = world.getTopSolidOrLiquidBlock(new BlockPos(x, -1, z)).getY(); EntityMagicLandmine landmine = new EntityMagicLandmine(world); landmine.setPosition(x + 0.5, y, z + 0.5); @@ -778,21 +777,18 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss, IE } @Override - public boolean isNonBoss() - { + public boolean isNonBoss() { return false; } @Override - public void addTrackingPlayer(EntityPlayerMP player) - { + public void addTrackingPlayer(EntityPlayerMP player) { super.addTrackingPlayer(player); bossInfo.addPlayer(player); } @Override - public void removeTrackingPlayer(EntityPlayerMP player) - { + public void removeTrackingPlayer(EntityPlayerMP player) { super.removeTrackingPlayer(player); bossInfo.removePlayer(player); } @@ -817,127 +813,73 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss, IE } } - private static boolean isCheatyBlock(World world, BlockPos pos) { - Block block = world.getBlockState(pos).getBlock(); - return CHEATY_BLOCKS.contains(Block.REGISTRY.getNameForObject(block)); - } + private void teleportRandomly() { + //choose a location to teleport to + double oldX = posX, oldY = posY, oldZ = posZ; + double newX, newY, newZ; + int tries = 0; - // [VanillaCopy] EntityEnderman.teleportRandomly, edits noted. - private boolean teleportRandomly() { - double d0 = this.posX + (this.rand.nextDouble() - 0.5D) * 64.0D; - double d1 = this.posY + (double)(this.rand.nextInt(64) - 32); - double d2 = this.posZ + (this.rand.nextDouble() - 0.5D) * 64.0D; - return this.teleportTo(d0, d1, d2); - } + do { + newX = source.getX() + (rand.nextDouble() - .5) * ARENA_RANGE; + newY = source.getY(); + newZ = source.getZ() + (rand.nextDouble() - .5) * ARENA_RANGE; + tries++; + //ensure it's inside the arena ring, and not just its bounding square + } + while(tries < 50 && vazkii.botania.common.core.helper.MathHelper.pointDistanceSpace(newX, newY, newZ, source.getX(), source.getY(), source.getZ()) > 12); - // [VanillaCopy] EntityEnderman.teleportTo, edits noted. - private boolean teleportTo(double x, double y, double z) { - /* Botania - no events - net.minecraftforge.event.entity.living.EnderTeleportEvent event = new net.minecraftforge.event.entity.living.EnderTeleportEvent(this, x, y, z, 0); - if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event)) return false; - boolean flag = this.attemptTeleport(event.getTargetX(), event.getTargetY(), event.getTargetZ()); - */ - - boolean flag = this.attemptTeleport(x, y, z); - - if (flag) - { - this.world.playSound((EntityPlayer)null, this.prevPosX, this.prevPosY, this.prevPosZ, SoundEvents.ENTITY_ENDERMEN_TELEPORT, this.getSoundCategory(), 1.0F, 1.0F); - this.playSound(SoundEvents.ENTITY_ENDERMEN_TELEPORT, 1.0F, 1.0F); + if(tries == 50) { + //failsafe: teleport to the beacon + newX = source.getX() + .5; + newY = source.getY() + 1.6; + newZ = source.getZ() + .5; } - return flag; - } + //teleport there + setPositionAndUpdate(newX, newY, newZ); - // [VanillaCopy] of super, edits noted - @Override - public boolean attemptTeleport(double x, double y, double z) { - double d0 = this.posX; - double d1 = this.posY; - double d2 = this.posZ; - this.posX = x; - this.posY = y; - this.posZ = z; - boolean flag = false; - BlockPos blockpos = new BlockPos(this); - World world = this.world; - Random random = this.getRNG(); + //play sound + world.playSound(null, oldX, oldY, oldZ, SoundEvents.ENTITY_ENDERMEN_TELEPORT, this.getSoundCategory(), 1.0F, 1.0F); + this.playSound(SoundEvents.ENTITY_ENDERMEN_TELEPORT, 1.0F, 1.0F); - if (world.isBlockLoaded(blockpos)) - { - boolean flag1 = false; + Random random = getRNG(); - while (!flag1 && blockpos.getY() > 0) - { - BlockPos blockpos1 = blockpos.down(); - IBlockState iblockstate = world.getBlockState(blockpos1); - - if (iblockstate.getMaterial().blocksMovement()) - { - flag1 = true; - } - else - { - --this.posY; - blockpos = blockpos1; - } - } - - if (flag1) - { - this.setPositionAndUpdate(this.posX, this.posY, this.posZ); - - if (world.getCollisionBoxes(this, this.getEntityBoundingBox()).isEmpty() && !world.containsAnyLiquid(this.getEntityBoundingBox())) - { - flag = true; - } - - // Botania - Prevent out of bounds teleporting - if(vazkii.botania.common.core.helper.MathHelper.pointDistanceSpace(posX, posY, posZ, source.getX(), source.getY(), source.getZ()) > 12) - flag = false; - } + //spawn particles along the path + int particleCount = 128; + for(int i = 0; i < particleCount; ++i) { + double progress = i / (double) (particleCount - 1); + float vx = (random.nextFloat() - 0.5F) * 0.2F; + float vy = (random.nextFloat() - 0.5F) * 0.2F; + float vz = (random.nextFloat() - 0.5F) * 0.2F; + double px = oldX + (newX - oldX) * progress + (random.nextDouble() - 0.5D) * width * 2.0D; + double py = oldY + (newY - oldY) * progress + random.nextDouble() * height; + double pz = oldZ + (newZ - oldZ) * progress + (random.nextDouble() - 0.5D) * width * 2.0D; + world.spawnParticle(EnumParticleTypes.PORTAL, px, py, pz, vx, vy, vz); } - if (!flag) - { - this.setPositionAndUpdate(d0, d1, d2); - return false; - } - else - { - int i = 128; + Vec3d oldPosVec = new Vec3d(oldX, oldY + height / 2, oldZ); + Vec3d newPosVec = new Vec3d(newX, newY + height / 2, newZ); - for (int j = 0; j < 128; ++j) - { - double d6 = (double)j / 127.0D; - float f = (random.nextFloat() - 0.5F) * 0.2F; - float f1 = (random.nextFloat() - 0.5F) * 0.2F; - float f2 = (random.nextFloat() - 0.5F) * 0.2F; - double d3 = d0 + (this.posX - d0) * d6 + (random.nextDouble() - 0.5D) * (double)this.width * 2.0D; - double d4 = d1 + (this.posY - d1) * d6 + random.nextDouble() * (double)this.height; - double d5 = d2 + (this.posZ - d2) * d6 + (random.nextDouble() - 0.5D) * (double)this.width * 2.0D; - world.spawnParticle(EnumParticleTypes.PORTAL, d3, d4, d5, (double)f, (double)f1, (double)f2, new int[0]); + if(oldPosVec.squareDistanceTo(newPosVec) > 1) { + //damage players in the path of the teleport + for(EntityPlayer player : getPlayersAround()) { + RayTraceResult rtr = player.getEntityBoundingBox().grow(0.25).calculateIntercept(oldPosVec, newPosVec); + if(rtr != null) + player.attackEntityFrom(DamageSource.causeMobDamage(this), 6); } - // Botania - invalid/unneeded check - /*if (this instanceof EntityCreature) - { - ((EntityCreature)this).getNavigator().clearPathEntity(); - }*/ + //break blocks in the path of the teleport + int breakSteps = (int) oldPosVec.distanceTo(newPosVec); + if(breakSteps >= 2) { + for(int i = 0; i < breakSteps; i++) { + float progress = i / (float) (breakSteps - 1); + int breakX = MathHelper.floor(oldX + (newX - oldX) * progress); + int breakY = MathHelper.floor(oldY + (newY - oldY) * progress); + int breakZ = MathHelper.floor(oldZ + (newZ - oldZ) * progress); - // Botania - damage any players in our way - Vec3d origPos = new Vec3d(d0, d1 + height / 2, d2); - Vec3d newPos = new Vec3d(posX, posY + height / 2, posZ); - - if(origPos.squareDistanceTo(newPos) > 1) { - for(EntityPlayer player : getPlayersAround()) { - RayTraceResult rtr = player.getEntityBoundingBox().grow(0.25).calculateIntercept(origPos, newPos); - if(rtr != null) - player.attackEntityFrom(DamageSource.causeMobDamage(this), 6); + smashBlocksAround(breakX, breakY, breakZ, 1); } } - - return true; } } From 010bdfcb4a956f49170052796f451ae723c08d56 Mon Sep 17 00:00:00 2001 From: Hubry Date: Fri, 22 Feb 2019 07:51:00 +0100 Subject: [PATCH 29/31] Add corporea crystal cube locking (#2855) * Add corporea crystal cube locking, modeled after hovering hourglass * Disable rendering of some things when the lexicon is held It looked quite bad when the lexicon info rendered behind the block's display * Sync the hourglass when wand of the forest is dispensed --- .../client/core/handler/HUDHandler.java | 24 ++++++++------ .../botania/common/block/BlockHourglass.java | 5 ++- .../corporea/BlockCorporeaCrystalCube.java | 31 ++++++++++++++++--- .../corporea/TileCorporeaCrystalCube.java | 16 +++++----- .../botania/common/lexicon/LexiconData.java | 2 +- .../resources/assets/botania/lang/en_us.lang | 2 ++ 6 files changed, 56 insertions(+), 24 deletions(-) diff --git a/src/main/java/vazkii/botania/client/core/handler/HUDHandler.java b/src/main/java/vazkii/botania/client/core/handler/HUDHandler.java index 0ac50fe41..1a903348e 100644 --- a/src/main/java/vazkii/botania/client/core/handler/HUDHandler.java +++ b/src/main/java/vazkii/botania/client/core/handler/HUDHandler.java @@ -141,16 +141,17 @@ public final class HUDHandler { } } else if(block != null && PlayerHelper.hasHeldItemClass(mc.player, ILexicon.class)) drawLexiconHUD(PlayerHelper.getFirstHeldItemClass(mc.player, ILexicon.class), state, pos, event.getResolution()); - if(tile != null && tile instanceof TilePool && !mc.player.getHeldItemMainhand().isEmpty()) + if(tile instanceof TilePool && !mc.player.getHeldItemMainhand().isEmpty()) renderPoolRecipeHUD(event.getResolution(), (TilePool) tile, mc.player.getHeldItemMainhand()); } - if(tile != null && tile instanceof TileAltar) - ((TileAltar) tile).renderHUD(mc, event.getResolution()); - else if(tile != null && tile instanceof TileRuneAltar) - ((TileRuneAltar) tile).renderHUD(mc, event.getResolution()); - - if(tile != null && tile instanceof TileCorporeaCrystalCube) - renderCrystalCubeHUD(event.getResolution(), (TileCorporeaCrystalCube) tile); + if(!PlayerHelper.hasHeldItemClass(mc.player, ILexicon.class)) { + if(tile instanceof TileAltar) + ((TileAltar) tile).renderHUD(mc, event.getResolution()); + else if(tile instanceof TileRuneAltar) + ((TileRuneAltar) tile).renderHUD(mc, event.getResolution()); + else if(tile instanceof TileCorporeaCrystalCube) + renderCrystalCubeHUD(event.getResolution(), (TileCorporeaCrystalCube) tile); + } } TileCorporeaIndex.getInputHandler(); @@ -356,11 +357,14 @@ public final class HUDHandler { int strlen = Math.max(mc.fontRenderer.getStringWidth(s1), mc.fontRenderer.getStringWidth(s2)); int w = res.getScaledWidth(); int h = res.getScaledHeight(); - Gui.drawRect(w / 2 + 8, h / 2 - 12, w / 2 + strlen + 32, h / 2 + 10, 0x44000000); - Gui.drawRect(w / 2 + 6, h / 2 - 14, w / 2 + strlen + 34, h / 2 + 12, 0x44000000); + int boxH = h / 2 + (tile.locked ? 20 : 10); + Gui.drawRect(w / 2 + 8, h / 2 - 12, w / 2 + strlen + 32, boxH, 0x44000000); + Gui.drawRect(w / 2 + 6, h / 2 - 14, w / 2 + strlen + 34, boxH + 2, 0x44000000); mc.fontRenderer.drawStringWithShadow(target.getDisplayName(), w / 2 + 30, h / 2 - 10, 0x6666FF); mc.fontRenderer.drawStringWithShadow(tile.getItemCount() + "x", w / 2 + 30, h / 2, 0xFFFFFF); + if(tile.locked) + mc.fontRenderer.drawStringWithShadow(I18n.format("botaniamisc.locked"), w / 2 + 30, h / 2 + 10, 0xFFAA00); net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting(); GlStateManager.enableRescaleNormal(); mc.getRenderItem().renderItemAndEffectIntoGUI(target, w / 2 + 10, h / 2 - 10); diff --git a/src/main/java/vazkii/botania/common/block/BlockHourglass.java b/src/main/java/vazkii/botania/common/block/BlockHourglass.java index a2c189a32..f18b9d426 100644 --- a/src/main/java/vazkii/botania/common/block/BlockHourglass.java +++ b/src/main/java/vazkii/botania/common/block/BlockHourglass.java @@ -36,6 +36,7 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.items.ItemHandlerHelper; import vazkii.botania.api.internal.IManaBurst; +import vazkii.botania.api.internal.VanillaPacketDispatcher; import vazkii.botania.api.lexicon.ILexiconable; import vazkii.botania.api.lexicon.LexiconEntry; import vazkii.botania.api.mana.IManaTrigger; @@ -185,7 +186,9 @@ public class BlockHourglass extends BlockMod implements IManaTrigger, IWandable, public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, BlockPos pos, EnumFacing side) { TileHourglass tile = (TileHourglass) world.getTileEntity(pos); tile.lock = !tile.lock; - return false; + if(!world.isRemote) + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(tile); + return true; } @SideOnly(Side.CLIENT) diff --git a/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaCrystalCube.java b/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaCrystalCube.java index a15c163c8..148267374 100644 --- a/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaCrystalCube.java +++ b/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaCrystalCube.java @@ -10,6 +10,8 @@ */ package vazkii.botania.common.block.corporea; +import javax.annotation.Nonnull; + import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.block.properties.IProperty; @@ -23,6 +25,7 @@ import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.text.TextComponentTranslation; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.client.ForgeHooksClient; @@ -31,17 +34,18 @@ import net.minecraftforge.common.property.IUnlistedProperty; import net.minecraftforge.common.property.Properties; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; +import vazkii.botania.api.internal.VanillaPacketDispatcher; import vazkii.botania.api.lexicon.ILexiconable; import vazkii.botania.api.lexicon.LexiconEntry; +import vazkii.botania.api.wand.IWandable; import vazkii.botania.client.core.handler.ModelHandler; import vazkii.botania.common.block.tile.corporea.TileCorporeaBase; import vazkii.botania.common.block.tile.corporea.TileCorporeaCrystalCube; +import vazkii.botania.common.item.ModItems; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; -import javax.annotation.Nonnull; - -public class BlockCorporeaCrystalCube extends BlockCorporeaBase implements ILexiconable { +public class BlockCorporeaCrystalCube extends BlockCorporeaBase implements ILexiconable, IWandable { private static final AxisAlignedBB AABB = new AxisAlignedBB(3.0/16, 0, 3.0/16, 13.0/16, 1, 13.0/16); @@ -93,8 +97,26 @@ public class BlockCorporeaCrystalCube extends BlockCorporeaBase implements ILexi public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing s, float xs, float ys, float zs) { ItemStack stack = player.getHeldItem(hand); if(!stack.isEmpty()) { + if(stack.getItem() == ModItems.twigWand && player.isSneaking()) + return false; TileCorporeaCrystalCube cube = (TileCorporeaCrystalCube) world.getTileEntity(pos); - cube.setRequestTarget(stack); + if(cube.locked) { + if(!world.isRemote) + player.sendStatusMessage(new TextComponentTranslation("botaniamisc.crystalCubeLocked"), false); + } else + cube.setRequestTarget(stack); + return true; + } + return false; + } + + @Override + public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, BlockPos pos, EnumFacing side) { + if(player == null || player.isSneaking()) { + TileCorporeaCrystalCube cube = (TileCorporeaCrystalCube) world.getTileEntity(pos); + cube.locked = !cube.locked; + if(!world.isRemote) + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(cube); return true; } return false; @@ -143,5 +165,4 @@ public class BlockCorporeaCrystalCube extends BlockCorporeaBase implements ILexi ModelHandler.registerInventoryVariant(this); ForgeHooksClient.registerTESRItemStack(Item.getItemFromBlock(this), 0, TileCorporeaCrystalCube.class); } - } diff --git a/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaCrystalCube.java b/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaCrystalCube.java index 34ac87596..8ad3af540 100644 --- a/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaCrystalCube.java +++ b/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaCrystalCube.java @@ -35,13 +35,13 @@ public class TileCorporeaCrystalCube extends TileCorporeaBase implements ICorpor private static final String TAG_REQUEST_TARGET = "requestTarget"; private static final String TAG_ITEM_COUNT = "itemCount"; + private static final String TAG_LOCK = "lock"; - private static final double LOG_2 = Math.log(2); - - ItemStack requestTarget = ItemStack.EMPTY; - int itemCount = 0; - int ticks = 0; - int compValue = 0; + private ItemStack requestTarget = ItemStack.EMPTY; + private int itemCount = 0; + private int ticks = 0; + private int compValue = 0; + public boolean locked = false; private final IAnimationStateMachine asm; @@ -61,7 +61,7 @@ public class TileCorporeaCrystalCube extends TileCorporeaBase implements ICorpor } public void setRequestTarget(ItemStack stack) { - if(!stack.isEmpty()) { + if(!stack.isEmpty() && !locked) { ItemStack copy = stack.copy(); copy.setCount(1); requestTarget = copy; @@ -125,6 +125,7 @@ public class TileCorporeaCrystalCube extends TileCorporeaBase implements ICorpor cmp = requestTarget.writeToNBT(cmp); par1nbtTagCompound.setTag(TAG_REQUEST_TARGET, cmp); par1nbtTagCompound.setInteger(TAG_ITEM_COUNT, itemCount); + par1nbtTagCompound.setBoolean(TAG_LOCK, locked); } @Override @@ -133,6 +134,7 @@ public class TileCorporeaCrystalCube extends TileCorporeaBase implements ICorpor NBTTagCompound cmp = par1nbtTagCompound.getCompoundTag(TAG_REQUEST_TARGET); requestTarget = new ItemStack(cmp); itemCount = par1nbtTagCompound.getInteger(TAG_ITEM_COUNT); + locked = par1nbtTagCompound.getBoolean(TAG_LOCK); } public int getComparatorValue() { diff --git a/src/main/java/vazkii/botania/common/lexicon/LexiconData.java b/src/main/java/vazkii/botania/common/lexicon/LexiconData.java index 7a598f70d..1caf68d87 100644 --- a/src/main/java/vazkii/botania/common/lexicon/LexiconData.java +++ b/src/main/java/vazkii/botania/common/lexicon/LexiconData.java @@ -1118,7 +1118,7 @@ public final class LexiconData { new PageCraftingRecipe("3", ModCraftingRecipes.recipeBlackHoleTalisman)); corporeaCrystalCube = new AlfheimLexiconEntry(LibLexicon.ENDER_CORPOREA_CRYSTAL_CUBE, categoryEnder); - corporeaCrystalCube.setLexiconPages(new PageText("0"), new PageText("1"), new PageText("3"), + corporeaCrystalCube.setLexiconPages(new PageText("0"), new PageText("1"), new PageText("3"), new PageText("4"), new PageCraftingRecipe("2", ModCraftingRecipes.recipeCorporeaCrystalCube)); luminizerTransport = new AlfheimLexiconEntry(LibLexicon.ENDER_LUMINIZER_TRANSPORT, categoryEnder); diff --git a/src/main/resources/assets/botania/lang/en_us.lang b/src/main/resources/assets/botania/lang/en_us.lang index 49a0698f6..dee855196 100644 --- a/src/main/resources/assets/botania/lang/en_us.lang +++ b/src/main/resources/assets/botania/lang/en_us.lang @@ -119,6 +119,7 @@ botaniamisc.inactive=&cInactive botaniamisc.advancements=Botania Advancements botaniamisc.dropIkea=&bDropping this item will break it down into its components botaniamisc.hourglassLock=This Hourglass is locked. Right click it with a Wand of the Forest to unlock it. +botaniamisc.crystalCubeLocked=This Crystal Cube is locked. To change the displayed item, unlock it with a Wand of the Forest. botaniamisc.locked=Locked botaniamisc.stopped=Stopped botaniamisc.lockedStopped=Locked, Stopped @@ -3292,6 +3293,7 @@ botania.tagline.corporeaCrystalCube=View and request items from a Corporea netwo botania.page.corporeaCrystalCube0=A seer usually looks through a crystal ball to see the future. Well, a corporea handler would look through a crystal cube to see the present. The &1Corporea Crystal Cube&0 acts as a visual medium to interact ith one's &4Corporea Network&0. Placing the block down and giving it a &1Corporea Spark&0 is the obvious first step to hooking it up to the network. botania.page.corporeaCrystalCube1=When the block is connected, right clicking it with any sort of item will have it monitor that item, allowing someone who's looking at it see how many exist in the network. The display updates about once every second.
While there's an item selected, left clicking the block will request one of that item from the network. Shift-left clicking requests a whole stack. botania.page.corporeaCrystalCube3=The &1Corporea Crystal Cube&0 can be used alongside a &1Redstone Comparator&0. This will output the amount of items of the type it's looking for in the system. The output value follows a logarithmic progression, or on layman's terms, every level requires twice as many of the item as the previous one, starting at 1. 0 items would be signal 0. 1 item for 1, 2 items for 2, 4 items for 3, 8 items for 4, 16 items for 5 and so on up to 15. +botania.page.corporeaCrystalCube4=Right clicking on the block with a &1Wand of the Forest&0 while sneaking locks (and unlocks) it, similarly to the &1Hovering Hourglass&0. When locked, the monitored item can't be changed, just in case someone right clicks it on accident. botania.page.corporeaCrystalCube2=I can see forever # -- CORPOREA RETAINER From 11c98a7ab2d4c9a3f7f7179b0882efde520b38d4 Mon Sep 17 00:00:00 2001 From: Vincent Lee Date: Sun, 24 Feb 2019 19:54:39 -0600 Subject: [PATCH 30/31] Fix gaia guardians riding vehicles, a regression since 1.9. Yay. Recloses #1476 --- .../java/vazkii/botania/common/entity/EntityDoppleganger.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/vazkii/botania/common/entity/EntityDoppleganger.java b/src/main/java/vazkii/botania/common/entity/EntityDoppleganger.java index f70758a6f..cfb73bd7d 100644 --- a/src/main/java/vazkii/botania/common/entity/EntityDoppleganger.java +++ b/src/main/java/vazkii/botania/common/entity/EntityDoppleganger.java @@ -656,7 +656,7 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss, IE bossInfo.setPercent(getHealth() / getMaxHealth()); - if(!getPassengers().isEmpty()) + if(isRiding()) dismountRidingEntity(); if(world.getDifficulty() == EnumDifficulty.PEACEFUL) From 9fde29e04744859f4c15bf2b9403683f543fcc2c Mon Sep 17 00:00:00 2001 From: Vasco Lavos Date: Thu, 28 Feb 2019 20:27:05 +0000 Subject: [PATCH 31/31] Update contributors.properties --- contributors.properties | 1 + 1 file changed, 1 insertion(+) diff --git a/contributors.properties b/contributors.properties index 8cb4e329f..2ee4eff6e 100644 --- a/contributors.properties +++ b/contributors.properties @@ -162,3 +162,4 @@ ellpeck=spectrolus mecharm=14 studkid=3 brannie17=puredaisy +byunni_rabbit=orechid