mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-28 07:35:47 +00:00
Merge remote-tracking branch 'origin/mc-1.12' into dev
This commit is contained in:
commit
cd8e78f60a
11 files changed
+160
-37
No files matched your search
@@ -68,7 +68,7 @@ import forestry.plugins.PluginTechReborn;
|
||||
version = Constants.VERSION,
|
||||
guiFactory = "forestry.core.config.ForestryGuiConfigFactory",
|
||||
acceptedMinecraftVersions = "[1.12.2,1.13.0)",
|
||||
dependencies = "required-after:forge@[14.23.2.2637,);"
|
||||
dependencies = "required-after:forge@[14.23.2.2643,);"
|
||||
+ "after:jei@[4.7.8.91,);"
|
||||
+ "after:" + PluginIC2.MOD_ID + ";"
|
||||
+ "after:" + PluginNatura.MOD_ID + ";"
|
||||
|
||||
@@ -27,4 +27,12 @@ public interface ICrateRegistry {
|
||||
|
||||
void registerCrate(String oreDictName);
|
||||
|
||||
/**
|
||||
* prevent a crate from being registered
|
||||
* @param stack the ItemStack to blacklist
|
||||
*/
|
||||
default void blacklistCrate(ItemStack stack) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -52,7 +52,6 @@ import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.registries.IForgeRegistry;
|
||||
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.fml.common.event.FMLInterModComms.IMCMessage;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
||||
@@ -933,7 +932,7 @@ public class ModuleApiculture extends BlankForestryModule {
|
||||
continue;
|
||||
}
|
||||
|
||||
FMLCommonHandler.instance().getFMLLogger().debug("Blacklisting bee species identified by " + item);
|
||||
Log.debug("Blacklisting bee species identified by " + item);
|
||||
AlleleManager.alleleRegistry.blacklistAllele(item);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@ import net.minecraft.world.World;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@@ -59,6 +58,7 @@ import forestry.apiculture.BeekeepingLogic;
|
||||
import forestry.apiculture.ModuleApiculture;
|
||||
import forestry.apiculture.items.ItemRegistryApiculture;
|
||||
import forestry.core.genetics.SpeciesRoot;
|
||||
import forestry.core.utils.Log;
|
||||
|
||||
public class BeeRoot extends SpeciesRoot implements IBeeRoot {
|
||||
|
||||
@@ -183,7 +183,7 @@ public class BeeRoot extends SpeciesRoot implements IBeeRoot {
|
||||
|
||||
@Override
|
||||
public ISpeciesType getTypeForMutation(int position) {
|
||||
switch (position){
|
||||
switch (position) {
|
||||
case 0:
|
||||
return EnumBeeType.PRINCESS;
|
||||
case 1:
|
||||
@@ -323,7 +323,7 @@ public class BeeRoot extends SpeciesRoot implements IBeeRoot {
|
||||
Preconditions.checkNotNull(mode);
|
||||
|
||||
setBeekeepingMode(world, mode);
|
||||
FMLCommonHandler.instance().getFMLLogger().debug("Set beekeeping mode for a world to " + mode);
|
||||
Log.debug("Set beekeeping mode for a world to " + mode);
|
||||
|
||||
return activeBeekeepingMode;
|
||||
}
|
||||
@@ -349,7 +349,7 @@ public class BeeRoot extends SpeciesRoot implements IBeeRoot {
|
||||
}
|
||||
}
|
||||
|
||||
FMLCommonHandler.instance().getFMLLogger().debug("Failed to find a beekeeping mode called '%s', reverting to fallback.");
|
||||
Log.debug("Failed to find a beekeeping mode called '%s', reverting to fallback.");
|
||||
return beekeepingModes.get(0);
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,6 @@ import com.mojang.authlib.GameProfile;
|
||||
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@@ -77,6 +76,7 @@ import forestry.core.genetics.SpeciesRoot;
|
||||
import forestry.core.network.packets.PacketFXSignal;
|
||||
import forestry.core.tiles.TileUtil;
|
||||
import forestry.core.utils.BlockUtil;
|
||||
import forestry.core.utils.Log;
|
||||
import forestry.core.utils.NetworkUtil;
|
||||
|
||||
public class TreeRoot extends SpeciesRoot implements ITreeRoot {
|
||||
@@ -338,7 +338,7 @@ public class TreeRoot extends SpeciesRoot implements ITreeRoot {
|
||||
ITreekeepingMode mode = getTreekeepingMode(modeName);
|
||||
Preconditions.checkNotNull(mode);
|
||||
setTreekeepingMode(world, mode);
|
||||
FMLCommonHandler.instance().getFMLLogger().debug("Set Treekeeping mode for a world to " + mode);
|
||||
Log.debug("Set Treekeeping mode for a world to " + mode);
|
||||
|
||||
return activeTreekeepingMode;
|
||||
}
|
||||
@@ -362,7 +362,7 @@ public class TreeRoot extends SpeciesRoot implements ITreeRoot {
|
||||
}
|
||||
}
|
||||
|
||||
FMLCommonHandler.instance().getFMLLogger().debug("Failed to find a Treekeeping mode called '%s', reverting to fallback.");
|
||||
Log.debug("Failed to find a Treekeeping mode called '%s', reverting to fallback.");
|
||||
return treekeepingModes.get(0);
|
||||
}
|
||||
|
||||
|
||||
@@ -214,7 +214,7 @@ public class ModuleFarming extends BlankForestryModule {
|
||||
Circuits.farmShroomManual = new CircuitFarmLogic("manualShroom", mushroomFarm, true);
|
||||
mushroomFarm.registerSoil(new ItemStack(Blocks.MYCELIUM), Blocks.MYCELIUM.getDefaultState());
|
||||
mushroomFarm.registerSoil(new ItemStack(Blocks.DIRT, 1, 2),
|
||||
Blocks.DIRT.getDefaultState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.PODZOL), true);
|
||||
Blocks.DIRT.getDefaultState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.PODZOL), true);
|
||||
|
||||
Circuits.farmPeatManaged = new CircuitFarmLogic("managedPeat", peatFarm, false);
|
||||
Circuits.farmPeatManual = new CircuitFarmLogic("manualPeat", peatFarm, true);
|
||||
@@ -234,12 +234,12 @@ public class ModuleFarming extends BlankForestryModule {
|
||||
|
||||
Circuits.farmSucculentManaged = new CircuitFarmLogic("managedSucculent", succulentFarm, false);
|
||||
Circuits.farmSucculentManual = new CircuitFarmLogic("manualSucculent", succulentFarm, true);
|
||||
succulentFarm.registerSoil(new ItemStack(Blocks.SAND), Blocks.SAND.getDefaultState(),true);
|
||||
succulentFarm.registerSoil(new ItemStack(Blocks.SAND), Blocks.SAND.getDefaultState(), true);
|
||||
|
||||
Circuits.farmPoalesManaged = new CircuitFarmLogic("managedPoales", poalesFarm, false);
|
||||
Circuits.farmPoalesManual = new CircuitFarmLogic("manualPoales", poalesFarm, true);
|
||||
poalesFarm.registerSoil(new ItemStack(Blocks.SAND), Blocks.SAND.getDefaultState(),true);
|
||||
poalesFarm.registerSoil(new ItemStack(Blocks.DIRT), Blocks.DIRT.getDefaultState(),false);
|
||||
poalesFarm.registerSoil(new ItemStack(Blocks.SAND), Blocks.SAND.getDefaultState(), true);
|
||||
poalesFarm.registerSoil(new ItemStack(Blocks.DIRT), Blocks.DIRT.getDefaultState(), false);
|
||||
|
||||
Circuits.farmGourdManaged = new CircuitFarmLogic("managedGourd", gourdFarm, false);
|
||||
Circuits.farmGourdManual = new CircuitFarmLogic("manualGourd", gourdFarm, true);
|
||||
@@ -318,7 +318,7 @@ public class ModuleFarming extends BlankForestryModule {
|
||||
ChipsetManager.circuitRegistry.registerDeprecatedCircuitReplacement("managedVegetable", Circuits.farmCropsManaged);
|
||||
ChipsetManager.circuitRegistry.registerDeprecatedCircuitReplacement("manualVegetable", Circuits.farmCropsManual);
|
||||
|
||||
if(layoutManaged == null || layoutManual == null){
|
||||
if (layoutManaged == null || layoutManual == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
package forestry.storage;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collection;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
@@ -61,6 +62,9 @@ public class CrateRegistry implements ICrateRegistry {
|
||||
|
||||
@Override
|
||||
public void registerCrate(String oreDictName) {
|
||||
if (ModuleCrates.cratesRejectedOreDict.contains(oreDictName)) {
|
||||
return;
|
||||
}
|
||||
if (OreDictionary.doesOreNameExist(oreDictName)) {
|
||||
for (ItemStack stack : OreDictionary.getOres(oreDictName)) {
|
||||
if (stack != null) {
|
||||
@@ -83,6 +87,17 @@ public class CrateRegistry implements ICrateRegistry {
|
||||
|
||||
@Override
|
||||
public void registerCrate(ItemStack stack) {
|
||||
Collection<ItemStack> testStacks = ModuleCrates.cratesRejectedItem.get(stack.getItem());
|
||||
for (ItemStack testStack : testStacks) {
|
||||
if (ItemStackUtil.areItemStacksEqualIgnoreCount(stack, testStack)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
registerCrate(stack, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void blacklistCrate(ItemStack stack) {
|
||||
ModuleCrates.cratesRejectedItem.put(stack.getItem(), stack);
|
||||
}
|
||||
}
|
||||
@@ -140,7 +140,6 @@ public class ModuleBackpacks extends BlankForestryModule {
|
||||
|
||||
@Override
|
||||
public void preInit() {
|
||||
registerFenceAndFenceGatesToOreDict();
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
@@ -386,22 +385,6 @@ public class ModuleBackpacks extends BlankForestryModule {
|
||||
backpackAcceptedItemDefaults.putAll(backpackInterface.getBackpackAcceptedItems());
|
||||
}
|
||||
|
||||
// Should be ore dicted in Forge at some point.
|
||||
private static void registerFenceAndFenceGatesToOreDict() {
|
||||
OreDictionary.registerOre(OreDictUtil.FENCE_WOOD, Blocks.OAK_FENCE);
|
||||
OreDictionary.registerOre(OreDictUtil.FENCE_WOOD, Blocks.SPRUCE_FENCE);
|
||||
OreDictionary.registerOre(OreDictUtil.FENCE_WOOD, Blocks.BIRCH_FENCE);
|
||||
OreDictionary.registerOre(OreDictUtil.FENCE_WOOD, Blocks.JUNGLE_FENCE);
|
||||
OreDictionary.registerOre(OreDictUtil.FENCE_WOOD, Blocks.DARK_OAK_FENCE);
|
||||
OreDictionary.registerOre(OreDictUtil.FENCE_WOOD, Blocks.ACACIA_FENCE);
|
||||
OreDictionary.registerOre(OreDictUtil.FENCE_GATE_WOOD, Blocks.OAK_FENCE_GATE);
|
||||
OreDictionary.registerOre(OreDictUtil.FENCE_GATE_WOOD, Blocks.SPRUCE_FENCE_GATE);
|
||||
OreDictionary.registerOre(OreDictUtil.FENCE_GATE_WOOD, Blocks.BIRCH_FENCE_GATE);
|
||||
OreDictionary.registerOre(OreDictUtil.FENCE_GATE_WOOD, Blocks.JUNGLE_FENCE_GATE);
|
||||
OreDictionary.registerOre(OreDictUtil.FENCE_GATE_WOOD, Blocks.DARK_OAK_FENCE_GATE);
|
||||
OreDictionary.registerOre(OreDictUtil.FENCE_GATE_WOOD, Blocks.ACACIA_FENCE_GATE);
|
||||
}
|
||||
|
||||
private static List<String> getItemStrings(List<ItemStack> itemStacks) {
|
||||
List<String> itemStrings = new ArrayList<>(itemStacks.size());
|
||||
for (ItemStack itemStack : itemStacks) {
|
||||
@@ -464,7 +447,7 @@ public class ModuleBackpacks extends BlankForestryModule {
|
||||
|
||||
// accepted oreDict
|
||||
{
|
||||
String[] defaultOreRegexpNames =new String[0];
|
||||
String[] defaultOreRegexpNames = new String[0];
|
||||
List<String> defaultOreRegexpList = backpackAcceptedOreDictRegexpDefaults.get(backpackUid);
|
||||
if (defaultOreRegexpList != null) {
|
||||
Collections.sort(defaultOreRegexpList);
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
package forestry.storage;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
@@ -16,16 +20,23 @@ import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import net.minecraftforge.fml.common.SidedProxy;
|
||||
import net.minecraftforge.fml.common.event.FMLInterModComms;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.Forestry;
|
||||
import forestry.api.modules.ForestryModule;
|
||||
import forestry.api.recipes.RecipeManagers;
|
||||
import forestry.api.storage.StorageManager;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.config.LocalizedConfiguration;
|
||||
import forestry.core.utils.IMCUtil;
|
||||
import forestry.core.utils.ItemStackUtil;
|
||||
import forestry.core.utils.Log;
|
||||
import forestry.modules.BlankForestryModule;
|
||||
import forestry.modules.ForestryModuleUids;
|
||||
import forestry.modules.ModuleHelper;
|
||||
@@ -37,6 +48,11 @@ import forestry.storage.proxy.ProxyStorage;
|
||||
@ForestryModule(moduleID = ForestryModuleUids.CRATE, containerID = Constants.MOD_ID, name = "Crate", author = "SirSengir", url = Constants.URL, unlocalizedDescription = "for.module.crates.description")
|
||||
public class ModuleCrates extends BlankForestryModule {
|
||||
|
||||
private static final String CONFIG_CATEGORY = "crates";
|
||||
|
||||
public static final List<String> cratesRejectedOreDict = new ArrayList<>();
|
||||
public static Multimap<Item, ItemStack> cratesRejectedItem = HashMultimap.create();
|
||||
|
||||
private static final List<ItemCrated> crates = new ArrayList<>();
|
||||
|
||||
@SuppressWarnings("NullableProblems")
|
||||
@@ -65,6 +81,103 @@ public class ModuleCrates extends BlankForestryModule {
|
||||
@Override
|
||||
public void preInit() {
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
final String newConfig = CONFIG_CATEGORY + ".cfg";
|
||||
|
||||
File configFile = new File(Forestry.instance.getConfigFolder(), newConfig);
|
||||
LocalizedConfiguration config = new LocalizedConfiguration(configFile, "1.0.0");
|
||||
if (!config.getDefinedConfigVersion().equals(config.getLoadedConfigVersion())) {
|
||||
boolean deleted = configFile.delete();
|
||||
if (deleted) {
|
||||
config = new LocalizedConfiguration(configFile, "1.0.0");
|
||||
}
|
||||
}
|
||||
|
||||
handleConfig(config);
|
||||
|
||||
config.save();
|
||||
}
|
||||
|
||||
private void handleConfig(LocalizedConfiguration config) {
|
||||
|
||||
// accepted items
|
||||
{
|
||||
String[] crateItemList = config.getStringListLocalized("crates.items", "accepted", Constants.EMPTY_STRINGS);
|
||||
List<ItemStack> crateItems = ItemStackUtil.parseItemStackStrings(crateItemList, OreDictionary.WILDCARD_VALUE);
|
||||
for (ItemStack crateItem : crateItems) {
|
||||
StorageManager.crateRegistry.registerCrate(crateItem);
|
||||
}
|
||||
}
|
||||
|
||||
// rejected items
|
||||
{
|
||||
String[] crateItemList = config.getStringListLocalized("crates.items", "rejected", Constants.EMPTY_STRINGS);
|
||||
for (ItemStack stack : ItemStackUtil.parseItemStackStrings(crateItemList, OreDictionary.WILDCARD_VALUE)) {
|
||||
cratesRejectedItem.put(stack.getItem(), stack);
|
||||
}
|
||||
}
|
||||
|
||||
// accepted oreDict
|
||||
{
|
||||
String[] crateOreDictList = config.getStringListLocalized("crates.oredict", "accepted", Constants.EMPTY_STRINGS);
|
||||
|
||||
for (String name : OreDictionary.getOreNames()) {
|
||||
if (name == null) {
|
||||
Log.error("Found a null oreName in the ore dictionary");
|
||||
} else {
|
||||
for (String regex : crateOreDictList) {
|
||||
if (name.matches(regex)) {
|
||||
StorageManager.crateRegistry.registerCrate(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// rejected oreDict
|
||||
{
|
||||
String[] crateOreDictList = config.getStringListLocalized("crates.oredict", "rejected", Constants.EMPTY_STRINGS);
|
||||
|
||||
for (String name : OreDictionary.getOreNames()) {
|
||||
if (name == null) {
|
||||
Log.error("Found a null oreName in the ore dictionary");
|
||||
} else {
|
||||
for (String regex : crateOreDictList) {
|
||||
if (name.matches(regex)) {
|
||||
cratesRejectedOreDict.add(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean processIMCMessage(FMLInterModComms.IMCMessage message) {
|
||||
if (message.key.equals("add-crate-items")) {
|
||||
ItemStack value = message.getItemStackValue();
|
||||
if (value != null) {
|
||||
StorageManager.crateRegistry.registerCrate(value);
|
||||
} else {
|
||||
IMCUtil.logInvalidIMCMessage(message);
|
||||
}
|
||||
return true;
|
||||
} else if (message.key.equals("add-crate-oredict")) {
|
||||
String value = message.getStringValue();
|
||||
StorageManager.crateRegistry.registerCrate(value);
|
||||
return true;
|
||||
} else if (message.key.equals("blacklist-crate-item")) {
|
||||
ItemStack value = message.getItemStackValue();
|
||||
if (value != null) {
|
||||
cratesRejectedItem.put(value.getItem(), value);
|
||||
} else {
|
||||
IMCUtil.logInvalidIMCMessage(message);
|
||||
}
|
||||
return true;
|
||||
} else if (message.key.equals("blacklist-crate-oredict")) {
|
||||
cratesRejectedOreDict.add(message.getStringValue());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -80,7 +193,7 @@ public class ModuleCrates extends BlankForestryModule {
|
||||
if (ModuleHelper.isEnabled(ForestryModuleUids.FACTORY)) {
|
||||
// / CRATES
|
||||
RecipeManagers.carpenterManager.addRecipe(20, new FluidStack(FluidRegistry.WATER, Fluid.BUCKET_VOLUME), ItemStack.EMPTY, items.crate.getItemStack(24),
|
||||
" # ", "# #", " # ", '#', "logWood");
|
||||
" # ", "# #", " # ", '#', "logWood");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user