implement the aura bottle into the progression

This commit is contained in:
Ellpeck 2018-11-08 18:03:58 +01:00
parent b20c1be95f
commit 8e9979b192
22 changed files with 142 additions and 26 deletions

View file

@ -80,15 +80,21 @@ public final class Helper {
return ((a & 255) << 24) | ((r & 255) << 16) | ((g & 255) << 8) | (b & 255); return ((a & 255) << 24) | ((r & 255) << 16) | ((g & 255) << 8) | (b & 255);
} }
public static int getItemIndex(List<ItemStack> list, ItemStack item) { public static int getItemIndex(List<ItemStack> list, ItemStack item, boolean nbt) {
for (int i = 0; i < list.size(); i++) { for (int i = 0; i < list.size(); i++) {
if (list.get(i).isItemEqual(item)) { if (areItemsEqual(list.get(i), item, nbt)) {
return i; return i;
} }
} }
return -1; return -1;
} }
public static boolean areItemsEqual(ItemStack first, ItemStack second, boolean nbt) {
if (!ItemStack.areItemsEqual(first, second))
return false;
return !nbt || ItemStack.areItemStackShareTagsEqual(first, second);
}
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public static void renderItemInWorld(ItemStack stack) { public static void renderItemInWorld(ItemStack stack) {
if (!stack.isEmpty()) { if (!stack.isEmpty()) {

View file

@ -1,5 +1,6 @@
package de.ellpeck.naturesaura.blocks.tiles; package de.ellpeck.naturesaura.blocks.tiles;
import de.ellpeck.naturesaura.Helper;
import de.ellpeck.naturesaura.aura.chunk.AuraChunk; import de.ellpeck.naturesaura.aura.chunk.AuraChunk;
import de.ellpeck.naturesaura.packet.PacketHandler; import de.ellpeck.naturesaura.packet.PacketHandler;
import de.ellpeck.naturesaura.packet.PacketParticleStream; import de.ellpeck.naturesaura.packet.PacketParticleStream;
@ -69,7 +70,8 @@ public class TileEntityFurnaceHeater extends TileEntityImpl implements ITickable
return false; return false;
ItemStack currOutput = furnace.getStackInSlot(2); ItemStack currOutput = furnace.getStackInSlot(2);
return currOutput.isEmpty() || output.isItemEqual(currOutput) && currOutput.getCount() + output.getCount() <= output.getMaxStackSize(); return currOutput.isEmpty() ||
Helper.areItemsEqual(currOutput, output, true) && currOutput.getCount() + output.getCount() <= output.getMaxStackSize();
} else } else
return false; return false;
} }

View file

@ -1,5 +1,6 @@
package de.ellpeck.naturesaura.blocks.tiles; package de.ellpeck.naturesaura.blocks.tiles;
import de.ellpeck.naturesaura.Helper;
import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.aura.AuraType; import de.ellpeck.naturesaura.aura.AuraType;
import de.ellpeck.naturesaura.aura.Capabilities; import de.ellpeck.naturesaura.aura.Capabilities;
@ -111,7 +112,7 @@ public class TileEntityNatureAltar extends TileEntityImpl implements ITickable {
this.currentRecipe = AltarRecipe.forInput(stack); this.currentRecipe = AltarRecipe.forInput(stack);
} }
} else { } else {
if (stack.isEmpty() || !stack.isItemEqual(this.currentRecipe.input)) { if (stack.isEmpty() || !Helper.areItemsEqual(stack, this.currentRecipe.input, true)) {
this.currentRecipe = null; this.currentRecipe = null;
this.timer = 0; this.timer = 0;
} else if (this.hasCatalyst(this.currentRecipe.catalyst)) { } else if (this.hasCatalyst(this.currentRecipe.catalyst)) {

View file

@ -90,7 +90,7 @@ public class TileEntityPlacer extends TileEntityImpl implements ITickable {
for (EntityItemFrame frame : frames) { for (EntityItemFrame frame : frames) {
ItemStack frameStack = frame.getDisplayedItem(); ItemStack frameStack = frame.getDisplayedItem();
if (!frameStack.isEmpty() && stack.isItemEqual(frameStack)) if (!frameStack.isEmpty() && Helper.areItemsEqual(stack, frameStack, false))
return true; return true;
} }
return false; return false;

View file

@ -151,7 +151,7 @@ public class TileEntityWoodStand extends TileEntityImpl implements ITickable {
if (tile instanceof TileEntityWoodStand) { if (tile instanceof TileEntityWoodStand) {
ItemStack stack = ((TileEntityWoodStand) tile).items.getStackInSlot(0); ItemStack stack = ((TileEntityWoodStand) tile).items.getStackInSlot(0);
if (!stack.isEmpty()) { if (!stack.isEmpty()) {
int index = Helper.getItemIndex(required, stack); int index = Helper.getItemIndex(required, stack, true);
if (index >= 0) { if (index >= 0) {
required.remove(index); required.remove(index);
} else { } else {

View file

@ -29,7 +29,7 @@ public class TerrainGenEvents {
ItemStack saplingStack = sapling.getBlock().getItem(world, pos, sapling); ItemStack saplingStack = sapling.getBlock().getItem(world, pos, sapling);
if (!saplingStack.isEmpty()) { if (!saplingStack.isEmpty()) {
for (TreeRitualRecipe recipe : TreeRitualRecipe.RECIPES.values()) { for (TreeRitualRecipe recipe : TreeRitualRecipe.RECIPES.values()) {
if (recipe.saplingType.isItemEqual(saplingStack)) { if (Helper.areItemsEqual(saplingStack, recipe.saplingType, true)) {
List<ItemStack> required = new ArrayList<>(Arrays.asList(recipe.items)); List<ItemStack> required = new ArrayList<>(Arrays.asList(recipe.items));
MutableObject<TileEntityWoodStand> toPick = new MutableObject<>(); MutableObject<TileEntityWoodStand> toPick = new MutableObject<>();
@ -39,7 +39,7 @@ public class TerrainGenEvents {
TileEntityWoodStand stand = (TileEntityWoodStand) tile; TileEntityWoodStand stand = (TileEntityWoodStand) tile;
ItemStack stack = stand.items.getStackInSlot(0); ItemStack stack = stand.items.getStackInSlot(0);
if (!stack.isEmpty()) { if (!stack.isEmpty()) {
int index = Helper.getItemIndex(required, stack); int index = Helper.getItemIndex(required, stack, true);
if (index >= 0) { if (index >= 0) {
required.remove(index); required.remove(index);

View file

@ -48,7 +48,7 @@ public class ItemAuraBottle extends ItemImpl {
setType(new ItemStack(this), AuraType.forWorld(player.world))); setType(new ItemStack(this), AuraType.forWorld(player.world)));
BlockPos spot = AuraChunk.getHighestSpot(player.world, pos, 30, pos); BlockPos spot = AuraChunk.getHighestSpot(player.world, pos, 30, pos);
AuraChunk.getAuraChunk(player.world, spot).drainAura(spot, 500); AuraChunk.getAuraChunk(player.world, spot).drainAura(spot, 200);
player.world.playSound(null, player.posX, player.posY, player.posZ, player.world.playSound(null, player.posX, player.posY, player.posZ,
SoundEvents.ITEM_BOTTLE_FILL_DRAGONBREATH, SoundCategory.PLAYERS, 1F, 1F); SoundEvents.ITEM_BOTTLE_FILL_DRAGONBREATH, SoundCategory.PLAYERS, 1F, 1F);
@ -76,6 +76,8 @@ public class ItemAuraBottle extends ItemImpl {
if (!stack.hasTagCompound()) if (!stack.hasTagCompound())
return AuraType.OTHER; return AuraType.OTHER;
String type = stack.getTagCompound().getString("type"); String type = stack.getTagCompound().getString("type");
if (type.isEmpty())
return AuraType.OTHER;
return AuraType.valueOf(type); return AuraType.valueOf(type);
} }

View file

@ -1,5 +1,6 @@
package de.ellpeck.naturesaura.recipes; package de.ellpeck.naturesaura.recipes;
import de.ellpeck.naturesaura.Helper;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
@ -31,7 +32,7 @@ public class AltarRecipe {
public static AltarRecipe forInput(ItemStack input) { public static AltarRecipe forInput(ItemStack input) {
for (AltarRecipe recipe : RECIPES.values()) { for (AltarRecipe recipe : RECIPES.values()) {
if (recipe.input.isItemEqual(input)) { if (Helper.areItemsEqual(recipe.input, input, true)) {
return recipe; return recipe;
} }
} }

View file

@ -1,7 +1,9 @@
package de.ellpeck.naturesaura.recipes; package de.ellpeck.naturesaura.recipes;
import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.aura.AuraType;
import de.ellpeck.naturesaura.blocks.ModBlocks; import de.ellpeck.naturesaura.blocks.ModBlocks;
import de.ellpeck.naturesaura.items.ItemAuraBottle;
import de.ellpeck.naturesaura.items.ModItems; import de.ellpeck.naturesaura.items.ModItems;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.init.Items; import net.minecraft.init.Items;
@ -23,7 +25,8 @@ public final class ModRecipes {
new ItemStack(Blocks.STONE), new ItemStack(Blocks.STONE),
new ItemStack(Blocks.STONE), new ItemStack(Blocks.STONE),
new ItemStack(ModItems.GOLD_LEAF), new ItemStack(ModItems.GOLD_LEAF),
new ItemStack(Items.GOLD_INGOT)); new ItemStack(Items.GOLD_INGOT),
ItemAuraBottle.setType(new ItemStack(ModItems.AURA_BOTTLE), AuraType.OVERWORLD));
new TreeRitualRecipe(new ResourceLocation(NaturesAura.MOD_ID, "ancient_sapling"), new TreeRitualRecipe(new ResourceLocation(NaturesAura.MOD_ID, "ancient_sapling"),
new ItemStack(Blocks.SAPLING), new ItemStack(ModBlocks.ANCIENT_SAPLING), 200, new ItemStack(Blocks.SAPLING), new ItemStack(ModBlocks.ANCIENT_SAPLING), 200,
new ItemStack(Blocks.SAPLING), new ItemStack(Blocks.SAPLING),
@ -40,7 +43,8 @@ public final class ModRecipes {
new ItemStack(ModItems.INFUSED_IRON), new ItemStack(ModItems.INFUSED_IRON),
new ItemStack(Items.FIRE_CHARGE), new ItemStack(Items.FIRE_CHARGE),
new ItemStack(Items.FLINT), new ItemStack(Items.FLINT),
new ItemStack(Blocks.MAGMA)); new ItemStack(Blocks.MAGMA),
ItemAuraBottle.setType(new ItemStack(ModItems.AURA_BOTTLE), AuraType.NETHER));
new TreeRitualRecipe(new ResourceLocation(NaturesAura.MOD_ID, "conversion_catalyst"), new TreeRitualRecipe(new ResourceLocation(NaturesAura.MOD_ID, "conversion_catalyst"),
new ItemStack(Blocks.SAPLING, 1, 3), new ItemStack(ModBlocks.CONVERSION_CATALYST), 600, new ItemStack(Blocks.SAPLING, 1, 3), new ItemStack(ModBlocks.CONVERSION_CATALYST), 600,
new ItemStack(Blocks.STONEBRICK, 1, 1), new ItemStack(Blocks.STONEBRICK, 1, 1),
@ -58,8 +62,8 @@ public final class ModRecipes {
null, 150, 40); null, 150, 40);
new AltarRecipe(new ResourceLocation(NaturesAura.MOD_ID, "chorus"), new AltarRecipe(new ResourceLocation(NaturesAura.MOD_ID, "chorus"),
new ItemStack(Blocks.CHORUS_FLOWER), new ItemStack(Items.DRAGON_BREATH), ItemAuraBottle.setType(new ItemStack(ModItems.AURA_BOTTLE), AuraType.END), new ItemStack(Items.DRAGON_BREATH),
ModBlocks.CONVERSION_CATALYST, 1000, 120); ModBlocks.CONVERSION_CATALYST, 350, 80);
new AltarRecipe(new ResourceLocation(NaturesAura.MOD_ID, "leather"), new AltarRecipe(new ResourceLocation(NaturesAura.MOD_ID, "leather"),
new ItemStack(Items.ROTTEN_FLESH), new ItemStack(Items.LEATHER), new ItemStack(Items.ROTTEN_FLESH), new ItemStack(Items.LEATHER),
ModBlocks.CONVERSION_CATALYST, 400, 50); ModBlocks.CONVERSION_CATALYST, 400, 50);

View file

@ -10,7 +10,7 @@
"translate": "advancement.naturesaura.altar.desc" "translate": "advancement.naturesaura.altar.desc"
} }
}, },
"parent": "naturesaura:wood_stand", "parent": "naturesaura:aura_bottle_overworld",
"criteria": { "criteria": {
"book": { "book": {
"trigger": "minecraft:inventory_changed", "trigger": "minecraft:inventory_changed",

View file

@ -0,0 +1,28 @@
{
"display": {
"icon": {
"item": "naturesaura:aura_bottle",
"nbt": "{\"type\":\"END\"}"
},
"title": {
"translate": "advancement.naturesaura.aura_bottle_end"
},
"description": {
"translate": "advancement.naturesaura.aura_bottle_end.desc"
}
},
"parent": "naturesaura:wood_stand",
"criteria": {
"bottle": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{
"item": "naturesaura:aura_bottle",
"nbt": "{\"type\":\"END\"}"
}
]
}
}
}
}

View file

@ -0,0 +1,28 @@
{
"display": {
"icon": {
"item": "naturesaura:aura_bottle",
"nbt": "{\"type\":\"NETHER\"}"
},
"title": {
"translate": "advancement.naturesaura.aura_bottle_nether"
},
"description": {
"translate": "advancement.naturesaura.aura_bottle_nether.desc"
}
},
"parent": "naturesaura:wood_stand",
"criteria": {
"bottle": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{
"item": "naturesaura:aura_bottle",
"nbt": "{\"type\":\"NETHER\"}"
}
]
}
}
}
}

View file

@ -0,0 +1,28 @@
{
"display": {
"icon": {
"item": "naturesaura:aura_bottle",
"nbt": "{\"type\":\"OVERWORLD\"}"
},
"title": {
"translate": "advancement.naturesaura.aura_bottle_overworld"
},
"description": {
"translate": "advancement.naturesaura.aura_bottle_overworld.desc"
}
},
"parent": "naturesaura:wood_stand",
"criteria": {
"bottle": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{
"item": "naturesaura:aura_bottle",
"nbt": "{\"type\":\"OVERWORLD\"}"
}
]
}
}
}
}

View file

@ -18,9 +18,6 @@
"items": [ "items": [
{ {
"item": "naturesaura:infused_iron" "item": "naturesaura:infused_iron"
},
{
"item": "naturesaura:infused_stone"
} }
] ]
} }

View file

@ -10,7 +10,7 @@
"translate": "advancement.naturesaura.potion_generator.desc" "translate": "advancement.naturesaura.potion_generator.desc"
} }
}, },
"parent": "naturesaura:flower_generator", "parent": "naturesaura:aura_bottle_nether",
"criteria": { "criteria": {
"generator": { "generator": {
"trigger": "minecraft:inventory_changed", "trigger": "minecraft:inventory_changed",

View file

@ -19,7 +19,8 @@
"conditions": { "conditions": {
"items": [ "items": [
{ {
"item": "patchouli:guide_book" "item": "patchouli:guide_book",
"nbt": "{\"patchouli:book\":\"naturesaura:book\"}"
} }
] ]
} }

View file

@ -67,7 +67,7 @@ advancement.naturesaura.wood_stand.desc=Create a Wooden Stand for the Ritual of
advancement.naturesaura.altar=Empowered advancement.naturesaura.altar=Empowered
advancement.naturesaura.altar.desc=Create a Natural Altar using the Ritual of the Forest advancement.naturesaura.altar.desc=Create a Natural Altar using the Ritual of the Forest
advancement.naturesaura.infused_materials=Iron Factory advancement.naturesaura.infused_materials=Iron Factory
advancement.naturesaura.infused_materials.desc=Use the Natural Altar to create Infused Iron and Infused Rock advancement.naturesaura.infused_materials.desc=Use the Natural Altar to create Infused Iron
advancement.naturesaura.furnace_heater=Cozy Warmth advancement.naturesaura.furnace_heater=Cozy Warmth
advancement.naturesaura.furnace_heater.desc=Create an Extraneous Firestarter to heat your furnace advancement.naturesaura.furnace_heater.desc=Create an Extraneous Firestarter to heat your furnace
advancement.naturesaura.potion_generator=Lurking Powers advancement.naturesaura.potion_generator=Lurking Powers
@ -80,5 +80,11 @@ advancement.naturesaura.conversion_catalyst=Not so Equivalent Exchange
advancement.naturesaura.conversion_catalyst.desc=Create a Conversion Catalyst for easy material conversion advancement.naturesaura.conversion_catalyst.desc=Create a Conversion Catalyst for easy material conversion
advancement.naturesaura.infused_tools=Gear Up Intensifies advancement.naturesaura.infused_tools=Gear Up Intensifies
advancement.naturesaura.infused_tools.desc=Create an Infused Iron Pickaxe and Blade advancement.naturesaura.infused_tools.desc=Create an Infused Iron Pickaxe and Blade
advancement.naturesaura.aura_bottle_overworld=A taste of Sunlight
advancement.naturesaura.aura_bottle_overworld.desc=Collect Aura using a Bottle in the Overworld
advancement.naturesaura.aura_bottle_nether=Spooky Scary Skeletons
advancement.naturesaura.aura_bottle_nether.desc=Collect Aura using a Bottle in the Nether
advancement.naturesaura.aura_bottle_end=Breathy Surroundings
advancement.naturesaura.aura_bottle_end.desc=Collect Aura using a Bottle in the End
command.naturesaura.aura.usage=/naaura <action> <amount> <range> command.naturesaura.aura.usage=/naaura <action> <amount> <range>

View file

@ -2,7 +2,7 @@
"name": "The Natural Altar", "name": "The Natural Altar",
"icon": "naturesaura:nature_altar", "icon": "naturesaura:nature_altar",
"category": "collecting", "category": "collecting",
"advancement": "naturesaura:wood_stand", "advancement": "naturesaura:aura_bottle_overworld",
"priority": true, "priority": true,
"pages": [ "pages": [
{ {

View file

@ -2,7 +2,7 @@
"name": "Aura Bottling", "name": "Aura Bottling",
"icon": "naturesaura:aura_bottle{type:'OVERWORLD'}", "icon": "naturesaura:aura_bottle{type:'OVERWORLD'}",
"category": "collecting", "category": "collecting",
"advancement": "naturesaura:gold_leaf", "advancement": "naturesaura:wood_stand",
"pages": [ "pages": [
{ {
"type": "text", "type": "text",
@ -11,6 +11,7 @@
{ {
"type": "spotlight", "type": "spotlight",
"item": "naturesaura:aura_bottle{type:'OVERWORLD'}", "item": "naturesaura:aura_bottle{type:'OVERWORLD'}",
"link_recipe": true,
"text": "Of course, based on the world that you are currently in, the type of $(aura) collected will slightly vary. For instance, in the normal world, $(aura) can be gathered in the form of sunlight, while in the Nether realm, $(aura) can be gathered in the form of ghosts." "text": "Of course, based on the world that you are currently in, the type of $(aura) collected will slightly vary. For instance, in the normal world, $(aura) can be gathered in the form of sunlight, while in the Nether realm, $(aura) can be gathered in the form of ghosts."
} }
] ]

View file

@ -2,7 +2,7 @@
"name": "Ritual of the Brewer", "name": "Ritual of the Brewer",
"icon": "naturesaura:potion_generator", "icon": "naturesaura:potion_generator",
"category": "creating", "category": "creating",
"advancement": "naturesaura:flower_generator", "advancement": "naturesaura:aura_bottle_nether",
"pages": [ "pages": [
{ {
"type": "text", "type": "text",

View file

@ -1,7 +1,7 @@
{ {
"type": "forge:ore_shaped", "type": "forge:ore_shaped",
"pattern": [ "pattern": [
"PIP", "PBP",
"IFI", "IFI",
"PIP" "PIP"
], ],
@ -16,6 +16,13 @@
"F": { "F": {
"item": "minecraft:double_plant", "item": "minecraft:double_plant",
"data": 5 "data": 5
},
"B": {
"type": "minecraft:item_nbt",
"item": "naturesaura:aura_bottle",
"nbt": {
"type": "OVERWORLD"
}
} }
}, },
"result": { "result": {

View file

@ -16,7 +16,11 @@
"item": "naturesaura:infused_iron" "item": "naturesaura:infused_iron"
}, },
"W": { "W": {
"item": "minecraft:nether_wart" "type": "minecraft:item_nbt",
"item": "naturesaura:aura_bottle",
"nbt": {
"type": "NETHER"
}
} }
}, },
"result": { "result": {