Compare commits

..
8 Commits
38 changed files with 144 additions and 399 deletions

No files matched your search

+29
View File
@@ -0,0 +1,29 @@
How to submit a bug report to Forestry
====================================
Please make sure the bug has not already been reported by [searching the issues](https://github.com/ForestryMC/ForestryMC/issues?q=is%3Aissue).
If you can, see if the bug still happens with the latest unstable build.
[The latest unstable builds are available here](http://jenkins.ic2.player.to/job/Forestry_Dev/)
For crashes, you must post a link to the full crash report.
[gist.github.com](gist.github.com) or [pastebin.com](www.pastebin.com) are good places to upload them.
Full crash reports are located in [the minecraft data folder](http://hopper.minecraft.net/help/finding-minecraft-data-folder/), in "crash-reports".
Thank you for reporting bugs!
How to contribute to Forestry
====================================
### Contributor License Agreement
Before pull requests can be accepted, the contributor needs to sign a contributor license agreement. (Essentially giving a license for using his code and/or media and for re-licensing it, for details read the agreement linked below.)
### How do I sign?
To keep the hassle for everyone involved to a minimum, Forestry uses CLAHub to manage the agreements. To get started, <a href="https://www.clahub.com/agreements/ForestryMC/ForestryMC">sign the Contributor License Agreement</a>.
### Why is this needed?
Without CLAs it at some point becomes essentially impossible to change the license of a project which accepts contributions from third parties. Without an explicit agreement every contributor would still own the copyright to his code. So as long as it (or parts of it) remain in the code base, he would have to agree to every license change. If enough time has passed, there may be dozens, perhaps even hundreds of contributors involved and it will be very hard to track down each and every one of them and get them to agree on a new license.
This would make it impossible to change the license to a more permissive one at a later date, so the code would be locked into CC BY-NC-ND 3.0 until it passes into the public domain about a hundred years from now. This situation is to be avoided and that’s why you are being bothered with this CLA.
+2 -4
View File
@@ -4,12 +4,10 @@ dependencies {
api("com.github.GTNewHorizons:GTNHLib:0.9.54:dev")
api('curse.maven:cofh-lib-220333:2388748')
compileOnlyApi('com.github.GTNewHorizons:Angelica:2.1.19:api')
devOnlyNonPublishable('com.github.GTNewHorizons:NotEnoughItems:2.8.107-GTNH:dev')
devOnlyNonPublishable('com.github.GTNewHorizons:NotEnoughItems:2.8.93-GTNH:dev')
compileOnly('com.github.GTNewHorizons:inventory-tweaks:1.7.1:api')
compileOnly('com.github.GTNewHorizons:BuildCraft:7.1.57:api')
compileOnly('com.github.GTNewHorizons:BuildCraft:7.1.59:api')
compileOnly('net.industrial-craft:industrialcraft-2:2.2.828-experimental:dev')
compileOnly('curse.maven:craftguide-75557:2459320')
compileOnly('com.ruling_0:MaterialLib:0.24.0-mu:dev')
compileOnly('com.github.GTNewHorizons:Postea:1.4.0-mu:dev')
devOnlyNonPublishable('net.xonich.mc:NoHotbarNeeded:0.0.3:dev')
}
+4 -4
View File
@@ -1,12 +1,12 @@
#This file is generated by updateDaemonJvm
toolchainUrl.FREE_BSD.AARCH64=https\://api.foojay.io/disco/v3.0/ids/1630f7ebef05444cb27a2709ea0249b3/redirect
toolchainUrl.FREE_BSD.AARCH64=https\://api.foojay.io/disco/v3.0/ids/cf726b4a1c84b50457225f9bba6d7650/redirect
toolchainUrl.FREE_BSD.X86_64=https\://api.foojay.io/disco/v3.0/ids/fa1e318c287360478e3c83a9a3ef1007/redirect
toolchainUrl.LINUX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/1630f7ebef05444cb27a2709ea0249b3/redirect
toolchainUrl.LINUX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/cf726b4a1c84b50457225f9bba6d7650/redirect
toolchainUrl.LINUX.X86_64=https\://api.foojay.io/disco/v3.0/ids/fa1e318c287360478e3c83a9a3ef1007/redirect
toolchainUrl.MAC_OS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/c2dd35c9d0aaf0ba6ad0791320f99dfc/redirect
toolchainUrl.MAC_OS.X86_64=https\://api.foojay.io/disco/v3.0/ids/e5810bd7fd1f8a586644409d395a7e55/redirect
toolchainUrl.UNIX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/1630f7ebef05444cb27a2709ea0249b3/redirect
toolchainUrl.UNIX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/cf726b4a1c84b50457225f9bba6d7650/redirect
toolchainUrl.UNIX.X86_64=https\://api.foojay.io/disco/v3.0/ids/fa1e318c287360478e3c83a9a3ef1007/redirect
toolchainUrl.WINDOWS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/7b3c4877c0749019e6805bb61e421497/redirect
toolchainUrl.WINDOWS.X86_64=https\://api.foojay.io/disco/v3.0/ids/8e1d9ee5d0f13e442218f6884a306da1/redirect
toolchainUrl.WINDOWS.X86_64=https\://api.foojay.io/disco/v3.0/ids/d76df094a9cbbabd3b08251f9e61444a/redirect
toolchainVersion=25
-1
View File
@@ -1,5 +1,4 @@
// Add any additional repositiroes for your dependencies here
repositories {
mavenLocal()
}
+1 -2
View File
@@ -63,8 +63,7 @@ import forestry.plugins.PluginManager;
+ "after:BiomesOPlenty;"
+ "after:IC2@[2.0.140,);"
+ "after:Natura@[2.2.0,);"
+ "after:HardcoreEnderExpansion;"
+ "after:materiallib;")
+ "after:HardcoreEnderExpansion;")
public class Forestry {
@Mod.Instance(Constants.MOD)
@@ -1,20 +0,0 @@
package forestry.api.apiculture;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
public interface IArmorApiaristMulti extends IArmorApiarist {
/**
* Called to determine how many pieces an armor "counts for". For instance, if this returns 4, the single piece will
* act as full protection.
*
* @param entity Entity being attacked
* @param armor Armor item
* @param cause Optional cause of attack, such as a bee effect identifier
* @return Amount of effective protected slots
*/
default int getProtectionCount(EntityLivingBase entity, ItemStack armor, String cause) {
return 1;
}
}
@@ -15,20 +15,26 @@ import net.minecraft.item.ItemStack;
import forestry.api.apiculture.IArmorApiarist;
import forestry.api.apiculture.IArmorApiaristHelper;
import forestry.api.apiculture.IArmorApiaristMulti;
public class ArmorApiaristHelper implements IArmorApiaristHelper {
@Override
public boolean isArmorApiarist(ItemStack stack, EntityLivingBase entity, String cause, boolean doProtect) {
if (stack == null) {
return false;
}
if (stack == null || !(stack.getItem() instanceof IArmorApiarist armor)) return false;
Item item = stack.getItem();
if (!(item instanceof IArmorApiarist)) {
return false;
}
IArmorApiarist armorApiarist = (IArmorApiarist) item;
try {
return armor.protectEntity(entity, stack, cause, doProtect);
return armorApiarist.protectEntity(entity, stack, cause, doProtect);
} catch (Throwable ignored) { // protectEntity is new to the API and may not be implemented by the armor
if (entity instanceof EntityPlayer) {
return armor.protectPlayer((EntityPlayer) entity, stack, cause, doProtect);
return armorApiarist.protectPlayer((EntityPlayer) entity, stack, cause, doProtect);
} else {
return true; // fallback on assuming IArmorApiarist will protect the entity
}
@@ -42,13 +48,11 @@ public class ArmorApiaristHelper implements IArmorApiaristHelper {
for (int i = 1; i <= 4; i++) {
ItemStack armorItem = entity.getEquipmentInSlot(i);
if (isArmorApiarist(armorItem, entity, cause, doProtect)) {
Item item = armorItem.getItem();
if (item instanceof IArmorApiaristMulti am) count += am.getProtectionCount(entity, armorItem, cause);
else count++;
count++;
}
}
return Math.min(count, 4);
return count;
}
@Override
@@ -111,14 +111,6 @@ public class AlvearyController extends RectangularMultiblockControllerBase
this.readFromNBT(data);
}
@Override
public void detachBlock(IMultiblockComponent part, boolean chunkUnloading) {
if (!chunkUnloading) {
inventory.dumpInventoryIntoWorld(this.worldObj, part.getCoordinates());
}
super.detachBlock(part, chunkUnloading);
}
@Override
protected void onBlockAdded(IMultiblockComponent newPart) {
if (newPart instanceof IAlvearyComponent) {
@@ -167,6 +159,8 @@ public class AlvearyController extends RectangularMultiblockControllerBase
activeComponents.remove(oldPart);
}
}
inventory.dumpInventoryIntoWorld(this.worldObj, oldPart.getCoordinates());
}
@Override
@@ -16,8 +16,8 @@ import net.minecraft.block.material.Material;
import net.minecraft.client.particle.EffectRenderer;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
@@ -72,7 +72,7 @@ public class BlockSlab extends net.minecraft.block.BlockSlab implements IWoodTyp
@SideOnly(Side.CLIENT)
@Override
public IIcon getIcon(int side, int meta) {
return IconProviderWood.getPlankIcon(EnumWoodType.VALUES[meta]);
return IconProviderWood.getPlankIcon(EnumWoodType.LARCH);
}
@Override
@@ -84,8 +84,7 @@ public class BlockSlab extends net.minecraft.block.BlockSlab implements IWoodTyp
@Override
protected ItemStack createStackedBlock(int meta) {
Item item = Item.getItemFromBlock(this);
return item != null ? new ItemStack(item, 2, 0) : null;
return new ItemStack(Blocks.wooden_slab, 2, meta & 7);
}
@Override
@@ -108,18 +107,6 @@ public class BlockSlab extends net.minecraft.block.BlockSlab implements IWoodTyp
return new TileWood();
}
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) {
// Special case for double slabs placed by building mods (e.g., MatterManipulator)
if (stack == null) return;
int damage = stack.getItemDamage();
if (damage < 0 || damage >= EnumWoodType.VALUES.length) return;
TileWood tile = TileWood.getWoodTile(world, x, y, z);
if (tile != null) {
tile.setWoodType(EnumWoodType.VALUES[damage]);
}
}
/* PROPERTIES */
@Override
public final ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) {
@@ -26,7 +26,6 @@ public class ItemRegistryArboriculture extends ItemRegistry {
OreDictionary.registerOre("treeSapling", sapling.getWildcard());
pollenFertile = registerItem(new ItemGermlingGE(EnumGermlingType.POLLEN), "pollenFertile");
OreDictionary.registerOre("itemPollenFertile", pollenFertile.getWildcard());
treealyzer = registerItem(new ItemTreealyzer(), "treealyzer");
grafter = registerItem(new ItemGrafter(4), "grafter");
grafterProven = registerItem(new ItemGrafter(149), "grafterProven");
@@ -202,8 +202,7 @@ public abstract class Genome implements IGenome {
private static IChromosome[] getChromosomes(NBTTagCompound genomeNBT, ISpeciesRoot speciesRoot) {
NBTTagList chromosomesNBT = genomeNBT.getTagList("Chromosomes", 10);
IAllele[] defaultTemplate = speciesRoot.getDefaultTemplate();
IChromosome[] chromosomes = new IChromosome[defaultTemplate.length];
IChromosome[] chromosomes = new IChromosome[speciesRoot.getDefaultTemplate().length];
for (int i = 0; i < chromosomesNBT.tagCount(); i++) {
NBTTagCompound chromosomeNBT = chromosomesNBT.getCompoundTagAt(i);
@@ -214,7 +213,7 @@ public abstract class Genome implements IGenome {
chromosomes[chromosomeOrdinal] = chromosome;
if (Config.clearInvalidChromosomes) {
IAllele template = defaultTemplate[chromosomeOrdinal];
IAllele template = speciesRoot.getDefaultTemplate()[chromosomeOrdinal];
Class<? extends IAllele> chromosomeClass = speciesRoot.getKaryotype()[chromosomeOrdinal]
.getAlleleClass();
if (chromosome.overrideInvalidAlleles(template, chromosomeClass)) {
@@ -32,10 +32,6 @@ public class MutationConditionRequiresResource implements IMutationCondition {
blockRequired = new ItemStack(block, 1, meta);
}
public ItemStack getBlockRequired() {
return blockRequired.copy();
}
@Override
public float getChance(World world, int x, int y, int z, IAllele allele0, IAllele allele1, IGenome genome0,
IGenome genome1, IClimateProvider climate) {
@@ -39,10 +39,6 @@ public class MutationConditionRequiresResourceOreDict implements IMutationCondit
}
}
public int getOreDictId() {
return oreDictId;
}
@Override
public float getChance(World world, int x, int y, int z, IAllele allele0, IAllele allele1, IGenome genome0,
IGenome genome1, IClimateProvider climate) {
@@ -8,7 +8,7 @@
******************************************************************************/
package forestry.core.gui;
import static forestry.core.inventory.ItemLocation.Type.PLAYER_INVENTORY;
import static forestry.core.inventory.ItemLocation.TYPE.PLAYER_INVENTORY;
import javax.annotation.Nullable;
@@ -53,7 +53,6 @@ public class GuiHandler implements IGuiHandler {
* @param invSlotIdx Index or slot in player inventory should be in range [0, 40).
*/
public static void openGui(EntityPlayer entityPlayer, IGuiHandlerItem guiHandler, short data, int invSlotIdx) {
assert invSlotIdx >= 0 && invSlotIdx < 40 : "Incorrect inventory index is used: " + invSlotIdx;
int guiData = encodeGuiData(guiHandler, data, invSlotIdx);
entityPlayer.openGui(ForestryAPI.instance, guiData, entityPlayer.worldObj, 0, 0, 0);
}
@@ -89,7 +88,7 @@ public class GuiHandler implements IGuiHandler {
*/
private static int encodeGuiData(IGuiHandlerForestry guiHandler, short data, int invSlotIdx) {
// inventory slot idx will be encoded in third byte
// player inventory has 40 slots which means that we need 6 bits to encode all values.
// player have 40 different inventory which means that we need 6 bits to encode all values.
// first 2 bits are reserved for type currently values 0(heldItem) and 1(item inventory) have meaning,
// 2 and 3 are reserved for possible extension.
if (invSlotIdx < -1 || invSlotIdx >= 40) {
@@ -87,7 +87,7 @@ public abstract class ItemInventory implements IInventory, IFilterSlotDelegate {
public boolean isParentItemEquipped() {
return switch (location.type()) {
case HELD_BY_PLAYER, UNKNOWN -> isSameItemInventory(player.getCurrentEquippedItem(), parent);
case PLAYER_INVENTORY -> isSameItemInventory(player.inventory.getStackInSlot(location.slotIdx()), parent);
case PLAYER_INVENTORY -> true;
};
}
@@ -95,10 +95,6 @@ public abstract class ItemInventory implements IInventory, IFilterSlotDelegate {
return player;
}
public ItemLocation getLocation() {
return location;
}
public boolean isParentItemInventory(ItemStack itemStack) {
ItemStack parent = getParent();
return isSameItemInventory(parent, itemStack);
@@ -5,24 +5,24 @@ package forestry.core.inventory;
*/
public class ItemLocation {
public enum Type {
public enum TYPE {
UNKNOWN,
HELD_BY_PLAYER,
PLAYER_INVENTORY
}
public static final ItemLocation UNKNOWN = new ItemLocation(Type.UNKNOWN, -1);
public static final ItemLocation HELD_BY_PLAYER = new ItemLocation(Type.HELD_BY_PLAYER, -1);
public static final ItemLocation UNKNOWN = new ItemLocation(TYPE.UNKNOWN, -1);
public static final ItemLocation HELD_BY_PLAYER = new ItemLocation(TYPE.HELD_BY_PLAYER, -1);
private final Type type;
private final TYPE type;
private final int slotIdx;
public ItemLocation(Type type, int slotIdx) {
public ItemLocation(TYPE type, int slotIdx) {
this.type = type;
this.slotIdx = slotIdx;
}
public Type type() {
public TYPE type() {
return type;
}
@@ -33,7 +33,7 @@ public abstract class ItemWithGui extends ItemForestry implements IGuiHandlerIte
}
protected void openGui(EntityPlayer entityplayer) {
GuiHandler.openGui(entityplayer, this, (short) 0, entityplayer.inventory.currentItem);
GuiHandler.openGui(entityplayer, this);
}
@Override
@@ -28,7 +28,7 @@ public enum PacketIdServer implements IPacketId {
BEE_LOGIC_ACTIVE_ENTITY_REQUEST,
// Factory
NEI_SELECT,
WORKTABLE_NEI_SELECT,
// Mail
LETTER_INFO_REQUEST,
@@ -23,7 +23,7 @@ import codechicken.nei.api.IOverlayHandler;
import codechicken.nei.api.IStackPositioner;
import codechicken.nei.recipe.IRecipeHandler;
import forestry.core.proxy.Proxies;
import forestry.factory.network.packets.PacketNEISelect;
import forestry.factory.network.packets.PacketWorktableNEISelect;
/**
* @author bdew
@@ -40,25 +40,9 @@ public class CustomOverlayHandler implements IOverlayHandler {
this.forceShift = forceShift;
}
@Override
public boolean requireShiftForOverlayRecipe() {
return false;
}
@Override
public void overlayRecipe(GuiContainer cont, IRecipeHandler recipe, int recipeIndex, boolean shift) {
int offsetX = 25;
int offsetY = 6;
int gridSpacing = 18;
List<PositionedStack> ingr;
if (recipe instanceof IGridRecipeHandler gridHandler) {
offsetX = gridHandler.getGridStartX();
offsetY = gridHandler.getGridStartY();
gridSpacing = gridHandler.getGridSpacing();
ingr = gridHandler.getGridStacks(recipeIndex);
} else {
ingr = recipe.getIngredientStacks(recipeIndex);
}
List<PositionedStack> ingr = recipe.getIngredientStacks(recipeIndex);
if (shift || forceShift) {
NBTTagList stacksnbt = new NBTTagList();
@@ -66,8 +50,8 @@ public class CustomOverlayHandler implements IOverlayHandler {
for (PositionedStack pstack : ingr) {
if (pstack != null) {
// This is back-asswards but i don't see a better way :(
int x = (pstack.relx - offsetX) / gridSpacing;
int y = (pstack.rely - offsetY) / gridSpacing;
int x = (pstack.relx - 25) / 18;
int y = (pstack.rely - 6) / 18;
ItemStack stack = pstack.item;
NBTTagCompound stacknbt = stack.writeToNBT(new NBTTagCompound());
@@ -84,7 +68,7 @@ public class CustomOverlayHandler implements IOverlayHandler {
NBTTagCompound data = new NBTTagCompound();
data.setTag("stacks", stacksnbt);
Proxies.net.sendToServer(new PacketNEISelect(data));
Proxies.net.sendToServer(new PacketWorktableNEISelect(data));
} else {
IStackPositioner positioner = new OffsetPositioner(xOffs, yOffs);
LayoutManager.overlayRenderer = new DefaultOverlayRenderer(ingr, positioner);
@@ -1,17 +0,0 @@
package forestry.core.recipes.nei;
import java.util.List;
import codechicken.nei.PositionedStack;
public interface IGridRecipeHandler {
int getGridStartX();
int getGridStartY();
int getGridSpacing();
List<PositionedStack> getGridStacks(int recipeIndex);
}
@@ -19,8 +19,6 @@ import forestry.api.arboriculture.TreeManager;
import forestry.api.lepidopterology.ButterflyManager;
import forestry.api.lepidopterology.EnumFlutterType;
import forestry.core.utils.Log;
import forestry.factory.gui.GuiCarpenter;
import forestry.factory.gui.GuiFabricator;
import forestry.factory.gui.GuiWorktable;
import forestry.factory.recipes.nei.NEIHandlerBottler;
import forestry.factory.recipes.nei.NEIHandlerCarpenter;
@@ -48,8 +46,6 @@ public class NEIIntegrationConfig implements IConfigureNEI {
CustomOverlayHandler handler = new CustomOverlayHandler(-14, 14, true);
API.registerGuiOverlayHandler(GuiWorktable.class, handler, "crafting");
API.registerGuiOverlayHandler(GuiCarpenter.class, handler, "forestry.carpenter");
API.registerGuiOverlayHandler(GuiFabricator.class, handler, "forestry.fabricator");
API.addSubset(
"Forestry.Bees.Princesses",
@@ -23,19 +23,18 @@ import net.minecraft.nbt.NBTTagList;
*/
public class SetRecipeCommandHandler {
private final Class<? extends Container>[] containerClasses;
private final Class<? extends Container> containerClass;
private final Class<? extends Slot> slotClass;
public SetRecipeCommandHandler(Class<? extends Container>[] containerClasses, Class<? extends Slot> slotClass) {
this.containerClasses = containerClasses;
public SetRecipeCommandHandler(Class<? extends Container> containerClass, Class<? extends Slot> slotClass) {
this.containerClass = containerClass;
this.slotClass = slotClass;
}
public void handle(NBTTagCompound data, EntityPlayerMP player) {
NBTTagList stacks = data.getTagList("stacks", 10);
Container cont = player.openContainer;
if (!isContainerClassCorrect(cont)) {
if (!containerClass.isInstance(cont)) {
return;
}
@@ -44,20 +43,17 @@ public class SetRecipeCommandHandler {
NBTTagCompound itemdata = stacks.getCompoundTagAt(i);
stmap.put(itemdata.getInteger("slot"), ItemStack.loadItemStackFromNBT(itemdata));
}
for (Slot slot : cont.inventorySlots) {
if (!slotClass.isInstance(slot)) {
for (Object slotobj : cont.inventorySlots) {
if (!slotClass.isInstance(slotobj)) {
continue;
}
slot.putStack(stmap.getOrDefault(slot.getSlotIndex(), null));
}
}
private boolean isContainerClassCorrect(Container cont) {
for (Class<? extends Container> containerClass : containerClasses) {
if (containerClass.isInstance(cont)) {
return true;
Slot slot = (Slot) slotobj;
if (stmap.containsKey(slot.getSlotIndex())) {
slot.putStack(stmap.get(slot.getSlotIndex()));
} else {
slot.putStack(null);
}
}
return false;
}
}
@@ -230,11 +230,23 @@ public abstract class BlockUtil {
return vec != null && (vec.xCoord >= minX && vec.xCoord <= maxX && vec.yCoord >= minY && vec.yCoord <= maxY);
}
private static Class<? extends Block> BW_MetaGenerated_WerkstoffBlocksClass;
private static Block BWBlocks;
private static Class<? extends Block> GTBlockMachines_Class;
private static Block GTBlockMachines;
private static final boolean bw = Loader.isModLoaded("bartworks");
private static final boolean gt = Loader.isModLoaded("gregtech") && !Loader.isModLoaded("gregapi");
static {
if (bw) try {
// noinspection unchecked
BW_MetaGenerated_WerkstoffBlocksClass = (Class<? extends Block>) Class
.forName("bartworks.system.material.BWMetaGeneratedWerkstoffBlocks");
BWBlocks = (Block) Class.forName("bartworks.system.material.WerkstoffLoader").getField("BWBlocks")
.get(null);
} catch (ClassNotFoundException | NoSuchFieldException | IllegalAccessException e) {
e.printStackTrace();
}
if (gt) try {
// noinspection unchecked
GTBlockMachines_Class = (Class<? extends Block>) Class.forName("gregtech.common.blocks.BlockMachines");
@@ -256,6 +268,12 @@ public abstract class BlockUtil {
} while (stillInside.test(tile));
block = world.getBlock(x, y - depth, z);
if (bw && BW_MetaGenerated_WerkstoffBlocksClass != null
&& BWBlocks != null
&& BW_MetaGenerated_WerkstoffBlocksClass.isInstance(block)) {
return new ItemStack(BWBlocks, 1, block.getDamageValue(world, x, y - depth, z));
}
if (gt && GTBlockMachines_Class != null && GTBlockMachines != null && GTBlockMachines_Class.isInstance(block)) {
return new ItemStack(GTBlockMachines, 1, block.getDamageValue(world, x, y - depth, z));
}
@@ -1,42 +0,0 @@
package forestry.core.utils;
import net.minecraft.item.ItemStack;
import com.ruling_0.materiallib.api.StackResolver;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.GameRegistry.UniqueIdentifier;
/// Resolves the `ml:<Material>:<shape>` stack string form, which names a MaterialLib item by material and shape.
///
/// MaterialLib types are named only here, so [Stack] can gate loading this class on `materiallib` being present.
public abstract class MaterialLibStacks {
public static Stack parse(String mlString) {
String[] parts = mlString.split(":+");
if (parts.length != 3) {
Log.warning(
"Stack string (" + mlString
+ ") isn't formatted properly. The MaterialLib format is ml:<Material>:<shape>, e.g. ml:Aluminium:ore_stone");
return null;
}
ItemStack stack = StackResolver.getStack(parts[1], parts[2], 1);
if (stack == null) {
return null;
}
UniqueIdentifier id = GameRegistry.findUniqueIdentifierFor(stack.getItem());
if (id == null) {
Log.warning("Stack string (" + mlString + ") resolved to an item with no registry name.");
return null;
}
return new Stack(id.toString(), stack.getItemDamage());
}
/// The named material's item in the named shape, or null when MaterialLib serves no such pair.
public static ItemStack getStack(String material, String shape) {
return StackResolver.getStack(material, shape, 1);
}
}
@@ -1,38 +0,0 @@
package forestry.core.utils;
import net.minecraft.nbt.NBTTagCompound;
import com.gtnewhorizons.postea.api.CustomDataReplacementManager;
import cpw.mods.fml.common.Loader;
/// Offers Forestry's mail boxes to Postea's custom world data API, so versioned transformers rewrite
/// their stacks exactly once per content version change. Safe to call without Postea installed: the Postea types
/// live in the inner holder, which only loads when the mod is present.
public final class PosteaCompat {
private static final boolean POSTEA = Loader.isModLoaded("postea");
private PosteaCompat() {}
/// Transforms a root read from disk in place; call before consuming it.
public static void transform(String storageId, NBTTagCompound root) {
if (POSTEA) Impl.transform(storageId, root);
}
/// Stamps a freshly built root about to be written to disk.
public static void stamp(NBTTagCompound root) {
if (POSTEA) Impl.stamp(root);
}
private static final class Impl {
static void transform(String storageId, NBTTagCompound root) {
CustomDataReplacementManager.transform(storageId, root);
}
static void stamp(NBTTagCompound root) {
CustomDataReplacementManager.stamp(root);
}
}
}
+1 -9
View File
@@ -58,20 +58,12 @@ public class Stack {
return null;
}
if (stackString.startsWith("ml:")) {
if (!ModUtil.isModLoaded("materiallib")) {
Log.warning("Stack string (" + stackString + ") needs MaterialLib, which is not loaded. Ignoring it.");
return null;
}
return MaterialLibStacks.parse(stackString);
}
String[] parts = stackString.split(":+");
if (parts.length != 2 && parts.length != 3) {
Log.warning(
"Stack string (" + stackString
+ ") isn't formatted properly. Suitable formats are <modId>:<name>, <modId>:<name>:<meta>, <modId>:<name>:* or ml:<Material>:<shape>, e.g. IC2:blockWall:*");
+ ") isn't formatted properly. Suitable formats are <modId>:<name>, <modId>:<name>:<meta> or <modId>:<name>:*, e.g. IC2:blockWall:*");
return null;
}
@@ -9,15 +9,15 @@
package forestry.factory.network;
import forestry.core.network.PacketRegistry;
import forestry.factory.network.packets.PacketNEISelect;
import forestry.factory.network.packets.PacketWorktableMemoryUpdate;
import forestry.factory.network.packets.PacketWorktableNEISelect;
import forestry.factory.network.packets.PacketWorktableRecipeUpdate;
public class PacketRegistryFactory extends PacketRegistry {
@Override
public void registerPackets() {
registerServerPacket(new PacketNEISelect());
registerServerPacket(new PacketWorktableNEISelect());
registerClientPacket(new PacketWorktableMemoryUpdate());
registerClientPacket(new PacketWorktableRecipeUpdate());
@@ -19,29 +19,27 @@ import forestry.core.network.IForestryPacketServer;
import forestry.core.network.PacketIdServer;
import forestry.core.network.packets.PacketNBT;
import forestry.core.recipes.nei.SetRecipeCommandHandler;
import forestry.factory.gui.ContainerCarpenter;
import forestry.factory.gui.ContainerFabricator;
import forestry.factory.gui.ContainerWorktable;
public class PacketNEISelect extends PacketNBT implements IForestryPacketServer {
public class PacketWorktableNEISelect extends PacketNBT implements IForestryPacketServer {
private static final SetRecipeCommandHandler neiSelectHandler = new SetRecipeCommandHandler(
new Class[] { ContainerWorktable.class, ContainerCarpenter.class, ContainerFabricator.class },
private static final SetRecipeCommandHandler worktableNEISelectHandler = new SetRecipeCommandHandler(
ContainerWorktable.class,
SlotCraftMatrix.class);
public PacketNEISelect() {}
public PacketWorktableNEISelect() {}
public PacketNEISelect(NBTTagCompound nbttagcompound) {
public PacketWorktableNEISelect(NBTTagCompound nbttagcompound) {
super(nbttagcompound);
}
@Override
public void onPacketData(DataInputStreamForestry data, EntityPlayerMP player) throws IOException {
neiSelectHandler.handle(getTagCompound(), player);
worktableNEISelectHandler.handle(getTagCompound(), player);
}
@Override
public PacketIdServer getPacketId() {
return PacketIdServer.NEI_SELECT;
return PacketIdServer.WORKTABLE_NEI_SELECT;
}
}
@@ -11,7 +11,6 @@ package forestry.factory.recipes.nei;
import java.awt.Point;
import java.awt.Rectangle;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import net.minecraft.client.gui.inventory.GuiContainer;
@@ -25,14 +24,13 @@ import codechicken.nei.api.API;
import forestry.api.recipes.ICarpenterRecipe;
import forestry.api.recipes.IDescriptiveRecipe;
import forestry.api.recipes.RecipeManagers;
import forestry.core.recipes.nei.IGridRecipeHandler;
import forestry.core.recipes.nei.NEIUtils;
import forestry.core.recipes.nei.PositionedFluidTank;
import forestry.core.recipes.nei.RecipeHandlerBase;
import forestry.core.utils.StringUtil;
import forestry.factory.gui.GuiCarpenter;
public class NEIHandlerCarpenter extends RecipeHandlerBase implements IGridRecipeHandler {
public class NEIHandlerCarpenter extends RecipeHandlerBase {
private static Class<? extends GuiContainer> guiClass;
@@ -42,35 +40,11 @@ public class NEIHandlerCarpenter extends RecipeHandlerBase implements IGridRecip
API.setGuiOffset(guiClass, 5, 14);
}
@Override
public int getGridStartX() {
return 5;
}
@Override
public int getGridStartY() {
return 6;
}
@Override
public int getGridSpacing() {
return 18;
}
@Override
public List<PositionedStack> getGridStacks(int recipeIndex) {
if (arecipes.get(recipeIndex) instanceof CachedCarpenterRecipe recipe) {
return recipe.inputs.subList(0, recipe.ingredientCount);
}
return Collections.emptyList();
}
public class CachedCarpenterRecipe extends CachedBaseRecipe {
public List<PositionedStack> inputs = new ArrayList<>();
public PositionedFluidTank tank;
public PositionedStack output;
public int ingredientCount;
public CachedCarpenterRecipe(ICarpenterRecipe recipe, boolean genPerms) {
IDescriptiveRecipe irecipe = recipe.getCraftingGridRecipe();
@@ -104,7 +78,6 @@ public class NEIHandlerCarpenter extends RecipeHandlerBase implements IGridRecip
}
public void setIngredients(int width, int height, Object[] items) {
ingredientCount = 0;
for (int x = 0; x < width; x++) {
for (int y = 0; y < height; y++) {
Object item = items[y * width + x];
@@ -116,14 +89,9 @@ public class NEIHandlerCarpenter extends RecipeHandlerBase implements IGridRecip
continue;
}
PositionedStack stack = new PositionedStack(
item,
getGridStartX() + x * getGridSpacing(),
getGridStartY() + y * getGridSpacing(),
false);
PositionedStack stack = new PositionedStack(item, 5 + x * 18, 6 + y * 18, false);
stack.setMaxSize(1);
this.inputs.add(stack);
ingredientCount++;
}
}
}
@@ -11,7 +11,6 @@ package forestry.factory.recipes.nei;
import java.awt.Point;
import java.awt.Rectangle;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -28,7 +27,6 @@ import codechicken.nei.recipe.GuiRecipe;
import forestry.api.recipes.IFabricatorRecipe;
import forestry.api.recipes.IFabricatorSmeltingRecipe;
import forestry.api.recipes.RecipeManagers;
import forestry.core.recipes.nei.IGridRecipeHandler;
import forestry.core.recipes.nei.NEIUtils;
import forestry.core.recipes.nei.PositionedFluidTank;
import forestry.core.recipes.nei.RecipeHandlerBase;
@@ -36,30 +34,7 @@ import forestry.core.utils.StringUtil;
import forestry.factory.gui.GuiFabricator;
import forestry.factory.recipes.FabricatorSmeltingRecipeManager;
public class NEIHandlerFabricator extends RecipeHandlerBase implements IGridRecipeHandler {
@Override
public int getGridStartX() {
return 62;
}
@Override
public int getGridStartY() {
return 6;
}
@Override
public int getGridSpacing() {
return 18;
}
@Override
public List<PositionedStack> getGridStacks(int recipeIndex) {
if (arecipes.get(recipeIndex) instanceof CachedFabricatorRecipe recipe) {
return recipe.inputs.subList(0, recipe.ingredientCount);
}
return Collections.emptyList();
}
public class NEIHandlerFabricator extends RecipeHandlerBase {
public class CachedFabricatorRecipe extends CachedBaseRecipe {
@@ -67,7 +42,6 @@ public class NEIHandlerFabricator extends RecipeHandlerBase implements IGridReci
public PositionedFluidTank tank;
public List<PositionedStack> inputs = new ArrayList<>();
public PositionedStack output;
public int ingredientCount;
public CachedFabricatorRecipe(IFabricatorRecipe recipe, boolean genPerms) {
if (recipe.getLiquid() != null) {
@@ -104,7 +78,6 @@ public class NEIHandlerFabricator extends RecipeHandlerBase implements IGridReci
}
public void setIngredients(int width, int height, Object[] items) {
ingredientCount = 0;
for (int x = 0; x < width; x++) {
for (int y = 0; y < height; y++) {
Object item = items[y * width + x];
@@ -116,14 +89,9 @@ public class NEIHandlerFabricator extends RecipeHandlerBase implements IGridReci
continue;
}
PositionedStack stack = new PositionedStack(
item,
getGridStartX() + x * getGridSpacing(),
getGridStartY() + y * getGridSpacing(),
false);
PositionedStack stack = new PositionedStack(item, 62 + x * 18, 6 + y * 18, false);
stack.setMaxSize(1);
this.inputs.add(stack);
ingredientCount++;
}
}
}
@@ -25,22 +25,16 @@ import forestry.plugins.PluginMail;
public class LetterProperties {
private enum State {
FRESH,
STAMPED,
OPENED,
EMPTIED;
public static final State[] VALUES = values();
EMPTIED
}
private enum Size {
EMPTY,
SMALL,
BIG;
public static final Size[] VALUES = values();
BIG
}
public static ItemStack createStampedLetterStack(ILetter letter) {
@@ -104,8 +98,8 @@ public class LetterProperties {
@SuppressWarnings("unchecked")
public static void getSubItems(Item item, CreativeTabs tab, @SuppressWarnings("rawtypes") List list) {
for (State state : State.VALUES) {
for (Size size : Size.VALUES) {
for (State state : State.values()) {
for (Size size : Size.values()) {
int meta = encodeMeta(state, size);
ItemStack letter = new ItemStack(item, 1, meta);
list.add(letter);
@@ -123,7 +117,7 @@ public class LetterProperties {
private static State getState(int meta) {
int ordinal = meta & 0x0f;
State[] values = State.VALUES;
State[] values = State.values();
if (ordinal >= values.length) {
ordinal = 0;
}
@@ -132,7 +126,7 @@ public class LetterProperties {
private static Size getSize(int meta) {
int ordinal = meta >> 4;
Size[] values = Size.VALUES;
Size[] values = Size.values();
if (ordinal >= values.length) {
ordinal = 0;
}
-3
View File
@@ -19,7 +19,6 @@ import forestry.api.mail.IMailAddress;
import forestry.api.mail.PostManager;
import forestry.core.inventory.InventoryAdapter;
import forestry.core.utils.InventoryUtil;
import forestry.core.utils.PosteaCompat;
public class POBox extends WorldSavedData implements IInventory {
@@ -43,7 +42,6 @@ public class POBox extends WorldSavedData implements IInventory {
@Override
public void readFromNBT(NBTTagCompound nbttagcompound) {
PosteaCompat.transform("forestry:" + mapName, nbttagcompound);
if (nbttagcompound.hasKey("address")) {
this.address = MailAddress.loadFromNBT(nbttagcompound.getCompoundTag("address"));
}
@@ -58,7 +56,6 @@ public class POBox extends WorldSavedData implements IInventory {
nbttagcompound.setTag("address", nbt);
}
letters.writeToNBT(nbttagcompound);
PosteaCompat.stamp(nbttagcompound);
}
public boolean storeLetter(ItemStack letterstack) {
@@ -59,25 +59,14 @@ public class PluginFluids extends ForestryPlugin {
public static ItemRegistryFluids items;
private static void createFluid(Fluids forestryFluid) {
if (!Config.isFluidEnabled(forestryFluid)) {
return;
}
String fluidName = forestryFluid.getTag();
boolean preRegistered = FluidRegistry.isFluidRegistered(fluidName);
if (!preRegistered) {
Fluid fluid = new Fluid(fluidName).setDensity(forestryFluid.getDensity())
.setViscosity(forestryFluid.getViscosity()).setTemperature(forestryFluid.getTemperature());
FluidRegistry.registerFluid(fluid);
}
// Milk is deliberately left blockless once another mod owns the fluid.
if (preRegistered && (forestryFluid == Fluids.MILK || forestryFluid.getBlock() != null)) {
return;
}
if (forestryFluid.getFluid() != null) {
createBlock(forestryFluid);
if (forestryFluid.getFluid() == null && Config.isFluidEnabled(forestryFluid)) {
String fluidName = forestryFluid.getTag();
if (!FluidRegistry.isFluidRegistered(fluidName)) {
Fluid fluid = new Fluid(fluidName).setDensity(forestryFluid.getDensity())
.setViscosity(forestryFluid.getViscosity()).setTemperature(forestryFluid.getTemperature());
FluidRegistry.registerFluid(fluid);
createBlock(forestryFluid);
}
}
}
@@ -48,7 +48,6 @@ import forestry.core.items.EnumElectronTube;
import forestry.core.recipes.RecipeUtil;
import forestry.core.utils.ItemStackUtil;
import forestry.core.utils.Log;
import forestry.core.utils.MaterialLibStacks;
import forestry.core.utils.ModUtil;
import forestry.energy.blocks.BlockEngineType;
import forestry.energy.blocks.BlockRegistryEnergy;
@@ -228,7 +227,7 @@ public class PluginIC2 extends ForestryPlugin {
}
if (rubber != null) {
crateRegistry.registerCrate(cratedPart(rubber, "Rubber", "ingot"), "cratedRubber");
crateRegistry.registerCrate(rubber, "cratedRubber");
}
if (scrap != null) {
@@ -240,24 +239,14 @@ public class PluginIC2 extends ForestryPlugin {
}
if (silver != null) {
crateRegistry.registerCrateUsingOreDict(cratedPart(silver, "Silver", "ingot"), "cratedSilver");
crateRegistry.registerCrateUsingOreDict(silver, "cratedSilver");
}
if (brass != null) {
crateRegistry.registerCrateUsingOreDict(cratedPart(brass, "Bronze", "ingot"), "cratedBrass");
crateRegistry.registerCrateUsingOreDict(brass, "cratedBrass");
}
}
/// GregTech's MaterialLib part in place of IndustrialCraft 2's copy of it, so uncrating hands out the part that
/// GregTech's recipes produce.
private static ItemStack cratedPart(ItemStack ic2Part, String material, String shape) {
if (!ModUtil.isModLoaded("gregtech")) {
return ic2Part;
}
ItemStack part = MaterialLibStacks.getStack(material, shape);
return part != null ? part : ic2Part;
}
@Optional.Method(modid = "IC2")
protected void registerRecipes() {
@@ -28,11 +28,6 @@ public class ItemInventoryBackpackPaged extends ItemInventoryBackpack implements
@Override
public void flipPage(EntityPlayer player, short page) {
ItemLocation loc = getLocation();
if (loc.type() == ItemLocation.Type.PLAYER_INVENTORY) {
GuiHandler.openGui(player, backpackNaturalist, page, loc.slotIdx());
} else {
GuiHandler.openGui(player, backpackNaturalist, page);
}
GuiHandler.openGui(player, backpackNaturalist, page);
}
}
@@ -23,7 +23,6 @@ import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.ForgeDirection;
import net.xonich.mc.nohotbarneeded.api.ActivatableFromInventoryServerSide;
import cpw.mods.fml.common.Optional;
import cpw.mods.fml.common.eventhandler.Event;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@@ -48,9 +47,6 @@ import forestry.storage.gui.GuiBackpack;
import forestry.storage.gui.GuiBackpackT2;
import forestry.storage.inventory.ItemInventoryBackpack;
@Optional.Interface(
iface = "net.xonich.mc.nohotbarneeded.api.ActivatableFromInventoryServerSide",
modid = "nohotbarneeded")
public class ItemBackpack extends ItemWithGui implements ActivatableFromInventoryServerSide {
private final IBackpackDefinition definition;
@@ -72,7 +68,7 @@ public class ItemBackpack extends ItemWithGui implements ActivatableFromInventor
@Override
protected void openGui(EntityPlayer entityplayer) {
GuiHandler.openGui(entityplayer, this, (short) type.ordinal(), entityplayer.inventory.currentItem);
GuiHandler.openGui(entityplayer, this, (short) type.ordinal());
}
@Override
@@ -326,7 +322,7 @@ public class ItemBackpack extends ItemWithGui implements ActivatableFromInventor
@Override
public Object getGui(EntityPlayer player, ItemStack heldItem, int data, ItemLocation loc) {
if (data >= EnumBackpackType.values().length) {
if (data > EnumBackpackType.values().length) {
return null;
}
EnumBackpackType type = EnumBackpackType.values()[data];
@@ -342,7 +338,7 @@ public class ItemBackpack extends ItemWithGui implements ActivatableFromInventor
@Override
public Object getContainer(EntityPlayer player, ItemStack heldItem, int data, ItemLocation loc) {
if (data >= EnumBackpackType.values().length) {
if (data > EnumBackpackType.values().length) {
return null;
}
EnumBackpackType type = EnumBackpackType.values()[data];
@@ -370,7 +366,6 @@ public class ItemBackpack extends ItemWithGui implements ActivatableFromInventor
}
@Override
@Optional.Method(modid = "nohotbarneeded")
public void activateFromInventory(EntityPlayerMP player, int slotIdx) {
GuiHandler.openGui(player, this, (short) type.ordinal(), slotIdx);
}
@@ -9,10 +9,8 @@
package forestry.storage.items;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import cpw.mods.fml.common.Optional;
import forestry.api.genetics.ISpeciesRoot;
import forestry.api.storage.EnumBackpackType;
import forestry.api.storage.IBackpackDefinition;
@@ -34,7 +32,7 @@ public class ItemBackpackNaturalist extends ItemBackpack {
@Override
protected void openGui(EntityPlayer entityplayer) {
GuiHandler.openGui(entityplayer, this, (short) 0, entityplayer.inventory.currentItem);
GuiHandler.openGui(entityplayer, this);
}
@Override
@@ -59,10 +57,4 @@ public class ItemBackpackNaturalist extends ItemBackpack {
loc);
return new ContainerNaturalistBackpack(player, inventory, page);
}
@Override
@Optional.Method(modid = "nohotbarneeded")
public void activateFromInventory(EntityPlayerMP player, int slotIdx) {
GuiHandler.openGui(player, this, /* page */(short) 0, slotIdx);
}
}
@@ -501,10 +501,10 @@ tile.for.log1=原木
tile.for.log2=原木
tile.for.log3=原木
tile.for.log4=原木
tile.for.planks.name=木材
tile.for.planks=木材
tile.for.slabs1=木材ハーフブロック
tile.for.slabs2=木材ハーフブロック
tile.for.fences.name=フェンス
tile.for.fences=フェンス
tile.harvester.0=伐採機
tile.harvester.1=収穫機
tile.harvester.2=ゴムの木収穫機
@@ -757,11 +757,9 @@ tile.candle.dyed.stump=Unlit Dyed Candle
tile.candle.lit=Lit Candle
tile.candle.dyed.lit=Lit Dyed Candle
tile.stump.0=Candle Stump
tile.for.apiculture.name=養蜂箱
tile.for.apiculture.0.name=養蜂箱
tile.for.apicultureChest.name=養蜂家のチェスト
tile.for.apicultureChest.0.name=養蜂家のチェスト
tile.for.apiculture.2.name=ビーハウス
tile.for.apiculture.0=Apiary
tile.for.apiculture.1=Apiarist's Chest
tile.for.apiculture.2=Bee House
item.for.beeQueenGE.name=Unknown Queen
####################
@@ -810,7 +808,7 @@ tile.log=Wood
tile.planks=Wood Planks
tile.slab=Wood Slab
tile.fences=Fence
tile.for.stairs.name=階段
tile.for.stairs=Stairs
wood.0=Larch
wood.1=Teak
wood.2=Acacia
@@ -835,8 +833,7 @@ wood.20=Pine
wood.21=Plum
wood.22=Maple
wood.23=Citrus
tile.for.arboriculture.name=樹医のチェスト
tile.for.arboriculture.0.name=樹医のチェスト
tile.for.arboriculture.0=Arborist's Chest
####################
# FARMING
@@ -909,8 +906,7 @@ item.butterfly=Butterfly
item.moth=Moth
item.flutterlyzer=Flutterlyzer
storage.backpack.lepidopterist=Lepidopterist's Backpack
tile.for.lepidopterology.name=鱗翅類学者のチェスト
tile.for.lepidopterology.0.name=鱗翅類学者のチェスト
tile.for.lepidopterology.0=Lepidopterist's Chest
####################
# MAIL