mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-19 19:49:54 +00:00
Clean up backpack API
This commit is contained in:
1 parent
039af049aa
commit
2d4c180389
24 files changed
+153
-180
No files matched your search
@@ -5,23 +5,13 @@
|
||||
******************************************************************************/
|
||||
package forestry.api.storage;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class BackpackManager {
|
||||
/**
|
||||
* 0 - Miner's Backpack 1 - Digger's Backpack 2 - Forester's Backpack 3 - Hunter's Backpack 4 - Adventurer's Backpack
|
||||
*
|
||||
* Use IMC messages to achieve the same effect!
|
||||
*/
|
||||
public static ArrayList<ItemStack>[] backpackItems;
|
||||
public static final String MINER_UID = "forestry.miner";
|
||||
public static final String DIGGER_UID = "forestry.digger";
|
||||
public static final String FORESTER_UID = "forestry.forester";
|
||||
public static final String ADVENTURER_UID = "forestry.adventurer";
|
||||
public static final String BUILDER_UID = "forestry.builder";
|
||||
public static final String HUNTER_UID = "forestry.hunter";
|
||||
|
||||
public static IBackpackInterface backpackInterface;
|
||||
|
||||
/**
|
||||
* Only use this if you know what you are doing. Prefer backpackInterface.
|
||||
*/
|
||||
public static HashMap<String, IBackpackDefinition> definitions = new HashMap<>();
|
||||
}
|
||||
@@ -6,5 +6,5 @@
|
||||
package forestry.api.storage;
|
||||
|
||||
public enum EnumBackpackType {
|
||||
APIARIST, T1, T2
|
||||
NORMAL, WOVEN, NATURALIST
|
||||
}
|
||||
@@ -11,11 +11,6 @@ import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IBackpackDefinition {
|
||||
|
||||
/**
|
||||
* @return A unique string identifier
|
||||
*/
|
||||
String getKey();
|
||||
|
||||
/**
|
||||
* @return Human-readable name of the backpack.
|
||||
*/
|
||||
|
||||
@@ -5,9 +5,23 @@
|
||||
******************************************************************************/
|
||||
package forestry.api.storage;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
public interface IBackpackInterface {
|
||||
/**
|
||||
* Get a backpack with a given uid so you can add items to it or get information about it.
|
||||
* returns null if there is no backpack for the given uid.
|
||||
*/
|
||||
@Nullable
|
||||
IBackpackDefinition getBackpack(@Nonnull String uid);
|
||||
|
||||
/**
|
||||
* Register a backpack with a given uid
|
||||
*/
|
||||
void registerBackpack(@Nonnull String uid, @Nonnull IBackpackDefinition definition);
|
||||
|
||||
/**
|
||||
* Adds a backpack with the given definition and type, returning the item.
|
||||
@@ -15,8 +29,10 @@ public interface IBackpackInterface {
|
||||
* @param definition
|
||||
* Definition of backpack behaviour.
|
||||
* @param type
|
||||
* Type of backpack. (T1 or T2 (= Woven)
|
||||
* Type of backpack.
|
||||
* @return Created backpack item.
|
||||
*/
|
||||
Item addBackpack(IBackpackDefinition definition, EnumBackpackType type);
|
||||
@Nonnull
|
||||
Item createBackpack(@Nonnull IBackpackDefinition definition, @Nonnull EnumBackpackType type);
|
||||
|
||||
}
|
||||
@@ -54,7 +54,7 @@ public class Constants implements IForestryConstants {
|
||||
// Item Ids
|
||||
|
||||
public static final int SLOTS_BACKPACK_DEFAULT = 15;
|
||||
public static final int SLOTS_BACKPACK_T2 = 45;
|
||||
public static final int SLOTS_BACKPACK_WOVEN = 45;
|
||||
public static final int SLOTS_BACKPACK_APIARIST = 125;
|
||||
|
||||
// Food stuff
|
||||
|
||||
@@ -25,7 +25,6 @@ import forestry.core.genetics.BreedingTracker;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.IForestryPacketClient;
|
||||
import forestry.core.network.PacketIdClient;
|
||||
import forestry.core.proxy.Proxies;
|
||||
|
||||
public class PacketGenomeTrackerSync extends PacketNBT implements IForestryPacketClient {
|
||||
|
||||
@@ -42,8 +41,8 @@ public class PacketGenomeTrackerSync extends PacketNBT implements IForestryPacke
|
||||
String type = getTagCompound().getString(BreedingTracker.TYPE_KEY);
|
||||
|
||||
ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(type);
|
||||
if (root != null) {
|
||||
tracker = root.getBreedingTracker(Proxies.common.getRenderWorld(), player.getGameProfile());
|
||||
if (root != null && player != null) {
|
||||
tracker = root.getBreedingTracker(player.getEntityWorld(), player.getGameProfile());
|
||||
}
|
||||
if (tracker != null) {
|
||||
tracker.decodeFromNBT(getTagCompound());
|
||||
|
||||
@@ -208,18 +208,14 @@ public class PluginBiomesOPlenty extends BlankForestryPlugin {
|
||||
public void registerBackpackItems() {
|
||||
// most blocks are covered by the oreDictionary
|
||||
|
||||
final int MINER = 0;
|
||||
final int DIGGER = 1;
|
||||
final int FORESTER = 2;
|
||||
|
||||
addBlocksToBackpack(MINER,
|
||||
addBlocksToBackpack(BackpackManager.MINER_UID,
|
||||
"driedDirt",
|
||||
"overgrownNetherrack",
|
||||
"cragRock",
|
||||
"ashStone"
|
||||
);
|
||||
|
||||
addBlocksToBackpack(DIGGER,
|
||||
addBlocksToBackpack(BackpackManager.DIGGER_UID,
|
||||
"bopGrass",
|
||||
"newBopGrass",
|
||||
"longGrass",
|
||||
@@ -231,17 +227,17 @@ public class PluginBiomesOPlenty extends BlankForestryPlugin {
|
||||
"newBopDirt"
|
||||
);
|
||||
|
||||
addBlocksToBackpack(FORESTER,
|
||||
addBlocksToBackpack(BackpackManager.FORESTER_UID,
|
||||
"petals"
|
||||
);
|
||||
}
|
||||
|
||||
private static void addBlocksToBackpack(int backpackId, String... blockNames) {
|
||||
private static void addBlocksToBackpack(String backpackUid, String... blockNames) {
|
||||
for (String blockName : blockNames) {
|
||||
Block block = GameRegistry.findBlock(BoP, blockName);
|
||||
if (block != null) {
|
||||
ItemStack blockStack = new ItemStack(block, 1, OreDictionary.WILDCARD_VALUE);
|
||||
BackpackManager.backpackItems[backpackId].add(blockStack);
|
||||
BackpackManager.backpackInterface.getBackpack(backpackUid).addValidItem(blockStack);
|
||||
} else {
|
||||
Log.warning("Missing block: ", blockName);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
******************************************************************************/
|
||||
package forestry.storage;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.awt.Color;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@@ -29,8 +31,6 @@ import forestry.core.utils.ItemStackUtil;
|
||||
|
||||
public class BackpackDefinition implements IBackpackDefinition {
|
||||
|
||||
private final String name;
|
||||
|
||||
private final int primaryColor; // - c03384
|
||||
private final int secondaryColor;
|
||||
|
||||
@@ -39,19 +39,13 @@ public class BackpackDefinition implements IBackpackDefinition {
|
||||
private final Set<Class> validItemClasses = new HashSet<>();
|
||||
private final Set<Class> validBlockClasses = new HashSet<>();
|
||||
|
||||
public BackpackDefinition(String name, int primaryColor) {
|
||||
this(name, primaryColor, 0xffffff);
|
||||
public BackpackDefinition(@Nonnull Color primaryColor) {
|
||||
this(primaryColor, new Color(0xffffff));
|
||||
}
|
||||
|
||||
public BackpackDefinition(String name, int primaryColor, int secondaryColor) {
|
||||
this.name = name;
|
||||
this.primaryColor = primaryColor;
|
||||
this.secondaryColor = secondaryColor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getKey() {
|
||||
return name;
|
||||
public BackpackDefinition(@Nonnull Color primaryColor, @Nonnull Color secondaryColor) {
|
||||
this.primaryColor = primaryColor.getRGB();
|
||||
this.secondaryColor = secondaryColor.getRGB();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -114,10 +108,10 @@ public class BackpackDefinition implements IBackpackDefinition {
|
||||
}
|
||||
|
||||
public void addValidOreDictName(String oreDictName) {
|
||||
// if (OreDictionary.doesOreNameExist(oreDictName)) { //TODO: add this back when using a forge version that supports it
|
||||
int oreId = OreDictionary.getOreID(oreDictName);
|
||||
validOreIds.add(oreId);
|
||||
// }
|
||||
if (OreDictionary.doesOreNameExist(oreDictName)) {
|
||||
int oreId = OreDictionary.getOreID(oreDictName);
|
||||
validOreIds.add(oreId);
|
||||
}
|
||||
}
|
||||
|
||||
public void addValidOreDictNames(List<String> oreDictNames) {
|
||||
@@ -220,8 +214,8 @@ public class BackpackDefinition implements IBackpackDefinition {
|
||||
|
||||
public static class BackpackDefinitionApiarist extends BackpackDefinition {
|
||||
|
||||
public BackpackDefinitionApiarist(int primaryColor) {
|
||||
super("apiarist", primaryColor);
|
||||
public BackpackDefinitionApiarist(@Nonnull Color primaryColor) {
|
||||
super(primaryColor);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -232,8 +226,8 @@ public class BackpackDefinition implements IBackpackDefinition {
|
||||
|
||||
public static class BackpackDefinitionLepidopterist extends BackpackDefinition {
|
||||
|
||||
public BackpackDefinitionLepidopterist(int primaryColor) {
|
||||
super("lepidopterist", primaryColor);
|
||||
public BackpackDefinitionLepidopterist(@Nonnull Color primaryColor) {
|
||||
super(primaryColor);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -10,18 +10,38 @@
|
||||
******************************************************************************/
|
||||
package forestry.storage;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
import forestry.api.storage.BackpackManager;
|
||||
import forestry.api.storage.EnumBackpackType;
|
||||
import forestry.api.storage.IBackpackDefinition;
|
||||
import forestry.api.storage.IBackpackInterface;
|
||||
import forestry.storage.items.ItemBackpack;
|
||||
|
||||
public class BackpackInterface implements IBackpackInterface {
|
||||
/**
|
||||
* Only use this if you know what you are doing. Prefer backpackInterface.
|
||||
*/
|
||||
public final Map<String, IBackpackDefinition> definitions = new HashMap<>();
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Item addBackpack(IBackpackDefinition definition, EnumBackpackType type) {
|
||||
BackpackManager.definitions.put(definition.getKey(), definition);
|
||||
public IBackpackDefinition getBackpack(@Nonnull String uid) {
|
||||
return definitions.get(uid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBackpack(@Nonnull String uid, @Nonnull IBackpackDefinition definition) {
|
||||
definitions.put(uid, definition);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Item createBackpack(@Nonnull IBackpackDefinition definition, @Nonnull EnumBackpackType type) {
|
||||
return new ItemBackpack(definition, type);
|
||||
}
|
||||
}
|
||||
@@ -94,13 +94,6 @@ public class PluginStorage extends BlankForestryPlugin {
|
||||
|
||||
private static final List<ItemCrated> crates = new ArrayList<>();
|
||||
private static final String CONFIG_CATEGORY = "backpacks";
|
||||
|
||||
private final ArrayList<ItemStack> minerItems = new ArrayList<>();
|
||||
private final ArrayList<ItemStack> diggerItems = new ArrayList<>();
|
||||
private final ArrayList<ItemStack> foresterItems = new ArrayList<>();
|
||||
private final ArrayList<ItemStack> hunterItems = new ArrayList<>();
|
||||
private final ArrayList<ItemStack> adventurerItems = new ArrayList<>();
|
||||
private final ArrayList<ItemStack> builderItems = new ArrayList<>();
|
||||
|
||||
public static ItemRegistryStorage items;
|
||||
|
||||
@@ -112,56 +105,35 @@ public class PluginStorage extends BlankForestryPlugin {
|
||||
|
||||
BackpackManager.backpackInterface = new BackpackInterface();
|
||||
|
||||
BackpackManager.backpackItems = new ArrayList[6];
|
||||
|
||||
BackpackManager.backpackItems[0] = minerItems;
|
||||
BackpackManager.backpackItems[1] = diggerItems;
|
||||
BackpackManager.backpackItems[2] = foresterItems;
|
||||
BackpackManager.backpackItems[3] = hunterItems;
|
||||
BackpackManager.backpackItems[4] = adventurerItems;
|
||||
BackpackManager.backpackItems[5] = builderItems;
|
||||
|
||||
BackpackDefinition definition;
|
||||
|
||||
if (ForestryAPI.enabledPlugins.contains(ForestryPluginUids.APICULTURE)) {
|
||||
definition = new BackpackDefinitionApiarist(new Color(0xc4923d).getRGB());
|
||||
BackpackManager.definitions.put(definition.getKey(), definition);
|
||||
definition = new BackpackDefinitionApiarist(new Color(0xc4923d));
|
||||
BackpackManager.backpackInterface.registerBackpack("apiarist", definition);
|
||||
}
|
||||
|
||||
if (ForestryAPI.enabledPlugins.contains(ForestryPluginUids.LEPIDOPTEROLOGY)) {
|
||||
definition = new BackpackDefinitionLepidopterist(new Color(0x995b31).getRGB());
|
||||
BackpackManager.definitions.put(definition.getKey(), definition);
|
||||
definition = new BackpackDefinitionLepidopterist(new Color(0x995b31));
|
||||
BackpackManager.backpackInterface.registerBackpack("lepidopterist", definition);
|
||||
}
|
||||
|
||||
definition = new BackpackDefinition("miner", new Color(0x36187d).getRGB());
|
||||
BackpackManager.definitions.put(definition.getKey(), definition);
|
||||
definition = new BackpackDefinition(new Color(0x36187d));
|
||||
BackpackManager.backpackInterface.registerBackpack(BackpackManager.MINER_UID, definition);
|
||||
|
||||
definition = new BackpackDefinition("digger", new Color(0x363cc5).getRGB());
|
||||
BackpackManager.definitions.put(definition.getKey(), definition);
|
||||
definition = new BackpackDefinition(new Color(0x363cc5));
|
||||
BackpackManager.backpackInterface.registerBackpack(BackpackManager.DIGGER_UID, definition);
|
||||
|
||||
definition = new BackpackDefinition("forester", new Color(0x347427).getRGB());
|
||||
BackpackManager.definitions.put(definition.getKey(), definition);
|
||||
definition = new BackpackDefinition(new Color(0x347427));
|
||||
BackpackManager.backpackInterface.registerBackpack(BackpackManager.FORESTER_UID, definition);
|
||||
|
||||
definition = new BackpackDefinition("hunter", new Color(0x412215).getRGB());
|
||||
BackpackManager.definitions.put(definition.getKey(), definition);
|
||||
definition = new BackpackDefinition(new Color(0x412215));
|
||||
BackpackManager.backpackInterface.registerBackpack(BackpackManager.HUNTER_UID, definition);
|
||||
|
||||
definition = new BackpackDefinition("adventurer", new Color(0x7fb8c2).getRGB());
|
||||
BackpackManager.definitions.put(definition.getKey(), definition);
|
||||
definition = new BackpackDefinition(new Color(0x7fb8c2));
|
||||
BackpackManager.backpackInterface.registerBackpack(BackpackManager.ADVENTURER_UID, definition);
|
||||
|
||||
definition = new BackpackDefinition("builder", new Color(0xdd3a3a).getRGB());
|
||||
BackpackManager.definitions.put(definition.getKey(), definition);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disabledSetupAPI() {
|
||||
BackpackManager.backpackItems = new ArrayList[6];
|
||||
BackpackManager.backpackItems[0] = minerItems;
|
||||
BackpackManager.backpackItems[1] = diggerItems;
|
||||
BackpackManager.backpackItems[2] = foresterItems;
|
||||
BackpackManager.backpackItems[3] = hunterItems;
|
||||
BackpackManager.backpackItems[4] = adventurerItems;
|
||||
BackpackManager.backpackItems[5] = builderItems;
|
||||
definition = new BackpackDefinition(new Color(0xdd3a3a));
|
||||
BackpackManager.backpackInterface.registerBackpack(BackpackManager.BUILDER_UID, definition);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -185,16 +157,16 @@ public class PluginStorage extends BlankForestryPlugin {
|
||||
|
||||
LocalizedConfiguration config = new LocalizedConfiguration(configFile, "1.0.0");
|
||||
|
||||
handleBackpackConfig(config, "miner");
|
||||
handleBackpackConfig(config, "digger");
|
||||
handleBackpackConfig(config, "forester");
|
||||
handleBackpackConfig(config, "hunter");
|
||||
handleBackpackConfig(config, "adventurer");
|
||||
handleBackpackConfig(config, "builder");
|
||||
handleBackpackConfig(config, BackpackManager.MINER_UID);
|
||||
handleBackpackConfig(config, BackpackManager.DIGGER_UID);
|
||||
handleBackpackConfig(config, BackpackManager.FORESTER_UID);
|
||||
handleBackpackConfig(config, BackpackManager.HUNTER_UID);
|
||||
handleBackpackConfig(config, BackpackManager.ADVENTURER_UID);
|
||||
handleBackpackConfig(config, BackpackManager.BUILDER_UID);
|
||||
|
||||
config.save();
|
||||
|
||||
BackpackDefinition forester = (BackpackDefinition) BackpackManager.definitions.get("forester");
|
||||
BackpackDefinition forester = (BackpackDefinition) BackpackManager.backpackInterface.getBackpack(BackpackManager.FORESTER_UID);
|
||||
forester.addValidBlockClasses(Arrays.<Class>asList(
|
||||
IPlantable.class,
|
||||
IGrowable.class,
|
||||
@@ -205,7 +177,7 @@ public class PluginStorage extends BlankForestryPlugin {
|
||||
IGrowable.class
|
||||
));
|
||||
|
||||
BackpackDefinition builder = (BackpackDefinition) BackpackManager.definitions.get("builder");
|
||||
BackpackDefinition builder = (BackpackDefinition) BackpackManager.backpackInterface.getBackpack(BackpackManager.BUILDER_UID);
|
||||
builder.addValidBlockClasses(Arrays.<Class>asList(
|
||||
BlockStairs.class,
|
||||
BlockFence.class,
|
||||
@@ -227,21 +199,14 @@ public class PluginStorage extends BlankForestryPlugin {
|
||||
builder.addValidItemClass(ItemDoor.class);
|
||||
}
|
||||
|
||||
private void setDefaultsForConfig() {
|
||||
private static void setDefaultsForConfig() {
|
||||
|
||||
final BackpackDefinition miner = (BackpackDefinition) BackpackManager.definitions.get("miner");
|
||||
final BackpackDefinition digger = (BackpackDefinition) BackpackManager.definitions.get("digger");
|
||||
final BackpackDefinition forester = (BackpackDefinition) BackpackManager.definitions.get("forester");
|
||||
final BackpackDefinition adventurer = (BackpackDefinition) BackpackManager.definitions.get("adventurer");
|
||||
final BackpackDefinition builder = (BackpackDefinition) BackpackManager.definitions.get("builder");
|
||||
final BackpackDefinition hunter = (BackpackDefinition) BackpackManager.definitions.get("hunter");
|
||||
|
||||
miner.addValidItems(minerItems);
|
||||
digger.addValidItems(diggerItems);
|
||||
forester.addValidItems(foresterItems);
|
||||
hunter.addValidItems(hunterItems);
|
||||
adventurer.addValidItems(adventurerItems);
|
||||
builder.addValidItems(builderItems);
|
||||
final BackpackDefinition miner = (BackpackDefinition) BackpackManager.backpackInterface.getBackpack(BackpackManager.MINER_UID);
|
||||
final BackpackDefinition digger = (BackpackDefinition) BackpackManager.backpackInterface.getBackpack(BackpackManager.DIGGER_UID);
|
||||
final BackpackDefinition forester = (BackpackDefinition) BackpackManager.backpackInterface.getBackpack(BackpackManager.FORESTER_UID);
|
||||
final BackpackDefinition adventurer = (BackpackDefinition) BackpackManager.backpackInterface.getBackpack(BackpackManager.ADVENTURER_UID);
|
||||
final BackpackDefinition builder = (BackpackDefinition) BackpackManager.backpackInterface.getBackpack(BackpackManager.BUILDER_UID);
|
||||
final BackpackDefinition hunter = (BackpackDefinition) BackpackManager.backpackInterface.getBackpack(BackpackManager.HUNTER_UID);
|
||||
|
||||
final Pattern minerOreDictPattern = Pattern.compile("(ore|dust|gem|ingot|nugget|crushed|cluster|denseore)[A-Z].*");
|
||||
final Pattern diggerOreDictPattern = Pattern.compile("(stone)[A-Z].*");
|
||||
@@ -404,7 +369,7 @@ public class PluginStorage extends BlankForestryPlugin {
|
||||
}
|
||||
|
||||
private static void handleBackpackConfig(LocalizedConfiguration config, String backpackName) {
|
||||
BackpackDefinition backpackDefinition = (BackpackDefinition) BackpackManager.definitions.get(backpackName);
|
||||
BackpackDefinition backpackDefinition = (BackpackDefinition) BackpackManager.backpackInterface.getBackpack(backpackName);
|
||||
|
||||
List<ItemStack> backpackItems;
|
||||
List<String> backpackOreDict = new ArrayList<>();
|
||||
@@ -488,13 +453,12 @@ public class PluginStorage extends BlankForestryPlugin {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!BackpackManager.definitions.containsKey(tokens[0])) {
|
||||
IBackpackDefinition backpackDefinition = BackpackManager.backpackInterface.getBackpack(tokens[0]);
|
||||
if (backpackDefinition == null) {
|
||||
String errorMessage = IMCUtil.getInvalidIMCMessageText(message);
|
||||
Log.warning("%s For non-existent backpack %s.", errorMessage, tokens[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
IBackpackDefinition backpackDefinition = BackpackManager.definitions.get(tokens[0]);
|
||||
List<ItemStack> itemStacks = ItemStackUtil.parseItemStackStrings(tokens[1], 0);
|
||||
backpackDefinition.addValidItems(itemStacks);
|
||||
|
||||
@@ -539,7 +503,7 @@ public class PluginStorage extends BlankForestryPlugin {
|
||||
RecipeManagers.carpenterManager.addRecipe(20, Fluids.WATER.getFluid(1000), null, items.crate.getItemStack(24),
|
||||
" # ", "# #", " # ", '#', "logWood");
|
||||
|
||||
// / BACKPACKS T2
|
||||
// / BACKPACKS WOVEN
|
||||
addT2BackpackRecipe(items.minerBackpack, items.minerBackpackT2);
|
||||
addT2BackpackRecipe(items.diggerBackpack, items.diggerBackpackT2);
|
||||
addT2BackpackRecipe(items.foresterBackpack, items.foresterBackpackT2);
|
||||
|
||||
@@ -235,7 +235,7 @@ public class ItemBackpack extends ItemWithGui {
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void registerModel(Item item, IModelManager manager) {
|
||||
EnumBackpackType t = type == EnumBackpackType.APIARIST ? EnumBackpackType.T1 : type;
|
||||
EnumBackpackType t = (type == EnumBackpackType.NATURALIST) ? EnumBackpackType.NORMAL : type;
|
||||
String typeTag = "backpacks/" + t.toString().toLowerCase(Locale.ENGLISH);
|
||||
models = new ModelResourceLocation[4];
|
||||
models[0] = new ModelResourceLocation("forestry:" + typeTag + "_neutral", "inventory");
|
||||
@@ -254,7 +254,6 @@ public class ItemBackpack extends ItemWithGui {
|
||||
|
||||
@Override
|
||||
public ModelResourceLocation getModelLocation(ItemStack stack) {
|
||||
EnumBackpackType t = type == EnumBackpackType.APIARIST ? EnumBackpackType.T1 : type;
|
||||
return models[stack.getItemDamage()];
|
||||
}
|
||||
|
||||
@@ -274,11 +273,11 @@ public class ItemBackpack extends ItemWithGui {
|
||||
|
||||
private static int getSlotsForType(EnumBackpackType type) {
|
||||
switch (type) {
|
||||
case APIARIST:
|
||||
case NATURALIST:
|
||||
return Constants.SLOTS_BACKPACK_APIARIST;
|
||||
case T2:
|
||||
return Constants.SLOTS_BACKPACK_T2;
|
||||
case T1:
|
||||
case WOVEN:
|
||||
return Constants.SLOTS_BACKPACK_WOVEN;
|
||||
case NORMAL:
|
||||
default:
|
||||
return Constants.SLOTS_BACKPACK_DEFAULT;
|
||||
}
|
||||
@@ -305,9 +304,9 @@ public class ItemBackpack extends ItemWithGui {
|
||||
}
|
||||
EnumBackpackType type = EnumBackpackType.values()[data];
|
||||
switch (type) {
|
||||
case T1:
|
||||
case NORMAL:
|
||||
return new GuiBackpack(new ContainerBackpack(player, ContainerBackpack.Size.DEFAULT, heldItem));
|
||||
case T2:
|
||||
case WOVEN:
|
||||
return new GuiBackpackT2(new ContainerBackpack(player, ContainerBackpack.Size.T2, heldItem));
|
||||
}
|
||||
return null;
|
||||
@@ -320,9 +319,9 @@ public class ItemBackpack extends ItemWithGui {
|
||||
}
|
||||
EnumBackpackType type = EnumBackpackType.values()[data];
|
||||
switch (type) {
|
||||
case T1:
|
||||
case NORMAL:
|
||||
return new ContainerBackpack(player, ContainerBackpack.Size.DEFAULT, heldItem);
|
||||
case T2:
|
||||
case WOVEN:
|
||||
return new ContainerBackpack(player, ContainerBackpack.Size.T2, heldItem);
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -48,8 +48,8 @@ public class ItemRegistryStorage extends ItemRegistry {
|
||||
IBackpackDefinition definition;
|
||||
|
||||
if (ForestryAPI.enabledPlugins.contains(ForestryPluginUids.APICULTURE)) {
|
||||
definition = BackpackManager.definitions.get("apiarist");
|
||||
apiaristBackpack = new ItemBackpackNaturalist(BeeManager.beeRoot, definition, EnumBackpackType.APIARIST);
|
||||
definition = BackpackManager.backpackInterface.getBackpack("apiarist");
|
||||
apiaristBackpack = new ItemBackpackNaturalist(BeeManager.beeRoot, definition, EnumBackpackType.NATURALIST);
|
||||
apiaristBackpack.setCreativeTab(Tabs.tabApiculture);
|
||||
registerItem(apiaristBackpack, "apiaristBag");
|
||||
} else {
|
||||
@@ -57,36 +57,36 @@ public class ItemRegistryStorage extends ItemRegistry {
|
||||
}
|
||||
|
||||
if (ForestryAPI.enabledPlugins.contains(ForestryPluginUids.LEPIDOPTEROLOGY)) {
|
||||
definition = BackpackManager.definitions.get("lepidopterist");
|
||||
lepidopteristBackpack = new ItemBackpackNaturalist(ButterflyManager.butterflyRoot, definition, EnumBackpackType.APIARIST);
|
||||
definition = BackpackManager.backpackInterface.getBackpack("lepidopterist");
|
||||
lepidopteristBackpack = new ItemBackpackNaturalist(ButterflyManager.butterflyRoot, definition, EnumBackpackType.NATURALIST);
|
||||
lepidopteristBackpack.setCreativeTab(Tabs.tabLepidopterology);
|
||||
registerItem(lepidopteristBackpack, "lepidopteristBag");
|
||||
} else {
|
||||
lepidopteristBackpack = null;
|
||||
}
|
||||
|
||||
definition = BackpackManager.definitions.get("miner");
|
||||
minerBackpack = registerItem(BackpackManager.backpackInterface.addBackpack(definition, EnumBackpackType.T1), "minerBag");
|
||||
minerBackpackT2 = registerItem(BackpackManager.backpackInterface.addBackpack(definition, EnumBackpackType.T2), "minerBagT2");
|
||||
definition = BackpackManager.backpackInterface.getBackpack(BackpackManager.MINER_UID);
|
||||
minerBackpack = registerItem(BackpackManager.backpackInterface.createBackpack(definition, EnumBackpackType.NORMAL), "minerBag");
|
||||
minerBackpackT2 = registerItem(BackpackManager.backpackInterface.createBackpack(definition, EnumBackpackType.WOVEN), "minerBagT2");
|
||||
|
||||
definition = BackpackManager.definitions.get("digger");
|
||||
diggerBackpack = registerItem(BackpackManager.backpackInterface.addBackpack(definition, EnumBackpackType.T1), "diggerBag");
|
||||
diggerBackpackT2 = registerItem(BackpackManager.backpackInterface.addBackpack(definition, EnumBackpackType.T2), "diggerBagT2");
|
||||
definition = BackpackManager.backpackInterface.getBackpack(BackpackManager.DIGGER_UID);
|
||||
diggerBackpack = registerItem(BackpackManager.backpackInterface.createBackpack(definition, EnumBackpackType.NORMAL), "diggerBag");
|
||||
diggerBackpackT2 = registerItem(BackpackManager.backpackInterface.createBackpack(definition, EnumBackpackType.WOVEN), "diggerBagT2");
|
||||
|
||||
definition = BackpackManager.definitions.get("forester");
|
||||
foresterBackpack = registerItem(BackpackManager.backpackInterface.addBackpack(definition, EnumBackpackType.T1), "foresterBag");
|
||||
foresterBackpackT2 = registerItem(BackpackManager.backpackInterface.addBackpack(definition, EnumBackpackType.T2), "foresterBagT2");
|
||||
definition = BackpackManager.backpackInterface.getBackpack(BackpackManager.FORESTER_UID);
|
||||
foresterBackpack = registerItem(BackpackManager.backpackInterface.createBackpack(definition, EnumBackpackType.NORMAL), "foresterBag");
|
||||
foresterBackpackT2 = registerItem(BackpackManager.backpackInterface.createBackpack(definition, EnumBackpackType.WOVEN), "foresterBagT2");
|
||||
|
||||
definition = BackpackManager.definitions.get("hunter");
|
||||
hunterBackpack = registerItem(BackpackManager.backpackInterface.addBackpack(definition, EnumBackpackType.T1), "hunterBag");
|
||||
hunterBackpackT2 = registerItem(BackpackManager.backpackInterface.addBackpack(definition, EnumBackpackType.T2), "hunterBagT2");
|
||||
definition = BackpackManager.backpackInterface.getBackpack(BackpackManager.HUNTER_UID);
|
||||
hunterBackpack = registerItem(BackpackManager.backpackInterface.createBackpack(definition, EnumBackpackType.NORMAL), "hunterBag");
|
||||
hunterBackpackT2 = registerItem(BackpackManager.backpackInterface.createBackpack(definition, EnumBackpackType.WOVEN), "hunterBagT2");
|
||||
|
||||
definition = BackpackManager.definitions.get("adventurer");
|
||||
adventurerBackpack = registerItem(BackpackManager.backpackInterface.addBackpack(definition, EnumBackpackType.T1), "adventurerBag");
|
||||
adventurerBackpackT2 = registerItem(BackpackManager.backpackInterface.addBackpack(definition, EnumBackpackType.T2), "adventurerBagT2");
|
||||
definition = BackpackManager.backpackInterface.getBackpack(BackpackManager.ADVENTURER_UID);
|
||||
adventurerBackpack = registerItem(BackpackManager.backpackInterface.createBackpack(definition, EnumBackpackType.NORMAL), "adventurerBag");
|
||||
adventurerBackpackT2 = registerItem(BackpackManager.backpackInterface.createBackpack(definition, EnumBackpackType.WOVEN), "adventurerBagT2");
|
||||
|
||||
definition = BackpackManager.definitions.get("builder");
|
||||
builderBackpack = registerItem(BackpackManager.backpackInterface.addBackpack(definition, EnumBackpackType.T1), "builderBag");
|
||||
builderBackpackT2 = registerItem(BackpackManager.backpackInterface.addBackpack(definition, EnumBackpackType.T2), "builderBagT2");
|
||||
definition = BackpackManager.backpackInterface.getBackpack(BackpackManager.BUILDER_UID);
|
||||
builderBackpack = registerItem(BackpackManager.backpackInterface.createBackpack(definition, EnumBackpackType.NORMAL), "builderBag");
|
||||
builderBackpackT2 = registerItem(BackpackManager.backpackInterface.createBackpack(definition, EnumBackpackType.WOVEN), "builderBagT2");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user