finished the offering table

This commit is contained in:
Ellpeck 2018-11-21 01:05:50 +01:00
parent caf4fe9b1e
commit ab2b8612cd
15 changed files with 159 additions and 12 deletions

View file

@ -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

View file

@ -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<ItemStack> 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()));
}
}

View file

@ -22,7 +22,7 @@ public class RenderOfferingTable extends TileEntitySpecialRenderer<TileEntityOff
if (!stack.isEmpty()) {
this.rand.setSeed(Item.getIdFromItem(stack.getItem()) + stack.getMetadata());
int amount = MathHelper.ceil(stack.getCount() / 8F);
int amount = MathHelper.ceil(stack.getCount() / 2F);
for (int i = 0; i < amount; i++) {
GlStateManager.pushMatrix();
Item item = stack.getItem();

View file

@ -2,13 +2,16 @@ package de.ellpeck.naturesaura.compat.jei;
import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.api.recipes.AltarRecipe;
import de.ellpeck.naturesaura.api.recipes.OfferingRecipe;
import de.ellpeck.naturesaura.api.recipes.TreeRitualRecipe;
import de.ellpeck.naturesaura.blocks.ModBlocks;
import de.ellpeck.naturesaura.compat.jei.altar.AltarCategory;
import de.ellpeck.naturesaura.compat.jei.altar.AltarWrapper;
import de.ellpeck.naturesaura.compat.jei.offering.OfferingCategory;
import de.ellpeck.naturesaura.compat.jei.offering.OfferingWrapper;
import de.ellpeck.naturesaura.compat.jei.treeritual.TreeRitualCategory;
import de.ellpeck.naturesaura.compat.jei.treeritual.TreeRitualWrapper;
import de.ellpeck.naturesaura.api.recipes.AltarRecipe;
import de.ellpeck.naturesaura.api.recipes.TreeRitualRecipe;
import mezz.jei.api.IGuiHelper;
import mezz.jei.api.IModPlugin;
import mezz.jei.api.IModRegistry;
@ -21,13 +24,15 @@ public class JEINaturesAuraPlugin implements IModPlugin {
public static final String TREE_RITUAL = NaturesAura.MOD_ID + ".tree_ritual";
public static final String ALTAR = NaturesAura.MOD_ID + ".altar";
public static final String OFFERING = NaturesAura.MOD_ID + ".offering";
@Override
public void registerCategories(IRecipeCategoryRegistration registry) {
IGuiHelper helper = registry.getJeiHelpers().getGuiHelper();
registry.addRecipeCategories(
new TreeRitualCategory(helper),
new AltarCategory(helper)
new AltarCategory(helper),
new OfferingCategory(helper)
);
}
@ -35,13 +40,16 @@ public class JEINaturesAuraPlugin implements IModPlugin {
public void register(IModRegistry registry) {
registry.handleRecipes(TreeRitualRecipe.class, TreeRitualWrapper::new, TREE_RITUAL);
registry.handleRecipes(AltarRecipe.class, AltarWrapper::new, ALTAR);
registry.handleRecipes(OfferingRecipe.class, OfferingWrapper::new, OFFERING);
registry.addRecipes(NaturesAuraAPI.TREE_RITUAL_RECIPES.values(), TREE_RITUAL);
registry.addRecipes(NaturesAuraAPI.ALTAR_RECIPES.values(), ALTAR);
registry.addRecipes(NaturesAuraAPI.OFFERING_RECIPES.values(), OFFERING);
registry.addRecipeCatalyst(new ItemStack(ModBlocks.GOLD_POWDER), TREE_RITUAL);
registry.addRecipeCatalyst(new ItemStack(ModBlocks.WOOD_STAND), TREE_RITUAL);
registry.addRecipeCatalyst(new ItemStack(ModBlocks.NATURE_ALTAR), ALTAR);
registry.addRecipeCatalyst(new ItemStack(ModBlocks.CONVERSION_CATALYST), ALTAR);
registry.addRecipeCatalyst(new ItemStack(ModBlocks.OFFERING_TABLE), OFFERING);
}
}

View file

@ -0,0 +1,56 @@
package de.ellpeck.naturesaura.compat.jei.offering;
import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.api.recipes.OfferingRecipe;
import de.ellpeck.naturesaura.compat.jei.JEINaturesAuraPlugin;
import mezz.jei.api.IGuiHelper;
import mezz.jei.api.gui.IDrawable;
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 net.minecraft.client.resources.I18n;
import net.minecraft.util.ResourceLocation;
import java.util.Arrays;
public class OfferingCategory implements IRecipeCategory<OfferingWrapper> {
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()));
}
}

View file

@ -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.<ItemStack>builder()
.add(this.recipe.input.getMatchingStacks())
.add(this.recipe.startItem.getMatchingStacks()).build());
ingredients.setOutput(VanillaTypes.ITEM, this.recipe.output);
}
}

View file

@ -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");
}

View file

@ -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;
}
}
});

View file

@ -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(),

View file

@ -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.

View file

@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "naturesaura:items/calling_spirit"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "naturesaura:items/sky_ingot"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 607 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 491 B