From 162b02d82dcb38ef2e9189cd07e9e95540317346 Mon Sep 17 00:00:00 2001 From: alcatrazEscapee Date: Fri, 21 Sep 2018 23:32:40 -0400 Subject: [PATCH] Fire pit works (just) Lots of tweaks and fixes here and there: biome registry no longer gives type warnings; opening a gui now should make use of an enum; trees now have heat + burn time values. Added stick heat capability for stick -> torch recipe. Also added Firepit recipe manager (for future recipe madness) Signed-off-by: alcatrazEscapee --- .../net/dries007/tfc/CommonEventHandler.java | 6 +- .../net/dries007/tfc/TerraFirmaCraft.java | 4 + .../api/capability/ItemStickCapability.java | 96 ++++++++++ .../capability/heat/CapabilityItemHeat.java | 32 +++- .../tfc/api/capability/heat/IItemHeat.java | 21 ++- .../api/capability/heat/ItemHeatHandler.java | 16 +- .../java/net/dries007/tfc/api/types/Tree.java | 39 ++++- .../dries007/tfc/client/TFCGuiHandler.java | 11 +- .../tfc/objects/blocks/BlockFirePit.java | 18 +- .../tfc/objects/blocks/BlocksTFC.java | 2 + .../tfc/objects/blocks/wood/BlockLogTFC.java | 8 +- .../objects/inventory/ItemStackHandlerTE.java | 1 - .../dries007/tfc/objects/items/ItemDebug.java | 17 ++ .../tfc/objects/items/ItemFireStarter.java | 62 +++++-- .../tfc/objects/items/ItemGoldPan.java | 3 +- .../dries007/tfc/objects/items/ItemMisc.java | 15 +- .../dries007/tfc/objects/items/ItemsTFC.java | 4 +- .../tfc/objects/items/ceramics/ItemMold.java | 13 ++ .../items/ceramics/ItemSmallVessel.java | 11 +- .../recipes/firepit/FirePitRecipe.java | 44 +++++ .../recipes/firepit/FirePitRecipeManager.java | 48 +++++ .../dries007/tfc/objects/te/TEFirePit.java | 164 +++++++++++++++++- .../net/dries007/tfc/types/DefaultTrees.java | 39 +++-- .../java/net/dries007/tfc/util/Helpers.java | 1 + .../tfc/util/OreDictionaryHelper.java | 3 +- .../tfc/world/classic/biomes/BiomesTFC.java | 38 ++-- .../world/classic/worldgen/WorldGenTrees.java | 3 +- src/main/resources/assets/tfc/lang/en_us.lang | 3 + 28 files changed, 630 insertions(+), 92 deletions(-) create mode 100644 src/main/java/net/dries007/tfc/api/capability/ItemStickCapability.java create mode 100644 src/main/java/net/dries007/tfc/objects/recipes/firepit/FirePitRecipe.java create mode 100644 src/main/java/net/dries007/tfc/objects/recipes/firepit/FirePitRecipeManager.java diff --git a/src/main/java/net/dries007/tfc/CommonEventHandler.java b/src/main/java/net/dries007/tfc/CommonEventHandler.java index 2a87551880..b1c365c413 100644 --- a/src/main/java/net/dries007/tfc/CommonEventHandler.java +++ b/src/main/java/net/dries007/tfc/CommonEventHandler.java @@ -1,6 +1,7 @@ /* * Work under Copyright. Licensed under the EUPL. * See the project README.md and LICENSE.txt for more information. + * */ package net.dries007.tfc; @@ -24,6 +25,7 @@ import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.dries007.tfc.api.capability.ItemStickCapability; import net.dries007.tfc.api.capability.size.CapabilityItemSize; import net.dries007.tfc.api.capability.size.Size; import net.dries007.tfc.api.capability.size.Weight; @@ -57,7 +59,7 @@ public void onBlockHarvestDrops(BlockEvent.HarvestDropsEvent event) double chance = ConfigTFC.GENERAL.leafStickDropChance; if (!heldItem.isEmpty() && Helpers.containsAnyOfCaseInsensitive(heldItem.getItem().getToolClasses(heldItem), ConfigTFC.GENERAL.leafStickDropChanceBonusClasses)) chance = ConfigTFC.GENERAL.leafStickDropChanceBonus; - if (event.getWorld().rand.nextFloat() < chance) + if (Constants.RNG.nextFloat() < chance) event.getDrops().add(new ItemStack(Items.STICK)); } } @@ -234,7 +236,7 @@ public void attachItemCapabilities(AttachCapabilitiesEvent e) if (item == Items.COAL) CapabilityItemSize.add(e, Items.COAL, Size.SMALL, Weight.MEDIUM, canStack); else if (item == Items.STICK) - CapabilityItemSize.add(e, Items.STICK, Size.SMALL, Weight.LIGHT, canStack); + e.addCapability(ItemStickCapability.KEY, new ItemStickCapability(e.getObject().getTagCompound())); // Final checks for general item types else if (item instanceof ItemTool) diff --git a/src/main/java/net/dries007/tfc/TerraFirmaCraft.java b/src/main/java/net/dries007/tfc/TerraFirmaCraft.java index d9d9f47b6b..0896e805c3 100644 --- a/src/main/java/net/dries007/tfc/TerraFirmaCraft.java +++ b/src/main/java/net/dries007/tfc/TerraFirmaCraft.java @@ -1,6 +1,7 @@ /* * Work under Copyright. Licensed under the EUPL. * See the project README.md and LICENSE.txt for more information. + * */ package net.dries007.tfc; @@ -26,6 +27,7 @@ import net.dries007.tfc.cmd.TreeGenCommand; import net.dries007.tfc.objects.entity.EntitiesTFC; import net.dries007.tfc.objects.items.ItemsTFC; +import net.dries007.tfc.objects.recipes.firepit.FirePitRecipeManager; import net.dries007.tfc.util.OreDictionaryHelper; import net.dries007.tfc.util.OreSpawnData; import net.dries007.tfc.world.classic.CalenderTFC; @@ -155,6 +157,8 @@ public void postInit(FMLPostInitializationEvent event) if (!isSignedBuild) log.warn("You are not running an official build. Please do not use this and then report bugs or issues."); + FirePitRecipeManager.postInit(); + OreSpawnData.reloadOreGen(); } diff --git a/src/main/java/net/dries007/tfc/api/capability/ItemStickCapability.java b/src/main/java/net/dries007/tfc/api/capability/ItemStickCapability.java new file mode 100644 index 0000000000..7519090573 --- /dev/null +++ b/src/main/java/net/dries007/tfc/api/capability/ItemStickCapability.java @@ -0,0 +1,96 @@ +/* + * Work under Copyright. Licensed under the EUPL. + * See the project README.md and LICENSE.txt for more information. + * + */ + +package net.dries007.tfc.api.capability; + +import java.util.List; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +import net.minecraft.client.resources.I18n; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.common.capabilities.Capability; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +import net.dries007.tfc.api.capability.heat.CapabilityItemHeat; +import net.dries007.tfc.api.capability.heat.ItemHeatHandler; +import net.dries007.tfc.api.capability.size.CapabilityItemSize; +import net.dries007.tfc.api.capability.size.IItemSize; +import net.dries007.tfc.api.capability.size.Size; +import net.dries007.tfc.api.capability.size.Weight; + +import static net.dries007.tfc.api.util.TFCConstants.MOD_ID; + +public class ItemStickCapability extends ItemHeatHandler implements IItemSize +{ + public static final ResourceLocation KEY = new ResourceLocation(MOD_ID, "stick"); + private static final float MELTING_POINT = 80f; + private static final float HEAT_CAPACITY = 1f; + + public ItemStickCapability(@Nullable NBTTagCompound nbt) + { + //todo: check values + super(nbt, HEAT_CAPACITY, MELTING_POINT); + if (nbt != null) + deserializeNBT(nbt); + } + + @Override + public Size getSize(@Nonnull ItemStack stack) + { + return Size.SMALL; + } + + @Override + public Weight getWeight(@Nonnull ItemStack stack) + { + return Weight.LIGHT; + } + + @Override + public float getHeatCapacity() + { + return HEAT_CAPACITY; + } + + @Override + public float getMeltingPoint() + { + return MELTING_POINT; + } + + @Override + public boolean hasCapability(@Nonnull Capability capability, @Nullable EnumFacing facing) + { + return capability == CapabilityItemHeat.ITEM_HEAT_CAPABILITY || capability == CapabilityItemSize.ITEM_SIZE_CAPABILITY; + } + + @Nullable + @Override + @SuppressWarnings("unchecked") + public T getCapability(@Nonnull Capability capability, @Nullable EnumFacing facing) + { + return hasCapability(capability, facing) ? (T) this : null; + } + + @SideOnly(Side.CLIENT) + @Override + public void addHeatInfo(ItemStack stack, List text, boolean clearStackNBT) + { + float temperature = getTemperature(); + if (temperature > MELTING_POINT * 0.9f) + text.add(I18n.format("tfc.enum.heat.torch.lit")); + else if (temperature > 1f) + text.add(I18n.format("tfc.enum.heat.torch.catchingFire")); + + if (clearStackNBT && temperature <= 0 && stack.hasTagCompound()) + stack.setTagCompound(null); + } +} diff --git a/src/main/java/net/dries007/tfc/api/capability/heat/CapabilityItemHeat.java b/src/main/java/net/dries007/tfc/api/capability/heat/CapabilityItemHeat.java index 0ca900e89e..bb8d90f2d7 100644 --- a/src/main/java/net/dries007/tfc/api/capability/heat/CapabilityItemHeat.java +++ b/src/main/java/net/dries007/tfc/api/capability/heat/CapabilityItemHeat.java @@ -1,12 +1,14 @@ /* * Work under Copyright. Licensed under the EUPL. * See the project README.md and LICENSE.txt for more information. + * */ package net.dries007.tfc.api.capability.heat; import javax.annotation.Nonnull; +import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumFacing; @@ -26,12 +28,40 @@ public static void preInit() CapabilityManager.INSTANCE.register(IItemHeat.class, new ItemHeatStorage(), ItemHeatHandler::new); } + /** + * Call this from within IItemHeat#getTemperature(); + */ public static float adjustTemp(float temp, float heatCapacity, long ticksSinceUpdate) { - float newTemp = temp - heatCapacity * (float) ticksSinceUpdate * (float) ConfigTFC.GENERAL.temperatureModifier; + final float newTemp = temp - heatCapacity * (float) ticksSinceUpdate * (float) ConfigTFC.GENERAL.temperatureModifier; return newTemp < 0 ? 0 : newTemp; } + /** + * Use this to increase the heat on an item stack + */ + public static void addTemp(ItemStack stack, float modifier) + { + final IItemHeat cap = stack.getCapability(ITEM_HEAT_CAPABILITY, null); + if (cap != null) + { + addTemp(cap, modifier); + stack.setTagCompound(cap.serializeNBT()); + } + } + + /** + * Use this to increase the heat on an IItemHeat instance. + * Note: to save the change you will need to still call stack.setTagCompound(cap.serializeNBT()); + * + * @param modifier the modifier for how much this will heat up: 0 - 1 slows down cooling, 1 = no heating or cooling, > 1 heats, 2 heats at the same rate it cools + */ + public static void addTemp(IItemHeat instance, float modifier) + { + final float temp = instance.getTemperature() + modifier * instance.getHeatCapacity() * (float) ConfigTFC.GENERAL.temperatureModifier; + instance.setTemperature(temp > 1600f ? 1600f : temp); + } + public static class ItemHeatStorage implements Capability.IStorage { @Nonnull diff --git a/src/main/java/net/dries007/tfc/api/capability/heat/IItemHeat.java b/src/main/java/net/dries007/tfc/api/capability/heat/IItemHeat.java index 2ffc480833..d8346b42d7 100644 --- a/src/main/java/net/dries007/tfc/api/capability/heat/IItemHeat.java +++ b/src/main/java/net/dries007/tfc/api/capability/heat/IItemHeat.java @@ -1,6 +1,7 @@ /* * Work under Copyright. Licensed under the EUPL. * See the project README.md and LICENSE.txt for more information. + * */ package net.dries007.tfc.api.capability.heat; @@ -25,11 +26,26 @@ public interface IItemHeat extends INBTSerializable { /** * Gets the current temperature. Should call CapabilityItemHeat.adjustTemp() internally - * * @return the temperature. Between 0 - 1600 */ float getTemperature(); + /** + * Gets the Heat capacity. (A measure of how fast this items heats up or cools down) + * Implementation is left up to the heating object. (See TEFirePit for example) + * + * @return a value between 0 and 1 + */ + float getHeatCapacity(); + + /** + * Gets the melting point of the item. + * Depending on the item, this may not mean anything. + * + * @return a temperature between 0 - 1600 that is the melting point + */ + float getMeltingPoint(); + /** * Sets the temperature. Used for anything that modifies the temperature. * @param temperature the temperature to set. Between 0 - 1600 @@ -39,12 +55,11 @@ public interface IItemHeat extends INBTSerializable /** * If the object can melt / transform, return if it is transformed * This can mean many different things depending on the object - * * @return is the object transformed. */ default boolean isMolten() { - return false; + return getTemperature() > getMeltingPoint(); } /** diff --git a/src/main/java/net/dries007/tfc/api/capability/heat/ItemHeatHandler.java b/src/main/java/net/dries007/tfc/api/capability/heat/ItemHeatHandler.java index 50e8c2b9b5..49b5d66f73 100644 --- a/src/main/java/net/dries007/tfc/api/capability/heat/ItemHeatHandler.java +++ b/src/main/java/net/dries007/tfc/api/capability/heat/ItemHeatHandler.java @@ -1,6 +1,7 @@ /* * Work under Copyright. Licensed under the EUPL. * See the project README.md and LICENSE.txt for more information. + * */ package net.dries007.tfc.api.capability.heat; @@ -19,8 +20,6 @@ * This is an implementation of ItemHeat that automatically cools down over time * Prefer extending or using this than implementing IItemHeat directly * Exceptions if you want to extend another capability object (see SmallVessel) but you should still implement this functionality somewhere - * - * todo: make this into an interface with defaults? */ public class ItemHeatHandler implements ICapabilitySerializable, IItemHeat { @@ -66,6 +65,19 @@ public void setTemperature(float temperature) this.lastUpdateTick = CalenderTFC.getTotalTime(); } + @Override + public float getHeatCapacity() + { + return heatCapacity; + } + + @Override + public float getMeltingPoint() + { + return meltingPoint; + } + + // Override for that 0.00001% efficiency @Override public boolean isMolten() { diff --git a/src/main/java/net/dries007/tfc/api/types/Tree.java b/src/main/java/net/dries007/tfc/api/types/Tree.java index 929fac7626..4a8b01b322 100644 --- a/src/main/java/net/dries007/tfc/api/types/Tree.java +++ b/src/main/java/net/dries007/tfc/api/types/Tree.java @@ -1,6 +1,7 @@ /* * Work under Copyright. Licensed under the EUPL. * See the project README.md and LICENSE.txt for more information. + * */ package net.dries007.tfc.api.types; @@ -32,6 +33,8 @@ public class Tree extends IForgeRegistryEntry.Impl private final float maxRain; private final float minDensity; private final float maxDensity; + private final float burnTemp; + private final int burnTicks; // Used when growing a tree private final ITreeGenerator gen; @@ -58,13 +61,15 @@ public class Tree extends IForgeRegistryEntry.Impl * @param maxGrowthRadius used to check growth conditions * @param maxHeight used to check growth conditions * @param maxDecayDistance maximum decay distance for leaves - * @param isConifer todo + * @param isConifer todo: make this do something * @param hasBushes will the tree generate small bushes * @param minGrowthTime the amount of time (in in-game days) that this tree requires to grow + * @param burnTemp the temperature at which this will burn in a fire pit or similar + * @param burnTicks the number of ticks that this will burn in a fire pit or similar */ public Tree(@Nonnull ResourceLocation name, @Nonnull ITreeGenerator gen, float minTemp, float maxTemp, float minRain, float maxRain, float minDensity, float maxDensity, float dominance, - int maxGrowthRadius, int maxHeight, int maxDecayDistance, boolean isConifer, boolean hasBushes, float minGrowthTime) + int maxGrowthRadius, int maxHeight, int maxDecayDistance, boolean isConifer, boolean hasBushes, float minGrowthTime, float burnTemp, int burnTicks) { this.minTemp = minTemp; this.maxTemp = maxTemp; @@ -79,6 +84,8 @@ public Tree(@Nonnull ResourceLocation name, @Nonnull ITreeGenerator gen, this.minDensity = minDensity; this.maxDensity = maxDensity; this.hasBushes = hasBushes; + this.burnTemp = burnTemp; + this.burnTicks = burnTicks; this.gen = gen; setRegistryName(name); @@ -86,12 +93,12 @@ public Tree(@Nonnull ResourceLocation name, @Nonnull ITreeGenerator gen, public void makeTreeWithoutChecking(TemplateManager manager, World world, BlockPos pos, Random rand) { - getGen().generateTree(manager, world, pos, this, rand); + gen.generateTree(manager, world, pos, this, rand); } public void makeTree(TemplateManager manager, World world, BlockPos pos, Random rand) { - if (getGen().canGenerateTree(world, pos, this)) + if (gen.canGenerateTree(world, pos, this)) makeTreeWithoutChecking(manager, world, pos, rand); } @@ -132,7 +139,7 @@ public boolean isConifer() return isConifer; } - public boolean isHasBushes() + public boolean hasBushes() { return hasBushes; } @@ -142,9 +149,14 @@ public float getMinGrowthTime() return minGrowthTime; } - public ITreeGenerator getGen() + public float getBurnTemp() { - return gen; + return burnTemp; + } + + public int getBurnTicks() + { + return burnTicks; } @Override @@ -168,6 +180,8 @@ public static class Builder private boolean isConifer; private boolean canMakeBushes; private float minGrowthTime; + private float burnTemp; + private int burnTicks; private ITreeGenerator gen; private ResourceLocation name; @@ -188,6 +202,8 @@ public Builder(@Nonnull ResourceLocation name, float minRain, float maxRain, flo this.minGrowthTime = 7; this.minDensity = 0.1f; this.maxDensity = 2f; + this.burnTemp = 675; + this.burnTicks = 1500; } public Builder setRadius(int maxGrowthRadius) @@ -239,9 +255,16 @@ public Builder setDominance(float dom) return this; } + public Builder setBurnInfo(float burnTemp, int burnTicks) + { + this.burnTemp = burnTemp; + this.burnTicks = burnTicks; + return this; + } + public Tree build() { - return new Tree(name, gen, minTemp, maxTemp, minRain, maxRain, minDensity, maxDensity, dominance, maxGrowthRadius, maxHeight, maxDecayDistance, isConifer, canMakeBushes, minGrowthTime); + return new Tree(name, gen, minTemp, maxTemp, minRain, maxRain, minDensity, maxDensity, dominance, maxGrowthRadius, maxHeight, maxDecayDistance, isConifer, canMakeBushes, minGrowthTime, burnTemp, burnTicks); } } } diff --git a/src/main/java/net/dries007/tfc/client/TFCGuiHandler.java b/src/main/java/net/dries007/tfc/client/TFCGuiHandler.java index b1a1474cce..c7c3eafe8f 100644 --- a/src/main/java/net/dries007/tfc/client/TFCGuiHandler.java +++ b/src/main/java/net/dries007/tfc/client/TFCGuiHandler.java @@ -1,10 +1,12 @@ /* * Work under Copyright. Licensed under the EUPL. * See the project README.md and LICENSE.txt for more information. + * */ package net.dries007.tfc.client; +import javax.annotation.Nonnull; import javax.annotation.Nullable; import net.minecraft.entity.player.EntityPlayer; @@ -55,7 +57,6 @@ public Container getServerGuiElement(int ID, EntityPlayer player, World world, i BlockPos pos = new BlockPos(x, y, z); ItemStack stack = player.getHeldItemMainhand(); Type type = Type.valueOf(ID); - if (type == null) return null; switch (type) { case LOG_PILE: @@ -82,7 +83,6 @@ public Object getClientGuiElement(int ID, EntityPlayer player, World world, int { Container container = getServerGuiElement(ID, player, world, x, y, z); Type type = Type.valueOf(ID); - if (type == null) return null; switch (type) { case LOG_PILE: @@ -106,14 +106,15 @@ public enum Type SMALL_VESSEL, SMALL_VESSEL_LIQUID, MOLD, - FIRE_PIT; + FIRE_PIT, + NULL; private static Type[] values = values(); - @Nullable + @Nonnull private static Type valueOf(int id) { - return id < 0 || id >= values.length ? null : values[id]; + return id < 0 || id >= values.length ? NULL : values[id]; } } } diff --git a/src/main/java/net/dries007/tfc/objects/blocks/BlockFirePit.java b/src/main/java/net/dries007/tfc/objects/blocks/BlockFirePit.java index 6e1b46801a..b1ab5fda66 100644 --- a/src/main/java/net/dries007/tfc/objects/blocks/BlockFirePit.java +++ b/src/main/java/net/dries007/tfc/objects/blocks/BlockFirePit.java @@ -1,6 +1,7 @@ /* * Work under Copyright. Licensed under the EUPL. * See the project README.md and LICENSE.txt for more information. + * */ package net.dries007.tfc.objects.blocks; @@ -157,14 +158,15 @@ public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, { if (!worldIn.isRemote) { - ItemStack held = player.getHeldItem(hand); - if (state.getValue(LIT)) //todo: remove debug feature - worldIn.setBlockState(pos, state.withProperty(LIT, false)); - - if (ItemFireStarter.canIgnite(held)) - worldIn.setBlockState(pos, state.withProperty(LIT, true)); - - if (!player.isSneaking()) + if (player.isSneaking()) + { + ItemStack held = player.getHeldItem(hand); + if (ItemFireStarter.canIgnite(held)) + { + worldIn.setBlockState(pos, state.withProperty(LIT, true)); + } + } + else { TFCGuiHandler.openGui(worldIn, pos, player, TFCGuiHandler.Type.FIRE_PIT); } diff --git a/src/main/java/net/dries007/tfc/objects/blocks/BlocksTFC.java b/src/main/java/net/dries007/tfc/objects/blocks/BlocksTFC.java index d88d1c0bd9..fc22439ce4 100644 --- a/src/main/java/net/dries007/tfc/objects/blocks/BlocksTFC.java +++ b/src/main/java/net/dries007/tfc/objects/blocks/BlocksTFC.java @@ -1,6 +1,7 @@ /* * Work under Copyright. Licensed under the EUPL. * See the project README.md and LICENSE.txt for more information. + * */ package net.dries007.tfc.objects.blocks; @@ -104,6 +105,7 @@ public final class BlocksTFC public static final BlockCharcoalPile CHARCOAL_PILE = null; public static final BlockLogPile LOG_PILE = null; public static final BlockIngotPile INGOT_PILE = null; + public static final BlockTorchTFC TORCH = null; // All these are for use in model registration. Do not use for block lookups. // Use the static get methods in the classes instead. diff --git a/src/main/java/net/dries007/tfc/objects/blocks/wood/BlockLogTFC.java b/src/main/java/net/dries007/tfc/objects/blocks/wood/BlockLogTFC.java index 7b4b3e77e7..9f549254cd 100644 --- a/src/main/java/net/dries007/tfc/objects/blocks/wood/BlockLogTFC.java +++ b/src/main/java/net/dries007/tfc/objects/blocks/wood/BlockLogTFC.java @@ -1,6 +1,7 @@ /* * Work under Copyright. Licensed under the EUPL. * See the project README.md and LICENSE.txt for more information. + * */ package net.dries007.tfc.objects.blocks.wood; @@ -51,7 +52,7 @@ public static BlockLogTFC get(Tree wood) return MAP.get(wood); } - public final Tree wood; + private final Tree wood; public BlockLogTFC(Tree wood) { @@ -169,6 +170,11 @@ public int getMetaFromState(IBlockState state) return state.getValue(LOG_AXIS).ordinal() | (state.getValue(PLACED) ? 0b100 : 0) | (state.getValue(SMALL) ? 0b1000 : 0); } + public Tree getWood() + { + return wood; + } + @Override protected BlockStateContainer createBlockState() { diff --git a/src/main/java/net/dries007/tfc/objects/inventory/ItemStackHandlerTE.java b/src/main/java/net/dries007/tfc/objects/inventory/ItemStackHandlerTE.java index b27b65b51e..0ec41b9bb8 100644 --- a/src/main/java/net/dries007/tfc/objects/inventory/ItemStackHandlerTE.java +++ b/src/main/java/net/dries007/tfc/objects/inventory/ItemStackHandlerTE.java @@ -17,7 +17,6 @@ public class ItemStackHandlerTE extends ItemStackHandler public ItemStackHandlerTE(TESidedInventory tile, int size) { super(size); - this.tile = tile; } diff --git a/src/main/java/net/dries007/tfc/objects/items/ItemDebug.java b/src/main/java/net/dries007/tfc/objects/items/ItemDebug.java index 62b9fcf9be..905727b770 100644 --- a/src/main/java/net/dries007/tfc/objects/items/ItemDebug.java +++ b/src/main/java/net/dries007/tfc/objects/items/ItemDebug.java @@ -1,6 +1,7 @@ /* * Work under Copyright. Licensed under the EUPL. * See the project README.md and LICENSE.txt for more information. + * */ package net.dries007.tfc.objects.items; @@ -13,10 +14,15 @@ import net.minecraft.item.EnumRarity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumActionResult; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import mcp.MethodsReturnNonnullByDefault; +import net.dries007.tfc.objects.te.TEFirePit; +import net.dries007.tfc.util.Helpers; @MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault @@ -70,4 +76,15 @@ public boolean canDestroyBlockInCreative(World world, BlockPos pos, ItemStack st { return false; } + + @Override + public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) + { + TEFirePit te = Helpers.getTE(worldIn, pos, TEFirePit.class); + if (te != null) + { + te.debug(); + } + return EnumActionResult.SUCCESS; + } } diff --git a/src/main/java/net/dries007/tfc/objects/items/ItemFireStarter.java b/src/main/java/net/dries007/tfc/objects/items/ItemFireStarter.java index 2e9c56bdda..80f3c8828c 100644 --- a/src/main/java/net/dries007/tfc/objects/items/ItemFireStarter.java +++ b/src/main/java/net/dries007/tfc/objects/items/ItemFireStarter.java @@ -1,10 +1,12 @@ /* * Work under Copyright. Licensed under the EUPL. * See the project README.md and LICENSE.txt for more information. + * */ package net.dries007.tfc.objects.items; +import java.util.ArrayList; import java.util.List; import java.util.function.Predicate; import javax.annotation.Nullable; @@ -32,6 +34,7 @@ import net.dries007.tfc.api.capability.size.Size; import net.dries007.tfc.api.capability.size.Weight; import net.dries007.tfc.objects.blocks.BlocksTFC; +import net.dries007.tfc.objects.te.TEFirePit; import net.dries007.tfc.objects.te.TELogPile; import net.dries007.tfc.objects.te.TEPitKiln; import net.dries007.tfc.util.Helpers; @@ -51,6 +54,7 @@ public static boolean canIgnite(ItemStack stack) { if (stack.isEmpty()) return false; Item item = stack.getItem(); + //noinspection ConstantConditions return item == ItemsTFC.FIRESTARTER || item == Items.FLINT_AND_STEEL || item == Items.FIRE_CHARGE || item instanceof ItemFlintAndSteel; } @@ -102,13 +106,13 @@ public void onUsingTick(ItemStack stack, EntityLivingBase entityLivingBase, int final int count = total - countLeft; final BlockPos pos = result.getBlockPos().add(0, 1, 0); final World world = player.world; - final float chance = world.rand.nextFloat(); // todo: raining etc? + final float chance = itemRand.nextFloat(); // todo: raining etc? if (world.isRemote) // Client { - if (chance > 0.7 && world.rand.nextFloat() < count / (double) total) + if (chance > 0.7 && itemRand.nextFloat() < count / (double) total) world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, result.hitVec.x, result.hitVec.y, result.hitVec.z, 0.0F, 0.1F, 0.0F); - if (chance > 0.7 && countLeft < 10 && world.rand.nextFloat() < count / (double) total) + if (chance > 0.7 && countLeft < 10 && itemRand.nextFloat() < count / (double) total) world.spawnParticle(EnumParticleTypes.FLAME, result.hitVec.x, result.hitVec.y, result.hitVec.z, 0.0F, 0.0F, 0.0F); } else if (countLeft == 1) // Server, and last tick of use @@ -137,21 +141,55 @@ else if (state.getBlock() == BlocksTFC.PIT_KILN) } else { - // Fire pit + // Try fire pit stack.damageItem(1, player); - final List list = world.getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(pos.getX(), pos.getY(), pos.getZ(), pos.getX() + 1, pos.getY() + 0.5, pos.getZ() + 1), i -> IS_KINDLING.test(i) || IS_STICK.test(i)); + final List items = world.getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(pos, pos.add(1, 2, 1))); + final List stuffToUse = new ArrayList<>(); - int sticks = list.stream().filter(IS_STICK).mapToInt(e -> e.getItem().getCount()).sum(); - int kindling = list.stream().filter(IS_KINDLING).mapToInt(e -> e.getItem().getCount()).sum(); + int sticks = 3, kindling = 1; + EntityItem log = null; - if (sticks < 3) return; + for (EntityItem entity : items) + { + if (Helpers.doesStackMatchOre(entity.getItem(), "stickWood")) + { + sticks -= entity.getItem().getCount(); + stuffToUse.add(entity); + } + else if (Helpers.doesStackMatchOre(entity.getItem(), "kindling")) + { + kindling -= entity.getItem().getCount(); + stuffToUse.add(entity); + } + else if (log == null && Helpers.doesStackMatchOre(entity.getItem(), "logWood")) + { + log = entity; + } + } - if (world.rand.nextFloat() < chance + Math.min(kindling * 0.1, 0.5)) + if (sticks <= 0 && kindling <= 0 && log != null) + { + final float kindlingModifier = Math.min(-0.1f * (float) kindling, 0.5f); + if (itemRand.nextFloat() < chance + kindlingModifier) + { + //noinspection ConstantConditions + world.setBlockState(pos, BlocksTFC.FIREPIT.getDefaultState().withProperty(LIT, true)); + TEFirePit te = Helpers.getTE(world, pos, TEFirePit.class); + if (te != null) + { + te.onCreate(log.getItem()); + } + stuffToUse.forEach(Entity::setDead); + log.getItem().shrink(1); + if (log.getItem().getCount() == 0) + log.setDead(); + } + } + else { - //noinspection ConstantConditions - world.setBlockState(pos, BlocksTFC.FIREPIT.getDefaultState().withProperty(LIT, true), 11); //todo: fire - list.forEach(Entity::setDead); + // Else, start a fire + // todo: start a fire } } } diff --git a/src/main/java/net/dries007/tfc/objects/items/ItemGoldPan.java b/src/main/java/net/dries007/tfc/objects/items/ItemGoldPan.java index f2707cb394..208c8dab29 100644 --- a/src/main/java/net/dries007/tfc/objects/items/ItemGoldPan.java +++ b/src/main/java/net/dries007/tfc/objects/items/ItemGoldPan.java @@ -1,6 +1,7 @@ /* * Work under Copyright. Licensed under the EUPL. * See the project README.md and LICENSE.txt for more information. + * */ package net.dries007.tfc.objects.items; @@ -95,7 +96,7 @@ public void onUsingTick(ItemStack stack, EntityLivingBase entityLivingBase, int final int count = total - countLeft; final BlockPos pos = result.getBlockPos().add(0, 1, 0); final World world = player.world; - final float chance = world.rand.nextFloat(); + final float chance = itemRand.nextFloat(); //todo: this is a copypaste from firestarter, it needs to pan, not start fires. } diff --git a/src/main/java/net/dries007/tfc/objects/items/ItemMisc.java b/src/main/java/net/dries007/tfc/objects/items/ItemMisc.java index 12f5d31496..a8a396cd6a 100644 --- a/src/main/java/net/dries007/tfc/objects/items/ItemMisc.java +++ b/src/main/java/net/dries007/tfc/objects/items/ItemMisc.java @@ -13,15 +13,28 @@ import net.dries007.tfc.api.capability.size.IItemSize; import net.dries007.tfc.api.capability.size.Size; import net.dries007.tfc.api.capability.size.Weight; +import net.dries007.tfc.util.OreDictionaryHelper; public class ItemMisc extends ItemTFC implements IItemSize { private final Size size; private final Weight weight; + public ItemMisc(Size size, Weight weight, Object... oreNameParts) + { + this(size, weight); + + for (Object obj : oreNameParts) + { + if (obj instanceof Object[]) + OreDictionaryHelper.register(this, (Object[]) obj); + else + OreDictionaryHelper.register(this, obj); + } + } + public ItemMisc(Size size, Weight weight) { - super(); this.size = size; this.weight = weight; } diff --git a/src/main/java/net/dries007/tfc/objects/items/ItemsTFC.java b/src/main/java/net/dries007/tfc/objects/items/ItemsTFC.java index 9e6839bf70..ce6dac04dc 100644 --- a/src/main/java/net/dries007/tfc/objects/items/ItemsTFC.java +++ b/src/main/java/net/dries007/tfc/objects/items/ItemsTFC.java @@ -1,6 +1,7 @@ /* * Work under Copyright. Licensed under the EUPL. * See the project README.md and LICENSE.txt for more information. + * */ package net.dries007.tfc.objects.items; @@ -82,7 +83,6 @@ public static ImmutableList getAllGemItems() public static void registerItems(RegistryEvent.Register event) { IForgeRegistry r = event.getRegistry(); - Builder simpleItems = ImmutableList.builder(); simpleItems.add(register(r, "wand", new ItemDebug(), CT_MISC)); @@ -182,7 +182,7 @@ public static void registerItems(RegistryEvent.Register event) r.register(new ItemFlat().setRegistryName(MOD_ID, "flat/fire_clay")); simpleItems.add(register(r, "firestarter", new ItemFireStarter(), CT_MISC)); - simpleItems.add(register(r, "hay", new ItemMisc(Size.SMALL, Weight.LIGHT), CT_MISC)); + simpleItems.add(register(r, "hay", new ItemMisc(Size.SMALL, Weight.LIGHT, "kindling", "other", new String[] {"fancy", "kindling"}, new String[] {"extra", "fancy", "kindling"}), CT_MISC)); register(r, "goldpan", new ItemGoldPan(), CT_MISC); // todo: Bow? Arrows? diff --git a/src/main/java/net/dries007/tfc/objects/items/ceramics/ItemMold.java b/src/main/java/net/dries007/tfc/objects/items/ceramics/ItemMold.java index cab6474bcb..4e7940c47e 100644 --- a/src/main/java/net/dries007/tfc/objects/items/ceramics/ItemMold.java +++ b/src/main/java/net/dries007/tfc/objects/items/ceramics/ItemMold.java @@ -1,6 +1,7 @@ /* * Work under Copyright. Licensed under the EUPL. * See the project README.md and LICENSE.txt for more information. + * */ package net.dries007.tfc.objects.items.ceramics; @@ -224,6 +225,18 @@ public void addHeatInfo(ItemStack stack, List text, boolean clearStackNB IMoldHandler.super.addHeatInfo(stack, text, false); // Never clear the NBT based on heat alone } + @Override + public float getHeatCapacity() + { + return heatCapacity; + } + + @Override + public float getMeltingPoint() + { + return meltingPoint; + } + private void updateFluidData(FluidStack fluid) { if (fluid != null && fluid.getFluid() instanceof FluidMetal) diff --git a/src/main/java/net/dries007/tfc/objects/items/ceramics/ItemSmallVessel.java b/src/main/java/net/dries007/tfc/objects/items/ceramics/ItemSmallVessel.java index cdbe75cd3c..a06957d6be 100644 --- a/src/main/java/net/dries007/tfc/objects/items/ceramics/ItemSmallVessel.java +++ b/src/main/java/net/dries007/tfc/objects/items/ceramics/ItemSmallVessel.java @@ -1,6 +1,7 @@ /* * Work under Copyright. Licensed under the EUPL. * See the project README.md and LICENSE.txt for more information. + * */ package net.dries007.tfc.objects.items.ceramics; @@ -326,9 +327,15 @@ public void setTemperature(float temperature) } @Override - public boolean isMolten() + public float getHeatCapacity() { - return getTemperature() >= meltingPoint; + return heatCapacity; + } + + @Override + public float getMeltingPoint() + { + return meltingPoint; } @SideOnly(Side.CLIENT) diff --git a/src/main/java/net/dries007/tfc/objects/recipes/firepit/FirePitRecipe.java b/src/main/java/net/dries007/tfc/objects/recipes/firepit/FirePitRecipe.java new file mode 100644 index 0000000000..3b01687f3f --- /dev/null +++ b/src/main/java/net/dries007/tfc/objects/recipes/firepit/FirePitRecipe.java @@ -0,0 +1,44 @@ +/* + * Work under Copyright. Licensed under the EUPL. + * See the project README.md and LICENSE.txt for more information. + * + */ + +package net.dries007.tfc.objects.recipes.firepit; + +import net.minecraft.item.ItemStack; + +import net.dries007.tfc.api.capability.heat.CapabilityItemHeat; +import net.dries007.tfc.api.capability.heat.IItemHeat; + +public class FirePitRecipe +{ + private final ItemStack output; + + private ItemStack input; + + public FirePitRecipe(ItemStack input, ItemStack output) + { + IItemHeat cap = input.getCapability(CapabilityItemHeat.ITEM_HEAT_CAPABILITY, null); + if (cap == null) + throw new IllegalArgumentException("The input stack must implement IItemHeat capability for it to be used in a fire pit recipe!"); + + this.input = input; + this.output = output; + } + + public boolean matchesInput(ItemStack stack) + { + return stack.isItemEqual(input); + } + + public boolean matchesInput(FirePitRecipe recipeOther) + { + return matchesInput(recipeOther.input); + } + + public ItemStack getOutput() + { + return output.copy(); + } +} diff --git a/src/main/java/net/dries007/tfc/objects/recipes/firepit/FirePitRecipeManager.java b/src/main/java/net/dries007/tfc/objects/recipes/firepit/FirePitRecipeManager.java new file mode 100644 index 0000000000..a94686b1ee --- /dev/null +++ b/src/main/java/net/dries007/tfc/objects/recipes/firepit/FirePitRecipeManager.java @@ -0,0 +1,48 @@ +/* + * Work under Copyright. Licensed under the EUPL. + * See the project README.md and LICENSE.txt for more information. + * + */ + +package net.dries007.tfc.objects.recipes.firepit; + +import java.util.ArrayList; +import java.util.List; +import javax.annotation.Nullable; + +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; + +import net.dries007.tfc.objects.blocks.BlocksTFC; + +public class FirePitRecipeManager +{ + private static List recipes = new ArrayList<>(); + + @SuppressWarnings("ConstantConditions") + public static void postInit() + { + recipes.clear(); + + // todo: recipes here + recipes.add(new FirePitRecipe(new ItemStack(Items.STICK), new ItemStack(BlocksTFC.TORCH, 2))); + + // todo: craft tweaker supported recipes + } + + public static boolean add(FirePitRecipe recipe) + { + for (FirePitRecipe r : recipes) + if (r.matchesInput(recipe)) + return false; + + recipes.add(recipe); + return true; + } + + @Nullable + public static FirePitRecipe get(ItemStack stack) + { + return recipes.stream().filter(x -> x.matchesInput(stack)).findFirst().orElse(null); + } +} diff --git a/src/main/java/net/dries007/tfc/objects/te/TEFirePit.java b/src/main/java/net/dries007/tfc/objects/te/TEFirePit.java index c5893775e9..d75c61d40e 100644 --- a/src/main/java/net/dries007/tfc/objects/te/TEFirePit.java +++ b/src/main/java/net/dries007/tfc/objects/te/TEFirePit.java @@ -6,15 +6,25 @@ package net.dries007.tfc.objects.te; +import java.util.List; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; +import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.ITickable; +import net.minecraft.util.math.AxisAlignedBB; +import net.dries007.tfc.TerraFirmaCraft; import net.dries007.tfc.api.capability.heat.CapabilityItemHeat; +import net.dries007.tfc.api.capability.heat.IItemHeat; +import net.dries007.tfc.objects.blocks.wood.BlockLogTFC; +import net.dries007.tfc.objects.recipes.firepit.FirePitRecipe; +import net.dries007.tfc.objects.recipes.firepit.FirePitRecipeManager; import net.dries007.tfc.util.Helpers; import static net.dries007.tfc.objects.blocks.BlockFirePit.LIT; @@ -23,23 +33,59 @@ public class TEFirePit extends TESidedInventory implements ITickable { // To avoid "magic numbers" + public static final int SLOT_FUEL_CONSUME = 0; public static final int SLOT_FUEL_INPUT = 3; public static final int SLOT_ITEM_INPUT = 4; + public static final int SLOT_OUTPUT_1 = 5; + public static final int SLOT_OUTPUT_2 = 6; + + // todo: adjust this to change how fast firepit heats up items (item_heating_mod) or how fast it heats up (temperature_modifier) + private static final float TEMPERATURE_MODIFIER = 1f; + private static final float ITEM_HEATING_MODIFIER = 2f; + + public static int getFuelAmount(ItemStack stack) + { + // todo: make this a proper registry or lookup somewhere + if (stack.getItem() instanceof ItemBlock) + { + Block block = ((ItemBlock) stack.getItem()).getBlock(); + if (block instanceof BlockLogTFC) + { + return ((BlockLogTFC) block).getWood().getBurnTicks(); + } + } + return 0; + } + + public static float getFuelTemperature(ItemStack stack) + { + // todo: make this a proper registry or lookup somewhere + if (stack.getItem() instanceof ItemBlock) + { + Block block = ((ItemBlock) stack.getItem()).getBlock(); + if (block instanceof BlockLogTFC) + { + return ((BlockLogTFC) block).getWood().getBurnTemp(); + } + } + return 0f; + } private static boolean isStackFuel(ItemStack stack) { - return Helpers.doesStackMatchOre(stack, "logWood"); + return getFuelAmount(stack) != 0; } private static boolean isStackCookable(ItemStack stack) { - return stack.hasCapability(CapabilityItemHeat.ITEM_HEAT_CAPABILITY, null); // todo + return stack.hasCapability(CapabilityItemHeat.ITEM_HEAT_CAPABILITY, null); } private boolean requiresSlotUpdate = false; private float temperature; // Current Temperature private float burnTicks; // Ticks remaining on the current item of fuel private float burnTemperature; // Temperature provided from the current item of fuel + private int pickupTimer; public TEFirePit() { @@ -49,28 +95,102 @@ public TEFirePit() temperature = 0; burnTemperature = 0; burnTicks = 0; + pickupTimer = 0; } @Override public void update() { // do timer things + if (world.isRemote) return; IBlockState state = world.getBlockState(pos); - boolean burning = state.getValue(LIT); - if (burning) + if (state.getValue(LIT)) { + // Update fuel if (burnTicks > 0) { burnTicks--; - if (burnTicks == 0) + } + if (burnTicks == 0) + { + // Consume fuel + ItemStack stack = inventory.getStackInSlot(SLOT_FUEL_CONSUME); + if (stack.isEmpty()) { + world.setBlockState(pos, state.withProperty(LIT, false)); + burnTicks = 0; + burnTemperature = 0; } + else + { + inventory.setStackInSlot(SLOT_FUEL_CONSUME, ItemStack.EMPTY); + burnTicks += getFuelAmount(stack); + burnTemperature = getFuelTemperature(stack); + } + } + } + // Always update temperature / cooking, until the fire pit is not hot anymore + if (temperature > 0 || burnTemperature > 0) + { + // Update temperature + if (temperature < burnTemperature) + { + temperature += TEMPERATURE_MODIFIER; + } + else if (temperature > burnTemperature) + { + temperature -= TEMPERATURE_MODIFIER; + } + + // Update items in slots + // Loop through input + 2 output slots + for (int i = SLOT_ITEM_INPUT; i < SLOT_ITEM_INPUT + 3; i++) + { + ItemStack stack = inventory.getStackInSlot(i); + IItemHeat cap = stack.getCapability(CapabilityItemHeat.ITEM_HEAT_CAPABILITY, null); + if (cap != null) + { + float itemTemp = cap.getTemperature(); + if (temperature > itemTemp) + { + CapabilityItemHeat.addTemp(cap, ITEM_HEATING_MODIFIER); + stack.setTagCompound(cap.serializeNBT()); + } + + // For now only check the input slot + if (cap.isMolten() && i == SLOT_ITEM_INPUT) + { + // todo: This is the bit that needs to be more advanced than this + FirePitRecipe recipe = FirePitRecipeManager.get(stack); + if (recipe != null) + { + inventory.setStackInSlot(SLOT_ITEM_INPUT, Helpers.consumeItem(stack, 1)); + ItemStack outStack = recipe.getOutput(); + outStack = inventory.insertItem(SLOT_OUTPUT_1, outStack, false); + if (!outStack.isEmpty()) + { + inventory.insertItem(SLOT_OUTPUT_2, outStack, false); + } + } + } + } } } + // This is here to avoid duplication glitches if (requiresSlotUpdate) + { cascadeFuelSlots(); + } + + // Pick up fuel items in the world + pickupTimer--; + if (pickupTimer <= 0) + { + if (pickupItemsFromWorld()) + pickupTimer = 20; + } } @Override @@ -119,6 +239,12 @@ public NBTTagCompound writeToNBT(NBTTagCompound nbt) return super.writeToNBT(nbt); } + public void onCreate(ItemStack log) + { + burnTicks += getFuelAmount(log); + burnTemperature += getFuelTemperature(log); + } + private void cascadeFuelSlots() { // This will cascade all fuel down to the lowest available slot @@ -140,4 +266,32 @@ private void cascadeFuelSlots() requiresSlotUpdate = false; } + public void debug() + { + TerraFirmaCraft.getLog().debug("Debugging Fire pit:"); + TerraFirmaCraft.getLog().debug("Temp {} | Burn Temp {} | Fuel Ticks {}", temperature, burnTemperature, burnTicks); + TerraFirmaCraft.getLog().debug("Burning? {}", world.getBlockState(pos).getValue(LIT)); + } + + // Return false if it should not reset the count (AKA should it try and pick up next tick as well) + private boolean pickupItemsFromWorld() + { + final List items = world.getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(pos, pos.add(1, 1, 1))); + for (EntityItem entity : items) + { + if (isStackFuel(entity.getItem()) && inventory.getStackInSlot(SLOT_FUEL_INPUT).isEmpty()) + { + ItemStack toAdd = entity.getItem(); + toAdd.setCount(1); + ItemStack leftover = inventory.insertItem(SLOT_FUEL_INPUT, toAdd, false); + if (leftover.isEmpty()) + entity.setDead(); + else + entity.setItem(leftover); + return false; + } + } + return true; + } + } diff --git a/src/main/java/net/dries007/tfc/types/DefaultTrees.java b/src/main/java/net/dries007/tfc/types/DefaultTrees.java index 19a4f67307..a63de54e4b 100644 --- a/src/main/java/net/dries007/tfc/types/DefaultTrees.java +++ b/src/main/java/net/dries007/tfc/types/DefaultTrees.java @@ -1,6 +1,7 @@ /* * Work under Copyright. Licensed under the EUPL. * See the project README.md and LICENSE.txt for more information. + * */ package net.dries007.tfc.types; @@ -62,25 +63,25 @@ public class DefaultTrees public static void onPreRegisterRockCategory(TFCRegistryEvent.RegisterPreBlock event) { event.getRegistry().registerAll( - new Tree.Builder(ACACIA, 30f, 210f, 19f, 31f, GEN_ACACIA).setRadius(3).setGrowthTime(11).setDensity(0.1f, 0.6f).build(), - new Tree.Builder(ASH, 60f, 140f, -6f, 12f, GEN_NORMAL).build(), - new Tree.Builder(ASPEN, 10f, 80f, -10f, 16f, GEN_MEDIUM).setGrowthTime(8).build(), - new Tree.Builder(BIRCH, 20f, 180f, -15f, 7f, GEN_TALL).build(), - new Tree.Builder(BLACKWOOD, 0f, 120f, 4f, 33f, GEN_MEDIUM).setHeight(10).setGrowthTime(8).build(), - new Tree.Builder(CHESTNUT, 160f, 320f, 11f, 35f, GEN_NORMAL).setRadius(1).build(), - new Tree.Builder(DOUGLAS_FIR, 280f, 480f, -2f, 14f, GEN_TALL).setDominance(5.2f).setHeight(14).setBushes().setDensity(0.25f, 2f).build(), - new Tree.Builder(HICKORY, 80f, 250f, 7f, 29f, GEN_TALL).setGrowthTime(10).build(), - new Tree.Builder(MAPLE, 140f, 360f, 3f, 20f, GEN_MEDIUM).setDominance(6.3f).setRadius(1).build(), - new Tree.Builder(OAK, 180f, 430f, -8f, 12f, GEN_TALL).setHeight(14).setGrowthTime(10).build(), - new Tree.Builder(PALM, 280f, 500f, 16f, 35f, GEN_TROPICAL).setDecayDist(6).build(), - new Tree.Builder(PINE, 59f, 250f, -15f, 7f, GEN_CONIFER).setConifer().setDensity(0.1f, 0.8f).build(), - new Tree.Builder(ROSEWOOD, 10f, 190f, 8f, 18f, GEN_MEDIUM).setHeight(10).setGrowthTime(8).build(), - new Tree.Builder(SEQUOIA, 250f, 420f, -5f, 12f, GEN_SEQUOIA).setRadius(3).setHeight(24).setDecayDist(6).setGrowthTime(18).setConifer().setBushes().setDensity(0.4f, 0.9f).build(), - new Tree.Builder(SPRUCE, 120f, 380f, -11f, 6f, GEN_CONIFER).setConifer().setDensity(0.1f, 0.8f).build(), - new Tree.Builder(SYCAMORE, 120f, 290f, 17f, 33f, GEN_MEDIUM).setRadius(1).setGrowthTime(8).setBushes().setDensity(0.25f, 2f).build(), - new Tree.Builder(WHITE_CEDAR, 10f, 240f, -8f, 17f, GEN_TALL).setHeight(10).build(), - new Tree.Builder(WILLOW, 230f, 400f, 15f, 32f, GEN_WILLOW).setGrowthTime(11).setBushes().setDensity(0.7f, 2f).build(), - new Tree.Builder(KAPOK, 210f, 500f, 15f, 35f, GEN_KAPOK_COMPOSITE).setDominance(8.5f).setRadius(3).setHeight(24).setDecayDist(6).setGrowthTime(18).setBushes().setDensity(0.6f, 2f).build() + new Tree.Builder(ACACIA, 30f, 210f, 19f, 31f, GEN_ACACIA).setRadius(3).setHeight(12).setGrowthTime(11).setDensity(0.1f, 0.6f).setBurnInfo(650f, 1000).build(), + new Tree.Builder(ASH, 60f, 140f, -6f, 12f, GEN_NORMAL).setRadius(1).setBurnInfo(696f, 1250).build(), + new Tree.Builder(ASPEN, 10f, 80f, -10f, 16f, GEN_MEDIUM).setRadius(1).setGrowthTime(8).setBurnInfo(611f, 1000).build(), + new Tree.Builder(BIRCH, 20f, 180f, -15f, 7f, GEN_TALL).setBurnInfo(652f, 1750).build(), + new Tree.Builder(BLACKWOOD, 0f, 120f, 4f, 33f, GEN_MEDIUM).setHeight(12).setGrowthTime(8).setBurnInfo(720f, 1750).build(), + new Tree.Builder(CHESTNUT, 160f, 320f, 11f, 35f, GEN_NORMAL).setRadius(1).setBurnInfo(651f, 1500).build(), + new Tree.Builder(DOUGLAS_FIR, 280f, 480f, -2f, 14f, GEN_TALL).setDominance(5.2f).setHeight(16).setBushes().setDensity(0.25f, 2f).setBurnInfo(707f, 1500).build(), + new Tree.Builder(HICKORY, 80f, 250f, 7f, 29f, GEN_TALL).setGrowthTime(10).setBurnInfo(762f, 2000).build(), + new Tree.Builder(MAPLE, 140f, 360f, 3f, 20f, GEN_MEDIUM).setDominance(6.3f).setRadius(1).setBurnInfo(745f, 2000).build(), + new Tree.Builder(OAK, 180f, 430f, -8f, 12f, GEN_TALL).setHeight(16).setGrowthTime(10).setBurnInfo(728f, 2250).build(), + new Tree.Builder(PALM, 280f, 500f, 16f, 35f, GEN_TROPICAL).setDecayDist(6).setBurnInfo(730f, 1250).build(), + new Tree.Builder(PINE, 60f, 250f, -15f, 7f, GEN_CONIFER).setConifer().setDensity(0.1f, 0.8f).setBurnInfo(627f, 1250).build(), + new Tree.Builder(ROSEWOOD, 10f, 190f, 8f, 18f, GEN_MEDIUM).setHeight(12).setGrowthTime(8).setBurnInfo(640f, 1500).build(), + new Tree.Builder(SEQUOIA, 250f, 420f, -5f, 12f, GEN_SEQUOIA).setRadius(3).setHeight(24).setDecayDist(6).setGrowthTime(18).setConifer().setBushes().setDensity(0.4f, 0.9f).setBurnInfo(612f, 1750).build(), + new Tree.Builder(SPRUCE, 120f, 380f, -11f, 6f, GEN_CONIFER).setConifer().setDensity(0.1f, 0.8f).setBurnInfo(608f, 1500).build(), + new Tree.Builder(SYCAMORE, 120f, 290f, 17f, 33f, GEN_MEDIUM).setRadius(1).setGrowthTime(8).setBushes().setDensity(0.25f, 2f).setBurnInfo(653f, 1750).build(), + new Tree.Builder(WHITE_CEDAR, 10f, 240f, -8f, 17f, GEN_TALL).setHeight(16).setBurnInfo(625f, 1500).build(), + new Tree.Builder(WILLOW, 230f, 400f, 15f, 32f, GEN_WILLOW).setGrowthTime(11).setBushes().setDensity(0.7f, 2f).setBurnInfo(603f, 1000).build(), + new Tree.Builder(KAPOK, 210f, 500f, 15f, 35f, GEN_KAPOK_COMPOSITE).setDominance(8.5f).setRadius(3).setHeight(24).setDecayDist(6).setGrowthTime(18).setBushes().setDensity(0.6f, 2f).setBurnInfo(645f, 1000).build() ); } } diff --git a/src/main/java/net/dries007/tfc/util/Helpers.java b/src/main/java/net/dries007/tfc/util/Helpers.java index 870a3616dd..fb34a89d2b 100644 --- a/src/main/java/net/dries007/tfc/util/Helpers.java +++ b/src/main/java/net/dries007/tfc/util/Helpers.java @@ -1,6 +1,7 @@ /* * Work under Copyright. Licensed under the EUPL. * See the project README.md and LICENSE.txt for more information. + * */ package net.dries007.tfc.util; diff --git a/src/main/java/net/dries007/tfc/util/OreDictionaryHelper.java b/src/main/java/net/dries007/tfc/util/OreDictionaryHelper.java index 618e7bf4a9..035a6acd3c 100644 --- a/src/main/java/net/dries007/tfc/util/OreDictionaryHelper.java +++ b/src/main/java/net/dries007/tfc/util/OreDictionaryHelper.java @@ -1,6 +1,7 @@ /* * Work under Copyright. Licensed under the EUPL. * See the project README.md and LICENSE.txt for more information. + * */ package net.dries007.tfc.util; @@ -103,7 +104,7 @@ private static Predicate createPredicateStack(String... names) private static void register(Thing thing, Object... parts) { - if (done) throw new IllegalStateException("Cannot use the helper to register after init has past."); + if (done) throw new IllegalStateException("Cannot use the helper to register after postInit has past."); MAP.put(thing, toString(parts)); } diff --git a/src/main/java/net/dries007/tfc/world/classic/biomes/BiomesTFC.java b/src/main/java/net/dries007/tfc/world/classic/biomes/BiomesTFC.java index 2ca96610ba..55a9546f32 100644 --- a/src/main/java/net/dries007/tfc/world/classic/biomes/BiomesTFC.java +++ b/src/main/java/net/dries007/tfc/world/classic/biomes/BiomesTFC.java @@ -1,11 +1,13 @@ /* * Work under Copyright. Licensed under the EUPL. * See the project README.md and LICENSE.txt for more information. + * */ package net.dries007.tfc.world.classic.biomes; import net.minecraft.world.biome.Biome; +import net.minecraftforge.common.BiomeDictionary; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; @@ -42,22 +44,23 @@ public final class BiomesTFC public static void registerBiomes(RegistryEvent.Register event) { IForgeRegistry r = event.getRegistry(); - register(r, new BiomeTFC(new Biome.BiomeProperties(MOD_NAME + " Ocean").setBaseHeight(-3.6f).setHeightVariation(-2.69999f))); - register(r, new BiomeTFC(new Biome.BiomeProperties(MOD_NAME + " River").setBaseHeight(-3.2f).setHeightVariation(-3.0f))); - register(r, new BiomeTFC(new Biome.BiomeProperties(MOD_NAME + " Beach").setBaseHeight(-2.69f).setHeightVariation(-2.68f))); - register(r, new BiomeTFC(new Biome.BiomeProperties(MOD_NAME + " Gravel beach").setBaseHeight(-2.69f).setHeightVariation(-2.68f).setBaseBiome("tfc:beach"))); - register(r, new BiomeTFC(new Biome.BiomeProperties(MOD_NAME + " High hills").setBaseHeight(-1.9000001f).setHeightVariation(-1.1f))); - register(r, new BiomeTFC(new Biome.BiomeProperties(MOD_NAME + " Plains").setBaseHeight(-2.6000001f).setHeightVariation(-2.54f))); - register(r, new BiomeTFC(new Biome.BiomeProperties(MOD_NAME + " Swampland").setBaseHeight(-2.8f).setHeightVariation(-2.6000001f), 8, 45)); - register(r, new BiomeTFC(new Biome.BiomeProperties(MOD_NAME + " High hills edge").setBaseHeight(-2.5f).setHeightVariation(-2.3f).setBaseBiome("tfc:high_hills"))); - register(r, new BiomeTFC(new Biome.BiomeProperties(MOD_NAME + " Rolling hills").setBaseHeight(-2.6000001f).setHeightVariation(-2.3f))); - register(r, new BiomeTFC(new Biome.BiomeProperties(MOD_NAME + " Mountains").setBaseHeight(-1.9000001f).setHeightVariation(-1.1f))); - register(r, new BiomeTFC(new Biome.BiomeProperties(MOD_NAME + " Mountains edge").setBaseHeight(-2.3f).setHeightVariation(-1.9000001f).setBaseBiome("tfc:mountains"))); - register(r, new BiomeTFC(new Biome.BiomeProperties(MOD_NAME + " High plains").setBaseHeight(-2.3f).setHeightVariation(-2.27f))); - register(r, new BiomeTFC(new Biome.BiomeProperties(MOD_NAME + " Deep ocean").setBaseHeight(-4.2f).setHeightVariation(-2.69999f).setBaseBiome("tfc:ocean"))); - register(r, new BiomeTFC(new Biome.BiomeProperties(MOD_NAME + " Lake").setBaseHeight(-3.2f).setHeightVariation(-2.6990001f).setBaseBiome("tfc:ocean"), 2, 5/*todo: was 0*/)); - -// register(r, new BiomeTFC(new Biome.BiomeProperties("tfc_hell").setRainDisabled().setTemperature(2.0F).setRainfall(0.0F))); + + register(r, new BiomeTFC(new Biome.BiomeProperties(MOD_NAME + " Ocean").setBaseHeight(-3.6f).setHeightVariation(-2.69999f)), BiomeDictionary.Type.OCEAN, BiomeDictionary.Type.WET, BiomeDictionary.Type.WATER); + register(r, new BiomeTFC(new Biome.BiomeProperties(MOD_NAME + " River").setBaseHeight(-3.2f).setHeightVariation(-3f)), BiomeDictionary.Type.RIVER, BiomeDictionary.Type.WET, BiomeDictionary.Type.WATER); + register(r, new BiomeTFC(new Biome.BiomeProperties(MOD_NAME + " Beach").setBaseHeight(-2.69f).setHeightVariation(-2.68f)), BiomeDictionary.Type.BEACH); + register(r, new BiomeTFC(new Biome.BiomeProperties(MOD_NAME + " Gravel Beach").setBaseHeight(-2.69f).setHeightVariation(-2.68f).setBaseBiome("tfc:beach")), BiomeDictionary.Type.BEACH); + register(r, new BiomeTFC(new Biome.BiomeProperties(MOD_NAME + " High Hills").setBaseHeight(-1.9000001f).setHeightVariation(-1.1f)), BiomeDictionary.Type.HILLS); + register(r, new BiomeTFC(new Biome.BiomeProperties(MOD_NAME + " Plains").setBaseHeight(-2.6000001f).setHeightVariation(-2.54f)), BiomeDictionary.Type.PLAINS); + register(r, new BiomeTFC(new Biome.BiomeProperties(MOD_NAME + " Swampland").setBaseHeight(-2.8f).setHeightVariation(-2.6000001f), 8, 45), BiomeDictionary.Type.SWAMP); + register(r, new BiomeTFC(new Biome.BiomeProperties(MOD_NAME + " High Hills Edge").setBaseHeight(-2.5f).setHeightVariation(-2.3f).setBaseBiome("tfc:high_hills")), BiomeDictionary.Type.HILLS, BiomeDictionary.Type.PLAINS); + register(r, new BiomeTFC(new Biome.BiomeProperties(MOD_NAME + " Rolling Hills").setBaseHeight(-2.6000001f).setHeightVariation(-2.3f)), BiomeDictionary.Type.HILLS); + register(r, new BiomeTFC(new Biome.BiomeProperties(MOD_NAME + " Mountians").setBaseHeight(-1.9000001f).setHeightVariation(-1.1f)), BiomeDictionary.Type.MOUNTAIN); + register(r, new BiomeTFC(new Biome.BiomeProperties(MOD_NAME + " Mountians Edge").setBaseHeight(-2.3f).setHeightVariation(-1.9000001f).setBaseBiome("tfc:mountians")), BiomeDictionary.Type.MOUNTAIN); + register(r, new BiomeTFC(new Biome.BiomeProperties(MOD_NAME + " High Plains").setBaseHeight(-2.3f).setHeightVariation(-2.27f)), BiomeDictionary.Type.HILLS, BiomeDictionary.Type.PLAINS); + register(r, new BiomeTFC(new Biome.BiomeProperties(MOD_NAME + " Deep Ocean").setBaseHeight(-4.2f).setHeightVariation(-2.69999f).setBaseBiome("tfc:ocean")), BiomeDictionary.Type.OCEAN, BiomeDictionary.Type.WET, BiomeDictionary.Type.WATER); + register(r, new BiomeTFC(new Biome.BiomeProperties(MOD_NAME + " Lake").setBaseHeight(-3.2f).setHeightVariation(-2.6990001f).setBaseBiome("tfc:ocean"), 2, 5), BiomeDictionary.Type.RIVER, BiomeDictionary.Type.WET, BiomeDictionary.Type.WATER); + + // register(r, new BiomeTFC(new Biome.BiomeProperties("tfc_hell").setRainDisabled().setTemperature(2.0F).setRainfall(0.0F))); } public static boolean isOceanicBiome(int id) @@ -122,9 +125,10 @@ public static BiomeTFC[] getOverworldGenerateBiomes() return OVERWORLD_GENERATE_BIOMES; } - private static void register(IForgeRegistry r, Biome item) + private static void register(IForgeRegistry r, Biome item, BiomeDictionary.Type... types) { r.register(item.setRegistryName(MOD_ID, item.biomeName.replace(MOD_NAME + " ", "").replace(' ', '_').toLowerCase())); + BiomeDictionary.addTypes(item, types); } private BiomesTFC() {} diff --git a/src/main/java/net/dries007/tfc/world/classic/worldgen/WorldGenTrees.java b/src/main/java/net/dries007/tfc/world/classic/worldgen/WorldGenTrees.java index 6283e69e04..2d1f28661c 100644 --- a/src/main/java/net/dries007/tfc/world/classic/worldgen/WorldGenTrees.java +++ b/src/main/java/net/dries007/tfc/world/classic/worldgen/WorldGenTrees.java @@ -1,6 +1,7 @@ /* * Work under Copyright. Licensed under the EUPL. * See the project README.md and LICENSE.txt for more information. + * */ package net.dries007.tfc.world.classic.worldgen; @@ -94,7 +95,7 @@ public void generate(Random random, int chunkX, int chunkZ, World world, IChunkG tree.makeTree(manager, world, pos, random); } - trees.removeIf(t -> !t.isHasBushes()); + trees.removeIf(t -> !t.hasBushes()); // Small bushes in high density areas if (density > 0.6f && !trees.isEmpty()) // Density requirement is the same for jungles (kapok trees) to generate { diff --git a/src/main/resources/assets/tfc/lang/en_us.lang b/src/main/resources/assets/tfc/lang/en_us.lang index 6ae7cc2534..46ccb4cd86 100644 --- a/src/main/resources/assets/tfc/lang/en_us.lang +++ b/src/main/resources/assets/tfc/lang/en_us.lang @@ -125,6 +125,9 @@ tfc.enum.heat.yellow_white=Yellow White tfc.enum.heat.white=White tfc.enum.heat.brilliant_white=Brilliant White +tfc.enum.heat.torch.catchingFire=Catching Fire +tfc.enum.heat.torch.lit=Lit + # Items item.tfc.wand.name=TFC Debug Wand item.tfc.firestarter.name=Firestarter