diff --git a/src/main/java/de/ellpeck/naturesaura/api/recipes/ing/AmountIngredient.java b/src/main/java/de/ellpeck/naturesaura/api/recipes/ing/AmountIngredient.java index 32315f87..625f404b 100644 --- a/src/main/java/de/ellpeck/naturesaura/api/recipes/ing/AmountIngredient.java +++ b/src/main/java/de/ellpeck/naturesaura/api/recipes/ing/AmountIngredient.java @@ -8,6 +8,7 @@ public class AmountIngredient extends Ingredient { public final Ingredient delegate; public final int amount; + private ItemStack[] matchingStacks; public AmountIngredient(Ingredient delegate, int amount) { super(0); @@ -21,7 +22,16 @@ public class AmountIngredient extends Ingredient { @Override public ItemStack[] getMatchingStacks() { - return this.delegate.getMatchingStacks(); + if (this.matchingStacks == null) { + ItemStack[] delegate = this.delegate.getMatchingStacks(); + this.matchingStacks = new ItemStack[delegate.length]; + for (int i = 0; i < delegate.length; i++) { + ItemStack copy = delegate[i].copy(); + copy.setCount(this.amount); + this.matchingStacks[i] = copy; + } + } + return this.matchingStacks; } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityOfferingTable.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityOfferingTable.java index a477bc7f..57782782 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityOfferingTable.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityOfferingTable.java @@ -3,6 +3,8 @@ package de.ellpeck.naturesaura.blocks.tiles; import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.recipes.OfferingRecipe; import de.ellpeck.naturesaura.blocks.multi.Multiblocks; +import de.ellpeck.naturesaura.packet.PacketHandler; +import de.ellpeck.naturesaura.packet.PacketParticles; import net.minecraft.entity.effect.EntityLightningBolt; import net.minecraft.entity.item.EntityItem; import net.minecraft.item.ItemStack; @@ -20,7 +22,12 @@ import java.util.List; import java.util.Queue; public class TileEntityOfferingTable extends TileEntityImpl implements ITickable { - public final ItemStackHandler items = new ItemStackHandlerNA(1, this, true); + public final ItemStackHandler items = new ItemStackHandlerNA(1, this, true) { + @Override + public int getSlotLimit(int slot) { + return 16; + } + }; private final Queue itemsToSpawn = new ArrayDeque<>(); @Override @@ -62,15 +69,17 @@ public class TileEntityOfferingTable extends TileEntityImpl implements ITickable this.itemsToSpawn.add(recipe.output.copy()); this.world.addWeatherEffect(new EntityLightningBolt(this.world, this.pos.getX(), this.pos.getY(), this.pos.getZ(), true)); + PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles( + (float) item.posX, (float) item.posY, (float) item.posZ, 13, + this.pos.getX(), this.pos.getY(), this.pos.getZ())); + break; } } else if (this.world.getTotalWorldTime() % 3 == 0) { if (!this.itemsToSpawn.isEmpty()) this.world.spawnEntity(new EntityItem( this.world, - this.pos.getX() + 0.5F + this.world.rand.nextGaussian() * 3F, - 256, - this.pos.getZ() + 0.5F + this.world.rand.nextGaussian() * 3F, + this.pos.getX() + 0.5F, 256, this.pos.getZ() + 0.5F, this.itemsToSpawn.remove())); } } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/render/RenderOfferingTable.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/render/RenderOfferingTable.java index 8bfd6437..814e37ce 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/render/RenderOfferingTable.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/render/RenderOfferingTable.java @@ -22,7 +22,7 @@ public class RenderOfferingTable extends TileEntitySpecialRenderer { + + private final IDrawable background; + + public OfferingCategory(IGuiHelper helper) { + this.background = helper.createDrawable(new ResourceLocation(NaturesAura.MOD_ID, "textures/gui/jei/offering.png"), 0, 0, 87, 36); + } + + @Override + public String getUid() { + return JEINaturesAuraPlugin.OFFERING; + } + + @Override + public String getTitle() { + return I18n.format("container." + JEINaturesAuraPlugin.OFFERING + ".name"); + } + + @Override + public String getModName() { + return NaturesAura.MOD_NAME; + } + + @Override + public IDrawable getBackground() { + return this.background; + } + + @Override + public void setRecipe(IRecipeLayout recipeLayout, OfferingWrapper recipeWrapper, IIngredients ingredients) { + IGuiItemStackGroup group = recipeLayout.getItemStacks(); + OfferingRecipe recipe = recipeWrapper.recipe; + group.init(0, true, 0, 14); + group.set(0, Arrays.asList(recipe.input.getMatchingStacks())); + group.init(1, false, 65, 14); + group.set(1, recipe.output); + group.init(2, true, 27, 0); + group.set(2, Arrays.asList(recipe.startItem.getMatchingStacks())); + } +} diff --git a/src/main/java/de/ellpeck/naturesaura/compat/jei/offering/OfferingWrapper.java b/src/main/java/de/ellpeck/naturesaura/compat/jei/offering/OfferingWrapper.java new file mode 100644 index 00000000..9b4d30c6 --- /dev/null +++ b/src/main/java/de/ellpeck/naturesaura/compat/jei/offering/OfferingWrapper.java @@ -0,0 +1,25 @@ +package de.ellpeck.naturesaura.compat.jei.offering; + +import com.google.common.collect.ImmutableList; +import de.ellpeck.naturesaura.api.recipes.OfferingRecipe; +import mezz.jei.api.ingredients.IIngredients; +import mezz.jei.api.ingredients.VanillaTypes; +import mezz.jei.api.recipe.IRecipeWrapper; +import net.minecraft.item.ItemStack; + +public class OfferingWrapper implements IRecipeWrapper { + + public final OfferingRecipe recipe; + + public OfferingWrapper(OfferingRecipe recipe) { + this.recipe = recipe; + } + + @Override + public void getIngredients(IIngredients ingredients) { + ingredients.setInputs(VanillaTypes.ITEM, ImmutableList.builder() + .add(this.recipe.input.getMatchingStacks()) + .add(this.recipe.startItem.getMatchingStacks()).build()); + ingredients.setOutput(VanillaTypes.ITEM, this.recipe.output); + } +} diff --git a/src/main/java/de/ellpeck/naturesaura/items/ModItems.java b/src/main/java/de/ellpeck/naturesaura/items/ModItems.java index 17125894..32000e4c 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/ModItems.java +++ b/src/main/java/de/ellpeck/naturesaura/items/ModItems.java @@ -29,4 +29,6 @@ public final class ModItems { public static final Item BOTTLE_TWO = new ItemImpl("bottle_two_the_rebottling"); public static final Item AURA_BOTTLE = new ItemAuraBottle(); public static final Item FARMING_STENCIL = new ItemImpl("farming_stencil"); + public static final Item SKY_INGOT = new ItemImpl("sky_ingot"); + public static final Item CALLING_SPIRIT = new ItemImpl("calling_spirit"); } diff --git a/src/main/java/de/ellpeck/naturesaura/packet/PacketParticles.java b/src/main/java/de/ellpeck/naturesaura/packet/PacketParticles.java index 14b84f20..b5de7429 100644 --- a/src/main/java/de/ellpeck/naturesaura/packet/PacketParticles.java +++ b/src/main/java/de/ellpeck/naturesaura/packet/PacketParticles.java @@ -232,6 +232,28 @@ public class PacketParticles implements IMessage { world.rand.nextFloat() * 0.04F + 0.04F, world.rand.nextGaussian() * 0.03F, 0x5ccc30, 1F + world.rand.nextFloat() * 1.5F, 60, 0F, false, true); + break; + case 13: // Offering table + int genX = message.data[0]; + int genY = message.data[1]; + int genZ = message.data[2]; + for (int i = world.rand.nextInt(20) + 10; i >= 0; i--) + NaturesAuraAPI.instance().spawnMagicParticle( + message.posX, message.posY + 0.5F, message.posZ, + world.rand.nextGaussian() * 0.02F, + world.rand.nextFloat() * 0.25F, + world.rand.nextGaussian() * 0.02F, + 0xffadfd, 1.5F, 40, 0F, false, true); + for (int i = world.rand.nextInt(50) + 30; i >= 0; i--) + NaturesAuraAPI.instance().spawnMagicParticle( + genX + 0.5F + world.rand.nextGaussian() * 2.5F, + genY + 0.1F, + genZ + 0.5F + world.rand.nextGaussian() * 2.5F, + world.rand.nextGaussian() * 0.01F, + world.rand.nextFloat() * 0.01F, + world.rand.nextGaussian() * 0.01F, + 0xd3e4ff, 1.5F, 150, 0F, false, true); + break; } } }); diff --git a/src/main/java/de/ellpeck/naturesaura/recipes/ModRecipes.java b/src/main/java/de/ellpeck/naturesaura/recipes/ModRecipes.java index 2c50e4a8..34fe06d7 100644 --- a/src/main/java/de/ellpeck/naturesaura/recipes/ModRecipes.java +++ b/src/main/java/de/ellpeck/naturesaura/recipes/ModRecipes.java @@ -83,10 +83,10 @@ public final class ModRecipes { Ingredient.fromItem(Items.ROTTEN_FLESH), new ItemStack(Items.LEATHER), Helper.blockIng(ModBlocks.CONVERSION_CATALYST), 400, 50).register(); - new OfferingRecipe(new ResourceLocation(NaturesAura.MOD_ID, "test"), + new OfferingRecipe(new ResourceLocation(NaturesAura.MOD_ID, "sky_ingot"), new AmountIngredient(new ItemStack(ModItems.INFUSED_IRON, 3)), - Ingredient.fromItem(Items.DIAMOND), - new ItemStack(Blocks.DIRT)).register(); + Ingredient.fromItem(ModItems.CALLING_SPIRIT), + new ItemStack(ModItems.SKY_INGOT)).register(); NaturesAuraAPI.BOTANIST_PICKAXE_CONVERSIONS.put( Blocks.COBBLESTONE.getDefaultState(), diff --git a/src/main/resources/assets/naturesaura/lang/en_US.lang b/src/main/resources/assets/naturesaura/lang/en_US.lang index bab03d5d..06d0128d 100644 --- a/src/main/resources/assets/naturesaura/lang/en_US.lang +++ b/src/main/resources/assets/naturesaura/lang/en_US.lang @@ -54,9 +54,12 @@ item.naturesaura.aura_bottle.naturesaura:end.name=Bottled Darkness item.naturesaura.aura_bottle.naturesaura:other.name=Bottled Substance item.naturesaura.farming_stencil.name=Farming Stencil item.naturesaura.bottle_two_the_rebottling.name=Bottle and Cork +item.naturesaura.sky_ingot.name=Ingot of the Skies +item.naturesaura.calling_spirit.name=Spirit of Calling container.naturesaura.tree_ritual.name=Ritual of the Forest container.naturesaura.altar.name=Natural Altar Infusion +container.naturesaura.offering.name=Offering to the Gods info.naturesaura.aura_in_area=Aura Around info.naturesaura.book.landing=$(aura) is a complicated matter, and creating, collecting and making use of it can be difficult.$(br)The $(item)Book of Natural Aura$() contains all the information one requires to do so. diff --git a/src/main/resources/assets/naturesaura/models/item/calling_spirit.json b/src/main/resources/assets/naturesaura/models/item/calling_spirit.json new file mode 100644 index 00000000..85d8bda1 --- /dev/null +++ b/src/main/resources/assets/naturesaura/models/item/calling_spirit.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "naturesaura:items/calling_spirit" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/naturesaura/models/item/sky_ingot.json b/src/main/resources/assets/naturesaura/models/item/sky_ingot.json new file mode 100644 index 00000000..6d3d3f36 --- /dev/null +++ b/src/main/resources/assets/naturesaura/models/item/sky_ingot.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "naturesaura:items/sky_ingot" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/naturesaura/textures/gui/jei/offering.png b/src/main/resources/assets/naturesaura/textures/gui/jei/offering.png new file mode 100644 index 00000000..5668e12d Binary files /dev/null and b/src/main/resources/assets/naturesaura/textures/gui/jei/offering.png differ diff --git a/src/main/resources/assets/naturesaura/textures/items/calling_spirit.png b/src/main/resources/assets/naturesaura/textures/items/calling_spirit.png new file mode 100644 index 00000000..6ff6529a Binary files /dev/null and b/src/main/resources/assets/naturesaura/textures/items/calling_spirit.png differ diff --git a/src/main/resources/assets/naturesaura/textures/items/sky_ingot.png b/src/main/resources/assets/naturesaura/textures/items/sky_ingot.png new file mode 100644 index 00000000..16beb8d8 Binary files /dev/null and b/src/main/resources/assets/naturesaura/textures/items/sky_ingot.png differ