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/build.properties b/build.properties index c93bdf6db..5e598177a 100644 --- a/build.properties +++ b/build.properties @@ -1,5 +1,5 @@ # -#Fri Nov 30 05:12:11 GMT 2018 +#Tue Feb 19 20:11:12 GMT 2019 mod_name=Botania cf_meta_version=1.12.2 forge_version=14.23.5.2768 @@ -8,4 +8,4 @@ mc_mappings=stable_39 version=r1.10 dir_output=../Build Output/Botania/ mc_version=1.12.2 -build_number=359 +build_number=361 diff --git a/contributors.properties b/contributors.properties index fb5ac7299..2ee4eff6e 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,10 @@ _neotron_=9 taciturasa=6 nachog2003=9 ewsmith=rafflowsia +attifyon=1 +sarkasaa=spectrolus +ellpeck=spectrolus +mecharm=14 +studkid=3 +brannie17=puredaisy +byunni_rabbit=orechid diff --git a/src/main/java/vazkii/botania/api/BotaniaAPI.java b/src/main/java/vazkii/botania/api/BotaniaAPI.java index e2a73ef4f..1e1cbbc50 100644 --- a/src/main/java/vazkii/botania/api/BotaniaAPI.java +++ b/src/main/java/vazkii/botania/api/BotaniaAPI.java @@ -67,8 +67,8 @@ import vazkii.botania.common.item.ModItems; import javax.annotation.Nonnull; 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; @@ -104,6 +104,7 @@ public final class BotaniaAPI { public static final Set looniumBlacklist = new LinkedHashSet<>(); public static final Map> paintableBlocks = new LinkedHashMap<>(); public static final Set> gravityRodBlacklist = new LinkedHashSet<>(); + public static final Set gaiaBreakBlacklist = new HashSet<>(); // TODO 1.13 move these to eliminate dependence on botania proper in Ingredients private static final int[] MAX_DAMAGE_ARRAY = new int[]{13, 15, 16, 11}; @@ -473,6 +474,7 @@ public final class BotaniaAPI { registerPaintableBlock(Blocks.STAINED_HARDENED_CLAY, BlockColored.COLOR); registerPaintableBlock(Blocks.WOOL, BlockColored.COLOR); registerPaintableBlock(Blocks.CARPET, BlockCarpet.COLOR); + blacklistBlockFromGaiaGuardian(Blocks.BEACON); } /** @@ -805,4 +807,7 @@ public final class BotaniaAPI { return subTiles.keySet(); } + public static void blacklistBlockFromGaiaGuardian(Block block) { + gaiaBreakBlacklist.add(block); + } } 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; } diff --git a/src/main/java/vazkii/botania/api/package-info.java b/src/main/java/vazkii/botania/api/package-info.java index a16b19864..c70cd4134 100644 --- a/src/main/java/vazkii/botania/api/package-info.java +++ b/src/main/java/vazkii/botania/api/package-info.java @@ -1,4 +1,2 @@ -@API(owner = "botania", apiVersion = "92", provides = "BotaniaAPI") package vazkii.botania.api; -import net.minecraftforge.fml.common.API; 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/client/core/handler/HUDHandler.java b/src/main/java/vazkii/botania/client/core/handler/HUDHandler.java index a56dcd34d..726430c3a 100644 --- a/src/main/java/vazkii/botania/client/core/handler/HUDHandler.java +++ b/src/main/java/vazkii/botania/client/core/handler/HUDHandler.java @@ -130,7 +130,7 @@ public final class HUDHandler { if(PlayerHelper.hasAnyHeldItem(mc.player)) { if(pos != null && PlayerHelper.hasHeldItem(mc.player, ModItems.twigWand)) { - renderWandModeDisplay(PlayerHelper.getFirstHeldItem(mc.player, ModItems.twigWand), event.getResolution()); + renderWandModeDisplay(PlayerHelper.getFirstHeldItem(mc.player, ModItems.twigWand)); if(block instanceof IWandHUD) { profiler.startSection("wandItem"); @@ -138,17 +138,18 @@ public final class HUDHandler { profiler.endSection(); } } 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()) + drawLexiconHUD(PlayerHelper.getFirstHeldItemClass(mc.player, ILexicon.class), state, pos); + if(tile instanceof TilePool && !mc.player.getHeldItemMainhand().isEmpty()) renderPoolRecipeHUD((TilePool) tile, mc.player.getHeldItemMainhand()); } - if(tile != null && tile instanceof TileAltar) - ((TileAltar) tile).renderHUD(mc); - else if(tile != null && tile instanceof TileRuneAltar) - ((TileRuneAltar) tile).renderHUD(mc); - - if(tile != null && tile instanceof TileCorporeaCrystalCube) - renderCrystalCubeHUD((TileCorporeaCrystalCube) tile); + if(!PlayerHelper.hasHeldItemClass(mc.player, ILexicon.class)) { + if(tile instanceof TileAltar) + ((TileAltar) tile).renderHUD(mc); + else if(tile instanceof TileRuneAltar) + ((TileRuneAltar) tile).renderHUD(mc); + else if(tile instanceof TileCorporeaCrystalCube) + renderCrystalCubeHUD((TileCorporeaCrystalCube) tile); + } } TileCorporeaIndex.getInputHandler(); @@ -354,11 +355,14 @@ public final class HUDHandler { int strlen = Math.max(mc.fontRenderer.getStringWidth(s1), mc.fontRenderer.getStringWidth(s2)); int w = mc.mainWindow.getScaledWidth(); int h = mc.mainWindow.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(s1, 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.getItemRenderer().renderItemAndEffectIntoGUI(target, w / 2 + 10, h / 2 - 10); 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 c68eaf2c0..316c47e9b 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; @@ -33,7 +35,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; @@ -49,13 +54,17 @@ 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.lib.LibBlockNames; 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; @@ -103,8 +112,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); @@ -165,6 +178,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 39f8b557c..4bedff84f 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.flask), 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 949bfaa1b..fb383d7c2 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 78a6f0509..c5b1383a6 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 93827bb62..5fdecdd54 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.defaultAltar)); 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/client/model/FloatingFlowerModel.java b/src/main/java/vazkii/botania/client/model/FloatingFlowerModel.java index da444b247..515a35a86 100644 --- a/src/main/java/vazkii/botania/client/model/FloatingFlowerModel.java +++ b/src/main/java/vazkii/botania/client/model/FloatingFlowerModel.java @@ -108,6 +108,11 @@ public class FloatingFlowerModel implements IBakedModel { private CompositeBakedModel getModel(IFloatingFlower.IslandType islandType, ResourceLocation identifier) { ModelManager modelManager = Minecraft.getInstance().getItemRenderer().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 { diff --git a/src/main/java/vazkii/botania/common/block/BlockAltGrass.java b/src/main/java/vazkii/botania/common/block/BlockAltGrass.java index a603a4397..e0eea838b 100644 --- a/src/main/java/vazkii/botania/common/block/BlockAltGrass.java +++ b/src/main/java/vazkii/botania/common/block/BlockAltGrass.java @@ -10,6 +10,7 @@ */ package vazkii.botania.common.block; +import net.minecraft.block.BlockStem; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; @@ -17,10 +18,12 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.init.Particles; import net.minecraft.item.Item; +import net.minecraft.item.ItemHoe; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumFacing; import net.minecraft.util.IItemProvider; import net.minecraft.util.IStringSerializable; +import net.minecraft.util.EnumHand; import net.minecraft.util.NonNullList; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; @@ -65,7 +68,19 @@ public class BlockAltGrass extends BlockMod implements ILexiconable { public boolean isToolEffective(IBlockState state, ToolType tool) { return tool.equals(ToolType.SHOVEL); } - + + @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 tick(IBlockState state, World world, BlockPos pos, Random rand) { if(!world.isRemote && state.getBlock() == this && world.getLight(pos.up()) >= 9) { @@ -89,7 +104,7 @@ public class BlockAltGrass extends BlockMod implements ILexiconable { @Override public boolean canSustainPlant(@Nonnull IBlockState state, @Nonnull IBlockReader 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; } @OnlyIn(Dist.CLIENT) diff --git a/src/main/java/vazkii/botania/common/block/BlockHourglass.java b/src/main/java/vazkii/botania/common/block/BlockHourglass.java index 289f82228..39bad6659 100644 --- a/src/main/java/vazkii/botania/common/block/BlockHourglass.java +++ b/src/main/java/vazkii/botania/common/block/BlockHourglass.java @@ -35,6 +35,7 @@ import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; 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; @@ -164,7 +165,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; } @OnlyIn(Dist.CLIENT) diff --git a/src/main/java/vazkii/botania/common/block/BlockPylon.java b/src/main/java/vazkii/botania/common/block/BlockPylon.java index cf2b9137a..3488e4031 100644 --- a/src/main/java/vazkii/botania/common/block/BlockPylon.java +++ b/src/main/java/vazkii/botania/common/block/BlockPylon.java @@ -26,9 +26,8 @@ import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.world.IBlockReader; import net.minecraft.world.IWorldReader; import net.minecraft.world.World; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; 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.client.core.handler.ModelHandler; @@ -54,6 +53,7 @@ public class BlockPylon extends BlockMod implements ILexiconable, IInfusionStabi public BlockPylon(Variant v, Properties builder) { super(builder); this.variant = v; + BotaniaAPI.blacklistBlockFromGaiaGuardian(this); } @Nonnull 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 6860a994c..b394465b7 100644 --- a/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaCrystalCube.java +++ b/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaCrystalCube.java @@ -11,6 +11,7 @@ package vazkii.botania.common.block.corporea; import net.minecraft.block.Block; +import javax.annotation.Nonnull; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.block.properties.IProperty; @@ -26,6 +27,7 @@ import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockReader; import net.minecraft.world.IBlockReader; +import net.minecraft.util.text.TextComponentTranslation; import net.minecraft.world.World; import net.minecraftforge.client.ForgeHooksClient; import net.minecraftforge.common.property.ExtendedBlockState; @@ -33,17 +35,18 @@ import net.minecraftforge.common.property.IUnlistedProperty; import net.minecraftforge.common.property.Properties; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +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); @@ -82,8 +85,26 @@ public class BlockCorporeaCrystalCube extends BlockCorporeaBase implements ILexi public boolean onBlockActivated(IBlockState state, World world, BlockPos pos, 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; @@ -127,5 +148,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/mana/BlockPrism.java b/src/main/java/vazkii/botania/common/block/mana/BlockPrism.java index 90b9527da..736de3a37 100644 --- a/src/main/java/vazkii/botania/common/block/mana/BlockPrism.java +++ b/src/main/java/vazkii/botania/common/block/mana/BlockPrism.java @@ -92,13 +92,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.with(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.with(BotaniaStateProps.HAS_LENS, false), 1 | 2); } return true; @@ -140,7 +136,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/subtile/functional/SubTileHopperhock.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileHopperhock.java index 48fa04ff6..87882efc1 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 @@ -78,7 +78,7 @@ public class SubTileHopperhock extends SubTileFunctional { for(EnumFacing dir : EnumFacing.BY_INDEX) { 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); 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 0a9d61111..5202ea2d1 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.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; +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); 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 260d72427..cac903e45 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileCraftCrate.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileCraftCrate.java @@ -114,7 +114,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; } 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 519792257..18c28ed46 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileFloatingFlower.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileFloatingFlower.java @@ -15,6 +15,8 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntityType; import net.minecraftforge.registries.ObjectHolder; +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; @@ -28,7 +30,7 @@ public class TileFloatingFlower extends TileMod implements IFloatingFlower { private static final String TAG_ISLAND_TYPE = "islandType"; public static ItemStack forcedStack = ItemStack.EMPTY; - IslandType type = IslandType.GRASS; + private IslandType type = IslandType.GRASS; public TileFloatingFlower() { super(TYPE); @@ -44,6 +46,15 @@ public class TileFloatingFlower extends TileMod implements IFloatingFlower { return new ItemStack(getBlockState().getBlock()); } + @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); 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 b8f7e6fc9..c99053ec5 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 @@ -41,13 +41,13 @@ public class TileCorporeaCrystalCube extends TileCorporeaBase implements ICorpor public static TileEntityType TYPE; private static final String TAG_REQUEST_TARGET = "requestTarget"; private static final String TAG_ITEM_COUNT = "itemCount"; - - private static final double LOG_2 = Math.log(2); + private static final String TAG_LOCK = "lock"; 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; private final LazyOptional asmCap; @@ -71,7 +71,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; @@ -135,6 +135,7 @@ public class TileCorporeaCrystalCube extends TileCorporeaBase implements ICorpor cmp = requestTarget.write(cmp); par1nbtTagCompound.put(TAG_REQUEST_TARGET, cmp); par1nbtTagCompound.putInt(TAG_ITEM_COUNT, itemCount); + par1nbtTagCompound.putBoolean(TAG_LOCK, locked); } @Override @@ -143,6 +144,7 @@ public class TileCorporeaCrystalCube extends TileCorporeaBase implements ICorpor NBTTagCompound cmp = par1nbtTagCompound.getCompound(TAG_REQUEST_TARGET); requestTarget = ItemStack.read(cmp); itemCount = par1nbtTagCompound.getInt(TAG_ITEM_COUNT); + locked = par1nbtTagCompound.getBoolean(TAG_LOCK); } public int getComparatorValue() { 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 2e43211ae..3887dc486 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 net.minecraft.tileentity.TileEntityType; @@ -20,6 +21,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 vazkii.botania.common.lib.LibBlockNames; import vazkii.botania.common.lib.LibMisc; @@ -82,6 +84,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)); + } + } } } 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 99bdad4f9..3546b3a1a 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 @@ -17,9 +17,11 @@ import net.minecraft.util.math.BlockPos; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.items.CapabilityItemHandler; +import net.minecraftforge.items.IItemHandler; import net.minecraftforge.registries.ObjectHolder; import vazkii.botania.common.lib.LibBlockNames; import vazkii.botania.common.lib.LibMisc; +import net.minecraftforge.items.wrapper.EmptyHandler; import javax.annotation.Nonnull; import java.util.Arrays; @@ -27,6 +29,7 @@ import java.util.Arrays; public class TileRedStringContainer extends TileRedString { @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.RED_STRING_CONTAINER) public static TileEntityType TYPE; + private static final LazyOptional EMPTY = LazyOptional.of(EmptyHandler::new); public TileRedStringContainer() { this(TYPE); @@ -40,7 +43,7 @@ public class TileRedStringContainer extends TileRedString { public boolean acceptBlock(BlockPos pos) { TileEntity tile = world.getTileEntity(pos); return tile != null - && Arrays.stream(EnumFacing.BY_INDEX) + && Arrays.stream(EnumFacing.values()) .anyMatch(e -> tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, e).isPresent()); } @@ -48,9 +51,12 @@ public class TileRedStringContainer extends TileRedString { @Override public LazyOptional getCapability(@Nonnull Capability cap, EnumFacing side) { // todo 1.13 need to invalidate when binding breaks - if(cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY - && getTileAtBinding() != null) - return getTileAtBinding().getCapability(cap, side); + if(cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { + if(getTileAtBinding() != null) { + return getTileAtBinding().getCapability(cap, side); + } + return EMPTY.cast(); + } return super.getCapability(cap, side); } 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/core/helper/ItemNBTHelper.java b/src/main/java/vazkii/botania/common/core/helper/ItemNBTHelper.java index 53d0c114f..cf3e0b0db 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]; @@ -124,4 +127,36 @@ public final class ItemNBTHelper { return verifyExistance(stack, tag) ? stack.getOrCreateTag().getList(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; + } } 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; diff --git a/src/main/java/vazkii/botania/common/entity/EntityDoppleganger.java b/src/main/java/vazkii/botania/common/entity/EntityDoppleganger.java index b4e26d267..ed0cd713b 100644 --- a/src/main/java/vazkii/botania/common/entity/EntityDoppleganger.java +++ b/src/main/java/vazkii/botania/common/entity/EntityDoppleganger.java @@ -40,6 +40,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; @@ -65,6 +66,7 @@ import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.registries.ObjectHolder; 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; @@ -89,8 +91,10 @@ import javax.annotation.Nullable; 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; @@ -100,6 +104,8 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss, IE public static EntityType TYPE; 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; @@ -129,8 +135,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; @@ -174,43 +180,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.gaiaPylon) { 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.gaiaPylon) { - 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); @@ -221,72 +237,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_ENDER_DRAGON_GROWL, 10F, 0.1F); e.onInitialSpawn(world.getDifficultyForLocation(new BlockPos(e)), null, 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 @@ -314,35 +304,35 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss, IE } @Override - public void writeAdditional(NBTTagCompound par1nbtTagCompound) { - super.writeAdditional(par1nbtTagCompound); - par1nbtTagCompound.setInt(TAG_INVUL_TIME, getInvulTime()); - par1nbtTagCompound.setBoolean(TAG_AGGRO, aggro); - par1nbtTagCompound.setInt(TAG_MOB_SPAWN_TICKS, mobSpawnTicks); + public void writeAdditional(NBTTagCompound cmp) { + super.writeAdditional(cmp); + cmp.putInt(TAG_INVUL_TIME, getInvulTime()); + cmp.putBoolean(TAG_AGGRO, aggro); + cmp.putInt(TAG_MOB_SPAWN_TICKS, mobSpawnTicks); - par1nbtTagCompound.setInt(TAG_SOURCE_X, source.getX()); - par1nbtTagCompound.setInt(TAG_SOURCE_Y, source.getY()); - par1nbtTagCompound.setInt(TAG_SOURCE_Z, source.getZ()); + cmp.putInt(TAG_SOURCE_X, source.getX()); + cmp.putInt(TAG_SOURCE_Y, source.getY()); + cmp.putInt(TAG_SOURCE_Z, source.getZ()); - par1nbtTagCompound.setBoolean(TAG_HARD_MODE, hardMode); - par1nbtTagCompound.setInt(TAG_PLAYER_COUNT, playerCount); + cmp.putBoolean(TAG_HARD_MODE, hardMode); + cmp.putInt(TAG_PLAYER_COUNT, playerCount); } @Override - public void readAdditional(NBTTagCompound par1nbtTagCompound) { - super.readAdditional(par1nbtTagCompound); - setInvulTime(par1nbtTagCompound.getInt(TAG_INVUL_TIME)); - aggro = par1nbtTagCompound.getBoolean(TAG_AGGRO); - mobSpawnTicks = par1nbtTagCompound.getInt(TAG_MOB_SPAWN_TICKS); + public void readAdditional(NBTTagCompound cmp) { + super.readAdditional(cmp); + setInvulTime(cmp.getInt(TAG_INVUL_TIME)); + aggro = cmp.getBoolean(TAG_AGGRO); + mobSpawnTicks = cmp.getInt(TAG_MOB_SPAWN_TICKS); - int x = par1nbtTagCompound.getInt(TAG_SOURCE_X); - int y = par1nbtTagCompound.getInt(TAG_SOURCE_Y); - int z = par1nbtTagCompound.getInt(TAG_SOURCE_Z); + int x = cmp.getInt(TAG_SOURCE_X); + int y = cmp.getInt(TAG_SOURCE_Y); + int z = cmp.getInt(TAG_SOURCE_Z); source = new BlockPos(x, y, z); - hardMode = par1nbtTagCompound.getBoolean(TAG_HARD_MODE); - if(par1nbtTagCompound.hasKey(TAG_PLAYER_COUNT)) - playerCount = par1nbtTagCompound.getInt(TAG_PLAYER_COUNT); + hardMode = cmp.getBoolean(TAG_HARD_MODE); + if(cmp.contains(TAG_PLAYER_COUNT)) + playerCount = cmp.getInt(TAG_PLAYER_COUNT); else playerCount = 1; if (this.hasCustomName()) { @@ -396,10 +386,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); @@ -448,8 +438,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(); @@ -495,12 +484,12 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss, IE super.remove(); } - 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(); @@ -546,20 +535,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); } } } @@ -647,28 +647,28 @@ 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.abilities.isFlying = player.abilities.isFlying && player.abilities.isCreativeMode; + player.abilities.isFlying &= player.abilities.isCreativeMode; return; } bossInfo.setPercent(getHealth() / getMaxHealth()); - if(!getPassengers().isEmpty()) + if(isPassenger()) stopRiding(); if(world.getDifficulty() == EnumDifficulty.PEACEFUL) - setDead(); + remove(); - smashCheatyBlocks(); + smashBlocksAround(MathHelper.floor(posX), MathHelper.floor(posY), MathHelper.floor(posZ), 1); List players = getPlayersAround(); if(players.isEmpty() && !world.playerEntities.isEmpty()) - setDead(); + remove(); else { for(EntityPlayer player : players) { for(EntityEquipmentSlot e : EntityEquipmentSlot.values()) { @@ -678,9 +678,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.abilities.isFlying = player.abilities.isFlying && player.abilities.isCreativeMode; + player.abilities.isFlying &= player.abilities.isCreativeMode; } } @@ -732,18 +735,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); @@ -779,21 +778,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); } @@ -818,127 +814,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.getRegistryName()); - } + 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; } } diff --git a/src/main/java/vazkii/botania/common/entity/EntityVineBall.java b/src/main/java/vazkii/botania/common/entity/EntityVineBall.java index 03cb34373..4d54605b5 100644 --- a/src/main/java/vazkii/botania/common/entity/EntityVineBall.java +++ b/src/main/java/vazkii/botania/common/entity/EntityVineBall.java @@ -31,6 +31,7 @@ import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.registries.ObjectHolder; +import vazkii.botania.common.block.BlockSolidVines; import vazkii.botania.common.block.ModBlocks; import vazkii.botania.common.item.ModItems; import vazkii.botania.common.lib.LibMisc; @@ -79,11 +80,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().with(propMap.get(dir.getOpposite()), true); + + if(first && !ModBlocks.solidVines.getDefaultState().isValidPosition(world, pos)) break; + first = false; + world.setBlockState(pos, stateSet, 1 | 2); world.playEvent(2001, pos, Block.getStateId(stateSet)); pos = pos.down(); diff --git a/src/main/java/vazkii/botania/common/item/ItemTwigWand.java b/src/main/java/vazkii/botania/common/item/ItemTwigWand.java index a96bd54db..b547b93a7 100644 --- a/src/main/java/vazkii/botania/common/item/ItemTwigWand.java +++ b/src/main/java/vazkii/botania/common/item/ItemTwigWand.java @@ -156,8 +156,6 @@ public class ItemTwigWand extends ItemMod implements ICoordBoundItem { return EnumActionResult.SUCCESS; } - - return EnumActionResult.PASS; } if(block instanceof IWandable) { 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 e8be1c82f..5921c1731 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 @@ -19,7 +19,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.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.gameevent.InputEvent.KeyInputEvent; @@ -29,6 +28,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; @@ -53,13 +53,11 @@ public class ItemDodgeRing extends ItemBauble { Minecraft mc = Minecraft.getInstance(); 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/bauble/ItemHolyCloak.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemHolyCloak.java index b45b297d6..e98b17ea6 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 @@ -50,7 +50,7 @@ public class ItemHolyCloak extends ItemBauble implements IBaubleRender { } private 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)) { 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 8d2f2bb7b..44a270b24 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,6 @@ package vazkii.botania.common.item.equipment.bauble; import baubles.api.BaubleType; import baubles.api.BaublesApi; -import com.google.common.collect.ImmutableList; import net.minecraft.block.Block; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityItem; @@ -109,7 +108,7 @@ public class ItemMagnetRing extends ItemBauble { } private boolean canPullItem(EntityItem item) { - if(!item.isAlive() || SubTileSolegnolia.hasSolegnoliaAround(item)) + if(!item.isAlive() || item.pickupDelay >= 40 || SubTileSolegnolia.hasSolegnoliaAround(item)) return false; ItemStack stack = item.getItem(); 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 c7a8c1e0b..2fc8a953a 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 @@ -16,6 +16,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; @@ -98,6 +99,7 @@ public class ItemManasteelShears extends ItemShears implements IManaUsingItem { ToolCommons.damageItem(itemstack, 1, player, MANA_PER_DAMAGE); player.addStat(StatList.BLOCK_MINED.get(block), 1); + player.world.setBlockState(pos, Blocks.AIR.getDefaultState(), 11); return true; } } 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 98ea7786e..6e8416f2a 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 @@ -173,7 +173,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 634060f60..a7c662d7e 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.item.ItemUseContext; @@ -28,7 +30,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.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; @@ -46,10 +47,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 2063da031..8258b25a7 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 3853269ca..e52de377f 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/lexicon/LexiconData.java b/src/main/java/vazkii/botania/common/lexicon/LexiconData.java index 0fd5f5372..8c46e64f2 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/java/vazkii/botania/common/lexicon/page/PagePetalRecipe.java b/src/main/java/vazkii/botania/common/lexicon/page/PagePetalRecipe.java index a43da51e7..af8554810 100644 --- a/src/main/java/vazkii/botania/common/lexicon/page/PagePetalRecipe.java +++ b/src/main/java/vazkii/botania/common/lexicon/page/PagePetalRecipe.java @@ -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); diff --git a/src/main/java/vazkii/botania/common/network/PacketDodge.java b/src/main/java/vazkii/botania/common/network/PacketDodge.java index f41c13f91..258750e79 100644 --- a/src/main/java/vazkii/botania/common/network/PacketDodge.java +++ b/src/main/java/vazkii/botania/common/network/PacketDodge.java @@ -16,7 +16,6 @@ import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; import net.minecraft.network.PacketBuffer; import net.minecraft.util.SoundCategory; -import net.minecraft.util.text.TextComponentString; import net.minecraft.util.text.TextComponentTranslation; import net.minecraftforge.fml.network.NetworkEvent; import net.minecraftforge.items.IItemHandler; @@ -41,14 +40,12 @@ public class PacketDodge { 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)) - player.connection.disconnect(new TextComponentTranslation("botaniamisc.invalidDodge")); + int slot = BaublesApi.isBaubleEquipped(player, ModItems.dodgeRing); + if(slot < 0) { + ctx.get().getSender().connection.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); }); diff --git a/src/main/resources/assets/botania/lang/en_us.lang b/src/main/resources/assets/botania/lang/en_us.lang index 784ba7492..87fb97463 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 diff --git a/src/main/resources/data/botania/recipes/black_petal_block.json b/src/main/resources/data/botania/recipes/black_petal_block.json index 5f2b5385a..de3f8a4bb 100644 --- a/src/main/resources/data/botania/recipes/black_petal_block.json +++ b/src/main/resources/data/botania/recipes/black_petal_block.json @@ -11,7 +11,8 @@ "group": "botania:petal_block", "key": { "P": { - "item": "#PETALBLACK" + "item": "botania:petal", + "data": 15 } } } \ No newline at end of file diff --git a/src/main/resources/data/botania/recipes/blue_petal_block.json b/src/main/resources/data/botania/recipes/blue_petal_block.json index 346118e86..ea6fadf73 100644 --- a/src/main/resources/data/botania/recipes/blue_petal_block.json +++ b/src/main/resources/data/botania/recipes/blue_petal_block.json @@ -11,7 +11,8 @@ "group": "botania:petal_block", "key": { "P": { - "item": "#PETALBLUE" + "item": "botania:petal", + "data": 11 } } } \ No newline at end of file diff --git a/src/main/resources/data/botania/recipes/brown_petal_block.json b/src/main/resources/data/botania/recipes/brown_petal_block.json index a83bb0b28..fb6a4d26d 100644 --- a/src/main/resources/data/botania/recipes/brown_petal_block.json +++ b/src/main/resources/data/botania/recipes/brown_petal_block.json @@ -11,7 +11,8 @@ "group": "botania:petal_block", "key": { "P": { - "item": "#PETALBROWN" + "item": "botania:petal", + "data": 12 } } } \ No newline at end of file diff --git a/src/main/resources/data/botania/recipes/cyan_petal_block.json b/src/main/resources/data/botania/recipes/cyan_petal_block.json index 2f6b70b2c..d972a5d02 100644 --- a/src/main/resources/data/botania/recipes/cyan_petal_block.json +++ b/src/main/resources/data/botania/recipes/cyan_petal_block.json @@ -11,7 +11,8 @@ "group": "botania:petal_block", "key": { "P": { - "item": "#PETALCYAN" + "item": "botania:petal", + "data": 9 } } } \ No newline at end of file diff --git a/src/main/resources/data/botania/recipes/gray_petal_block.json b/src/main/resources/data/botania/recipes/gray_petal_block.json index d2822e2d2..677fc66cc 100644 --- a/src/main/resources/data/botania/recipes/gray_petal_block.json +++ b/src/main/resources/data/botania/recipes/gray_petal_block.json @@ -11,7 +11,8 @@ "group": "botania:petal_block", "key": { "P": { - "item": "#PETALGRAY" + "item": "botania:petal", + "data": 7 } } } \ No newline at end of file diff --git a/src/main/resources/data/botania/recipes/green_petal_block.json b/src/main/resources/data/botania/recipes/green_petal_block.json index 131e08b64..231381ac2 100644 --- a/src/main/resources/data/botania/recipes/green_petal_block.json +++ b/src/main/resources/data/botania/recipes/green_petal_block.json @@ -11,7 +11,8 @@ "group": "botania:petal_block", "key": { "P": { - "item": "#PETALGREEN" + "item": "botania:petal", + "data": 13 } } } \ No newline at end of file diff --git a/src/main/resources/data/botania/recipes/light_blue_petal_block.json b/src/main/resources/data/botania/recipes/light_blue_petal_block.json index fc6dec840..1f97b893b 100644 --- a/src/main/resources/data/botania/recipes/light_blue_petal_block.json +++ b/src/main/resources/data/botania/recipes/light_blue_petal_block.json @@ -11,7 +11,8 @@ "group": "botania:petal_block", "key": { "P": { - "item": "#PETALLIGHTBLUE" + "item": "botania:petal", + "data": 3 } } } \ No newline at end of file diff --git a/src/main/resources/data/botania/recipes/lime_petal_block.json b/src/main/resources/data/botania/recipes/lime_petal_block.json index c1c9ac938..9d3ce9771 100644 --- a/src/main/resources/data/botania/recipes/lime_petal_block.json +++ b/src/main/resources/data/botania/recipes/lime_petal_block.json @@ -11,7 +11,8 @@ "group": "botania:petal_block", "key": { "P": { - "item": "#PETALLIME" + "item": "botania:petal", + "data": 5 } } } \ No newline at end of file diff --git a/src/main/resources/data/botania/recipes/magenta_petal_block.json b/src/main/resources/data/botania/recipes/magenta_petal_block.json index f2bd2b3e9..dad6ec15c 100644 --- a/src/main/resources/data/botania/recipes/magenta_petal_block.json +++ b/src/main/resources/data/botania/recipes/magenta_petal_block.json @@ -11,7 +11,8 @@ "group": "botania:petal_block", "key": { "P": { - "item": "#PETALMAGENTA" + "item": "botania:petal", + "data": 2 } } } \ No newline at end of file diff --git a/src/main/resources/data/botania/recipes/orange_petal_block.json b/src/main/resources/data/botania/recipes/orange_petal_block.json index 79076fdf2..1317bfb23 100644 --- a/src/main/resources/data/botania/recipes/orange_petal_block.json +++ b/src/main/resources/data/botania/recipes/orange_petal_block.json @@ -11,7 +11,8 @@ "group": "botania:petal_block", "key": { "P": { - "item": "#PETALORANGE" + "item": "botania:petal", + "data": 1 } } } \ No newline at end of file diff --git a/src/main/resources/data/botania/recipes/pink_petal_block.json b/src/main/resources/data/botania/recipes/pink_petal_block.json index dfd6b6820..b9b77c2b1 100644 --- a/src/main/resources/data/botania/recipes/pink_petal_block.json +++ b/src/main/resources/data/botania/recipes/pink_petal_block.json @@ -11,7 +11,8 @@ "group": "botania:petal_block", "key": { "P": { - "item": "#PETALPINK" + "item": "botania:petal", + "data": 6 } } } \ No newline at end of file diff --git a/src/main/resources/data/botania/recipes/purple_petal_block.json b/src/main/resources/data/botania/recipes/purple_petal_block.json index fe51c1be4..f449d729b 100644 --- a/src/main/resources/data/botania/recipes/purple_petal_block.json +++ b/src/main/resources/data/botania/recipes/purple_petal_block.json @@ -11,7 +11,8 @@ "group": "botania:petal_block", "key": { "P": { - "item": "#PETALPURPLE" + "item": "botania:petal", + "data": 10 } } } \ No newline at end of file diff --git a/src/main/resources/data/botania/recipes/red_petal_block.json b/src/main/resources/data/botania/recipes/red_petal_block.json index 8f86caa52..7ba725263 100644 --- a/src/main/resources/data/botania/recipes/red_petal_block.json +++ b/src/main/resources/data/botania/recipes/red_petal_block.json @@ -11,7 +11,8 @@ "group": "botania:petal_block", "key": { "P": { - "item": "#PETALRED" + "item": "botania:petal", + "data": 14 } } } \ No newline at end of file diff --git a/src/main/resources/data/botania/recipes/silver_petal_block.json b/src/main/resources/data/botania/recipes/silver_petal_block.json index 422541184..3a1018739 100644 --- a/src/main/resources/data/botania/recipes/silver_petal_block.json +++ b/src/main/resources/data/botania/recipes/silver_petal_block.json @@ -11,7 +11,8 @@ "group": "botania:petal_block", "key": { "P": { - "item": "#PETALLIGHTGRAY" + "item": "botania:petal", + "data": 8 } } } \ No newline at end of file diff --git a/src/main/resources/data/botania/recipes/white_petal_block.json b/src/main/resources/data/botania/recipes/white_petal_block.json index 8a0aeadb7..2a871005c 100644 --- a/src/main/resources/data/botania/recipes/white_petal_block.json +++ b/src/main/resources/data/botania/recipes/white_petal_block.json @@ -11,7 +11,8 @@ "group": "botania:petal_block", "key": { "P": { - "item": "#PETALWHITE" + "item": "botania:petal", + "data": 0 } } } \ No newline at end of file diff --git a/src/main/resources/data/botania/recipes/yellow_petal_block.json b/src/main/resources/data/botania/recipes/yellow_petal_block.json index 170677b29..1dde8ee52 100644 --- a/src/main/resources/data/botania/recipes/yellow_petal_block.json +++ b/src/main/resources/data/botania/recipes/yellow_petal_block.json @@ -11,7 +11,8 @@ "group": "botania:petal_block", "key": { "P": { - "item": "#PETALYELLOW" + "item": "botania:petal", + "data": 4 } } } \ No newline at end of file diff --git a/version/1.12.2.txt b/version/1.12.2.txt index 4987fba71..d3b362fd0 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-360 \ No newline at end of file diff --git a/web/changelog.txt b/web/changelog.txt index ce01e9c38..a0f884573 100644 --- a/web/changelog.txt +++ b/web/changelog.txt @@ -1,3 +1,31 @@ +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 +*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..1b5d6304d 100644 --- a/web/versions.ini +++ b/web/versions.ini @@ -309,4 +309,6 @@ 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 +r1.10-360=1.12.2 \ No newline at end of file