Compare commits

...
5 Commits
12 changed files with 343 additions and 18 deletions

No files matched your search

+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=5
@@ -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);
}
}
@@ -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";
}
}
@@ -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;
}
}
@@ -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;
@@ -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
@@ -93,8 +93,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));