Compare commits

...
15 Commits
39 changed files with 545 additions and 85 deletions

No files matched your search

+1 -1
View File
@@ -31,7 +31,7 @@ Beware of ugly code.
Bugfixes are generally welcome. If you want to contribute something which changes game mechanics, please talk to someone with commit privileges first. Nothing is more frustrating than putting a lot of work and effort into a new game mechanic and then having the PR rejected because it doesn’t fit gameplay-wise.
**If you submit a PR you must accept the [Contributor License Agreement](https://www.clahub.com/agreements/ForestryMC/ForestryMC). There is no way around that, since otherwise changing the license later - even to something more permissive! - , becomes close to impossible.**
**If you submit a PR you must accept the [Contributor License Agreement](https://cla-assistant.io/ForestryMC/ForestryMC). There is no way around that, since otherwise changing the license later - even to something more permissive! - , becomes close to impossible.**
### License & Copyright
+1 -1
View File
@@ -2,4 +2,4 @@ mcversion=1.7.10
forgeversion=10.13.3.1370-1.7.10
version_major=4
version_minor=0
version_patch=4
version_patch=6
+1
View File
@@ -3,3 +3,4 @@ samtrion;[email protected];2015-01-18
GenuineSounds;[email protected];2015-02-26
airbreather;[email protected];2015-04-10
ganymedes01;[email protected];2015-05-27
infinityraider;theoneandonlyraider@gmail;com;2015-10-03
+1 -1
Submodule lang updated: 2518a210e7...fc688b7589.
@@ -34,6 +34,7 @@ import net.minecraft.tileentity.TileEntityFlowerPot;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.world.World;
import net.minecraftforge.common.IPlantable;
import net.minecraftforge.oredict.OreDictionary;
import cpw.mods.fml.common.registry.GameRegistry;
@@ -190,15 +191,21 @@ public final class FlowerRegistry implements IFlowerRegistry {
meta = world.getBlockMetadata(x, y, z);
}
if (PluginManager.Module.AGRICRAFT.isEnabled() && (flowerType.equals(FlowerManager.FlowerTypeWheat) || flowerType.equals(FlowerManager.FlowerTypeNether))) {
if (PluginManager.Module.AGRICRAFT.isEnabled()) {
Block cropBlock = GameRegistry.findBlock("AgriCraft", "crops");
if (block == cropBlock) {
ArrayList<ItemStack> drops = block.getDrops(world, x, y, z, 7, 0);
if (drops.get(1).getItem() == Items.wheat_seeds && flowerType.equals(FlowerManager.FlowerTypeWheat)) {
return true;
}
if (drops.get(1).getItem() == Items.nether_wart && flowerType.equals(FlowerManager.FlowerTypeNether)) {
return true;
if(block instanceof IPlantable) {
//For agricraft versions which implement IPlantable in the BlockCrop class
block = ((IPlantable) block).getPlant(world, x, y, z);
} else {
//For earlier versions of AgriCraft
ArrayList<ItemStack> drops = block.getDrops(world, x, y, z, 7, 0);
if (drops.get(1).getItem() == Items.wheat_seeds && flowerType.equals(FlowerManager.FlowerTypeWheat)) {
return true;
}
if (drops.get(1).getItem() == Items.nether_wart && flowerType.equals(FlowerManager.FlowerTypeNether)) {
return true;
}
}
}
}
@@ -20,6 +20,7 @@ import forestry.api.circuits.ChipsetManager;
import forestry.api.circuits.ICircuit;
import forestry.api.circuits.ICircuitBoard;
import forestry.api.circuits.ICircuitLayout;
import forestry.api.circuits.ICircuitSocketType;
import forestry.core.proxy.Proxies;
import forestry.core.utils.StringUtil;
@@ -82,11 +83,7 @@ public class CircuitBoard<T> implements ICircuitBoard {
ChipsetManager.circuitRegistry.getDefaultLayout();
}
List<ICircuit> readcircuits = new ArrayList<ICircuit>();
if (circuits != null) {
return;
}
circuits = new ICircuit[4];
for (int i = 0; i < 4; i++) {
if (!nbttagcompound.hasKey("CA.I" + i)) {
@@ -94,10 +91,9 @@ public class CircuitBoard<T> implements ICircuitBoard {
}
ICircuit circuit = ChipsetManager.circuitRegistry.getCircuit(nbttagcompound.getString("CA.I" + i));
if (circuit != null) {
readcircuits.add(circuit);
circuits[i] = circuit;
}
}
circuits = readcircuits.toArray(new ICircuit[readcircuits.size()]);
}
@Override
@@ -170,4 +166,9 @@ public class CircuitBoard<T> implements ICircuitBoard {
public ICircuit[] getCircuits() {
return circuits;
}
@Override
public ICircuitSocketType getSocketType() {
return layout.getSocketType();
}
}
@@ -11,14 +11,17 @@
package forestry.core.circuits;
import forestry.api.circuits.ICircuitLayout;
import forestry.api.circuits.ICircuitSocketType;
import forestry.core.utils.StringUtil;
public class CircuitLayout implements ICircuitLayout {
private final String uid;
private final ICircuitSocketType socketType;
public CircuitLayout(String uid) {
public CircuitLayout(String uid, ICircuitSocketType socketType) {
this.uid = uid;
this.socketType = socketType;
}
@Override
@@ -35,4 +38,9 @@ public class CircuitLayout implements ICircuitLayout {
public String getUsage() {
return StringUtil.localize("circuit.layout." + this.uid + ".usage");
}
@Override
public ICircuitSocketType getSocketType() {
return socketType;
}
}
@@ -17,6 +17,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import forestry.api.circuits.CircuitSocketType;
import forestry.api.circuits.ICircuit;
import forestry.api.circuits.ICircuitBoard;
import forestry.api.circuits.ICircuitLayout;
@@ -26,7 +27,7 @@ import forestry.core.config.ForestryItem;
public class CircuitRegistry implements ICircuitRegistry {
public static final ICircuitLayout DUMMY_LAYOUT = new CircuitLayout("dummy");
public static final ICircuitLayout DUMMY_LAYOUT = new CircuitLayout("dummy", CircuitSocketType.NONE);
private static final Map<String, ICircuitLayout> DUMMY_MAP = new LinkedHashMap<String, ICircuitLayout>();
private final Map<String, ICircuitLayout> layoutMap = new LinkedHashMap<String, ICircuitLayout>();
private final Map<String, ICircuit> circuitMap = new LinkedHashMap<String, ICircuit>();
@@ -10,10 +10,16 @@
******************************************************************************/
package forestry.core.circuits;
import java.util.Locale;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import forestry.api.circuits.CircuitSocketType;
import forestry.api.circuits.ICircuitLayout;
import forestry.api.circuits.ICircuitSocketType;
import forestry.api.farming.FarmDirection;
import forestry.core.circuits.ItemSolderingIron.CircuitRecipe;
import forestry.core.circuits.ItemSolderingIron.SolderingInventory;
import forestry.core.config.Constants;
@@ -37,17 +43,32 @@ public class GuiSolderingIron extends GuiForestry<ContainerSolderingIron, Solder
String title = layout.getName();
fontRendererObj.drawString(title, guiLeft + 8 + getCenteredOffset(title, 138), guiTop + 16, fontColor.get("gui.screen"));
for (int l = 2; l < inventory.getSizeInventory(); l++) {
for (int i = 0; i < 4; i++) {
String description;
CircuitRecipe recipe = ItemSolderingIron.SolderManager.getMatchingRecipe(layout, inventory.getStackInSlot(l));
ItemStack tube = inventory.getStackInSlot(i + 2);
CircuitRecipe recipe = ItemSolderingIron.SolderManager.getMatchingRecipe(layout, tube);
if (recipe == null) {
description = "(" + StringUtil.localize("gui.noeffect") + ")";
} else {
description = StringUtil.localize(recipe.circuit.getName()) + " (" + recipe.circuit.getLimit() + ")";
}
int row = (l - 2) * 20;
int row = i * 20;
fontRendererObj.drawString(description, guiLeft + 32, guiTop + 36 + row, fontColor.get("gui.screen"));
if (tube == null) {
try {
ICircuitSocketType socketType = layout.getSocketType();
if (CircuitSocketType.FARM.equals(socketType)) {
FarmDirection farmDirection = FarmDirection.values()[i];
String farmDirectionString = farmDirection.toString().toLowerCase(Locale.ENGLISH);
String localizedDirection = StringUtil.localize("gui.solder." + farmDirectionString);
fontRendererObj.drawString(localizedDirection, guiLeft + 17, guiTop + 36 + row, fontColor.get("gui.screen"));
}
} catch (Throwable ignored) {
// older circuit layouts do not have getSocketType()
}
}
}
}
@@ -12,10 +12,14 @@ package forestry.core.circuits;
import net.minecraft.item.ItemStack;
import forestry.api.circuits.ICircuitSocketType;
public interface ISocketable {
int getSocketCount();
ItemStack getSocket(int slot);
void setSocket(int slot, ItemStack stack);
ICircuitSocketType getSocketType();
}
@@ -134,11 +134,11 @@ public class ItemSolderingIron extends ItemForestry implements ISolderingIron {
layouts.rotateLeft();
}
private Collection<ICircuit> getCircuits(EnumCircuitBoardType type, boolean doConsume) {
private ICircuit[] getCircuits(boolean doConsume) {
ArrayList<ICircuit> circuits = new ArrayList<ICircuit>();
ICircuit[] circuits = new ICircuit[ingredientSlotCount];
for (short i = 0; i < type.sockets; i++) {
for (short i = 0; i < ingredientSlotCount; i++) {
ItemStack ingredient = getStackInSlot(ingredientSlot1 + i);
if (ingredient == null) {
continue;
@@ -157,7 +157,7 @@ public class ItemSolderingIron extends ItemForestry implements ISolderingIron {
if (doConsume) {
decrStackSize(ingredientSlot1 + i, recipe.resource.stackSize);
}
circuits.add(recipe.circuit);
circuits[i] = recipe.circuit;
}
return circuits;
@@ -192,25 +192,33 @@ public class ItemSolderingIron extends ItemForestry implements ISolderingIron {
}
EnumCircuitBoardType type = EnumCircuitBoardType.values()[blank.getItemDamage()];
Collection<ICircuit> circuits = getCircuits(type, false);
if (circuits.size() != type.sockets) {
if (getCircuitCount() != type.sockets) {
return;
}
circuits = getCircuits(type, true);
ICircuit[] circuits = getCircuits(true);
ICircuit[] circuitsArray = circuits.toArray(new ICircuit[circuits.size()]);
ItemStack circuitBoard = ItemCircuitBoard.createCircuitboard(type, layouts.getCurrent(), circuitsArray);
ItemStack circuitBoard = ItemCircuitBoard.createCircuitboard(type, layouts.getCurrent(), circuits);
setInventorySlotContents(finishedSlot, circuitBoard);
setInventorySlotContents(blankSlot, null);
}
public static int getCount(ICircuit circuit, ArrayList<ICircuit> circuits) {
private int getCircuitCount() {
ICircuit[] circuits = getCircuits(false);
int count = 0;
for (ICircuit circuit : circuits) {
if (circuit != null) {
count++;
}
}
return count;
}
public static int getCount(ICircuit circuit, ICircuit[] circuits) {
int count = 0;
for (ICircuit other : circuits) {
if (other.getUID().equals(circuit.getUID())) {
if (other != null && other.getUID().equals(circuit.getUID())) {
count++;
}
}
@@ -242,8 +250,8 @@ public class ItemSolderingIron extends ItemForestry implements ISolderingIron {
if (circuitCount != type.sockets) {
errorStates.add(EnumErrorCode.CIRCUITMISMATCH);
} else {
Collection<ICircuit> circuits = getCircuits(type, false);
if (circuits.size() != type.sockets) {
int count = getCircuitCount();
if (count != type.sockets) {
errorStates.add(EnumErrorCode.NOCIRCUITLAYOUT);
}
}
@@ -151,16 +151,18 @@ public final class FluidHelper {
return false;
}
if (!hasRoomForDrainedContainer(input, output, drainedItem, inputSlot, outputSlot)) {
// consume forestry containers if there is only one slot
if (outputSlot == inputSlot && drainedItem != null) {
Item item = drainedItem.getItem();
// consume forestry containers if there is no room for them
if (ForestryItem.canEmpty.isItemEqual(item) || ForestryItem.waxCapsule.isItemEqual(item) || ForestryItem.refractoryEmpty.isItemEqual(item)) {
drainedItem = null;
} else {
return false;
}
}
if (!hasRoomForDrainedContainer(input, output, drainedItem, inputSlot, outputSlot)) {
return false;
}
fluidHandler.fill(ForgeDirection.UNKNOWN, fluidInContainer, true);
if (drainedItem != null) {
@@ -14,6 +14,8 @@ import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import forestry.api.circuits.ChipsetManager;
import forestry.api.circuits.ICircuitBoard;
import forestry.core.circuits.ISocketable;
import forestry.core.network.PacketId;
import forestry.core.network.PacketSlotClick;
@@ -41,6 +43,23 @@ public class ContainerSocketedHelper<T extends TileEntity & ISocketable> impleme
return;
}
if (!ChipsetManager.circuitRegistry.isChipset(itemstack)) {
return;
}
ICircuitBoard circuitBoard = ChipsetManager.circuitRegistry.getCircuitboard(itemstack);
if (circuitBoard == null) {
return;
}
try {
if (!tile.getSocketType().equals(circuitBoard.getSocketType())) {
return;
}
} catch (Throwable ignored) {
// older circuitBoards don't have getSocketType()
}
ItemStack toSocket = itemstack.copy();
toSocket.stackSize = 1;
tile.setSocket(slot, toSocket);
@@ -20,6 +20,7 @@ public enum PacketId {
FX_SIGNAL,
WORKTABLE_MEMORY_UPDATE,
WORKTABLE_NEI_SELECT,
HABITAT_BIOME_POINTER,
CANDLE,
@@ -0,0 +1,80 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.core.recipes.nei;
import java.util.List;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import forestry.core.network.PacketId;
import forestry.core.network.PacketNBT;
import forestry.core.proxy.Proxies;
import codechicken.nei.LayoutManager;
import codechicken.nei.OffsetPositioner;
import codechicken.nei.PositionedStack;
import codechicken.nei.api.DefaultOverlayRenderer;
import codechicken.nei.api.IOverlayHandler;
import codechicken.nei.api.IStackPositioner;
import codechicken.nei.recipe.IRecipeHandler;
/**
* @author bdew
*/
public class CustomOverlayHandler implements IOverlayHandler {
private final int xOffs;
private final int yOffs;
private final boolean forceShift;
public CustomOverlayHandler(int xOffs, int yOffs, boolean forceShift) {
this.xOffs = xOffs;
this.yOffs = yOffs;
this.forceShift = forceShift;
}
@Override
public void overlayRecipe(GuiContainer cont, IRecipeHandler recipe, int recipeIndex, boolean shift) {
List<PositionedStack> ingr = recipe.getIngredientStacks(recipeIndex);
if (shift || forceShift) {
NBTTagList stacksnbt = new NBTTagList();
for (PositionedStack pstack : ingr) {
if (pstack != null) {
// This is back-asswards but i don't see a better way :(
int x = (pstack.relx - 25) / 18;
int y = (pstack.rely - 6) / 18;
ItemStack stack = pstack.item;
NBTTagCompound stacknbt = stack.writeToNBT(new NBTTagCompound());
stacknbt.setInteger("slot", y * 3 + x);
stacksnbt.appendTag(stacknbt);
}
ItemStack stack = recipe.getResultStack(recipeIndex).items[0];
NBTTagCompound stacknbt = stack.writeToNBT(new NBTTagCompound());
stacknbt.setInteger("slot", 9);
stacksnbt.appendTag(stacknbt);
}
NBTTagCompound data = new NBTTagCompound();
data.setTag("stacks", stacksnbt);
Proxies.net.sendToServer(new PacketNBT(PacketId.WORKTABLE_NEI_SELECT, data));
} else {
IStackPositioner positioner = new OffsetPositioner(xOffs, yOffs);
LayoutManager.overlayRenderer = new DefaultOverlayRenderer(ingr, positioner);
}
}
}
@@ -0,0 +1,57 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.core.recipes.nei;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import forestry.core.config.Constants;
import codechicken.nei.api.ItemFilter;
/**
* @author bdew
*/
public class ItemFilterForestry implements ItemFilter {
private final boolean items;
public ItemFilterForestry(Boolean items) {
this.items = items;
}
@Override
public boolean matches(ItemStack item) {
if (item == null || item.getItem() == null) {
return false;
}
if (item.getItem() instanceof ItemBlock && items) {
return false;
}
if (!(item.getItem() instanceof ItemBlock) && !items) {
return false;
}
String itemName = Item.itemRegistry.getNameForObject(item.getItem());
if (itemName == null) {
return false;
}
String[] s = itemName.split(":");
if (s.length <= 1) {
return false;
}
return s[0].equals(Constants.MOD);
}
}
@@ -0,0 +1,54 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.core.recipes.nei;
import net.minecraft.item.ItemStack;
import forestry.api.genetics.IIndividual;
import forestry.api.genetics.ISpeciesRoot;
import codechicken.nei.api.ItemFilter;
/**
* @author bdew
*/
public class ItemFilterGenetic implements ItemFilter {
private final ISpeciesRoot root;
private final int type;
private final boolean analyzedOnly;
public ItemFilterGenetic(ISpeciesRoot root, int type, boolean analyzedOnly) {
this.root = root;
this.type = type;
this.analyzedOnly = analyzedOnly;
}
private boolean isMember(ItemStack item) {
if (type >= 0) {
return root.isMember(item, type);
} else {
return root.isMember(item);
}
}
@Override
public boolean matches(ItemStack item) {
if (analyzedOnly) {
if (!isMember(item)) {
return false;
}
IIndividual individual = root.getMember(item);
return individual.isAnalyzed() || !individual.isSecret();
} else {
return isMember(item);
}
}
}
@@ -0,0 +1,30 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.core.recipes.nei;
import net.minecraft.item.ItemStack;
import forestry.api.genetics.AlleleManager;
/**
* @author bdew
*/
public class ItemFilterOther extends ItemFilterForestry {
public ItemFilterOther(Boolean items) {
super(items);
}
@Override
public boolean matches(ItemStack item) {
return super.matches(item) && !AlleleManager.alleleRegistry.isIndividual(item);
}
}
@@ -109,6 +109,11 @@ public class NEIHandlerShapedCustom extends RecipeHandlerBase {
return "crafting";
}
@Override
public String getOverlayIdentifier() {
return "crafting";
}
@Override
public String getRecipeName() {
return NEIUtils.translate("handler.forestry.shaped");
@@ -100,6 +100,11 @@ public class NEIHandlerShapelessCustom extends RecipeHandlerBase {
return "crafting";
}
@Override
public String getOverlayIdentifier() {
return "crafting";
}
@Override
public String getRecipeName() {
return NEIUtils.translate("handler.forestry.shapeless");
@@ -10,7 +10,15 @@
******************************************************************************/
package forestry.core.recipes.nei;
import net.minecraftforge.oredict.OreDictionary;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.EnumBeeType;
import forestry.api.arboriculture.EnumGermlingType;
import forestry.api.arboriculture.TreeManager;
import forestry.api.lepidopterology.EnumFlutterType;
import forestry.core.utils.Log;
import forestry.factory.gui.GuiWorktable;
import forestry.factory.recipes.nei.NEIHandlerBottler;
import forestry.factory.recipes.nei.NEIHandlerCarpenter;
import forestry.factory.recipes.nei.NEIHandlerCentrifuge;
@@ -19,6 +27,7 @@ import forestry.factory.recipes.nei.NEIHandlerFermenter;
import forestry.factory.recipes.nei.NEIHandlerMoistener;
import forestry.factory.recipes.nei.NEIHandlerSqueezer;
import forestry.factory.recipes.nei.NEIHandlerStill;
import forestry.plugins.PluginLepidopterology;
import codechicken.nei.api.API;
import codechicken.nei.api.IConfigureNEI;
@@ -39,6 +48,24 @@ public class NEIIntegrationConfig implements IConfigureNEI {
registerHandler(new NEIHandlerMoistener());
registerHandler(new NEIHandlerSqueezer());
registerHandler(new NEIHandlerStill());
CustomOverlayHandler handler = new CustomOverlayHandler(-14, 14, true);
API.registerGuiOverlayHandler(GuiWorktable.class, handler, "crafting");
API.addSubset("Forestry.Bees.Princesses", new ItemFilterGenetic(BeeManager.beeRoot, EnumBeeType.PRINCESS.ordinal(), true));
API.addSubset("Forestry.Bees.Drones", new ItemFilterGenetic(BeeManager.beeRoot, EnumBeeType.DRONE.ordinal(), true));
API.addSubset("Forestry.Bees.Larvae", new ItemFilterGenetic(BeeManager.beeRoot, EnumBeeType.LARVAE.ordinal(), true));
API.addSubset("Forestry.Trees.Saplings", new ItemFilterGenetic(TreeManager.treeRoot, EnumGermlingType.SAPLING.ordinal(), true));
API.addSubset("Forestry.Trees.Pollen", new ItemFilterGenetic(TreeManager.treeRoot, EnumGermlingType.POLLEN.ordinal(), true));
API.addSubset("Forestry.Butterflies.Butterflies", new ItemFilterGenetic(PluginLepidopterology.butterflyInterface, EnumFlutterType.BUTTERFLY.ordinal(), true));
API.addSubset("Forestry.Butterflies.Caterpillars", new ItemFilterGenetic(PluginLepidopterology.butterflyInterface, EnumFlutterType.CATERPILLAR.ordinal(), true));
API.addSubset("Forestry.Butterflies.Serum", new ItemFilterGenetic(PluginLepidopterology.butterflyInterface, EnumFlutterType.SERUM.ordinal(), true));
API.addSubset("Forestry.Bees.Combs", OreDictionary.getOres("beeComb"));
API.addSubset("Forestry.Blocks", new ItemFilterOther(false));
API.addSubset("Forestry.Items", new ItemFilterOther(true));
}
protected static void registerHandler(IRecipeHandlerBase handler) {
@@ -54,7 +81,7 @@ public class NEIIntegrationConfig implements IConfigureNEI {
@Override
public String getVersion() {
return "1.0.0";
return "1.1.0";
}
}
@@ -53,10 +53,6 @@ public abstract class RecipeHandlerBase extends TemplateRecipeHandler implements
public abstract String getRecipeID();
public String getRecipeSubName() {
return null;
}
public void changeToGuiTexture() {
GuiDraw.changeTexture(this.getGuiTexture());
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
@@ -70,9 +66,6 @@ public abstract class RecipeHandlerBase extends TemplateRecipeHandler implements
public void drawForeground(int recipe) {
super.drawForeground(recipe);
this.drawFluidTanks(recipe);
if (recipe % this.recipiesPerPage() == 0 && this.getRecipeSubName() != null) {
GuiDraw.drawStringC(this.getRecipeSubName(), 83, -2, 0x404040, false);
}
this.changeToGuiTexture();
}
@@ -0,0 +1,60 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.core.recipes.nei;
import java.util.HashMap;
import java.util.Map;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
/**
* @author bdew
*/
public class SetRecipeCommandHandler {
private final Class<? extends Container> containerClass;
private final Class<? extends Slot> slotClass;
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 (!containerClass.isInstance(cont)) {
return;
}
Map<Integer, ItemStack> stmap = new HashMap<Integer, ItemStack>();
for (int i = 0; i < stacks.tagCount(); i++) {
NBTTagCompound itemdata = stacks.getCompoundTagAt(i);
stmap.put(itemdata.getInteger("slot"), ItemStack.loadItemStackFromNBT(itemdata));
}
for (Object slotobj : cont.inventorySlots) {
if (!slotClass.isInstance(slotobj)) {
continue;
}
Slot slot = (Slot) slotobj;
if (stmap.containsKey(slot.getSlotIndex())) {
slot.putStack(stmap.get(slot.getSlotIndex()));
} else {
slot.putStack(null);
}
}
}
}
@@ -195,20 +195,19 @@ public class GeneticsUtil {
exclude.add(species);
for (IMutation mutation : species.getRoot().getPaths(species, speciesChromosome)) {
if (!exclude.contains(mutation.getAllele0())) {
int otherAdvance = getGeneticAdvancement(mutation.getAllele0(), exclude, speciesChromosome);
if (otherAdvance > highest) {
highest = otherAdvance;
}
}
if (!exclude.contains(mutation.getAllele1())) {
int otherAdvance = getGeneticAdvancement(mutation.getAllele1(), exclude, speciesChromosome);
if (otherAdvance > highest) {
highest = otherAdvance;
}
}
highest = getHighestAdvancement(mutation.getAllele0(), highest, exclude, speciesChromosome);
highest = getHighestAdvancement(mutation.getAllele1(), highest, exclude, speciesChromosome);
}
return 1 + highest;
}
private static int getHighestAdvancement(IAlleleSpecies mutationSpecies, int highest, Set<IAlleleSpecies> exclude, IChromosomeType speciesChromosome) {
if (exclude.contains(mutationSpecies) || AlleleManager.alleleRegistry.isBlacklisted(mutationSpecies.getUID())) {
return highest;
}
int otherAdvance = getGeneticAdvancement(mutationSpecies, exclude, speciesChromosome);
return otherAdvance > highest ? otherAdvance : highest;
}
}
@@ -18,7 +18,9 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import forestry.api.circuits.ChipsetManager;
import forestry.api.circuits.CircuitSocketType;
import forestry.api.circuits.ICircuitBoard;
import forestry.api.circuits.ICircuitSocketType;
import forestry.api.core.ForestryAPI;
import forestry.api.core.IErrorLogic;
import forestry.core.circuits.ISocketable;
@@ -309,6 +311,11 @@ public class TileEngineElectric extends TileEngine implements ISocketable, IInve
}
}
@Override
public ICircuitSocketType getSocketType() {
return CircuitSocketType.ELECTRIC_ENGINE;
}
private static class EngineTinInventoryAdapter extends TileInventoryAdapter<TileEngineElectric> {
public EngineTinInventoryAdapter(TileEngineElectric engineTin) {
super(engineTin, 1, "electrical");
@@ -13,13 +13,20 @@ package forestry.factory.network;
import java.io.IOException;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import forestry.core.gui.slots.SlotCraftMatrix;
import forestry.core.network.DataInputStreamForestry;
import forestry.core.network.IPacketHandler;
import forestry.core.network.PacketId;
import forestry.core.network.PacketNBT;
import forestry.core.recipes.nei.SetRecipeCommandHandler;
import forestry.factory.gui.ContainerWorktable;
public class PacketHandlerFactory implements IPacketHandler {
private static final SetRecipeCommandHandler worktableNEISelectHandler = new SetRecipeCommandHandler(ContainerWorktable.class, SlotCraftMatrix.class);
@Override
public boolean onPacketData(PacketId packetID, DataInputStreamForestry data, EntityPlayer player) throws IOException {
@@ -28,6 +35,11 @@ public class PacketHandlerFactory implements IPacketHandler {
PacketWorktableMemoryUpdate.onPacketData(data);
return true;
}
case WORKTABLE_NEI_SELECT: {
PacketNBT packet = new PacketNBT(data);
worktableNEISelectHandler.handle(packet.getTagCompound(), (EntityPlayerMP) player);
return true;
}
}
return false;
@@ -35,7 +35,9 @@ import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.common.Optional;
import forestry.api.circuits.ChipsetManager;
import forestry.api.circuits.CircuitSocketType;
import forestry.api.circuits.ICircuitBoard;
import forestry.api.circuits.ICircuitSocketType;
import forestry.api.core.ForestryAPI;
import forestry.api.core.IErrorLogic;
import forestry.api.recipes.ICentrifugeManager;
@@ -282,6 +284,11 @@ public class TileCentrifuge extends TilePowered implements ISocketable, ISidedIn
}
}
@Override
public ICircuitSocketType getSocketType() {
return CircuitSocketType.MACHINE;
}
/* RECIPE MANAGEMENT */
public static class CentrifugeRecipe implements ICentrifugeRecipe {
@@ -33,7 +33,9 @@ import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import forestry.api.circuits.ChipsetManager;
import forestry.api.circuits.CircuitSocketType;
import forestry.api.circuits.ICircuitBoard;
import forestry.api.circuits.ICircuitSocketType;
import forestry.api.core.ForestryAPI;
import forestry.api.core.IErrorLogic;
import forestry.api.recipes.ISqueezerManager;
@@ -315,6 +317,11 @@ public class TileSqueezer extends TilePowered implements ISocketable, ISidedInve
}
}
@Override
public ICircuitSocketType getSocketType() {
return CircuitSocketType.MACHINE;
}
public static class SqueezerInventory extends TileInventoryAdapter<TileSqueezer> {
public static final short SLOT_RESOURCE_1 = 0;
public static final short SLOTS_RESOURCE_COUNT = 9;
@@ -175,11 +175,14 @@ public class TileWorktable extends TileBase implements ICrafterWorktable {
ItemStack[] set = InventoryUtil.getStacks(currentRecipe.getMatrix(), SLOT_CRAFTING_1, SLOT_CRAFTING_COUNT);
ItemStack[] removed = InventoryUtil.removeSets(this, 1, set, SLOT_INVENTORY_1, SLOT_INVENTORY_COUNT, player, false, true, true);
if (removed == null) {
return false;
}
for (int i = 0; i < removed.length; i++) {
craftingInventory.setInventorySlotContents(i, removed[i]);
}
return removed != null;
return true;
}
@Override
@@ -42,8 +42,8 @@ public class GuiFarm extends GuiForestry<ContainerFarm, TileFarm> {
widgetManager.add(new FarmLogicSlot(widgetManager, 69, 22, FarmDirection.NORTH));
widgetManager.add(new FarmLogicSlot(widgetManager, 69, 58, FarmDirection.SOUTH));
widgetManager.add(new FarmLogicSlot(widgetManager, 51, 40, FarmDirection.EAST));
widgetManager.add(new FarmLogicSlot(widgetManager, 87, 40, FarmDirection.WEST));
widgetManager.add(new FarmLogicSlot(widgetManager, 51, 40, FarmDirection.WEST));
widgetManager.add(new FarmLogicSlot(widgetManager, 87, 40, FarmDirection.EAST));
this.xSize = 216;
this.ySize = 220;
@@ -20,6 +20,7 @@ import forestry.api.arboriculture.ITree;
import forestry.api.arboriculture.TreeManager;
import forestry.api.genetics.IIndividual;
import forestry.core.utils.GeneticsUtil;
import forestry.plugins.PluginManager;
public class FarmableVanillaSapling extends FarmableGenericSapling {
@@ -29,12 +30,16 @@ public class FarmableVanillaSapling extends FarmableGenericSapling {
@Override
public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, int x, int y, int z) {
IIndividual tree = GeneticsUtil.getGeneticEquivalent(germling);
if (!(tree instanceof ITree)) {
return false;
}
if (PluginManager.Module.ARBORICULTURE.isEnabled()) {
IIndividual tree = GeneticsUtil.getGeneticEquivalent(germling);
if (!(tree instanceof ITree)) {
return false;
}
return TreeManager.treeRoot.plantSapling(world, (ITree) tree, player.getGameProfile(), x, y, z);
return TreeManager.treeRoot.plantSapling(world, (ITree) tree, player.getGameProfile(), x, y, z);
} else {
return germling.copy().tryPlaceItemIntoWorld(player, world, x, y - 1, z, 1, 0, 0, 0);
}
}
}
@@ -19,6 +19,8 @@ import net.minecraft.world.World;
import net.minecraftforge.fluids.FluidStack;
import forestry.api.circuits.CircuitSocketType;
import forestry.api.circuits.ICircuitSocketType;
import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
import forestry.api.core.IErrorLogic;
@@ -152,6 +154,11 @@ public class FakeFarmController implements IFarmController {
}
@Override
public ICircuitSocketType getSocketType() {
return CircuitSocketType.NONE;
}
@Override
public IErrorLogic getErrorLogic() {
return FakeErrorLogic.instance;
@@ -35,7 +35,9 @@ import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import forestry.api.circuits.ChipsetManager;
import forestry.api.circuits.CircuitSocketType;
import forestry.api.circuits.ICircuitBoard;
import forestry.api.circuits.ICircuitSocketType;
import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
import forestry.api.core.IErrorLogic;
@@ -123,6 +125,9 @@ public class FarmController extends RectangularMultiblockControllerBase implemen
private final FarmHydrationManager hydrationManager;
private final FarmFertilizerManager fertilizerManager;
// the number of work ticks that this farm has had no power
private int noPowerTime = 0;
private BiomeGenBase cachedBiome;
public FarmController(World world) {
@@ -267,12 +272,28 @@ public class FarmController extends RectangularMultiblockControllerBase implemen
inventory.drainCan(tankManager);
}
boolean hasPower = false;
for (Map.Entry<IFarmComponent.Active, Integer> entry : farmActiveComponents.entrySet()) {
IFarmComponent.Active farmComponent = entry.getKey();
if (farmComponent instanceof TileGearbox) {
hasPower |= ((TileGearbox) farmComponent).getEnergyManager().getTotalEnergyStored() > 0;
}
int tickOffset = entry.getValue();
farmComponent.updateServer(tickCount + tickOffset);
}
if (hasPower) {
noPowerTime = 0;
getErrorLogic().setCondition(false, EnumErrorCode.NOPOWER);
} else {
if (noPowerTime <= 4) {
noPowerTime++;
} else {
getErrorLogic().setCondition(true, EnumErrorCode.NOPOWER);
}
}
//FIXME: be smarter about the farm needing to save
return true;
}
@@ -848,4 +869,8 @@ public class FarmController extends RectangularMultiblockControllerBase implemen
}
}
@Override
public ICircuitSocketType getSocketType() {
return CircuitSocketType.FARM;
}
}
@@ -18,6 +18,7 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.util.StatCollector;
import forestry.api.circuits.ICircuitSocketType;
import forestry.api.core.ForestryAPI;
import forestry.api.core.IErrorLogic;
import forestry.api.core.IErrorLogicSource;
@@ -178,6 +179,11 @@ public abstract class TileFarm extends RectangularMultiblockTileEntityBase imple
getFarmController().setSocket(slot, stack);
}
@Override
public ICircuitSocketType getSocketType() {
return getFarmController().getSocketType();
}
/* IStreamableGui */
@Override
public ChunkCoordinates getCoordinates() {
@@ -14,9 +14,7 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import forestry.api.core.IErrorLogic;
import forestry.api.farming.IFarmComponent;
import forestry.core.errors.EnumErrorCode;
import forestry.core.tiles.IPowerHandler;
import forestry.energy.EnergyManager;
import forestry.farming.multiblock.IFarmController;
@@ -57,13 +55,7 @@ public class TileGearbox extends TileFarm implements IPowerHandler, IFarmCompone
@Override
public void updateServer(int tickCount) {
IFarmController farmController = getFarmController();
IErrorLogic errorLogic = farmController.getErrorLogic();
boolean hasPower = energyManager.getTotalEnergyStored() > 0;
if (errorLogic.setCondition(!hasPower, EnumErrorCode.NOPOWER)) {
if (energyManager.getTotalEnergyStored() <= 0) {
return;
}
@@ -78,6 +70,7 @@ public class TileGearbox extends TileFarm implements IPowerHandler, IFarmCompone
}
if (workCounter >= WORK_CYCLES && (tickCount % 5 == 0)) {
IFarmController farmController = getFarmController();
if (farmController.doWork()) {
workCounter = 0;
previousDelays = 0;
@@ -23,6 +23,7 @@ import net.minecraftforge.oredict.OreDictionary;
import cpw.mods.fml.common.network.IGuiHandler;
import forestry.api.circuits.ChipsetManager;
import forestry.api.circuits.CircuitSocketType;
import forestry.api.circuits.ICircuitLayout;
import forestry.api.recipes.RecipeManagers;
import forestry.core.blocks.BlockBase;
@@ -234,7 +235,7 @@ public class PluginFactory extends ForestryPlugin {
'C', "chestWood"))
.setFaces(0, 1, 2, 3, 4, 4));
ICircuitLayout layoutMachineUpgrade = new CircuitLayout("machine.upgrade");
ICircuitLayout layoutMachineUpgrade = new CircuitLayout("machine.upgrade", CircuitSocketType.MACHINE);
ChipsetManager.circuitRegistry.registerLayout(layoutMachineUpgrade);
}
@@ -32,6 +32,7 @@ import cpw.mods.fml.common.registry.GameData;
import cpw.mods.fml.common.registry.GameRegistry;
import forestry.api.circuits.ChipsetManager;
import forestry.api.circuits.CircuitSocketType;
import forestry.api.circuits.ICircuitLayout;
import forestry.api.farming.Farmables;
import forestry.api.farming.IFarmable;
@@ -93,8 +94,10 @@ public class PluginFarming extends ForestryPlugin {
Farmables.farmables.put("farmArboreal", new ArrayList<IFarmable>());
Farmables.farmables.get("farmArboreal").add(new FarmableVanillaSapling());
Farmables.farmables.get("farmArboreal").add(new FarmableGE());
if (PluginManager.Module.ARBORICULTURE.isEnabled()) {
Farmables.farmables.get("farmArboreal").add(new FarmableGE());
}
Farmables.farmables.put("farmOrchard", new ArrayList<IFarmable>());
Farmables.farmables.get("farmOrchard").add(new FarmableBasicFruit(Blocks.wheat, 7));
Farmables.farmables.get("farmOrchard").add(new FarmableBasicFruit(Blocks.potatoes, 7));
@@ -133,9 +136,9 @@ public class PluginFarming extends ForestryPlugin {
proxy.initializeRendering();
// Layouts
ICircuitLayout layoutManaged = new CircuitLayout("farms.managed");
ICircuitLayout layoutManaged = new CircuitLayout("farms.managed", CircuitSocketType.FARM);
ChipsetManager.circuitRegistry.registerLayout(layoutManaged);
ICircuitLayout layoutManual = new CircuitLayout("farms.manual");
ICircuitLayout layoutManual = new CircuitLayout("farms.manual", CircuitSocketType.FARM);
ChipsetManager.circuitRegistry.registerLayout(layoutManual);
}
@@ -25,6 +25,7 @@ import cpw.mods.fml.common.event.FMLInterModComms;
import cpw.mods.fml.common.registry.GameData;
import forestry.api.circuits.ChipsetManager;
import forestry.api.circuits.CircuitSocketType;
import forestry.api.circuits.ICircuitLayout;
import forestry.api.fuels.EngineBronzeFuel;
import forestry.api.fuels.FuelManager;
@@ -169,7 +170,7 @@ public class PluginIC2 extends ForestryPlugin {
Circuit.farmRubberManual = new CircuitFarmLogic("manualRubber", FarmLogicRubber.class);
ICircuitLayout layoutEngineTin = new CircuitLayout("engine.tin");
ICircuitLayout layoutEngineTin = new CircuitLayout("engine.tin", CircuitSocketType.ELECTRIC_ENGINE);
ChipsetManager.circuitRegistry.registerLayout(layoutEngineTin);
}