From 649c13f5f0b40113089b69515d8dee5d57adfabf Mon Sep 17 00:00:00 2001 From: temp1011 <34900092+temp1011@users.noreply.github.com> Date: Fri, 27 Apr 2018 12:49:51 +0100 Subject: [PATCH 1/7] fix wrong localisation key for habitat locator #2100 (#2106) --- src/main/java/forestry/apiculture/gui/GuiHabitatLocator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/forestry/apiculture/gui/GuiHabitatLocator.java b/src/main/java/forestry/apiculture/gui/GuiHabitatLocator.java index d52d78cd1..edf2ae6c3 100755 --- a/src/main/java/forestry/apiculture/gui/GuiHabitatLocator.java +++ b/src/main/java/forestry/apiculture/gui/GuiHabitatLocator.java @@ -85,7 +85,7 @@ public class GuiHabitatLocator extends GuiForestry { protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) { super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY); - String str = Translator.translateToLocal("item.for.habitatLocator.name").toUpperCase(); + String str = Translator.translateToLocal("item.for.habitat_locator.name").toUpperCase(); fontRenderer.drawString(str, startX + 8 + textLayout.getCenteredOffset(str, 138), startY + 16, ColourProperties.INSTANCE.get("gui.screen")); // Set active according to valid biomes. From fd25e0822dc864646b96244cecd152fdd3b3f902 Mon Sep 17 00:00:00 2001 From: temp1011 <34900092+temp1011@users.noreply.github.com> Date: Fri, 27 Apr 2018 12:49:57 +0100 Subject: [PATCH 2/7] fix crash when raytrace result is null #2090 (#2105) --- .../forestry/core/items/ItemFluidContainerForestry.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/forestry/core/items/ItemFluidContainerForestry.java b/src/main/java/forestry/core/items/ItemFluidContainerForestry.java index d7d3c270f..eaa5eb942 100755 --- a/src/main/java/forestry/core/items/ItemFluidContainerForestry.java +++ b/src/main/java/forestry/core/items/ItemFluidContainerForestry.java @@ -77,7 +77,7 @@ public class ItemFluidContainerForestry extends ItemForestry { if (this.isInCreativeTab(tab)) { // empty subItems.add(new ItemStack(this)); - + // filled for (Fluid fluid : FluidRegistry.getRegisteredFluids().values()) { ItemStack itemStack = new ItemStack(this); @@ -194,9 +194,9 @@ public class ItemFluidContainerForestry extends ItemForestry { return new ActionResult<>(EnumActionResult.FAIL, heldItem); } } else { - if(Config.CapsuleFluidPickup) { + if (Config.CapsuleFluidPickup) { RayTraceResult target = this.rayTrace(world, player, true); - if (target.typeOfHit != RayTraceResult.Type.BLOCK) { + if (target == null || target.typeOfHit != RayTraceResult.Type.BLOCK) { return ActionResult.newResult(EnumActionResult.PASS, heldItem); } From 0ff0aa802ca8cf32f9d18d1c1faf578f7c61b53a Mon Sep 17 00:00:00 2001 From: temp1011 <34900092+temp1011@users.noreply.github.com> Date: Fri, 27 Apr 2018 12:50:38 +0100 Subject: [PATCH 3/7] Tech reborn plugin (#2078) * Add Plugin Tech Reborn --- build.gradle | 5 + gradle.properties | 3 +- src/main/java/forestry/Forestry.java | 4 +- .../farming/logic/FarmLogicRubber.java | 17 ++- .../farming/logic/crops/CropRubber.java | 17 ++- .../forestry/modules/ForestryModuleUids.java | 1 + .../forestry/plugins/PluginTechReborn.java | 137 ++++++++++++++++++ 7 files changed, 175 insertions(+), 9 deletions(-) create mode 100644 src/main/java/forestry/plugins/PluginTechReborn.java diff --git a/build.gradle b/build.gradle index 241211d2c..825da5bda 100644 --- a/build.gradle +++ b/build.gradle @@ -59,6 +59,10 @@ repositories { name = "ic2" url = "http://maven.ic2.player.to/" } + maven { + name = "Modmuss50" + url = "http://maven.modmuss50.me" + } } dependencies { @@ -66,6 +70,7 @@ dependencies { deobfCompile "mezz.jei:jei_${jei_mcversion}:${jei_version}:api" runtime "mezz.jei:jei_${jei_mcversion}:${jei_version}" deobfCompile "net.industrial-craft:industrialcraft-2:${ic2_version}:api" + deobfCompile "TechReborn:TechReborn-${TR_mcversion}:${TR_version}:api" } configurations { diff --git a/gradle.properties b/gradle.properties index 0dba89edb..610bbbf5a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,7 +8,8 @@ tesla_mcversion=1.12 jei_version=4.8.5.147 jei_mcversion=1.12.2 ic2_version=2.8.24-ex112 - +TR_mcversion=1.12.2 +TR_version=2.13.2.561 version_major=5 version_minor=8 version_patch=0 diff --git a/src/main/java/forestry/Forestry.java b/src/main/java/forestry/Forestry.java index 974e9a695..4e85e932c 100755 --- a/src/main/java/forestry/Forestry.java +++ b/src/main/java/forestry/Forestry.java @@ -55,6 +55,7 @@ import forestry.modules.ModuleManager; import forestry.plugins.ForestryCompatPlugins; import forestry.plugins.PluginIC2; import forestry.plugins.PluginNatura; +import forestry.plugins.PluginTechReborn; /** * Forestry Minecraft Mod @@ -71,7 +72,8 @@ import forestry.plugins.PluginNatura; + "after:jei@[4.7.8.91,);" + "after:" + PluginIC2.MOD_ID + ";" + "after:" + PluginNatura.MOD_ID + ";" - + "after:toughasnails;") + + "after:toughasnails;" + + "after:" + PluginTechReborn.MOD_ID + ";") public class Forestry { @SuppressWarnings("NullableProblems") diff --git a/src/main/java/forestry/farming/logic/FarmLogicRubber.java b/src/main/java/forestry/farming/logic/FarmLogicRubber.java index 009f63bb7..6871f51b0 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicRubber.java +++ b/src/main/java/forestry/farming/logic/FarmLogicRubber.java @@ -28,8 +28,10 @@ import forestry.api.farming.IFarmHousing; import forestry.api.farming.IFarmProperties; import forestry.core.utils.ItemStackUtil; import forestry.core.utils.Log; +import forestry.core.utils.ModUtil; import forestry.farming.logic.crops.CropRubber; import forestry.plugins.PluginIC2; +import forestry.plugins.PluginTechReborn; public class FarmLogicRubber extends FarmLogic { @@ -37,7 +39,8 @@ public class FarmLogicRubber extends FarmLogic { public FarmLogicRubber(IFarmProperties properties, boolean isManual) { super(properties, isManual); - if (PluginIC2.rubberWood == null || PluginIC2.resin == null) { + if ((PluginIC2.rubberWood == null || PluginIC2.resin == null) && + PluginTechReborn.rubberItemsSuccess()) { Log.warning("Failed to init a farm logic {} since IC2 rubber wood or resin were not found", getClass().getName()); active = false; } @@ -45,7 +48,12 @@ public class FarmLogicRubber extends FarmLogic { @Override public ItemStack getIconItemStack() { - return PluginIC2.resin; + if (ModUtil.isModLoaded(PluginIC2.MOD_ID)) { + return PluginIC2.resin; + } else if (ModUtil.isModLoaded(PluginTechReborn.MOD_ID)) { + return PluginTechReborn.sap; + } + return ItemStack.EMPTY; } @Override @@ -119,13 +127,14 @@ public class FarmLogicRubber extends FarmLogic { for (int j = 0; j < 10; j++) { BlockPos candidate = position.add(0, j, 0); - if(!world.isBlockLoaded(candidate)){ + if (!world.isBlockLoaded(candidate)) { return crops; } IBlockState blockState = world.getBlockState(candidate); Block block = blockState.getBlock(); - if (!ItemStackUtil.equals(block, PluginIC2.rubberWood)) { + if ((PluginIC2.rubberWood != null && !ItemStackUtil.equals(block, PluginIC2.rubberWood)) && + (PluginTechReborn.RUBBER_WOOD != null && !ItemStackUtil.equals(block, PluginTechReborn.RUBBER_WOOD))) { break; } diff --git a/src/main/java/forestry/farming/logic/crops/CropRubber.java b/src/main/java/forestry/farming/logic/crops/CropRubber.java index 47572d1e2..a161757df 100644 --- a/src/main/java/forestry/farming/logic/crops/CropRubber.java +++ b/src/main/java/forestry/farming/logic/crops/CropRubber.java @@ -18,6 +18,7 @@ import java.util.Map; import net.minecraft.block.Block; import net.minecraft.block.properties.IProperty; +import net.minecraft.block.properties.PropertyBool; import net.minecraft.block.state.IBlockState; import net.minecraft.item.ItemStack; import net.minecraft.util.NonNullList; @@ -29,6 +30,7 @@ import forestry.core.network.packets.PacketFXSignal; import forestry.core.utils.ItemStackUtil; import forestry.core.utils.NetworkUtil; import forestry.plugins.PluginIC2; +import forestry.plugins.PluginTechReborn; public class CropRubber extends CropDestroy { @@ -46,6 +48,9 @@ public class CropRubber extends CropDestroy { String valueWetString = wetPropertyEntry.getValue().toString(); String valueDryString = valueWetString.replace("wet", "dry"); IProperty property = wetPropertyEntry.getKey(); + if (property instanceof PropertyBool && property.getName().equals("hassap")) { + return sappyState.withProperty(PropertyBool.create("hassap"), false); + } IBlockState baseState = sappyState.getBlock().getBlockState().getBaseState(); IBlockState dryState = getStateWithValue(baseState, property, valueDryString); @@ -60,13 +65,15 @@ public class CropRubber extends CropDestroy { public static boolean hasRubberToHarvest(IBlockState blockState) { Block block = blockState.getBlock(); - if (ItemStackUtil.equals(block, PluginIC2.rubberWood)) { + if (PluginIC2.rubberWood != null && ItemStackUtil.equals(block, PluginIC2.rubberWood)) { ImmutableCollection> propertyValues = blockState.getProperties().values(); for (Comparable propertyValue : propertyValues) { if (propertyValue.toString().contains("wet")) { return true; } } + } else if (PluginTechReborn.RUBBER_WOOD != null && ItemStackUtil.equals(block, PluginTechReborn.RUBBER_WOOD)) { + return blockState.getValue(PropertyBool.create("hassap")); } return false; } @@ -83,8 +90,12 @@ public class CropRubber extends CropDestroy { @Override protected NonNullList harvestBlock(World world, BlockPos pos) { NonNullList harvested = NonNullList.create(); - harvested.add(PluginIC2.resin.copy()); - + Block harvestBlock = world.getBlockState(pos).getBlock(); + if (PluginIC2.rubberWood != null && ItemStackUtil.equals(harvestBlock, PluginIC2.rubberWood)) { + harvested.add(PluginIC2.resin.copy()); + } else if (PluginTechReborn.RUBBER_WOOD != null && ItemStackUtil.equals(harvestBlock, PluginTechReborn.RUBBER_WOOD)) { + harvested.add(PluginTechReborn.sap.copy()); + } PacketFXSignal packet = new PacketFXSignal(PacketFXSignal.VisualFXType.BLOCK_BREAK, PacketFXSignal.SoundFXType.BLOCK_BREAK, pos, blockState); NetworkUtil.sendNetworkPacket(packet, pos, world); diff --git a/src/main/java/forestry/modules/ForestryModuleUids.java b/src/main/java/forestry/modules/ForestryModuleUids.java index 0570f1583..30e2c660b 100644 --- a/src/main/java/forestry/modules/ForestryModuleUids.java +++ b/src/main/java/forestry/modules/ForestryModuleUids.java @@ -40,4 +40,5 @@ public class ForestryModuleUids { public static final String RUSTIC = "rustic"; public static final String ROOTS = "roots"; public static final String BETTER_WITH_MODS = "betterwithmods"; + public static final String TECH_REBORN = "techreborn"; } diff --git a/src/main/java/forestry/plugins/PluginTechReborn.java b/src/main/java/forestry/plugins/PluginTechReborn.java new file mode 100644 index 000000000..4bf2fb3a6 --- /dev/null +++ b/src/main/java/forestry/plugins/PluginTechReborn.java @@ -0,0 +1,137 @@ +package forestry.plugins; + +import com.google.common.collect.ImmutableMap; + +import javax.annotation.Nullable; + +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; + +import net.minecraftforge.fml.common.Optional; +import net.minecraftforge.fml.common.registry.GameRegistry.ItemStackHolder; + +import forestry.api.circuits.ChipsetManager; +import forestry.api.circuits.ICircuitLayout; +import forestry.api.core.ForestryAPI; +import forestry.api.farming.IFarmProperties; +import forestry.api.modules.ForestryModule; +import forestry.api.recipes.RecipeManagers; +import forestry.api.storage.BackpackManager; +import forestry.apiculture.ModuleApiculture; +import forestry.apiculture.items.EnumPropolis; +import forestry.apiculture.items.ItemRegistryApiculture; +import forestry.core.ModuleCore; +import forestry.core.blocks.BlockBogEarth; +import forestry.core.circuits.Circuits; +import forestry.core.config.Constants; +import forestry.core.fluids.Fluids; +import forestry.core.items.EnumElectronTube; +import forestry.core.recipes.RecipeUtil; +import forestry.core.utils.ItemStackUtil; +import forestry.core.utils.Log; +import forestry.core.utils.ModUtil; +import forestry.farming.FarmRegistry; +import forestry.farming.circuits.CircuitFarmLogic; +import forestry.farming.logic.FarmLogicRubber; +import forestry.farming.logic.farmables.FarmableSapling; +import forestry.modules.ForestryModuleUids; +import forestry.modules.ModuleHelper; + +import techreborn.api.ISubItemRetriever; +import techreborn.api.TechRebornAPI; + +@ForestryModule(containerID = ForestryCompatPlugins.ID, moduleID = ForestryModuleUids.TECH_REBORN, name = "TechReborn", author = "temp1011", url = Constants.URL, unlocalizedDescription = "for.module.techreborn.description") +public class PluginTechReborn extends CompatPlugin { + + public static final String MOD_ID = "techreborn"; + + @ItemStackHolder("techreborn:rubber_log") + @Nullable + public static ItemStack RUBBER_WOOD = null; + @ItemStackHolder("techreborn:rubber_sapling") + @Nullable + public static final ItemStack RUBBER_SAPLING = null; + + public static ItemStack sap; + public static ItemStack rubber; + + public PluginTechReborn() { + super("TechReborn", MOD_ID); + } + + @Override + public void preInit() { + IFarmProperties rubberFarm = FarmRegistry.getInstance().registerLogic("farmRubber", FarmLogicRubber::new); + + Circuits.farmRubberManual = new CircuitFarmLogic("manualRubber", rubberFarm, true); + } + + @Override + @Optional.Method(modid = MOD_ID) + public void doInit() { + ISubItemRetriever getItem = TechRebornAPI.subItemRetriever; + sap = getItem.getPartByName("rubberSap"); + rubber = getItem.getPartByName("rubber"); + + } + + @Override + @Optional.Method(modid = MOD_ID) + public void registerCrates() { + ItemStack scrap = TechRebornAPI.subItemRetriever.getPartByName("scrap"); + ItemStack uuMatter = getItemStack("uumatter"); + ModuleHelper.registerCrate(sap); + ModuleHelper.registerCrate(scrap); + ModuleHelper.registerCrate(uuMatter); + ModuleHelper.registerCrate("ingotLead"); + ModuleHelper.registerCrate("ingotAluminum"); + ModuleHelper.registerCrate("ingotBrass"); + ModuleHelper.registerCrate("ingotNickel"); + + if (!ModUtil.isModLoaded(PluginIC2.MOD_ID)) { + ModuleHelper.registerCrate("ingotSilver"); + ModuleHelper.registerCrate("itemRubber"); + } + } + + @Override + public void registerBackpackItems() { + ModuleHelper.addItemToBackpack(BackpackManager.FORESTER_UID, sap); + } + + @Override + @Optional.Method(modid = MOD_ID) + public void registerRecipes() { + RecipeManagers.fabricatorManager.addRecipe(ItemStack.EMPTY, + Fluids.GLASS.getFluid(500), + ModuleCore.items.tubes.get(EnumElectronTube.RUBBER, 4), + new Object[]{" X ", "#X#", "XXX", '#', "dustRedstone", 'X', "itemRubber"}); + + if (ModuleHelper.isEnabled(ForestryModuleUids.APICULTURE)) { + ItemRegistryApiculture beeItems = ModuleApiculture.getItems(); + if (!ModUtil.isModLoaded(PluginIC2.MOD_ID)) { + RecipeManagers.centrifugeManager.addRecipe(20, beeItems.propolis.get(EnumPropolis.NORMAL, 1), ImmutableMap.of(sap, 1.0f)); + } else { + Log.info("Using ic2 Propolis recipe rather than Tech Reborn"); + } + } + + int bogEarthOutputCan = ForestryAPI.activeMode.getIntegerSetting("recipe.output.bogearth.can"); + if (bogEarthOutputCan > 0) { + ItemStack waterCell = TechRebornAPI.subItemRetriever.getCellByName("water"); + ItemStack bogEarthCan = ModuleCore.getBlocks().bogEarth.get(BlockBogEarth.SoilType.BOG_EARTH, bogEarthOutputCan); + RecipeUtil.addRecipe("techreborn_bog_earth_can", bogEarthCan, "#Y#", "YXY", "#Y#", '#', Blocks.DIRT, 'X', waterCell, 'Y', "sand"); + } + + if (ModuleHelper.isEnabled(ForestryModuleUids.FARMING)) { + ICircuitLayout layoutManual = ChipsetManager.circuitRegistry.getLayout("forestry.farms.manual"); + ChipsetManager.solderManager.addRecipe(layoutManual, ModuleCore.items.tubes.get(EnumElectronTube.RUBBER, 1), Circuits.farmRubberManual); + ForestryAPI.farmRegistry.registerFarmables("rubberTreeFarm", new FarmableSapling(RUBBER_SAPLING, new ItemStack[0])); + } + } + + public static boolean rubberItemsSuccess() { + return ItemStackUtil.getItemFromRegistry("techreborn:rubber_wood") != null + && !new ItemStack(ItemStackUtil.getItemFromRegistry("techreborn:part"), 1, 31).isEmpty(); + } +} \ No newline at end of file From f12c6d2d11dc93913ac13e93a5e91c303f513aa7 Mon Sep 17 00:00:00 2001 From: temp1011 <34900092+temp1011@users.noreply.github.com> Date: Fri, 27 Apr 2018 12:51:04 +0100 Subject: [PATCH 4/7] Add IMC for registering flowers (#2027) --- .../forestry/apiculture/ModuleApiculture.java | 49 +++++++++++++++++-- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/src/main/java/forestry/apiculture/ModuleApiculture.java b/src/main/java/forestry/apiculture/ModuleApiculture.java index 45340bb9f..2ef7f289e 100644 --- a/src/main/java/forestry/apiculture/ModuleApiculture.java +++ b/src/main/java/forestry/apiculture/ModuleApiculture.java @@ -31,6 +31,8 @@ import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.init.PotionTypes; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTUtil; import net.minecraft.potion.PotionUtils; import net.minecraft.util.NonNullList; import net.minecraft.util.ResourceLocation; @@ -157,9 +159,9 @@ public class ModuleApiculture extends BlankForestryModule { public static int ticksPerBeeWorkCycle = 550; public static boolean hivesDamageOnPeaceful = false; - + public static boolean doSelfPollination = true; - + public static int maxFlowersSpawnedPerHive = 20; @Nullable public static VillagerRegistry.VillagerProfession villagerApiarist; @@ -282,7 +284,7 @@ public class ModuleApiculture extends BlankForestryModule { ticksPerBeeWorkCycle = config.getIntLocalized("beekeeping", "ticks.work", 550, 250, 850); hivesDamageOnPeaceful = config.getBooleanLocalized("beekeeping", "hivedamage.peaceful", false); - + doSelfPollination = config.getBooleanLocalized("beekeeping", "self.pollination", false); config.save(); @@ -988,11 +990,52 @@ public class ModuleApiculture extends BlankForestryModule { HiveConfig.addBlacklistedDim(dim); } return true; + } else if (message.key.equals("add-plantable-flower")) { + return addPlantableFlower(message); + } else if (message.key.equals("add-acceptable-flower")) { + return addAcceptableFlower(message); } return false; } + private boolean addPlantableFlower(IMCMessage message) { + try { + NBTTagCompound tagCompound = message.getNBTValue(); + IBlockState flowerState = NBTUtil.readBlockState(tagCompound); + double weight = tagCompound.getDouble("weight"); + List flowerTypes = new ArrayList<>(); + for (String key : tagCompound.getKeySet()) { + if (key.contains("flowertype")) { + flowerTypes.add(tagCompound.getString("flowertype")); + } + } + FlowerManager.flowerRegistry.registerPlantableFlower(flowerState, weight, flowerTypes.toArray(new String[flowerTypes.size()])); + return true; + } catch (Exception e) { + IMCUtil.logInvalidIMCMessage(message); + return false; + } + } + + private boolean addAcceptableFlower(IMCMessage message) { + try { + NBTTagCompound tagCompound = message.getNBTValue(); + IBlockState flowerState = NBTUtil.readBlockState(tagCompound); + List flowerTypes = new ArrayList<>(); + for (String key : tagCompound.getKeySet()) { + if (key.contains("flowertype")) { + flowerTypes.add(tagCompound.getString("flowertype")); + } + } + FlowerManager.flowerRegistry.registerAcceptableFlower(flowerState, flowerTypes.toArray(new String[flowerTypes.size()])); + return true; + } catch (Exception e) { + IMCUtil.logInvalidIMCMessage(message); + return false; + } + } + @SubscribeEvent @SideOnly(Side.CLIENT) public void textureHook(TextureStitchEvent.Pre event) { From dfb4504cde9fdeb8db3250eb2db88ce82c95f8f9 Mon Sep 17 00:00:00 2001 From: Jose Date: Fri, 27 Apr 2018 07:51:13 -0400 Subject: [PATCH 5/7] Tweak ash texture (#1902) * Make ash less confusing * Updated textures --- .../assets/forestry/textures/items/ash.png | Bin 178 -> 2243 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/src/main/resources/assets/forestry/textures/items/ash.png b/src/main/resources/assets/forestry/textures/items/ash.png index b160886b92d9134df3a9fadebad92e96e2becbae..eac6ca0e8b4c21bb00c3fecde1673a9ca68b621c 100755 GIT binary patch literal 2243 zcmcIme{9rL9PfuzJ*4R(Z^<95P^1oy6ex7FQUOWWIS z3nKK;!fO(~0?QhJ$ zu+;r>pu(u|Efz#2VgZs8gqCF_z=t75t&1o!9pV+f zGTg0b5a%p*Qe;>w?%*wqo#w4<9&V)>2Sqz5#zxYNK-&cyk0*Wv@}@~4!S7j+@P(dS zM2%sn0!7u=*IVjs7DcP37@p@T+DciiBtnpSL(~9qGOFi}GI*daYO-p`N)$I4K~RYq zE&?eX2_d2;X`^}~O()RmYf z!s0p@HF8ItNn+AgjcMWGNF|YiVHiO$9SLKSuGAXEQ1lw*4sj%xlhLSxTZ6z*w1A?7 zM+;Rp%7VMy_+vgG%2AW`aZ^#k0D6D{T?DF{lca5=jSeu3z;c3FK2D(N5vULKfdmXN z7R-{2HNc?y+5`^SvNyqsB!?Qt1NHd?Z&WuxRD@oSi$J0*vMdQ4BhkR_U`dJN?4-lS zT1lrWKFHe{K1e%;bs>9?BF4=0nf4=XD=8x4NM=ZI0^aGc+eDJH(oWLJvOEcB zYl!4SEG+`gY7aWtQMRWv8SNYp9?NQ~k`SYf0b+;~9jN0SkYw$ECV^9;Nt>OMLQa~4 z91jUx5`~bWMF8p(IRdI7rADg>{H7YW5>_;yBB7ky#?E`)?lMgY$zimh`xnl~y~S=6 zsohRmEsWXrNCpbGMAlJ_8xk9-9Ii@?!ZJSGodOWeP2nO$vm2m9B&Oxtq4~(8H6U6I(Fsct|2>%TwfjHoaN7+y?m8@!qmojuqqAVdD$u4ZUz`Vq5w#EM7Tc&2{IW+5OtUnzLD);*Ht&hP1((bcC`9XeaSW9jRQAKkv?kG#Hk ze%qXM>|KA8bHkEFeb)*)mbZKp{_XPgiSs@@)fU>_6zRo|tjZeLb76IXxW3_wc};0= zmM)ytl6o|FsngQ^L*oI0n3{3ldS+c(@5SkBPo6&#+*O8^?)z>lvR(IfN9y4jFa7kX zb3<3ZR^%C2^VV}68HcYwe?tiFUGZK;-jsV&ylorjr0-oZQOv5`3VQ8wdmEg&ymrs& zPj+@2!Zd7d+C3-Oql5XEhw`z`-U(mFF6Fll4lRB^@cGA)yzXFUFY{3Aw8N_lax$wr zdkJG7EV;64Fo*m8(ureguEYGy@D`VPcFwPQ@o$9c1$h7f delta 162 zcmX>sxQTIsL_G^L0|Ud`yN`l^lxToYh%1n`we`7q^XB^XdrzD=F@OH%UAqqEacngM zN-&lL`2{mLJiCzwSZi&;+Zuw1%}tLcc# z9j8M+%#J-F=Az0IiV~-qY)_fMv3O&5kw(P)gn|_c%+eAZO&K-}40}#-uCo0%dpXct N22WQ%mvv4FO#l!QJEi~t From 348149f4d64d0f7eda9b7c963ce5effb694a0ad3 Mon Sep 17 00:00:00 2001 From: temp1011 <34900092+temp1011@users.noreply.github.com> Date: Fri, 27 Apr 2018 12:51:22 +0100 Subject: [PATCH 6/7] Add config to let capsules be reusable (#2066) * Add config option to make capsules non consumable * Fix naming --- .../java/forestry/core/config/Config.java | 54 ++++++++++--------- .../core/items/FluidHandlerItemForestry.java | 12 +++++ 2 files changed, 41 insertions(+), 25 deletions(-) diff --git a/src/main/java/forestry/core/config/Config.java b/src/main/java/forestry/core/config/Config.java index d77e536ef..4da4b7cb6 100755 --- a/src/main/java/forestry/core/config/Config.java +++ b/src/main/java/forestry/core/config/Config.java @@ -63,7 +63,7 @@ public class Config { //Humus public static int humusDegradeDelimiter = 3; - + //Greenhouse public static int climateSourceRange = 36; public static float climateSourceEnergyModifier = 1.5F; @@ -125,6 +125,7 @@ public class Config { // Fluids public static boolean CapsuleFluidPickup = false; + public static boolean nonConsumableCapsules = false; // Gui tabs (Ledger) public static int guiTabSpeed = 8; @@ -158,37 +159,39 @@ public class Config { return enableExUtilEnderLily; } - public static boolean isExUtilRedOrchidEnabled() { return enableExUtilRedOrchid; } + public static boolean isExUtilRedOrchidEnabled() { + return enableExUtilRedOrchid; + } public static boolean isMagicalCropsSupportEnabled() { return enableMagicalCropsSupport; } - + public static void blacklistTreeDim(int dimID) { blacklistedTreeDims.add(dimID); } - + public static void whitelistTreeDim(int dimID) { whitelistedTreeDims.add(dimID); } - + public static void blacklistOreDim(int dimID) { blacklistedOreDims.add(dimID); } - + public static void whitelistOreDim(int dimID) { whitelistedOreDims.add(dimID); } - - public static boolean isValidOreDim(int dimID) { //blacklist has priority - if(blacklistedOreDims.isEmpty() || !blacklistedOreDims.contains(dimID)) { + + public static boolean isValidOreDim(int dimID) { //blacklist has priority + if (blacklistedOreDims.isEmpty() || !blacklistedOreDims.contains(dimID)) { return whitelistedOreDims.isEmpty() || whitelistedOreDims.contains(dimID); } return false; } - - public static boolean isValidTreeDim(int dimID) { //blacklist has priority - if(blacklistedTreeDims.isEmpty() || !blacklistedTreeDims.contains(dimID)) { + + public static boolean isValidTreeDim(int dimID) { //blacklist has priority + if (blacklistedTreeDims.isEmpty() || !blacklistedTreeDims.contains(dimID)) { return whitelistedTreeDims.isEmpty() || whitelistedTreeDims.contains(dimID); } return false; @@ -262,24 +265,24 @@ public class Config { generateApatiteOre = configCommon.getBooleanLocalized("world.generate.ore", "apatite", generateApatiteOre); generateCopperOre = configCommon.getBooleanLocalized("world.generate.ore", "copper", generateCopperOre); generateTinOre = configCommon.getBooleanLocalized("world.generate.ore", "tin", generateTinOre); - for(int dimId : configCommon.get("world.generate.ore", "dimBlacklist", new int[0]).getIntList()) { - blacklistedOreDims.add(dimId); + for (int dimId : configCommon.get("world.generate.ore", "dimBlacklist", new int[0]).getIntList()) { + blacklistedOreDims.add(dimId); } - for(int dimId : configCommon.get("world.generate.ore", "dimWhitelist", new int[0]).getIntList()) { + for (int dimId : configCommon.get("world.generate.ore", "dimWhitelist", new int[0]).getIntList()) { whitelistedOreDims.add(dimId); } - + enableVillagers = configCommon.getBooleanLocalized("world.generate", "villagers", enableVillagers); - + generateTrees = configCommon.getBooleanLocalized("world.generate", "trees", generateTrees); - for(int dimId : configCommon.get("world.generate.trees", "dimBlacklist", new int[0]).getIntList()){ - blacklistedTreeDims.add(dimId); + for (int dimId : configCommon.get("world.generate.trees", "dimBlacklist", new int[0]).getIntList()) { + blacklistedTreeDims.add(dimId); } - for(int dimId : configCommon.get("world.generate.trees", "dimWhitelist", new int[0]).getIntList()){ - whitelistedTreeDims.add(dimId); -} - - + for (int dimId : configCommon.get("world.generate.trees", "dimWhitelist", new int[0]).getIntList()) { + whitelistedTreeDims.add(dimId); + } + + craftingBronzeEnabled = configCommon.getBooleanLocalized("crafting", "bronze", craftingBronzeEnabled); craftingStampsEnabled = configCommon.getBooleanLocalized("crafting.stamps", "enabled", true); @@ -327,7 +330,8 @@ public class Config { ringFarms = configCommon.getBooleanLocalized("tweaks.cultivation", "ring", ringFarms); ringSize = configCommon.getIntLocalized("tweaks.cultivation", "ring_size", ringSize, 1, 8); - CapsuleFluidPickup = configCommon.getBooleanLocalized("tweaks", "capsule", CapsuleFluidPickup); + CapsuleFluidPickup = configCommon.getBooleanLocalized("tweaks.capsule", "capsulePickup", CapsuleFluidPickup); + nonConsumableCapsules = configCommon.getBooleanLocalized("tweaks.capsule", "capsuleReuseable", nonConsumableCapsules); climateSourceRange = configCommon.getIntLocalized("tweaks.greenhouse", "range", climateSourceRange, 9, 270); climateSourceEnergyModifier = configCommon.getFloatLocalized("tweaks.greenhouse", "energy", climateSourceEnergyModifier, 0.0F, 15.0F); diff --git a/src/main/java/forestry/core/items/FluidHandlerItemForestry.java b/src/main/java/forestry/core/items/FluidHandlerItemForestry.java index f61f79f5b..7c63f4baa 100644 --- a/src/main/java/forestry/core/items/FluidHandlerItemForestry.java +++ b/src/main/java/forestry/core/items/FluidHandlerItemForestry.java @@ -1,10 +1,13 @@ package forestry.core.items; import net.minecraft.item.ItemStack; + import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.capability.templates.FluidHandlerItemStackSimple; +import forestry.core.config.Config; + public class FluidHandlerItemForestry extends FluidHandlerItemStackSimple.Consumable { private final EnumContainerType containerType; @@ -42,5 +45,14 @@ public class FluidHandlerItemForestry extends FluidHandlerItemStackSimple.Consum super.setFluid(fluid); container.setItemDamage(1); // show the filled container model } + + @Override + protected void setContainerToEmpty() { + if (Config.nonConsumableCapsules) { //default behaviour of FluidHandlerItemStack + container.getTagCompound().removeTag(FLUID_NBT_KEY); + } else { + super.setContainerToEmpty(); + } + } } From 38447d4d134286e4f19aa220c9d16ebe3a7471f3 Mon Sep 17 00:00:00 2001 From: temp1011 <34900092+temp1011@users.noreply.github.com> Date: Fri, 27 Apr 2018 12:51:41 +0100 Subject: [PATCH 7/7] Start removing metadata from code in preparation for 1.13 (#2068) --- .../apiculture/blocks/BlockCandle.java | 4 +- .../apiculture/blocks/BlockStump.java | 5 +- .../core/network/packets/PacketFXSignal.java | 13 ++-- .../core/worldgen/WorldGenerator.java | 9 +-- .../farmables/FarmableRusticSapling.java | 5 +- .../forestry/farming/tiles/TileFarmPlain.java | 7 ++- .../items/ItemButterflyGE.java | 59 +++++++++---------- 7 files changed, 52 insertions(+), 50 deletions(-) diff --git a/src/main/java/forestry/apiculture/blocks/BlockCandle.java b/src/main/java/forestry/apiculture/blocks/BlockCandle.java index 75a71873a..77dd30c7b 100755 --- a/src/main/java/forestry/apiculture/blocks/BlockCandle.java +++ b/src/main/java/forestry/apiculture/blocks/BlockCandle.java @@ -63,9 +63,9 @@ public class BlockCandle extends BlockTorch implements IItemModelRegister, ITile public static final Set lightingItems; public static final String colourTagName = "colour"; - private static final PropertyEnum STATE = PropertyEnum.create("state", State.class); + public static final PropertyEnum STATE = PropertyEnum.create("state", State.class); - private enum State implements IStringSerializable { + enum State implements IStringSerializable { ON("on"), OFF("off"); private final String name; diff --git a/src/main/java/forestry/apiculture/blocks/BlockStump.java b/src/main/java/forestry/apiculture/blocks/BlockStump.java index bdf6d4213..871206b79 100755 --- a/src/main/java/forestry/apiculture/blocks/BlockStump.java +++ b/src/main/java/forestry/apiculture/blocks/BlockStump.java @@ -12,7 +12,6 @@ package forestry.apiculture.blocks; import java.util.Random; -import net.minecraft.block.Block; import net.minecraft.block.BlockTorch; import net.minecraft.block.SoundType; import net.minecraft.block.state.IBlockState; @@ -59,9 +58,7 @@ public class BlockStump extends BlockTorch implements IItemModelRegister { public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { ItemStack heldItem = playerIn.getHeldItem(hand); if (BlockCandle.lightingItems.contains(heldItem.getItem())) { - IBlockState blockState = worldIn.getBlockState(pos); - Block block = blockState.getBlock(); - IBlockState activatedState = ModuleApiculture.getBlocks().candle.getStateFromMeta(block.getMetaFromState(blockState)); + IBlockState activatedState = ModuleApiculture.getBlocks().candle.getDefaultState().withProperty(BlockCandle.STATE, BlockCandle.State.ON); worldIn.setBlockState(pos, activatedState, Constants.FLAG_BLOCK_SYNC); TileCandle tc = new TileCandle(); tc.setColour(16777215); // default to white diff --git a/src/main/java/forestry/core/network/packets/PacketFXSignal.java b/src/main/java/forestry/core/network/packets/PacketFXSignal.java index d8d081741..6861af0d7 100644 --- a/src/main/java/forestry/core/network/packets/PacketFXSignal.java +++ b/src/main/java/forestry/core/network/packets/PacketFXSignal.java @@ -22,6 +22,8 @@ import net.minecraft.block.SoundType; import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTUtil; import net.minecraft.util.SoundCategory; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; @@ -63,9 +65,9 @@ public class PacketFXSignal extends ForestryPacket implements IForestryPacketCli data.writeBlockPos(pos); data.writeByte(visualFX.ordinal()); data.writeByte(soundFX.ordinal()); - Block block = blockState.getBlock(); - data.writeVarInt(Block.getIdFromBlock(block)); - data.writeVarInt(block.getMetaFromState(blockState)); + NBTTagCompound tag = new NBTTagCompound(); + NBTUtil.writeBlockState(tag, blockState); + data.writeCompoundTag(tag); } @Override @@ -80,10 +82,9 @@ public class PacketFXSignal extends ForestryPacket implements IForestryPacketCli BlockPos pos = data.readBlockPos(); VisualFXType visualFX = VisualFXType.values()[data.readByte()]; SoundFXType soundFX = SoundFXType.values()[data.readByte()]; - Block block = Block.getBlockById(data.readVarInt()); - IBlockState blockState = block.getStateFromMeta(data.readVarInt()); - World world = player.world; + IBlockState blockState = NBTUtil.readBlockState(data.readCompoundTag()); + Block block = blockState.getBlock(); if (visualFX == VisualFXType.BLOCK_BREAK) { Minecraft.getMinecraft().effectRenderer.addBlockDestroyEffects(pos, blockState); diff --git a/src/main/java/forestry/core/worldgen/WorldGenerator.java b/src/main/java/forestry/core/worldgen/WorldGenerator.java index 0b359920a..77aee2748 100755 --- a/src/main/java/forestry/core/worldgen/WorldGenerator.java +++ b/src/main/java/forestry/core/worldgen/WorldGenerator.java @@ -68,15 +68,16 @@ public class WorldGenerator implements IWorldGenerator { } private void generateWorld(Random random, int chunkX, int chunkZ, World world) { - if(!Config.isValidOreDim(world.provider.getDimension())) + if (!Config.isValidOreDim(world.provider.getDimension())) { return; + } if (apatiteGenerator == null || copperGenerator == null || tinGenerator == null) { BlockResourceOre resourcesBlock = ModuleCore.getBlocks().resources; - IBlockState apatiteBlockState = resourcesBlock.getStateFromMeta(EnumResourceType.APATITE.getMeta()); - IBlockState copperBlockState = resourcesBlock.getStateFromMeta(EnumResourceType.COPPER.getMeta()); - IBlockState tinBlockState = resourcesBlock.getStateFromMeta(EnumResourceType.TIN.getMeta()); + IBlockState apatiteBlockState = resourcesBlock.getDefaultState().withProperty(BlockResourceOre.ORE_RESOURCES, EnumResourceType.APATITE); + IBlockState copperBlockState = resourcesBlock.getDefaultState().withProperty(BlockResourceOre.ORE_RESOURCES, EnumResourceType.COPPER); + IBlockState tinBlockState = resourcesBlock.getDefaultState().withProperty(BlockResourceOre.ORE_RESOURCES, EnumResourceType.TIN); apatiteGenerator = new WorldGenMinable(apatiteBlockState, 36); copperGenerator = new WorldGenMinable(copperBlockState, 6); tinGenerator = new WorldGenMinable(tinBlockState, 6); diff --git a/src/main/java/forestry/farming/logic/farmables/FarmableRusticSapling.java b/src/main/java/forestry/farming/logic/farmables/FarmableRusticSapling.java index 53e3ab2a1..b615c47aa 100644 --- a/src/main/java/forestry/farming/logic/farmables/FarmableRusticSapling.java +++ b/src/main/java/forestry/farming/logic/farmables/FarmableRusticSapling.java @@ -28,8 +28,9 @@ public class FarmableRusticSapling implements IFarmable { @Override public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, BlockPos pos) { - if (world.setBlockState(pos, germlingBlock.getStateFromMeta(germling.getItemDamage()))) { - PacketFXSignal packet = new PacketFXSignal(PacketFXSignal.SoundFXType.BLOCK_PLACE, pos, germlingBlock.getStateFromMeta(germling.getItemDamage())); + IBlockState blockState = germlingBlock.getStateFromMeta(germling.getItemDamage()); //TODO - stop using meta here + if (world.setBlockState(pos, blockState)) { + PacketFXSignal packet = new PacketFXSignal(PacketFXSignal.SoundFXType.BLOCK_PLACE, pos, blockState); NetworkUtil.sendNetworkPacket(packet, pos, world); return true; } diff --git a/src/main/java/forestry/farming/tiles/TileFarmPlain.java b/src/main/java/forestry/farming/tiles/TileFarmPlain.java index c78536c86..7c472febf 100644 --- a/src/main/java/forestry/farming/tiles/TileFarmPlain.java +++ b/src/main/java/forestry/farming/tiles/TileFarmPlain.java @@ -10,9 +10,12 @@ ******************************************************************************/ package forestry.farming.tiles; -import forestry.api.multiblock.IMultiblockController; import net.minecraft.util.math.BlockPos; +import forestry.api.multiblock.IMultiblockController; +import forestry.farming.blocks.BlockFarm; +import forestry.farming.blocks.EnumFarmBlockType; + public class TileFarmPlain extends TileFarm { @Override public void onMachineAssembled(IMultiblockController multiblockController, BlockPos minCoord, BlockPos maxCoord) { @@ -21,7 +24,7 @@ public class TileFarmPlain extends TileFarm { // set band block meta int bandY = maxCoord.getY() - 1; if (getPos().getY() == bandY) { - this.world.setBlockState(getPos(), getBlockType().getStateFromMeta(1), 2); + this.world.setBlockState(getPos(), getBlockType().getDefaultState().withProperty(BlockFarm.META, EnumFarmBlockType.BAND), 2); } } diff --git a/src/main/java/forestry/lepidopterology/items/ItemButterflyGE.java b/src/main/java/forestry/lepidopterology/items/ItemButterflyGE.java index 1ea5a4603..775a5bb58 100755 --- a/src/main/java/forestry/lepidopterology/items/ItemButterflyGE.java +++ b/src/main/java/forestry/lepidopterology/items/ItemButterflyGE.java @@ -133,7 +133,7 @@ public class ItemButterflyGE extends ItemGE implements ISpriteRegister, IColored if (rand.nextInt(24) != 0) { return false; } - + IButterfly butterfly = ButterflyManager.butterflyRoot.getMember(entityItem.getItem()); if (butterfly == null) { return false; @@ -163,25 +163,25 @@ public class ItemButterflyGE extends ItemGE implements ISpriteRegister, IColored @Override public void registerModel(Item item, IModelManager manager) { switch (this.type) { - case CATERPILLAR: - manager.registerItemModel(item, 0, "caterpillar"); - break; - case BUTTERFLY: - manager.registerItemModel(item, 0, "butterflyGE"); - break; - case COCOON: - manager.registerItemModel(item, new CocoonMeshDefinition()); - for (IAllele allele : AlleleManager.alleleRegistry.getRegisteredAlleles().values()) { - if (allele instanceof IAlleleButterflyCocoon) { - for (int age = 0; age < 3; age++) { - ModelBakery.registerItemVariants(this, - ((IAlleleButterflyCocoon) allele).getCocoonItemModel(age)); + case CATERPILLAR: + manager.registerItemModel(item, 0, "caterpillar"); + break; + case BUTTERFLY: + manager.registerItemModel(item, 0, "butterflyGE"); + break; + case COCOON: + manager.registerItemModel(item, new CocoonMeshDefinition()); + for (IAllele allele : AlleleManager.alleleRegistry.getRegisteredAlleles().values()) { + if (allele instanceof IAlleleButterflyCocoon) { + for (int age = 0; age < 3; age++) { + ModelBakery.registerItemVariants(this, + ((IAlleleButterflyCocoon) allele).getCocoonItemModel(age)); + } } } - } - break; - default: - manager.registerItemModel(item, 0, "liquids/jar"); + break; + default: + manager.registerItemModel(item, 0, "liquids/jar"); } } @@ -191,10 +191,10 @@ public class ItemButterflyGE extends ItemGE implements ISpriteRegister, IColored NBTTagCompound tagCompound = itemstack.getTagCompound(); IButterflyGenome genome; int age; - if(tagCompound == null){ + if (tagCompound == null) { genome = ButterflyDefinition.CabbageWhite.getGenome(); age = 0; - }else { + } else { if (!tagCompound.hasKey(NBT_AGE)) { tagCompound.setInteger(NBT_AGE, 0); } @@ -223,8 +223,7 @@ public class ItemButterflyGE extends ItemGE implements ISpriteRegister, IColored if (type == EnumFlutterType.COCOON) { pos = ButterflyManager.butterflyRoot.plantCocoon(world, pos, flutter, player.getGameProfile(), getAge(stack), true); if (pos != BlockPos.ORIGIN) { - PacketFXSignal packet = new PacketFXSignal(PacketFXSignal.SoundFXType.BLOCK_PLACE, pos, - world.getBlockState(pos)); + PacketFXSignal packet = new PacketFXSignal(PacketFXSignal.SoundFXType.BLOCK_PLACE, pos, blockState); NetworkUtil.sendNetworkPacket(packet, pos, world); if (!player.capabilities.isCreativeMode) { @@ -257,30 +256,30 @@ public class ItemButterflyGE extends ItemGE implements ISpriteRegister, IColored return EnumActionResult.PASS; } } - - public static void setAge(ItemStack cocoon, int age){ - if(cocoon.isEmpty()){ + + public static void setAge(ItemStack cocoon, int age) { + if (cocoon.isEmpty()) { return; } if (ButterflyManager.butterflyRoot.getType(cocoon) != EnumFlutterType.COCOON) { return; } NBTTagCompound tagCompound = cocoon.getTagCompound(); - if(tagCompound == null){ + if (tagCompound == null) { cocoon.setTagCompound(tagCompound = new NBTTagCompound()); } tagCompound.setInteger(NBT_AGE, age); } - - public static int getAge(ItemStack cocoon){ - if(cocoon.isEmpty()){ + + public static int getAge(ItemStack cocoon) { + if (cocoon.isEmpty()) { return 0; } if (ButterflyManager.butterflyRoot.getType(cocoon) != EnumFlutterType.COCOON) { return 0; } NBTTagCompound tagCompound = cocoon.getTagCompound(); - if(tagCompound == null){ + if (tagCompound == null) { return 0; } return tagCompound.getInteger(NBT_AGE);