mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-21 12:32:23 +00:00
Updated to Forestry 131
This commit is contained in:
commit
c6b2110182
128 files changed
+1399
-1219
No files matched your search
@@ -49,7 +49,7 @@ import net.minecraft.item.Item;
|
||||
modid = Defaults.MOD,
|
||||
name = "Forestry",
|
||||
version = Version.VERSION,
|
||||
dependencies = "required-after:Forge@[10.13.0.1180,);"
|
||||
dependencies = "required-after:Forge@[10.13.0.1207,);"
|
||||
+ "after:Buildcraft|Core;"
|
||||
+ "after:ExtrabiomesXL;"
|
||||
+ "after:BiomesOPlenty;"
|
||||
@@ -119,18 +119,22 @@ public class Forestry {
|
||||
if (block != null) {
|
||||
mapping.remap(Item.getItemFromBlock(block));
|
||||
Proxies.log.warning("Remapping item " + mapping.name + " to " + StringUtil.cleanBlockName(block));
|
||||
continue;
|
||||
}
|
||||
if (mapping.name.equals("builderBackpack"))
|
||||
} else if (mapping.name.equals("Forestry:builderBackpack")) {
|
||||
mapping.remap(ForestryItem.builderBackpack.item());
|
||||
if (mapping.name.equals("builderBackpackT2"))
|
||||
Proxies.log.warning("Remapping item " + mapping.name + " to " + ForestryItem.builderBackpack.name());
|
||||
} else if (mapping.name.equals("Forestry:builderBackpackT2")) {
|
||||
mapping.remap(ForestryItem.builderBackpackT2.item());
|
||||
if (mapping.name.equals("adventurerBackpack"))
|
||||
Proxies.log.warning("Remapping item " + mapping.name + " to " + ForestryItem.builderBackpackT2.name());
|
||||
} else if (mapping.name.equals("Forestry:adventurerBackpack")) {
|
||||
mapping.remap(ForestryItem.adventurerBackpack.item());
|
||||
if (mapping.name.equals("adventurerBackpackT2"))
|
||||
Proxies.log.warning("Remapping item " + mapping.name + " to " + ForestryItem.adventurerBackpack.name());
|
||||
} else if (mapping.name.equals("Forestry:adventurerBackpackT2")) {
|
||||
mapping.remap(ForestryItem.adventurerBackpackT2.item());
|
||||
if (mapping.name.equals("shortMead"))
|
||||
Proxies.log.warning("Remapping item " + mapping.name + " to " + ForestryItem.adventurerBackpackT2.name());
|
||||
} else if (mapping.name.equals("Forestry:shortMead")) {
|
||||
mapping.remap(ForestryItem.beverage.item());
|
||||
Proxies.log.warning("Remapping item " + mapping.name + " to " + ForestryItem.beverage.name());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -204,7 +204,10 @@ public class CommandBeekeepingMode extends CommandMC {
|
||||
private void listModes(ICommandSender sender, String[] arguments) {
|
||||
World world = getWorld(sender, arguments);
|
||||
|
||||
sendChatMessage(sender, StringUtil.localize("chat.bees.command.mode.current").replaceAll("%MODE", PluginApiculture.beeInterface.getBeekeepingMode(world).getName()).replaceAll("%WORLD", String.valueOf(world.getWorldInfo().getSaveVersion())));
|
||||
String message = StringUtil.localize("chat.bees.command.mode.current");
|
||||
message = message.replaceAll("%MODE", PluginApiculture.beeInterface.getBeekeepingMode(world).getName());
|
||||
message = message.replaceAll("%WORLD", String.valueOf(world.getWorldInfo().getSaveVersion()));
|
||||
sendChatMessage(sender, message);
|
||||
|
||||
String help = "";
|
||||
for (IBeekeepingMode mode : PluginApiculture.beeInterface.getBeekeepingModes()) {
|
||||
|
||||
@@ -147,6 +147,8 @@ public class BlockAlveary extends BlockStructure {
|
||||
return icons[BOTTOM];
|
||||
|
||||
switch (metadata) {
|
||||
case TileAlvearyPlain.BLOCK_META:
|
||||
return icons[PLAIN];
|
||||
case 1:
|
||||
return icons[ENTRANCE];
|
||||
case TileAlvearySwarmer.BLOCK_META:
|
||||
@@ -162,7 +164,7 @@ public class BlockAlveary extends BlockStructure {
|
||||
case TileAlvearySieve.BLOCK_META:
|
||||
return icons[SIEVE];
|
||||
default:
|
||||
return icons[PLAIN];
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -155,6 +155,9 @@ public class BlockBeehives extends BlockContainer {
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int i, int j) {
|
||||
if (j == 0 || j >= 8)
|
||||
return null;
|
||||
|
||||
if (i == 0 || i == 1) {
|
||||
if (j * 2 < icons.length && icons[j * 2] != null)
|
||||
return icons[j * 2];
|
||||
|
||||
@@ -136,10 +136,6 @@ public abstract class TileAlvearyClimatiser extends TileAlveary implements IPowe
|
||||
nbttagcompound.setInteger("Heating", transferTime);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return "tile.alveary.climatiser";
|
||||
}
|
||||
|
||||
/* NETWORK */
|
||||
@Override
|
||||
|
||||
@@ -77,7 +77,7 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return "tile.alveary.5";
|
||||
return getUnlocalizedName();
|
||||
}
|
||||
|
||||
/* UPDATING */
|
||||
|
||||
@@ -54,6 +54,8 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS
|
||||
public static final int SLOT_DRONE = 1;
|
||||
public static final int SLOT_PRODUCT_1 = 2;
|
||||
public static final int SLOT_PRODUCTION_COUNT = 7;
|
||||
public static final int BLOCK_META = 0;
|
||||
|
||||
// / MEMBERS
|
||||
protected IBeekeepingLogic beekeepingLogic;
|
||||
protected int biomeId;
|
||||
@@ -582,7 +584,7 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return "alveary.0";
|
||||
return getUnlocalizedName();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -45,10 +45,6 @@ public class TileAlvearySieve extends TileAlveary implements ICrafter, IBeeListe
|
||||
player.openGui(ForestryAPI.instance, GuiId.AlvearySieveGUI.ordinal(), worldObj, xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return "tile.alveary.7";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasFunction() {
|
||||
|
||||
@@ -46,10 +46,6 @@ public class TileAlvearyStabiliser extends TileAlveary implements IBeeModifier {
|
||||
((IAlvearyComponent)getCentralTE()).registerBeeModifier(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return "tile.alveary.6";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasFunction() {
|
||||
|
||||
@@ -267,7 +267,7 @@ public class TileAlvearySwarmer extends TileAlveary implements ISpecialInventory
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return "tile.alveary.2";
|
||||
return getUnlocalizedName();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -30,7 +30,7 @@ public class TileApiary extends TileBeehouse implements ISidedInventory {
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return "apiculture.0";
|
||||
return getUnlocalizedName();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -68,11 +68,6 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
|
||||
logic = PluginApiculture.beeInterface.createBeekeepingLogic(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return "apiculture.2";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openGui(EntityPlayer player, TileBase tile) {
|
||||
player.openGui(ForestryAPI.instance, GuiId.BeehouseGUI.ordinal(), worldObj, xCoord, yCoord, zCoord);
|
||||
|
||||
@@ -10,74 +10,17 @@
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.gui;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import forestry.core.gui.ContainerAlyzer;
|
||||
import forestry.core.config.ForestryItem;
|
||||
import forestry.apiculture.items.ItemBeeGE;
|
||||
import forestry.apiculture.items.ItemBeealyzer.BeealyzerInventory;
|
||||
import forestry.core.config.ForestryItem;
|
||||
import forestry.core.gui.ContainerItemInventory;
|
||||
import forestry.core.gui.slots.SlotCustom;
|
||||
import forestry.core.proxy.Proxies;
|
||||
|
||||
public class ContainerBeealyzer extends ContainerItemInventory {
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
BeealyzerInventory inventory;
|
||||
public class ContainerBeealyzer extends ContainerAlyzer {
|
||||
|
||||
public ContainerBeealyzer(InventoryPlayer inventoryplayer, BeealyzerInventory inventory) {
|
||||
super(inventory, inventoryplayer.player);
|
||||
|
||||
this.inventory = inventory;
|
||||
|
||||
// Energy
|
||||
this.addSlot(new SlotCustom(inventory, BeealyzerInventory.SLOT_ENERGY, 172, 8, new Object[] { ForestryItem.honeydew, ForestryItem.honeyDrop }));
|
||||
|
||||
// Bee to analyze
|
||||
this.addSlot(new SlotCustom(inventory, BeealyzerInventory.SLOT_SPECIMEN, 172, 26, new Object[] { ItemBeeGE.class }));
|
||||
|
||||
// Analyzed bee
|
||||
this.addSlot(new SlotCustom(inventory, BeealyzerInventory.SLOT_ANALYZE_1, 172, 57, new Object[] { ItemBeeGE.class }));
|
||||
this.addSlot(new SlotCustom(inventory, BeealyzerInventory.SLOT_ANALYZE_2, 172, 75, new Object[] { ItemBeeGE.class }));
|
||||
this.addSlot(new SlotCustom(inventory, BeealyzerInventory.SLOT_ANALYZE_3, 172, 93, new Object[] { ItemBeeGE.class }));
|
||||
this.addSlot(new SlotCustom(inventory, BeealyzerInventory.SLOT_ANALYZE_4, 172, 111, new Object[] { ItemBeeGE.class }));
|
||||
this.addSlot(new SlotCustom(inventory, BeealyzerInventory.SLOT_ANALYZE_5, 172, 129, new Object[] { ItemBeeGE.class }));
|
||||
|
||||
// Player inventory
|
||||
for (int i1 = 0; i1 < 3; i1++)
|
||||
for (int l1 = 0; l1 < 9; l1++)
|
||||
addSecuredSlot(inventoryplayer, l1 + i1 * 9 + 9, 18 + l1 * 18, 156 + i1 * 18);
|
||||
// Player hotbar
|
||||
for (int j1 = 0; j1 < 9; j1++)
|
||||
addSecuredSlot(inventoryplayer, j1, 18 + j1 * 18, 214);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onContainerClosed(EntityPlayer entityplayer) {
|
||||
|
||||
if (!Proxies.common.isSimulating(entityplayer.worldObj))
|
||||
return;
|
||||
|
||||
// Last slot is the energy slot, so we don't save that one.
|
||||
for (int i = 0; i < inventory.getSizeInventory(); i++) {
|
||||
if (i == BeealyzerInventory.SLOT_ENERGY)
|
||||
continue;
|
||||
ItemStack stack = inventory.getStackInSlot(i);
|
||||
if (stack == null)
|
||||
continue;
|
||||
|
||||
Proxies.common.dropItemPlayer(entityplayer, stack);
|
||||
inventory.setInventorySlotContents(i, null);
|
||||
}
|
||||
|
||||
inventory.onGuiSaved(entityplayer);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isAcceptedItem(EntityPlayer player, ItemStack stack) {
|
||||
return true;
|
||||
super(inventoryplayer, inventory, new Object[] { ForestryItem.honeydew, ForestryItem.honeyDrop }, new Object[] { ItemBeeGE.class });
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,12 +14,11 @@ import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import forestry.apiculture.gadgets.TileAlvearyPlain;
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.gui.GuiForestry;
|
||||
import forestry.core.gui.GuiForestryTitled;
|
||||
import forestry.core.utils.EnumTankLevel;
|
||||
import forestry.core.utils.StringUtil;
|
||||
import forestry.core.utils.Utils;
|
||||
|
||||
public class GuiAlveary extends GuiForestry<TileAlvearyPlain> {
|
||||
public class GuiAlveary extends GuiForestryTitled<TileAlvearyPlain> {
|
||||
|
||||
public GuiAlveary(InventoryPlayer inventory, TileAlvearyPlain tile) {
|
||||
super(Defaults.TEXTURE_PATH_GUI + "/alveary.png", new ContainerAlveary(inventory, tile), tile);
|
||||
@@ -27,13 +26,6 @@ public class GuiAlveary extends GuiForestry<TileAlvearyPlain> {
|
||||
ySize = 190;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
|
||||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||
String title = StringUtil.localize("tile." + tile.getInventoryName());
|
||||
this.fontRendererObj.drawString(title, getCenteredOffset(title), 6, fontColor.get("gui.title"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) {
|
||||
super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY);
|
||||
|
||||
@@ -14,23 +14,15 @@ import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import forestry.apiculture.gadgets.TileAlvearyHygroregulator;
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.gui.GuiForestry;
|
||||
import forestry.core.gui.GuiForestryTitled;
|
||||
import forestry.core.gui.widgets.TankWidget;
|
||||
import forestry.core.utils.StringUtil;
|
||||
|
||||
public class GuiAlvearyHygroregulator extends GuiForestry<TileAlvearyHygroregulator> {
|
||||
public class GuiAlvearyHygroregulator extends GuiForestryTitled<TileAlvearyHygroregulator> {
|
||||
|
||||
public GuiAlvearyHygroregulator(InventoryPlayer inventory, TileAlvearyHygroregulator tile) {
|
||||
super(Defaults.TEXTURE_PATH_GUI + "/hygroregulator.png", new ContainerAlvearyHygroregulator(inventory, tile));
|
||||
super(Defaults.TEXTURE_PATH_GUI + "/hygroregulator.png", new ContainerAlvearyHygroregulator(inventory, tile), tile);
|
||||
|
||||
widgetManager.add(new TankWidget(this.widgetManager, 104, 17, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
|
||||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||
String name = StringUtil.localize("tile.alveary.5");
|
||||
this.fontRendererObj.drawString(name, getCenteredOffset(name), 6, fontColor.get("gui.title"));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -15,12 +15,11 @@ import net.minecraft.entity.player.InventoryPlayer;
|
||||
import forestry.apiculture.gadgets.TileApiary;
|
||||
import forestry.apiculture.gadgets.TileBeehouse;
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.gui.GuiForestry;
|
||||
import forestry.core.gui.GuiForestryTitled;
|
||||
import forestry.core.utils.EnumTankLevel;
|
||||
import forestry.core.utils.StringUtil;
|
||||
import forestry.core.utils.Utils;
|
||||
|
||||
public class GuiApiary extends GuiForestry<TileBeehouse> {
|
||||
public class GuiApiary extends GuiForestryTitled<TileBeehouse> {
|
||||
|
||||
public GuiApiary(InventoryPlayer inventory, TileApiary tile) {
|
||||
super(Defaults.TEXTURE_PATH_GUI + "/apiary.png", new ContainerApiary(inventory, tile, true), tile);
|
||||
@@ -34,13 +33,6 @@ public class GuiApiary extends GuiForestry<TileBeehouse> {
|
||||
ySize = 190;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
|
||||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||
String name = StringUtil.localize("tile.for." + tile.getInventoryName());
|
||||
this.fontRendererObj.drawString(name, getCenteredOffset(name), 6, fontColor.get("gui.title"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) {
|
||||
super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY);
|
||||
|
||||
@@ -41,8 +41,7 @@ public class GuiBeealyzer extends GuiAlyzer {
|
||||
super(AlleleManager.alleleRegistry.getSpeciesRoot("rootBees"), player,
|
||||
new ContainerBeealyzer(player.inventory, inventory), inventory, 1, inventory.getSizeInventory());
|
||||
|
||||
xSize = 196;
|
||||
ySize = 238;
|
||||
guiName = "gui.beealyzer";
|
||||
|
||||
ArrayList<ItemStack> beeList = new ArrayList<ItemStack>();
|
||||
((ItemBeeGE) ForestryItem.beeDroneGE.item()).addCreativeItems(beeList, false);
|
||||
@@ -96,45 +95,6 @@ public class GuiBeealyzer extends GuiAlyzer {
|
||||
|
||||
}
|
||||
|
||||
private void drawAnalyticsOverview() {
|
||||
|
||||
startPage();
|
||||
|
||||
newLine();
|
||||
String title = StringUtil.localize("gui.beealyzer").toUpperCase();
|
||||
drawCenteredLine(title, 8, 158);
|
||||
newLine();
|
||||
|
||||
fontRendererObj.drawSplitString(StringUtil.localize("gui.beealyzer.help"), (int) ((guiLeft + COLUMN_0 + 4) * (1 / factor)),
|
||||
(int) ((guiTop + 42) * (1 / factor)), (int) (158 * (1 / factor)), fontColor.get("gui.screen"));
|
||||
newLine();
|
||||
newLine();
|
||||
newLine();
|
||||
newLine();
|
||||
|
||||
drawLine(StringUtil.localize("gui.beealyzer.overview") + ":", COLUMN_0 + 4);
|
||||
newLine();
|
||||
drawLine("I : " + StringUtil.localize("gui.general"), COLUMN_0 + 4);
|
||||
newLine();
|
||||
drawLine("II : " + StringUtil.localize("gui.environment"), COLUMN_0 + 4);
|
||||
newLine();
|
||||
drawLine("III: " + StringUtil.localize("gui.produce"), COLUMN_0 + 4);
|
||||
newLine();
|
||||
drawLine("IV : " + StringUtil.localize("gui.evolution"), COLUMN_0 + 4);
|
||||
|
||||
newLine();
|
||||
|
||||
String mode = breedingTracker.getModeName();
|
||||
if (mode != null && !mode.isEmpty()) {
|
||||
newLine();
|
||||
String rules = StringUtil.localize("gui.beealyzer.behaviour") + ": " + StringUtil.capitalize(mode);
|
||||
drawLine(rules, 8 + getCenteredOffset(title, 158), fontColor.get("gui.beealyzer.binomial"));
|
||||
}
|
||||
|
||||
endPage();
|
||||
|
||||
}
|
||||
|
||||
private void drawAnalyticsPage1(IBee bee, EnumBeeType type) {
|
||||
|
||||
startPage(COLUMN_0, COLUMN_1, COLUMN_2);
|
||||
@@ -268,16 +228,14 @@ public class GuiBeealyzer extends GuiAlyzer {
|
||||
if (!bee.isNatural())
|
||||
displayText = "bees.stock.ignoble";
|
||||
displayText = StringUtil.localize(displayText);
|
||||
// int offset = (int)(((158 - fontRendererObj.getStringWidth(origin)) / 2)*(1/factor));
|
||||
drawCenteredLine(displayText, 8, 158, fontColor.get("gui.beealyzer.binomial"));;
|
||||
drawCenteredLine(displayText, 8, 208, fontColor.get("gui.beealyzer.binomial"));
|
||||
}
|
||||
|
||||
if (bee.getGeneration() >= 0) {
|
||||
newLine();
|
||||
|
||||
displayText = StringUtil.localizeAndFormat("gui.beealyzer.generations", bee.getGeneration());
|
||||
// offset = (int)(((158 - fontRendererObj.getStringWidth(origin)) / 2)*(1/factor));
|
||||
drawCenteredLine(displayText, 8, 158, fontColor.get("gui.beealyzer.binomial"));
|
||||
drawCenteredLine(displayText, 8, 208, fontColor.get("gui.beealyzer.binomial"));
|
||||
}
|
||||
|
||||
endPage();
|
||||
|
||||
@@ -77,7 +77,10 @@ public class ItemBeeGE extends ItemGE {
|
||||
if(StatCollector.canTranslate("for." + customBeeKey)){
|
||||
return StringUtil.localize(customBeeKey);
|
||||
}
|
||||
return StringUtil.localize("bees.grammar." + type.getName()).replaceAll("%SPECIES", individual.getDisplayName()).replaceAll("%TYPE", StringUtil.localize("bees.grammar." + type.getName() + ".type"));
|
||||
String beeGrammar = StringUtil.localize("bees.grammar." + type.getName());
|
||||
String beeSpecies = individual.getDisplayName();
|
||||
String beeType = StringUtil.localize("bees.grammar." + type.getName() + ".type");
|
||||
return beeGrammar.replaceAll("%SPECIES", beeSpecies).replaceAll("%TYPE", beeType);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
|
||||
@@ -10,10 +10,10 @@
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.items;
|
||||
|
||||
import forestry.core.utils.AlyzerInventory;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.api.apiculture.IBee;
|
||||
@@ -27,22 +27,11 @@ import forestry.core.interfaces.IHintSource;
|
||||
import forestry.core.items.ItemInventoried;
|
||||
import forestry.core.network.GuiId;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.ItemInventory;
|
||||
import forestry.plugins.PluginApiculture;
|
||||
|
||||
public class ItemBeealyzer extends ItemInventoried {
|
||||
|
||||
public static class BeealyzerInventory extends ItemInventory implements IErrorSource, IHintSource {
|
||||
|
||||
public static final int SLOT_SPECIMEN = 0;
|
||||
public static final int SLOT_ANALYZE_1 = 1;
|
||||
public static final int SLOT_ANALYZE_2 = 2;
|
||||
public static final int SLOT_ANALYZE_3 = 3;
|
||||
public static final int SLOT_ANALYZE_4 = 4;
|
||||
public static final int SLOT_ANALYZE_5 = 6;
|
||||
public static final int SLOT_ENERGY = 5;
|
||||
|
||||
EntityPlayer player;
|
||||
public static class BeealyzerInventory extends AlyzerInventory implements IErrorSource, IHintSource {
|
||||
|
||||
public BeealyzerInventory(EntityPlayer player) {
|
||||
super(ItemBeealyzer.class, 7);
|
||||
@@ -54,21 +43,6 @@ public class ItemBeealyzer extends ItemInventoried {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
|
||||
NBTTagList nbttaglist = new NBTTagList();
|
||||
for (int i = SLOT_ENERGY; i < SLOT_ENERGY + 1; i++)
|
||||
if (inventoryStacks[i] != null) {
|
||||
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
|
||||
nbttagcompound1.setByte("Slot", (byte) i);
|
||||
inventoryStacks[i].writeToNBT(nbttagcompound1);
|
||||
nbttaglist.appendTag(nbttagcompound1);
|
||||
}
|
||||
nbttagcompound.setTag("Items", nbttaglist);
|
||||
|
||||
}
|
||||
|
||||
private boolean isEnergy(ItemStack itemstack) {
|
||||
if (itemstack == null || itemstack.stackSize <= 0)
|
||||
return false;
|
||||
|
||||
@@ -103,6 +103,7 @@ public class BlockLog extends Block implements IWoodTyped {
|
||||
@Override
|
||||
public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List itemList) {
|
||||
if(cat == LogCat.CAT6) {
|
||||
itemList.add(new ItemStack(this, 1, 0));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -123,7 +124,10 @@ public class BlockLog extends Block implements IWoodTyped {
|
||||
|
||||
int oriented = meta & 12;
|
||||
|
||||
WoodType type = getWoodType(getTypeFromMeta(meta));
|
||||
WoodType type = getWoodType(meta);
|
||||
if (type == null)
|
||||
return null;
|
||||
|
||||
switch (oriented) {
|
||||
case 4:
|
||||
if (side > 3)
|
||||
@@ -157,7 +161,7 @@ public class BlockLog extends Block implements IWoodTyped {
|
||||
/* PROPERTIES */
|
||||
@Override
|
||||
public float getBlockHardness(World world, int x, int y, int z) {
|
||||
return getWoodType(getTypeFromMeta(world.getBlockMetadata(x, y, z))).getHardness();
|
||||
return getWoodType(world.getBlockMetadata(x, y, z)).getHardness();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -192,10 +196,11 @@ public class BlockLog extends Block implements IWoodTyped {
|
||||
|
||||
@Override
|
||||
public WoodType getWoodType(int meta) {
|
||||
meta = getTypeFromMeta(meta);
|
||||
if(meta + cat.ordinal() * 4 < WoodType.VALUES.length)
|
||||
return WoodType.VALUES[meta + cat.ordinal() * 4];
|
||||
else
|
||||
return WoodType.LARCH;
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -10,77 +10,19 @@
|
||||
******************************************************************************/
|
||||
package forestry.arboriculture.gui;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.core.gui.ContainerAlyzer;
|
||||
import forestry.core.config.ForestryItem;
|
||||
import forestry.arboriculture.items.ItemGermlingGE;
|
||||
import forestry.arboriculture.items.ItemTreealyzer.TreealyzerInventory;
|
||||
import forestry.core.config.ForestryItem;
|
||||
import forestry.core.gui.ContainerItemInventory;
|
||||
import forestry.core.gui.slots.SlotCustom;
|
||||
import forestry.core.proxy.Proxies;
|
||||
|
||||
public class ContainerTreealyzer extends ContainerItemInventory {
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
public class ContainerTreealyzer extends ContainerAlyzer {
|
||||
|
||||
TreealyzerInventory inventory;
|
||||
|
||||
public ContainerTreealyzer(InventoryPlayer inventoryplayer, TreealyzerInventory inventory) {
|
||||
super(inventory, inventoryplayer.player);
|
||||
|
||||
this.inventory = inventory;
|
||||
|
||||
// Energy
|
||||
this.addSlot(new SlotCustom(inventory, TreealyzerInventory.SLOT_ENERGY, 172, 8, new Object[] { ForestryItem.honeydew, ForestryItem.honeyDrop }));
|
||||
|
||||
// Tree to analyze
|
||||
this.addSlot(new SlotCustom(inventory, TreealyzerInventory.SLOT_SPECIMEN, 172, 26, ArrayUtils.addAll(AlleleManager.ersatzSaplings.keySet().toArray(new Object[0]), ItemGermlingGE.class)));
|
||||
|
||||
// Analyzed tree
|
||||
this.addSlot(new SlotCustom(inventory, TreealyzerInventory.SLOT_ANALYZE_1, 172, 57, new Object[] { ItemGermlingGE.class }));
|
||||
this.addSlot(new SlotCustom(inventory, TreealyzerInventory.SLOT_ANALYZE_2, 172, 75, new Object[] { ItemGermlingGE.class }));
|
||||
this.addSlot(new SlotCustom(inventory, TreealyzerInventory.SLOT_ANALYZE_3, 172, 93, new Object[] { ItemGermlingGE.class }));
|
||||
this.addSlot(new SlotCustom(inventory, TreealyzerInventory.SLOT_ANALYZE_4, 172, 111, new Object[] { ItemGermlingGE.class }));
|
||||
this.addSlot(new SlotCustom(inventory, TreealyzerInventory.SLOT_ANALYZE_5, 172, 129, new Object[] { ItemGermlingGE.class }));
|
||||
|
||||
// Player inventory
|
||||
for (int i1 = 0; i1 < 3; i1++)
|
||||
for (int l1 = 0; l1 < 9; l1++)
|
||||
addSecuredSlot(inventoryplayer, l1 + i1 * 9 + 9, 18 + l1 * 18, 156 + i1 * 18);
|
||||
// Player hotbar
|
||||
for (int j1 = 0; j1 < 9; j1++)
|
||||
addSecuredSlot(inventoryplayer, j1, 18 + j1 * 18, 214);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onContainerClosed(EntityPlayer entityplayer) {
|
||||
|
||||
if (!Proxies.common.isSimulating(entityplayer.worldObj))
|
||||
return;
|
||||
|
||||
// Last slot is the energy slot, so we don't save that one.
|
||||
for (int i = 0; i < inventory.getSizeInventory(); i++) {
|
||||
if (i == TreealyzerInventory.SLOT_ENERGY)
|
||||
continue;
|
||||
ItemStack stack = inventory.getStackInSlot(i);
|
||||
if (stack == null)
|
||||
continue;
|
||||
|
||||
Proxies.common.dropItemPlayer(entityplayer, stack);
|
||||
inventory.setInventorySlotContents(i, null);
|
||||
}
|
||||
|
||||
inventory.onGuiSaved(entityplayer);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isAcceptedItem(EntityPlayer player, ItemStack stack) {
|
||||
return true;
|
||||
super(inventoryplayer, inventory, new Object[] { ForestryItem.honeydew, ForestryItem.honeyDrop }, new Object[] { ItemGermlingGE.class });
|
||||
}
|
||||
|
||||
}
|
||||
@@ -46,8 +46,7 @@ public class GuiTreealyzer extends GuiAlyzer {
|
||||
super(AlleleManager.alleleRegistry.getSpeciesRoot("rootTrees"), player,
|
||||
new ContainerTreealyzer(player.inventory, inventory), inventory, 1, inventory.getSizeInventory());
|
||||
|
||||
xSize = 196;
|
||||
ySize = 238;
|
||||
guiName = "gui.treealyzer";
|
||||
|
||||
ArrayList<ItemStack> treeList = new ArrayList<ItemStack>();
|
||||
((ItemGermlingGE) ForestryItem.sapling.item()).addCreativeItems(treeList, false);
|
||||
@@ -99,35 +98,6 @@ public class GuiTreealyzer extends GuiAlyzer {
|
||||
|
||||
}
|
||||
|
||||
private void drawAnalyticsOverview() {
|
||||
|
||||
startPage();
|
||||
|
||||
newLine();
|
||||
String title = StringUtil.localize("gui.treealyzer").toUpperCase();
|
||||
drawCenteredLine(title, 8, 158);
|
||||
newLine();
|
||||
|
||||
fontRendererObj.drawSplitString(StringUtil.localize("gui.treealyzer.help"), (int) ((guiLeft + COLUMN_0 + 4) * (1 / factor)),
|
||||
(int) ((guiTop + 42) * (1 / factor)), (int) (158 * (1 / factor)), fontColor.get("gui.screen"));
|
||||
newLine();
|
||||
newLine();
|
||||
newLine();
|
||||
newLine();
|
||||
|
||||
drawLine(StringUtil.localize("gui.treealyzer.overview") + ":", COLUMN_0 + 4);
|
||||
newLine();
|
||||
drawLine("I : " + StringUtil.localize("gui.general"), COLUMN_0 + 4);
|
||||
newLine();
|
||||
drawLine("II : " + StringUtil.localize("gui.environment"), COLUMN_0 + 4);
|
||||
newLine();
|
||||
drawLine("III: " + StringUtil.localize("gui.produce"), COLUMN_0 + 4);
|
||||
newLine();
|
||||
drawLine("IV : " + StringUtil.localize("gui.evolution"), COLUMN_0 + 4);
|
||||
|
||||
endPage();
|
||||
}
|
||||
|
||||
private void drawAnalyticsPage1(ITree tree, EnumGermlingType type) {
|
||||
|
||||
startPage(COLUMN_0, COLUMN_1, COLUMN_2);
|
||||
|
||||
@@ -13,9 +13,9 @@ package forestry.arboriculture.items;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.core.utils.AlyzerInventory;
|
||||
import forestry.api.arboriculture.ITree;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.core.Tabs;
|
||||
@@ -27,22 +27,12 @@ import forestry.core.interfaces.IHintSource;
|
||||
import forestry.core.items.ItemInventoried;
|
||||
import forestry.core.network.GuiId;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.ItemInventory;
|
||||
import forestry.core.utils.Utils;
|
||||
import forestry.plugins.PluginArboriculture;
|
||||
|
||||
public class ItemTreealyzer extends ItemInventoried {
|
||||
|
||||
public static class TreealyzerInventory extends ItemInventory implements IErrorSource, IHintSource {
|
||||
|
||||
public final static int SLOT_SPECIMEN = 0;
|
||||
public final static int SLOT_ANALYZE_1 = 1;
|
||||
public final static int SLOT_ANALYZE_2 = 2;
|
||||
public final static int SLOT_ANALYZE_3 = 3;
|
||||
public final static int SLOT_ANALYZE_4 = 4;
|
||||
public final static int SLOT_ANALYZE_5 = 6;
|
||||
public final static int SLOT_ENERGY = 5;
|
||||
EntityPlayer player;
|
||||
public static class TreealyzerInventory extends AlyzerInventory implements IErrorSource, IHintSource {
|
||||
|
||||
public TreealyzerInventory(EntityPlayer player) {
|
||||
super(ItemTreealyzer.class, 7);
|
||||
@@ -54,22 +44,6 @@ public class ItemTreealyzer extends ItemInventoried {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
|
||||
NBTTagList nbttaglist = new NBTTagList();
|
||||
for (int i = SLOT_ENERGY; i < SLOT_ENERGY + 1; i++) {
|
||||
if (inventoryStacks[i] != null) {
|
||||
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
|
||||
nbttagcompound1.setByte("Slot", (byte) i);
|
||||
inventoryStacks[i].writeToNBT(nbttagcompound1);
|
||||
nbttaglist.appendTag(nbttagcompound1);
|
||||
}
|
||||
}
|
||||
nbttagcompound.setTag("Items", nbttaglist);
|
||||
|
||||
}
|
||||
|
||||
private boolean isEnergy(ItemStack itemstack) {
|
||||
if (itemstack == null || itemstack.stackSize <= 0)
|
||||
return false;
|
||||
|
||||
@@ -34,6 +34,8 @@ public class ItemWoodBlock extends ItemForestryBlock {
|
||||
IWoodTyped block = (IWoodTyped) getBlock();
|
||||
int meta = itemstack.getItemDamage();
|
||||
WoodType woodType = block.getWoodType(meta);
|
||||
if (woodType == null)
|
||||
return null;
|
||||
return "tile.for." + block.getBlockKind() + "." + woodType.ordinal();
|
||||
}
|
||||
return super.getUnlocalizedName(itemstack);
|
||||
|
||||
@@ -66,7 +66,7 @@ public enum EnumErrorCode {
|
||||
|
||||
NOHONEY("noHoney", 22),
|
||||
|
||||
NOTPOSTPAID("notPostpaid", 23),
|
||||
NOTPOSTPAID("notPostpaid", "noStamps", 23),
|
||||
|
||||
NORECIPIENT("noRecipient", 24),
|
||||
|
||||
@@ -86,14 +86,28 @@ public enum EnumErrorCode {
|
||||
|
||||
CIRCUITMISMATCH("circuitMismatch", 26),
|
||||
|
||||
NOLIQUID("noLiquid", 29);
|
||||
NOLIQUID("noLiquid", 29),
|
||||
|
||||
NOPAPER("noPaper", 30),
|
||||
|
||||
NOSTAMPSNOPAPER("noStampsNoPaper", "noStamps", 31),
|
||||
|
||||
NOSUPPLIES("noSupplies", "noResource", 32),
|
||||
|
||||
NOTRADE("noTrade", "noResource", 33);
|
||||
|
||||
private String name;
|
||||
private String iconName;
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IIcon icon;
|
||||
|
||||
private EnumErrorCode(String name, int iconIndex) {
|
||||
this(name, name, iconIndex);
|
||||
}
|
||||
|
||||
private EnumErrorCode(String name, String iconName, int iconIndex) {
|
||||
this.name = name;
|
||||
this.iconName = iconName;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
@@ -106,7 +120,7 @@ public enum EnumErrorCode {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister register) {
|
||||
icon = TextureManager.getInstance().registerTex(register, "errors/" + name);
|
||||
icon = TextureManager.getInstance().registerTex(register, "errors/" + iconName);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
package forestry.core;
|
||||
|
||||
public interface IItemTyped {
|
||||
public Enum getTypeFromMeta(int meta);
|
||||
}
|
||||
@@ -242,7 +242,7 @@ public class BlockBase extends BlockForestry {
|
||||
@Override
|
||||
public IIcon getIcon(int side, int metadata) {
|
||||
if (metadata >= definitions.size() || definitions.get(metadata) == null)
|
||||
metadata = 0;
|
||||
return null;
|
||||
return definitions.get(metadata).getBlockTextureFromSideAndMetadata(side, metadata);
|
||||
}
|
||||
|
||||
|
||||
@@ -101,8 +101,10 @@ public class BlockResource extends Block {
|
||||
return iconApatite;
|
||||
else if (j == 1)
|
||||
return iconCopper;
|
||||
else
|
||||
else if (j == 2)
|
||||
return iconTin;
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,6 +14,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import forestry.core.IItemTyped;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
@@ -45,9 +46,13 @@ import forestry.core.render.TextureManager;
|
||||
* @author
|
||||
*
|
||||
*/
|
||||
public class BlockSoil extends Block {
|
||||
public class BlockSoil extends Block implements IItemTyped {
|
||||
|
||||
private final int degradeDelimiter = 3;
|
||||
public enum SoilType {
|
||||
HUMUS, BOG_EARTH, PEAT;
|
||||
}
|
||||
|
||||
private static final int degradeDelimiter = 3;
|
||||
|
||||
public BlockSoil() {
|
||||
super(Material.sand);
|
||||
@@ -66,16 +71,15 @@ public class BlockSoil extends Block {
|
||||
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
|
||||
ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
|
||||
|
||||
int type = (metadata & 0x03);
|
||||
int maturity = metadata >> 2;
|
||||
SoilType type = getTypeFromMeta(metadata);
|
||||
|
||||
if (maturity >= this.degradeDelimiter && type == 1) {
|
||||
if (type == SoilType.PEAT) {
|
||||
ret.add(ForestryItem.peat.getItemStack());
|
||||
ret.add(new ItemStack(Blocks.dirt));
|
||||
} else if (type == 0)
|
||||
} else if (type == SoilType.HUMUS)
|
||||
ret.add(new ItemStack(Blocks.dirt));
|
||||
else
|
||||
ret.add(new ItemStack(this, 1, type));
|
||||
ret.add(new ItemStack(this, 1, SoilType.BOG_EARTH.ordinal()));
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -91,14 +95,13 @@ public class BlockSoil extends Block {
|
||||
return;
|
||||
|
||||
int meta = world.getBlockMetadata(i, j, k);
|
||||
int type = (meta & 0x03);
|
||||
|
||||
if (type == 0)
|
||||
SoilType type = getTypeFromMeta(meta);
|
||||
|
||||
if (type == SoilType.HUMUS)
|
||||
updateTickHumus(world, i, j, k, random);
|
||||
else if (type == 1)
|
||||
else if (type == SoilType.BOG_EARTH)
|
||||
updateTickBogEarth(world, i, j, k, random);
|
||||
else
|
||||
Proxies.log.warning(this.getClass() + " with unknown type " + type + " encountered.");
|
||||
}
|
||||
|
||||
private void updateTickHumus(World world, int i, int j, int k, Random random) {
|
||||
@@ -155,17 +158,17 @@ public class BlockSoil extends Block {
|
||||
int type = meta & 0x03;
|
||||
int grade = meta >> 2;
|
||||
|
||||
// Increment (de)gradation
|
||||
grade++;
|
||||
// Increment (de)gradation
|
||||
grade++;
|
||||
|
||||
// Repackage in format TTGG
|
||||
meta = (grade << 2 | type);
|
||||
// Repackage in format TTGG
|
||||
meta = (grade << 2 | type);
|
||||
|
||||
if (grade >= this.degradeDelimiter)
|
||||
world.setBlock(i, j, k, Blocks.sand, 0, Defaults.FLAG_BLOCK_SYNCH);
|
||||
else
|
||||
world.setBlockMetadataWithNotify(i, j, k, meta, Defaults.FLAG_BLOCK_SYNCH);
|
||||
world.markBlockForUpdate(i, j, k);
|
||||
if (grade >= this.degradeDelimiter)
|
||||
world.setBlock(i, j, k, Blocks.sand, 0, Defaults.FLAG_BLOCK_SYNCH);
|
||||
else
|
||||
world.setBlockMetadataWithNotify(i, j, k, meta, Defaults.FLAG_BLOCK_SYNCH);
|
||||
world.markBlockForUpdate(i, j, k);
|
||||
}
|
||||
|
||||
public static boolean isMoistened(World world, int x, int y, int z) {
|
||||
@@ -192,15 +195,15 @@ public class BlockSoil extends Block {
|
||||
int type = meta & 0x03;
|
||||
int maturity = meta >> 2;
|
||||
|
||||
if (maturity >= this.degradeDelimiter)
|
||||
return;
|
||||
if (maturity >= this.degradeDelimiter)
|
||||
return;
|
||||
|
||||
// Increment (de)gradation
|
||||
maturity++;
|
||||
// Increment (de)gradation
|
||||
maturity++;
|
||||
|
||||
meta = (maturity << 2 | type);
|
||||
world.setBlockMetadataWithNotify(i, j, k, meta, Defaults.FLAG_BLOCK_SYNCH);
|
||||
world.markBlockForUpdate(i, j, k);
|
||||
meta = (maturity << 2 | type);
|
||||
world.setBlockMetadataWithNotify(i, j, k, meta, Defaults.FLAG_BLOCK_SYNCH);
|
||||
world.markBlockForUpdate(i, j, k);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -210,8 +213,9 @@ public class BlockSoil extends Block {
|
||||
return false;
|
||||
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
SoilType type = getTypeFromMeta(meta);
|
||||
|
||||
return (meta & 0x03) == 0;
|
||||
return type == SoilType.HUMUS;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -219,6 +223,19 @@ public class BlockSoil extends Block {
|
||||
return false;
|
||||
}
|
||||
|
||||
public SoilType getTypeFromMeta(int meta) {
|
||||
int type = meta & 0x03;
|
||||
int maturity = meta >> 2;
|
||||
|
||||
if (type == 1)
|
||||
if (maturity < degradeDelimiter)
|
||||
return SoilType.BOG_EARTH;
|
||||
else
|
||||
return SoilType.PEAT;
|
||||
else
|
||||
return SoilType.HUMUS;
|
||||
}
|
||||
|
||||
// / CREATIVE INVENTORY
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@Override
|
||||
@@ -245,19 +262,16 @@ public class BlockSoil extends Block {
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int i, int j) {
|
||||
public IIcon getIcon(int side, int meta) {
|
||||
|
||||
int meta = j;
|
||||
int type = meta & 0x03;
|
||||
int maturity = meta >> 2;
|
||||
SoilType type = getTypeFromMeta(meta);
|
||||
|
||||
if (type == 1)
|
||||
if (maturity < this.degradeDelimiter)
|
||||
return iconBogEarth;
|
||||
else
|
||||
return iconPeat;
|
||||
else
|
||||
return iconHumus;
|
||||
switch (type) {
|
||||
case HUMUS: return iconHumus;
|
||||
case BOG_EARTH: return iconBogEarth;
|
||||
case PEAT: return iconPeat;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -76,7 +76,7 @@ public class TileAnalyzer extends TileBase implements ISpecialInventory, ISidedI
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return StringUtil.localize("core.0");
|
||||
return getUnlocalizedName();
|
||||
}
|
||||
|
||||
/* GUI */
|
||||
|
||||
@@ -21,11 +21,6 @@ import forestry.core.utils.Utils;
|
||||
|
||||
public abstract class TileBase extends TileForestry implements IHintSource {
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOwnable() {
|
||||
return true;
|
||||
|
||||
@@ -47,7 +47,7 @@ public class TileEscritoire extends TileBase implements ISidedInventory, IRender
|
||||
private final InventoryAdapter inventory;
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return StringUtil.localize("core.1");
|
||||
return getUnlocalizedName();
|
||||
}
|
||||
|
||||
public TileEscritoire() {
|
||||
|
||||
@@ -297,7 +297,14 @@ public abstract class TileForestry extends TileEntity implements INetworkedEntit
|
||||
}
|
||||
|
||||
/* NAME */
|
||||
public abstract String getInventoryName();
|
||||
|
||||
/**
|
||||
* Gets the tile's unlocalized name, based on the block at the location of this entity (client-only).
|
||||
*/
|
||||
public String getUnlocalizedName() {
|
||||
String blockUnlocalizedName = getBlockType().getUnlocalizedName().replace("tile.for.","");
|
||||
return blockUnlocalizedName + "." + getBlockMetadata() + ".name";
|
||||
}
|
||||
|
||||
public boolean hasCustomInventoryName() {
|
||||
return true;
|
||||
|
||||
@@ -42,7 +42,7 @@ import forestry.plugins.PluginEnergy;
|
||||
import forestry.plugins.PluginFactory;
|
||||
import forestry.plugins.PluginMail;
|
||||
|
||||
public class TileMachine extends TileForestry implements ISpecialInventory, IClimatised, IHintSource {
|
||||
public abstract class TileMachine extends TileForestry implements ISpecialInventory, IClimatised, IHintSource {
|
||||
|
||||
public TileMachine() {
|
||||
}
|
||||
@@ -301,7 +301,7 @@ public class TileMachine extends TileForestry implements ISpecialInventory, ICli
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return "[Unknown]";
|
||||
return getUnlocalizedName();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -37,7 +37,7 @@ public abstract class TileNaturalistChest extends TileBase implements IInventory
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return StringUtil.localize("tile.mill.3");
|
||||
return getUnlocalizedName();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
package forestry.core.gui;
|
||||
|
||||
import forestry.core.gui.slots.SlotCustom;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.AlyzerInventory;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ContainerAlyzer extends ContainerItemInventory {
|
||||
|
||||
private AlyzerInventory inventory;
|
||||
|
||||
protected ContainerAlyzer(InventoryPlayer inventoryplayer, AlyzerInventory inventory, Object[] acceptedEnergy, Object[] acceptedSpecimens) {
|
||||
super(inventory, inventoryplayer.player);
|
||||
|
||||
this.inventory = inventory;
|
||||
|
||||
final int xPosLeftSlots = 223;
|
||||
|
||||
// Energy
|
||||
this.addSlot(new SlotCustom(inventory, inventory.SLOT_ENERGY, xPosLeftSlots, 8, acceptedEnergy));
|
||||
|
||||
// Bee to analyze
|
||||
this.addSlot(new SlotCustom(inventory, inventory.SLOT_SPECIMEN, xPosLeftSlots, 26, acceptedSpecimens));
|
||||
|
||||
// Analyzed bee
|
||||
this.addSlot(new SlotCustom(inventory, inventory.SLOT_ANALYZE_1, xPosLeftSlots, 57, acceptedSpecimens));
|
||||
this.addSlot(new SlotCustom(inventory, inventory.SLOT_ANALYZE_2, xPosLeftSlots, 75, acceptedSpecimens));
|
||||
this.addSlot(new SlotCustom(inventory, inventory.SLOT_ANALYZE_3, xPosLeftSlots, 93, acceptedSpecimens));
|
||||
this.addSlot(new SlotCustom(inventory, inventory.SLOT_ANALYZE_4, xPosLeftSlots, 111, acceptedSpecimens));
|
||||
this.addSlot(new SlotCustom(inventory, inventory.SLOT_ANALYZE_5, xPosLeftSlots, 129, acceptedSpecimens));
|
||||
|
||||
final int xPosPlayerInv = 43;
|
||||
final int xSpacePlayerInv = 18;
|
||||
final int yPosPlayerInv= 156;
|
||||
final int ySpacePlayerInv = 18;
|
||||
|
||||
// Player inventory
|
||||
for (int i1 = 0; i1 < 3; i1++) {
|
||||
for (int l1 = 0; l1 < 9; l1++) {
|
||||
int slot = l1 + i1 * 9 + 9;
|
||||
int x = xPosPlayerInv + (l1 * xSpacePlayerInv);
|
||||
int y = yPosPlayerInv + (i1 * ySpacePlayerInv);
|
||||
addSecuredSlot(inventoryplayer, slot, x, y);
|
||||
}
|
||||
}
|
||||
// Player hotbar
|
||||
for (int j1 = 0; j1 < 9; j1++) {
|
||||
int x = xPosPlayerInv + (j1 * xSpacePlayerInv);
|
||||
addSecuredSlot(inventoryplayer, j1, x, 214);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onContainerClosed(EntityPlayer entityplayer) {
|
||||
|
||||
if (!Proxies.common.isSimulating(entityplayer.worldObj))
|
||||
return;
|
||||
|
||||
// Last slot is the energy slot, so we don't save that one.
|
||||
for (int i = 0; i < inventory.getSizeInventory(); i++) {
|
||||
if (i == inventory.SLOT_ENERGY)
|
||||
continue;
|
||||
ItemStack stack = inventory.getStackInSlot(i);
|
||||
if (stack == null)
|
||||
continue;
|
||||
|
||||
Proxies.common.dropItemPlayer(entityplayer, stack);
|
||||
inventory.setInventorySlotContents(i, null);
|
||||
}
|
||||
|
||||
inventory.onGuiSaved(entityplayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isAcceptedItem(EntityPlayer player, ItemStack stack) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -21,6 +21,7 @@ import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraft.util.StatCollector;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import forestry.api.apiculture.EnumBeeChromosome;
|
||||
@@ -43,18 +44,23 @@ import forestry.core.utils.StringUtil;
|
||||
public abstract class GuiAlyzer extends GuiForestry<TileForestry> {
|
||||
|
||||
protected static final int COLUMN_0 = 12;
|
||||
protected static final int COLUMN_1 = 52;
|
||||
protected static final int COLUMN_2 = 108;
|
||||
protected static final int COLUMN_1 = 85;
|
||||
protected static final int COLUMN_2 = 150;
|
||||
|
||||
protected IInventory inventory;
|
||||
protected ISpeciesRoot speciesRoot;
|
||||
protected IBreedingTracker breedingTracker;
|
||||
|
||||
protected String guiName;
|
||||
|
||||
protected HashMap<String, ItemStack> iconStacks = new HashMap<String, ItemStack>();
|
||||
|
||||
public GuiAlyzer(ISpeciesRoot speciesRoot, EntityPlayer player, ContainerForestry container, IInventory inventory, int pageMax, int pageSize) {
|
||||
super(Defaults.TEXTURE_PATH_GUI + "/beealyzer.png", container);
|
||||
|
||||
xSize = 246;
|
||||
ySize = 238;
|
||||
|
||||
this.inventory = inventory;
|
||||
this.speciesRoot = speciesRoot;
|
||||
this.breedingTracker = speciesRoot.getBreedingTracker(player.worldObj, player.getGameProfile());
|
||||
@@ -94,8 +100,8 @@ public abstract class GuiAlyzer extends GuiForestry<TileForestry> {
|
||||
int columnwidth = column2 - column1 - 16;
|
||||
|
||||
RenderHelper.enableStandardItemLighting();
|
||||
drawItemStack(iconStacks.get(primary.getUID()), adjustToFactor(guiLeft + column1 + columnwidth + 2), adjustToFactor(guiTop + getLineY()));
|
||||
drawItemStack(iconStacks.get(secondary.getUID()), adjustToFactor(guiLeft + column2 + columnwidth + 4), adjustToFactor(guiTop + getLineY()));
|
||||
drawItemStack(iconStacks.get(primary.getUID()), adjustToFactor(guiLeft + column1 + columnwidth - 4), adjustToFactor(guiTop + getLineY()));
|
||||
drawItemStack(iconStacks.get(secondary.getUID()), adjustToFactor(guiLeft + column2 + columnwidth - 2), adjustToFactor(guiTop + getLineY()));
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
|
||||
String primaryName;
|
||||
@@ -124,6 +130,44 @@ public abstract class GuiAlyzer extends GuiForestry<TileForestry> {
|
||||
}
|
||||
}
|
||||
|
||||
protected void drawAnalyticsOverview() {
|
||||
|
||||
startPage();
|
||||
|
||||
newLine();
|
||||
String title = StringUtil.localize(guiName).toUpperCase();
|
||||
drawCenteredLine(title, 8, 208);
|
||||
newLine();
|
||||
|
||||
fontRendererObj.drawSplitString(StringUtil.localize(guiName + ".help"), (int) ((guiLeft + COLUMN_0 + 4) * (1 / factor)),
|
||||
(int) ((guiTop + 42) * (1 / factor)), (int) (195 * (1 / factor)), fontColor.get("gui.screen"));
|
||||
newLine();
|
||||
newLine();
|
||||
newLine();
|
||||
newLine();
|
||||
|
||||
drawLine(StringUtil.localize("gui.alyzer.overview") + ":", COLUMN_0 + 4);
|
||||
newLine();
|
||||
drawLine("I : " + StringUtil.localize("gui.general"), COLUMN_0 + 4);
|
||||
newLine();
|
||||
drawLine("II : " + StringUtil.localize("gui.environment"), COLUMN_0 + 4);
|
||||
newLine();
|
||||
drawLine("III: " + StringUtil.localize("gui.produce"), COLUMN_0 + 4);
|
||||
newLine();
|
||||
drawLine("IV : " + StringUtil.localize("gui.evolution"), COLUMN_0 + 4);
|
||||
|
||||
newLine();
|
||||
|
||||
String mode = breedingTracker.getModeName();
|
||||
if (mode != null && !mode.isEmpty()) {
|
||||
newLine();
|
||||
String rules = StringUtil.localize(guiName + ".behaviour") + ": " + StringUtil.capitalize(mode);
|
||||
drawCenteredLine(rules, 8, 208, fontColor.get(guiName + ".binomial"));
|
||||
}
|
||||
|
||||
endPage();
|
||||
}
|
||||
|
||||
protected final void drawAnalyticsPageClassification(IIndividual individual) {
|
||||
|
||||
startPage();
|
||||
@@ -151,9 +195,9 @@ public abstract class GuiAlyzer extends GuiForestry<TileForestry> {
|
||||
continue;
|
||||
|
||||
drawLine(group.getScientific(), x, group.getLevel().getColour());
|
||||
drawLine(group.getLevel().name(), 130, group.getLevel().getColour());
|
||||
drawLine(group.getLevel().name(), 155, group.getLevel().getColour());
|
||||
newLine();
|
||||
x += 8;
|
||||
x += 10;
|
||||
}
|
||||
|
||||
// Add the species name
|
||||
@@ -162,26 +206,26 @@ public abstract class GuiAlyzer extends GuiForestry<TileForestry> {
|
||||
binomial = group.getScientific().substring(0, 1) + ". " + binomial.toLowerCase(Locale.ENGLISH);
|
||||
|
||||
drawLine(binomial, x, 0xebae85);
|
||||
drawLine("SPECIES", 130, 0xebae85);
|
||||
drawLine("SPECIES", 155, 0xebae85);
|
||||
|
||||
newLine();
|
||||
newLine();
|
||||
drawLine(StringUtil.localize("gui.alyzer.authority") + ": " + individual.getGenome().getPrimary().getAuthority(), 12);
|
||||
if (AlleleManager.alleleRegistry.isBlacklisted(individual.getIdent())) {
|
||||
String extinct = ">> " + StringUtil.localize("gui.alyzer.extinct").toUpperCase() + " <<";
|
||||
fontRendererObj.drawStringWithShadow(extinct, adjustToFactor(guiLeft + 160) - fontRendererObj.getStringWidth(extinct),
|
||||
fontRendererObj.drawStringWithShadow(extinct, adjustToFactor(guiLeft + 208) - fontRendererObj.getStringWidth(extinct),
|
||||
adjustToFactor(guiTop + getLineY()), fontColor.get("gui.beealyzer.dominant"));
|
||||
}
|
||||
|
||||
newLine();
|
||||
String description = individual.getGenome().getPrimary().getDescription();
|
||||
if (description == null || description.isEmpty())
|
||||
drawSplitLine(StringUtil.localize("gui.alyzer.nodescription"), 12, 156, 0x666666);
|
||||
if (StringUtils.isBlank(description) || description.startsWith("for.description."))
|
||||
drawSplitLine(StringUtil.localize("gui.alyzer.nodescription"), 12, 208, 0x666666);
|
||||
else {
|
||||
String tokens[] = description.split("\\|");
|
||||
drawSplitLine(tokens[0], 12, 152, 0x666666);
|
||||
drawSplitLine(tokens[0], 12, 208, 0x666666);
|
||||
if (tokens.length > 1)
|
||||
fontRendererObj.drawStringWithShadow("- " + tokens[1], adjustToFactor(guiLeft + 160) - fontRendererObj.getStringWidth("- " + tokens[1]),
|
||||
fontRendererObj.drawStringWithShadow("- " + tokens[1], adjustToFactor(guiLeft + 208) - fontRendererObj.getStringWidth("- " + tokens[1]),
|
||||
adjustToFactor(guiTop + 145 - 14), 0x99cc32);
|
||||
}
|
||||
|
||||
@@ -222,7 +266,7 @@ public abstract class GuiAlyzer extends GuiForestry<TileForestry> {
|
||||
}
|
||||
|
||||
x += columnWidth;
|
||||
if (x > 150) {
|
||||
if (x > columnWidth * 4) {
|
||||
x = 0;
|
||||
newLine();
|
||||
newLine();
|
||||
@@ -254,30 +298,29 @@ public abstract class GuiAlyzer extends GuiForestry<TileForestry> {
|
||||
adjustToFactor(guiTop) + getLineY());
|
||||
*/
|
||||
|
||||
int line = 0;
|
||||
int column = 196;
|
||||
int line = 247;
|
||||
int column = 100;
|
||||
|
||||
switch (EnumMutateChance.rateChance(combination.getBaseChance())) {
|
||||
case HIGHEST:
|
||||
column = 226;
|
||||
line = 9;
|
||||
break;
|
||||
case HIGHER:
|
||||
column = 211;
|
||||
line = 9;
|
||||
break;
|
||||
case HIGH:
|
||||
line = 9;
|
||||
break;
|
||||
case NORMAL:
|
||||
column = 226;
|
||||
break;
|
||||
case LOW:
|
||||
column = 211;
|
||||
break;
|
||||
case LOWEST:
|
||||
default:
|
||||
break;
|
||||
case HIGHEST:
|
||||
column = 100;
|
||||
break;
|
||||
case HIGHER:
|
||||
column = 100 + 15;
|
||||
break;
|
||||
case HIGH:
|
||||
column = 100 + 15 * 2;
|
||||
break;
|
||||
case NORMAL:
|
||||
column = 100 + 15 * 3;
|
||||
break;
|
||||
case LOW:
|
||||
column = 100 + 15 * 4;
|
||||
break;
|
||||
case LOWEST:
|
||||
column = 100 + 15 * 5;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
Proxies.common.bindTexture(textureFile);
|
||||
@@ -289,35 +332,34 @@ public abstract class GuiAlyzer extends GuiForestry<TileForestry> {
|
||||
|
||||
// Question marks
|
||||
Proxies.common.bindTexture(textureFile);
|
||||
drawTexturedModalRect(adjustToFactor(guiLeft) + x, adjustToFactor(guiTop) + getLineY(), 196, 18, 16, 16);
|
||||
drawTexturedModalRect(adjustToFactor(guiLeft) + x, adjustToFactor(guiTop) + getLineY(), 78, 240, 16, 16);
|
||||
|
||||
Proxies.common.bindTexture(textureFile);
|
||||
drawTexturedModalRect(adjustToFactor(guiLeft) + x + 32, adjustToFactor(guiTop) + getLineY(), 196, 18, 16, 16);
|
||||
drawTexturedModalRect(adjustToFactor(guiLeft) + x + 32, adjustToFactor(guiTop) + getLineY(), 78, 240, 16, 16);
|
||||
|
||||
int line = 0;
|
||||
int column = 196;
|
||||
int line = 247;
|
||||
int column = 100;
|
||||
|
||||
switch (EnumMutateChance.rateChance(combination.getBaseChance())) {
|
||||
case HIGHEST:
|
||||
column = 226;
|
||||
line = 9;
|
||||
break;
|
||||
case HIGHER:
|
||||
column = 211;
|
||||
line = 9;
|
||||
break;
|
||||
case HIGH:
|
||||
line = 9;
|
||||
break;
|
||||
case NORMAL:
|
||||
column = 226;
|
||||
break;
|
||||
case LOW:
|
||||
column = 211;
|
||||
break;
|
||||
case LOWEST:
|
||||
default:
|
||||
break;
|
||||
case HIGHEST:
|
||||
column = 100;
|
||||
break;
|
||||
case HIGHER:
|
||||
column = 100 + 15;
|
||||
break;
|
||||
case HIGH:
|
||||
column = 100 + 15 * 2;
|
||||
break;
|
||||
case NORMAL:
|
||||
column = 100 + 15 * 3;
|
||||
break;
|
||||
case LOW:
|
||||
column = 100 + 15 * 4;
|
||||
break;
|
||||
case LOWEST:
|
||||
column = 100 + 15 * 5;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// Probability arrow
|
||||
@@ -367,22 +409,22 @@ public abstract class GuiAlyzer extends GuiForestry<TileForestry> {
|
||||
|
||||
private void drawDownSymbol(int x, int y) {
|
||||
Proxies.common.bindTexture(textureFile);
|
||||
drawTexturedModalRect((int) ((guiLeft + x) * (1 / factor)), (int) ((guiTop + getLineY()) * (1 / factor)), 196, 34, 15, 9);
|
||||
drawTexturedModalRect((int) ((guiLeft + x) * (1 / factor)), (int) ((guiTop + getLineY()) * (1 / factor)), 0, 247, 15, 9);
|
||||
}
|
||||
|
||||
private void drawUpSymbol(int x, int y) {
|
||||
Proxies.common.bindTexture(textureFile);
|
||||
drawTexturedModalRect((int) ((guiLeft + x) * (1 / factor)), (int) ((guiTop + getLineY()) * (1 / factor)), 211, 34, 15, 9);
|
||||
drawTexturedModalRect((int) ((guiLeft + x) * (1 / factor)), (int) ((guiTop + getLineY()) * (1 / factor)), 15, 247, 15, 9);
|
||||
}
|
||||
|
||||
private void drawBothSymbol(int x, int y) {
|
||||
Proxies.common.bindTexture(textureFile);
|
||||
drawTexturedModalRect((int) ((guiLeft + x) * (1 / factor)), (int) ((guiTop + getLineY()) * (1 / factor)), 226, 34, 15, 9);
|
||||
drawTexturedModalRect((int) ((guiLeft + x) * (1 / factor)), (int) ((guiTop + getLineY()) * (1 / factor)), 30, 247, 15, 9);
|
||||
}
|
||||
|
||||
private void drawNoneSymbol(int x, int y) {
|
||||
Proxies.common.bindTexture(textureFile);
|
||||
drawTexturedModalRect((int) ((guiLeft + x) * (1 / factor)), (int) ((guiTop + getLineY()) * (1 / factor)), 241, 34, 15, 9);
|
||||
drawTexturedModalRect((int) ((guiLeft + x) * (1 / factor)), (int) ((guiTop + getLineY()) * (1 / factor)), 45, 247, 15, 9);
|
||||
}
|
||||
|
||||
protected void drawFertilityInfo(int fertility, int x, int textColor, int texOffset) {
|
||||
@@ -390,7 +432,7 @@ public abstract class GuiAlyzer extends GuiForestry<TileForestry> {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
Proxies.common.bindTexture(textureFile);
|
||||
drawTexturedModalRect((int) ((guiLeft + x + 19) * (1 / factor)), (int) ((guiTop + getLineY()) * (1 / factor)), 196, 43 + texOffset, 12, 9);
|
||||
drawTexturedModalRect((int) ((guiLeft + x + 14) * (1 / factor)), (int) ((guiTop + getLineY()) * (1 / factor)), 60, 240 + texOffset, 12, 8);
|
||||
|
||||
drawLine(Integer.toString(fertility) + " x", x, textColor);
|
||||
}
|
||||
|
||||
@@ -16,10 +16,9 @@ import forestry.core.config.Defaults;
|
||||
import forestry.core.gadgets.TileAnalyzer;
|
||||
import forestry.core.gui.widgets.TankWidget;
|
||||
import forestry.core.utils.EnumTankLevel;
|
||||
import forestry.core.utils.StringUtil;
|
||||
import forestry.core.utils.Utils;
|
||||
|
||||
public class GuiAnalyzer extends GuiForestry<TileAnalyzer> {
|
||||
public class GuiAnalyzer extends GuiForestryTitled<TileAnalyzer> {
|
||||
|
||||
public GuiAnalyzer(InventoryPlayer inventory, TileAnalyzer tile) {
|
||||
super(Defaults.TEXTURE_PATH_GUI + "/alyzer.png", new ContainerAnalyzer(inventory, tile), tile);
|
||||
@@ -27,13 +26,6 @@ public class GuiAnalyzer extends GuiForestry<TileAnalyzer> {
|
||||
widgetManager.add(new TankWidget(this.widgetManager, 95, 24, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
|
||||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||
String title = StringUtil.localize("tile.for." + tile.getInventoryName());
|
||||
this.fontRendererObj.drawString(title, getCenteredOffset(title), 6, fontColor.get("gui.title"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) {
|
||||
super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY);
|
||||
|
||||
@@ -53,10 +53,6 @@ public abstract class GuiForestry<T extends TileForestry> extends GuiContainer {
|
||||
public ResourceLocation textureFile;
|
||||
protected FontColour fontColor;
|
||||
|
||||
public GuiForestry(ContainerForestry container) {
|
||||
this("", container);
|
||||
}
|
||||
|
||||
public GuiForestry(String texture, ContainerForestry container) {
|
||||
this(new ResourceLocation("forestry", texture), container, null);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
/*******************************************************************************
|
||||
* 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.gui;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import forestry.core.gadgets.TileForestry;
|
||||
import forestry.core.utils.StringUtil;
|
||||
|
||||
public abstract class GuiForestryTitled<T extends TileForestry> extends GuiForestry<T> {
|
||||
|
||||
public GuiForestryTitled(String texture, ContainerForestry container, Object inventory) {
|
||||
super(texture, container, inventory);
|
||||
}
|
||||
|
||||
public GuiForestryTitled(ResourceLocation texture, ContainerForestry container, Object inventory) {
|
||||
super(texture, container, inventory);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
|
||||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||
String name = StringUtil.localizeTile(tile.getUnlocalizedName());
|
||||
this.fontRendererObj.drawString(name, getCenteredOffset(name), 6, fontColor.get("gui.title"));
|
||||
}
|
||||
}
|
||||
@@ -42,8 +42,8 @@ public class SlotCustom extends SlotForestry {
|
||||
private ICrafter crafter;
|
||||
private String blockedTexture = "slots/blocked";
|
||||
|
||||
public SlotCustom(IInventory iinventory, int i, int j, int k, boolean exclusion) {
|
||||
super(iinventory, i, j, k);
|
||||
public SlotCustom(IInventory iinventory, int slotIndex, int xPos, int yPos, boolean exclusion) {
|
||||
super(iinventory, slotIndex, xPos, yPos);
|
||||
items = new Object[0];
|
||||
this.exclusion = exclusion;
|
||||
}
|
||||
@@ -52,17 +52,17 @@ public class SlotCustom extends SlotForestry {
|
||||
this(iinventory, i, j, k, items.toArray());
|
||||
}*/
|
||||
|
||||
public SlotCustom(IInventory iinventory, Collection<?> items, int i, int j, int k) {
|
||||
this(iinventory, i, j, k, items.toArray());
|
||||
public SlotCustom(IInventory iinventory, Collection<?> items, int slotIndex, int xPos, int yPos) {
|
||||
this(iinventory, slotIndex, xPos, yPos, items.toArray());
|
||||
}
|
||||
|
||||
public SlotCustom(IInventory iinventory, int i, int j, int k, boolean exclusion, Object... items) {
|
||||
this(iinventory, i, j, k, items);
|
||||
public SlotCustom(IInventory iinventory, int slotIndex, int xPos, int yPos, boolean exclusion, Object... items) {
|
||||
this(iinventory, slotIndex, xPos, yPos, items);
|
||||
this.exclusion = exclusion;
|
||||
}
|
||||
|
||||
public SlotCustom(IInventory iinventory, int i, int j, int k, Object... items) {
|
||||
super(iinventory, i, j, k);
|
||||
public SlotCustom(IInventory iinventory, int slotIndex, int xPos, int yPos, Object... items) {
|
||||
super(iinventory, slotIndex, xPos, yPos);
|
||||
this.items = items;
|
||||
}
|
||||
|
||||
|
||||
@@ -81,13 +81,13 @@ public class ItemCrated extends Item implements IGenericCrate {
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public String getItemStackDisplayName(ItemStack itemstack) {
|
||||
// if (contained != null)
|
||||
// return StringUtil.localize("item.crated.adj") + " " + Proxies.common.getDisplayName(contained);
|
||||
// else
|
||||
// return StringUtil.localize("item.crated.unknown");
|
||||
// }
|
||||
@Override
|
||||
public String getItemStackDisplayName(ItemStack itemstack) {
|
||||
if (contained != null)
|
||||
return StringUtil.localize("item.crated.adj") + " " + Proxies.common.getDisplayName(contained);
|
||||
else
|
||||
return StringUtil.localize("item.crated.unknown");
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
|
||||
@@ -10,9 +10,12 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.items;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
public class ItemForestryBlock extends ItemBlock {
|
||||
|
||||
@@ -31,6 +34,12 @@ public class ItemForestryBlock extends ItemBlock {
|
||||
return field_150939_a;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public IIcon getIconFromDamage(int meta) {
|
||||
return this.getBlock().getIcon(1, meta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack itemstack) {
|
||||
return getBlock().getUnlocalizedName() + "." + itemstack.getItemDamage();
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package forestry.core.items;
|
||||
|
||||
import forestry.core.IItemTyped;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
/**
|
||||
* For blocks whose type depends on metadata.
|
||||
* This allows control over which localized name maps to which meta value.
|
||||
*/
|
||||
public class ItemTypedBlock extends ItemForestryBlock {
|
||||
|
||||
public ItemTypedBlock(Block block) {
|
||||
super(block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack itemstack) {
|
||||
Block block = getBlock();
|
||||
if (block instanceof IItemTyped) {
|
||||
IItemTyped blockTyped = (IItemTyped)block;
|
||||
Enum type = blockTyped.getTypeFromMeta(itemstack.getItemDamage());
|
||||
if (type != null)
|
||||
return getBlock().getUnlocalizedName() + "." + type.ordinal();
|
||||
else
|
||||
return null;
|
||||
}
|
||||
return super.getUnlocalizedName(itemstack);
|
||||
}
|
||||
}
|
||||
@@ -76,10 +76,13 @@ public class ClassMap {
|
||||
}
|
||||
for (Field member : gameProfileMember) {
|
||||
GameProfile profile = (GameProfile) member.get(obj);
|
||||
intPayload[index.intIndex] = (int) (profile.getId().getMostSignificantBits() >>> 32);
|
||||
intPayload[index.intIndex + 1] = (int) profile.getId().getMostSignificantBits();
|
||||
intPayload[index.intIndex + 2] = (int) (profile.getId().getLeastSignificantBits() >>> 32);
|
||||
intPayload[index.intIndex + 3] = (int) profile.getId().getLeastSignificantBits();
|
||||
UUID profileID = profile.getId();
|
||||
if (profileID == null)
|
||||
profileID = new UUID(0,0);
|
||||
intPayload[index.intIndex] = (int) profileID.getMostSignificantBits() >>> 32;
|
||||
intPayload[index.intIndex + 1] = (int) profileID.getMostSignificantBits();
|
||||
intPayload[index.intIndex + 2] = (int) profileID.getLeastSignificantBits() >>> 32;
|
||||
intPayload[index.intIndex + 3] = (int) profileID.getLeastSignificantBits();
|
||||
index.intIndex += 4;
|
||||
stringPayload[index.stringIndex] = profile.getName();
|
||||
index.stringIndex++;
|
||||
|
||||
@@ -42,7 +42,7 @@ public class PacketIds {
|
||||
public static final int LETTER_RECIPIENT = 80;
|
||||
public static final int LETTER_TEXT = 81;
|
||||
public static final int TRADING_ADDRESS_SET = 82;
|
||||
public static final int TRADING_INFO = 83;
|
||||
public static final int LETTER_INFO = 83;
|
||||
public static final int POBOX_INFO = 85;
|
||||
public static final int POBOX_INFO_REQUEST = 86;
|
||||
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package forestry.core.utils;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
|
||||
public class AlyzerInventory extends ItemInventory {
|
||||
|
||||
public static final int SLOT_SPECIMEN = 0;
|
||||
public static final int SLOT_ANALYZE_1 = 1;
|
||||
public static final int SLOT_ANALYZE_2 = 2;
|
||||
public static final int SLOT_ANALYZE_3 = 3;
|
||||
public static final int SLOT_ANALYZE_4 = 4;
|
||||
public static final int SLOT_ANALYZE_5 = 6;
|
||||
public static final int SLOT_ENERGY = 5;
|
||||
|
||||
protected EntityPlayer player;
|
||||
|
||||
public AlyzerInventory(Class<? extends Item> itemClass, int slots) {
|
||||
super(itemClass, slots);
|
||||
}
|
||||
|
||||
public AlyzerInventory(Class<? extends Item> itemClass, int size, ItemStack itemstack) {
|
||||
super(itemClass, size, itemstack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
|
||||
NBTTagList nbttaglist = new NBTTagList();
|
||||
for (int i = SLOT_ENERGY; i < SLOT_ENERGY + 1; i++) {
|
||||
if (inventoryStacks[i] != null) {
|
||||
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
|
||||
nbttagcompound1.setByte("Slot", (byte) i);
|
||||
inventoryStacks[i].writeToNBT(nbttagcompound1);
|
||||
nbttaglist.appendTag(nbttagcompound1);
|
||||
}
|
||||
}
|
||||
nbttagcompound.setTag("Items", nbttaglist);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -76,17 +76,20 @@ public class InventoryAdapter implements IInventory, INBTTagable {
|
||||
}
|
||||
|
||||
public boolean tryAddStacksCopy(ItemStack[] stacks, boolean all) {
|
||||
return tryAddStacksCopy(stacks, 0, this.getSizeInventory(), all);
|
||||
}
|
||||
|
||||
public boolean tryAddStacksCopy(ItemStack[] stacks, int startSlot, int slots, boolean all) {
|
||||
|
||||
boolean addedAll = true;
|
||||
for (ItemStack stack : stacks) {
|
||||
if (stack == null)
|
||||
continue;
|
||||
|
||||
if (!tryAddStack(stack.copy(), all))
|
||||
addedAll = false;
|
||||
if (!tryAddStack(stack.copy(), startSlot, slots, all))
|
||||
return false;
|
||||
}
|
||||
|
||||
return addedAll;
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean tryAddStacks(ItemStack[] stacks, boolean all) {
|
||||
@@ -121,7 +124,11 @@ public class InventoryAdapter implements IInventory, INBTTagable {
|
||||
}
|
||||
|
||||
public boolean tryAddStack(ItemStack stack, int startSlot, int slots, boolean all, boolean doAdd) {
|
||||
return addStack(stack, startSlot, slots, all, doAdd) > 0;
|
||||
int added = addStack(stack, startSlot, slots, all, doAdd);
|
||||
if (all)
|
||||
return added == stack.stackSize;
|
||||
else
|
||||
return added > 0;
|
||||
}
|
||||
|
||||
public int addStack(ItemStack stack, boolean all, boolean doAdd) {
|
||||
@@ -193,7 +200,7 @@ public class InventoryAdapter implements IInventory, INBTTagable {
|
||||
if (stack == null)
|
||||
continue;
|
||||
|
||||
if (StackUtils.equals(Blocks.air, queried)) {
|
||||
if (StackUtils.equals(Blocks.bedrock, queried)) {
|
||||
itemCount += stack.stackSize;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -193,7 +193,7 @@ public class StackUtils {
|
||||
* without decreasing the source stack.
|
||||
*
|
||||
* @param stack
|
||||
* @param i
|
||||
* @param amount
|
||||
* @return
|
||||
*/
|
||||
public static ItemStack createSplitStack(ItemStack stack, int amount) {
|
||||
@@ -309,6 +309,9 @@ public class StackUtils {
|
||||
if (isIdenticalItem(base, comparison))
|
||||
return true;
|
||||
|
||||
if (base == null || comparison == null)
|
||||
return false;
|
||||
|
||||
if (oreDictionary) {
|
||||
int[] idsBase = OreDictionary.getOreIDs(base);
|
||||
for (int idBase : idsBase) {
|
||||
|
||||
@@ -22,14 +22,12 @@ public class StringUtil {
|
||||
return StatCollector.translateToLocal("for." + key).replace("\\n", "\n").replace("@", "%").replace("\\%", "@");
|
||||
}
|
||||
|
||||
public static String localizeAndFormat(String key, Object... args) {
|
||||
String text = StringUtil.localize(key);
|
||||
public static String localizeTile(String key) {
|
||||
return StatCollector.translateToLocal("tile.for." + key).replace("\\n", "\n").replace("@", "%").replace("\\%", "@");
|
||||
}
|
||||
|
||||
try {
|
||||
return String.format(text, args);
|
||||
} catch (IllegalFormatException ex) {
|
||||
return "Format error: " + text;
|
||||
}
|
||||
public static String localizeAndFormat(String key, Object... args) {
|
||||
return localizeAndFormatRaw("for." + key, args);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -320,7 +320,7 @@ public class Utils {
|
||||
|
||||
public static int addRGBComponents(int colour, int r, int g, int b) {
|
||||
r = ((colour & 0xff0000) >> 16) + r;
|
||||
g = ((colour & 0xff00) >> 8) + b;
|
||||
g = ((colour & 0xff00) >> 8) + g;
|
||||
b = ((colour & 0xff)) + b;
|
||||
|
||||
r = r <= 255 ? r : 255;
|
||||
|
||||
@@ -405,12 +405,9 @@ public class EngineBronze extends Engine implements ISpecialInventory, ILiquidTa
|
||||
return super.isUseableByPlayer(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: just a specialsource workaround
|
||||
*/
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return super.getInventoryName();
|
||||
return getUnlocalizedName();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -397,12 +397,9 @@ public class EngineCopper extends Engine implements ISpecialInventory, ISidedInv
|
||||
return super.isUseableByPlayer(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: just a specialsource workaround
|
||||
*/
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return super.getInventoryName();
|
||||
return getUnlocalizedName();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -311,12 +311,9 @@ public class EngineTin extends Engine implements ISocketable, IInventory {
|
||||
return super.isUseableByPlayer(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: just a specialsource workaround
|
||||
*/
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return super.getInventoryName();
|
||||
return getUnlocalizedName();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -65,7 +65,7 @@ public class MachineGenerator extends TileBase implements ISpecialInventory, ILi
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return StringUtil.localize("engine.3");
|
||||
return getUnlocalizedName();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -15,12 +15,12 @@ package forestry.energy.gui;
|
||||
|
||||
import forestry.core.gadgets.Engine;
|
||||
import forestry.core.gui.ContainerForestry;
|
||||
import forestry.core.gui.GuiForestry;
|
||||
import forestry.core.gui.GuiForestryTitled;
|
||||
import forestry.core.gui.Ledger;
|
||||
import forestry.core.render.TextureManager;
|
||||
import forestry.core.utils.StringUtil;
|
||||
|
||||
public abstract class GuiEngine extends GuiForestry<Engine> {
|
||||
public abstract class GuiEngine extends GuiForestryTitled<Engine> {
|
||||
|
||||
protected class EngineLedger extends Ledger {
|
||||
|
||||
|
||||
@@ -103,19 +103,15 @@ public class GuiEngineBronze extends GuiEngine {
|
||||
widgetManager.add(new BiogasSlot(this.widgetManager, 30, 47, tile));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
|
||||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||
String name = StringUtil.localize("tile.for.engine.2");
|
||||
this.fontRendererObj.drawString(name, getCenteredOffset(name), 6, fontColor.get("gui.title"));
|
||||
protected EngineBronze getEngine() {
|
||||
return (EngineBronze)tile;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) {
|
||||
super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY);
|
||||
EngineBronze engine = (EngineBronze) tile;
|
||||
|
||||
int temp = engine.getOperatingTemperatureScaled(16);
|
||||
int temp = getEngine().getOperatingTemperatureScaled(16);
|
||||
if (temp > 16)
|
||||
temp = 16;
|
||||
if (temp > 0)
|
||||
|
||||
@@ -22,19 +22,15 @@ public class GuiEngineCopper extends GuiEngine {
|
||||
super(Defaults.TEXTURE_PATH_GUI + "/peatengine.png", new ContainerEngineCopper(inventory, tile), tile);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
|
||||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||
String name = StringUtil.localize("tile.for.engine.1");
|
||||
this.fontRendererObj.drawString(name, getCenteredOffset(name), 6, fontColor.get("gui.title"));
|
||||
this.fontRendererObj.drawString("Inventory", 8, this.ySize - 96 + 2, fontColor.get("gui.title"));
|
||||
protected EngineCopper getEngine() {
|
||||
return (EngineCopper)tile;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) {
|
||||
super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY);
|
||||
EngineCopper engine = (EngineCopper) tile;
|
||||
|
||||
EngineCopper engine = getEngine();
|
||||
int progress;
|
||||
if (engine.isBurning()) {
|
||||
progress = engine.getBurnTimeRemainingScaled(12);
|
||||
|
||||
@@ -25,19 +25,20 @@ public class GuiEngineTin extends GuiEngine {
|
||||
widgetManager.add(new SocketWidget(this.widgetManager, 30, 40, tile, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
|
||||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||
String name = StringUtil.localize("tile.for.engine.0");
|
||||
this.fontRendererObj.drawString(name, getCenteredOffset(name), 6, fontColor.get("gui.title"));
|
||||
protected EngineTin getEngine() {
|
||||
return (EngineTin)tile;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) {
|
||||
super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY);
|
||||
EngineTin engine = (EngineTin) tile;
|
||||
drawHealthMeter(guiLeft + 74, guiTop + 25, engine.getStorageScaled(46), engine.rateLevel(engine.getStorageScaled(100)));
|
||||
|
||||
EngineTin engine = getEngine();
|
||||
int storageHeight = engine.getStorageScaled(46);
|
||||
int storageMaxHeight = engine.getStorageScaled(100);
|
||||
EnumTankLevel rated = engine.rateLevel(storageMaxHeight);
|
||||
|
||||
drawHealthMeter(guiLeft + 74, guiTop + 25, storageHeight, rated);
|
||||
}
|
||||
|
||||
private void drawHealthMeter(int x, int y, int height, EnumTankLevel rated) {
|
||||
|
||||
@@ -13,25 +13,17 @@ package forestry.energy.gui;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.gui.GuiForestry;
|
||||
import forestry.core.gui.GuiForestryTitled;
|
||||
import forestry.core.gui.widgets.TankWidget;
|
||||
import forestry.core.utils.StringUtil;
|
||||
import forestry.energy.gadgets.MachineGenerator;
|
||||
|
||||
public class GuiGenerator extends GuiForestry<MachineGenerator> {
|
||||
public class GuiGenerator extends GuiForestryTitled<MachineGenerator> {
|
||||
|
||||
public GuiGenerator(InventoryPlayer inventory, MachineGenerator tile) {
|
||||
super(Defaults.TEXTURE_PATH_GUI + "/generator.png", new ContainerGenerator(inventory, tile), tile);
|
||||
widgetManager.add(new TankWidget(this.widgetManager, 49, 17, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
|
||||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||
String title = StringUtil.localize("tile.for." + tile.getInventoryName());
|
||||
this.fontRendererObj.drawString(title, getCenteredOffset(title), 6, fontColor.get("gui.title"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) {
|
||||
super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY);
|
||||
|
||||
@@ -168,7 +168,7 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return "factory.0";
|
||||
return getUnlocalizedName();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -239,7 +239,7 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return "factory.1";
|
||||
return getUnlocalizedName();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -148,7 +148,7 @@ public class MachineCentrifuge extends TilePowered implements ISidedInventory, I
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return "factory.2";
|
||||
return getUnlocalizedName();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -248,7 +248,7 @@ public class MachineFabricator extends TilePowered implements ICrafter, ISpecial
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return "factory2.0";
|
||||
return getUnlocalizedName();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -200,7 +200,7 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return "factory.3";
|
||||
return getUnlocalizedName();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -145,7 +145,7 @@ public class MachineMoistener extends TilePowered implements ISpecialInventory,
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return "factory.4";
|
||||
return getUnlocalizedName();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -70,7 +70,7 @@ public class MachineRaintank extends TileBase implements ISidedInventory, ILiqui
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return "factory2.1";
|
||||
return getUnlocalizedName();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -156,7 +156,7 @@ public class MachineSqueezer extends TilePowered implements ISpecialInventory, I
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return "factory.5";
|
||||
return getUnlocalizedName();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -135,7 +135,7 @@ public class MachineStill extends TilePowered implements ISpecialInventory, ISid
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return "factory.6";
|
||||
return getUnlocalizedName();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -34,7 +34,7 @@ public class MillRainmaker extends Mill implements ISpecialInventory {
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return "Rainmaker";
|
||||
return getUnlocalizedName();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -120,7 +120,7 @@ public class TileWorktable extends TileBase implements ICrafter {
|
||||
@Override
|
||||
public ItemStack getCraftingResult(InventoryCrafting inventorycrafting) {
|
||||
if (updateCachedIRecipe())
|
||||
return cachedRecipe.getRecipeOutput();
|
||||
return cachedRecipe.getCraftingResult(inventorycrafting);
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -193,29 +193,25 @@ public class TileWorktable extends TileBase implements ICrafter {
|
||||
|
||||
private LinkedList<Recipe> recipes = new LinkedList<Recipe>();
|
||||
private long lastUpdate;
|
||||
public final int capacity = 9;
|
||||
|
||||
public long getLastUpdate() {
|
||||
return lastUpdate;
|
||||
}
|
||||
|
||||
public Recipe getOrCreateRecipe(World world, InventoryCrafting crafting) {
|
||||
|
||||
Recipe memory = getMemorized(crafting, world);
|
||||
if (memory != null) {
|
||||
return memory;
|
||||
}
|
||||
|
||||
return new Recipe(crafting);
|
||||
}
|
||||
|
||||
public void memorizeRecipe(World world, Recipe recipe) {
|
||||
public void memorizeRecipe(World world, Recipe recipe, InventoryCrafting crafting) {
|
||||
|
||||
lastUpdate = world.getTotalWorldTime();
|
||||
recipe.updateLastUse(world);
|
||||
|
||||
if (recipes.contains(recipe))
|
||||
Recipe memory = getMemorized(crafting, world);
|
||||
if (memory != null) {
|
||||
int index = recipes.indexOf(memory);
|
||||
recipes.set(index, recipe);
|
||||
return;
|
||||
if (recipes.size() < 8) {
|
||||
}
|
||||
|
||||
if (recipes.size() < capacity) {
|
||||
recipes.add(recipe);
|
||||
return;
|
||||
}
|
||||
@@ -361,6 +357,7 @@ public class TileWorktable extends TileBase implements ICrafter {
|
||||
}
|
||||
/* MEMBERS */
|
||||
private Recipe currentRecipe;
|
||||
private InventoryCrafting currentCrafting;
|
||||
private final RecipeMemory memorized;
|
||||
private final TileInventoryAdapter craftingInventory;
|
||||
private final TileInventoryAdapter accessibleInventory;
|
||||
@@ -372,11 +369,6 @@ public class TileWorktable extends TileBase implements ICrafter {
|
||||
memorized = new RecipeMemory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return "factory2.2";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openGui(EntityPlayer player, TileBase tile) {
|
||||
player.openGui(ForestryAPI.instance, GuiId.WorktableGUI.ordinal(), player.worldObj, xCoord, yCoord, zCoord);
|
||||
@@ -425,7 +417,7 @@ public class TileWorktable extends TileBase implements ICrafter {
|
||||
}
|
||||
|
||||
public void chooseRecipe(int recipeIndex) {
|
||||
if (recipeIndex == 9) {
|
||||
if (recipeIndex >= memorized.capacity) {
|
||||
for (int slot = 0; slot < craftingInventory.getSizeInventory(); slot++) {
|
||||
craftingInventory.setInventorySlotContents(slot, null);
|
||||
}
|
||||
@@ -447,13 +439,19 @@ public class TileWorktable extends TileBase implements ICrafter {
|
||||
public void setRecipe(InventoryCrafting crafting) {
|
||||
|
||||
IRecipe recipe = RECIPE_BRIDGE.getRecipe(crafting, worldObj);
|
||||
currentRecipe = recipe != null ? memorized.getOrCreateRecipe(worldObj, crafting) : null;
|
||||
updateCraftResult();
|
||||
if (recipe == null) {
|
||||
currentRecipe = null;
|
||||
currentCrafting = null;
|
||||
} else {
|
||||
currentRecipe = new Recipe(crafting);
|
||||
currentCrafting = crafting;
|
||||
}
|
||||
updateCraftResult(currentCrafting);
|
||||
}
|
||||
|
||||
private void updateCraftResult() {
|
||||
private void updateCraftResult(InventoryCrafting inventorycrafting) {
|
||||
if (currentRecipe != null) {
|
||||
ItemStack result = currentRecipe.getCraftingResult(null);
|
||||
ItemStack result = currentRecipe.getCraftingResult(inventorycrafting);
|
||||
if (result != null) {
|
||||
craftingInventory.setInventorySlotContents(SLOT_CRAFTING_RESULT, result.copy());
|
||||
return;
|
||||
@@ -467,7 +465,10 @@ public class TileWorktable extends TileBase implements ICrafter {
|
||||
// Need at least one matched set
|
||||
if (currentRecipe == null)
|
||||
return false;
|
||||
return StackUtils.containsSets(currentRecipe.getMatrix().getStacks(SLOT_CRAFTING_1, 9), accessibleInventory.getStacks(SLOT_INVENTORY_1, SLOT_INVENTORY_COUNT), currentRecipe.getRecipeOutput(), true, true) > 0;
|
||||
|
||||
ItemStack[] set = currentRecipe.getMatrix().getStacks();
|
||||
ItemStack[] stock = accessibleInventory.getStacks();
|
||||
return StackUtils.containsSets(set, stock, currentRecipe.getRecipeOutput(), true, true) > 0;
|
||||
}
|
||||
|
||||
private void removeResources(EntityPlayer player) {
|
||||
@@ -511,9 +512,9 @@ public class TileWorktable extends TileBase implements ICrafter {
|
||||
return null;
|
||||
|
||||
if (Proxies.common.isSimulating(worldObj))
|
||||
memorized.memorizeRecipe(worldObj, currentRecipe);
|
||||
memorized.memorizeRecipe(worldObj, currentRecipe, currentCrafting);
|
||||
removeResources(player);
|
||||
updateCraftResult();
|
||||
updateCraftResult(currentCrafting);
|
||||
return currentRecipe.getRecipeOutput().copy();
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
******************************************************************************/
|
||||
package forestry.factory.gui;
|
||||
|
||||
import forestry.core.utils.StackUtils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.InventoryCraftResult;
|
||||
@@ -25,6 +26,7 @@ import forestry.core.network.PacketPayload;
|
||||
import forestry.core.network.PacketUpdate;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.factory.gadgets.TileWorktable;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ContainerWorktable extends ContainerForestry implements IContainerCrafting, IGuiSelectable {
|
||||
|
||||
@@ -91,10 +93,16 @@ public class ContainerWorktable extends ContainerForestry implements IContainerC
|
||||
|
||||
@Override
|
||||
public void onCraftMatrixChanged(IInventory iinventory, int slot) {
|
||||
// craftingInventory.setInventorySlotContents(slot, iinventory.getStackInSlot(slot));
|
||||
if (slot < craftMatrix.getSizeInventory())
|
||||
craftMatrix.setInventorySlotContents(slot, iinventory.getStackInSlot(slot));
|
||||
updateRecipe();
|
||||
if (slot >= craftMatrix.getSizeInventory())
|
||||
return;
|
||||
|
||||
ItemStack stack = iinventory.getStackInSlot(slot);
|
||||
ItemStack currentStack = craftMatrix.getStackInSlot(slot);
|
||||
|
||||
if (!StackUtils.isIdenticalItem(stack, currentStack)) {
|
||||
craftMatrix.setInventorySlotContents(slot, stack);
|
||||
updateRecipe();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateMatrix() {
|
||||
@@ -107,6 +115,10 @@ public class ContainerWorktable extends ContainerForestry implements IContainerC
|
||||
tile.setRecipe(craftMatrix);
|
||||
}
|
||||
|
||||
public void clearRecipe() {
|
||||
sendRecipeClick(0, tile.getMemory().capacity);
|
||||
}
|
||||
|
||||
public void sendRecipeClick(int mouseButton, int recipeIndex) {
|
||||
PacketPayload payload = new PacketPayload(2, 0, 0);
|
||||
payload.intPayload[0] = mouseButton;
|
||||
|
||||
@@ -13,25 +13,17 @@ package forestry.factory.gui;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.gui.GuiForestry;
|
||||
import forestry.core.gui.GuiForestryTitled;
|
||||
import forestry.core.gui.widgets.TankWidget;
|
||||
import forestry.core.utils.StringUtil;
|
||||
import forestry.factory.gadgets.MachineBottler;
|
||||
|
||||
public class GuiBottler extends GuiForestry<MachineBottler> {
|
||||
public class GuiBottler extends GuiForestryTitled<MachineBottler> {
|
||||
|
||||
public GuiBottler(InventoryPlayer inventory, MachineBottler processor) {
|
||||
super(Defaults.TEXTURE_PATH_GUI + "/bottler.png", new ContainerBottler(inventory, processor), processor);
|
||||
widgetManager.add(new TankWidget(this.widgetManager, 53, 17, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
|
||||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||
String name = StringUtil.localize("tile.for." + tile.getInventoryName());
|
||||
this.fontRendererObj.drawString(name, getCenteredOffset(name), 6, fontColor.get("gui.title"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) {
|
||||
super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY);
|
||||
|
||||
@@ -13,12 +13,11 @@ package forestry.factory.gui;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.gui.GuiForestry;
|
||||
import forestry.core.gui.GuiForestryTitled;
|
||||
import forestry.core.gui.widgets.TankWidget;
|
||||
import forestry.core.utils.StringUtil;
|
||||
import forestry.factory.gadgets.MachineCarpenter;
|
||||
|
||||
public class GuiCarpenter extends GuiForestry<MachineCarpenter> {
|
||||
public class GuiCarpenter extends GuiForestryTitled<MachineCarpenter> {
|
||||
|
||||
public GuiCarpenter(InventoryPlayer inventory, MachineCarpenter tile) {
|
||||
super(Defaults.TEXTURE_PATH_GUI + "/carpenter.png", new ContainerCarpenter(inventory, tile), tile);
|
||||
@@ -33,13 +32,6 @@ public class GuiCarpenter extends GuiForestry<MachineCarpenter> {
|
||||
inventorySlots.onContainerClosed(mc.thePlayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
|
||||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||
String name = StringUtil.localize("tile.for." + tile.getInventoryName());
|
||||
this.fontRendererObj.drawString(name, getCenteredOffset(name), 6, fontColor.get("gui.title"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) {
|
||||
super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY);
|
||||
|
||||
@@ -13,23 +13,15 @@ package forestry.factory.gui;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.gui.GuiForestry;
|
||||
import forestry.core.utils.StringUtil;
|
||||
import forestry.core.gui.GuiForestryTitled;
|
||||
import forestry.factory.gadgets.MachineCentrifuge;
|
||||
|
||||
public class GuiCentrifuge extends GuiForestry<MachineCentrifuge> {
|
||||
public class GuiCentrifuge extends GuiForestryTitled<MachineCentrifuge> {
|
||||
|
||||
public GuiCentrifuge(InventoryPlayer inventory, MachineCentrifuge tile) {
|
||||
super(Defaults.TEXTURE_PATH_GUI + "/centrifuge.png", new ContainerCentrifuge(inventory, tile), tile);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
|
||||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||
String name = StringUtil.localize("tile.for." + tile.getInventoryName());
|
||||
this.fontRendererObj.drawString(name, getCenteredOffset(name), 6, fontColor.get("gui.title"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) {
|
||||
super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY);
|
||||
|
||||
@@ -13,12 +13,11 @@ package forestry.factory.gui;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.gui.GuiForestry;
|
||||
import forestry.core.gui.GuiForestryTitled;
|
||||
import forestry.core.gui.widgets.ReservoirWidget;
|
||||
import forestry.core.utils.StringUtil;
|
||||
import forestry.factory.gadgets.MachineFabricator;
|
||||
|
||||
public class GuiFabricator extends GuiForestry<MachineFabricator> {
|
||||
public class GuiFabricator extends GuiForestryTitled<MachineFabricator> {
|
||||
|
||||
public GuiFabricator(InventoryPlayer player, MachineFabricator tile) {
|
||||
super(Defaults.TEXTURE_PATH_GUI + "/fabricator.png", new ContainerFabricator(player, tile), tile);
|
||||
@@ -26,13 +25,6 @@ public class GuiFabricator extends GuiForestry<MachineFabricator> {
|
||||
widgetManager.add(new ReservoirWidget(this.widgetManager, 26, 48, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
|
||||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||
String name = StringUtil.localize("tile.for." + tile.getInventoryName());
|
||||
this.fontRendererObj.drawString(name, getCenteredOffset(name), 6, fontColor.get("gui.title"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) {
|
||||
super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY);
|
||||
|
||||
@@ -13,12 +13,11 @@ package forestry.factory.gui;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.gui.GuiForestry;
|
||||
import forestry.core.gui.GuiForestryTitled;
|
||||
import forestry.core.gui.widgets.TankWidget;
|
||||
import forestry.core.utils.StringUtil;
|
||||
import forestry.factory.gadgets.MachineFermenter;
|
||||
|
||||
public class GuiFermenter extends GuiForestry<MachineFermenter> {
|
||||
public class GuiFermenter extends GuiForestryTitled<MachineFermenter> {
|
||||
|
||||
public GuiFermenter(InventoryPlayer inventory, MachineFermenter tile) {
|
||||
super(Defaults.TEXTURE_PATH_GUI + "/fermenter.png", new ContainerFermenter(inventory, tile), tile);
|
||||
@@ -26,13 +25,6 @@ public class GuiFermenter extends GuiForestry<MachineFermenter> {
|
||||
widgetManager.add(new TankWidget(this.widgetManager, 125, 19, 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
|
||||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||
String name = StringUtil.localize("tile.for." + tile.getInventoryName());
|
||||
this.fontRendererObj.drawString(name, getCenteredOffset(name), 6, fontColor.get("gui.title"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) {
|
||||
super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY);
|
||||
|
||||
@@ -13,25 +13,17 @@ package forestry.factory.gui;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.gui.GuiForestry;
|
||||
import forestry.core.gui.GuiForestryTitled;
|
||||
import forestry.core.gui.widgets.TankWidget;
|
||||
import forestry.core.utils.StringUtil;
|
||||
import forestry.factory.gadgets.MachineMoistener;
|
||||
|
||||
public class GuiMoistener extends GuiForestry<MachineMoistener> {
|
||||
public class GuiMoistener extends GuiForestryTitled<MachineMoistener> {
|
||||
|
||||
public GuiMoistener(InventoryPlayer inventory, MachineMoistener tile) {
|
||||
super(Defaults.TEXTURE_PATH_GUI + "/moistener.png", new ContainerMoistener(inventory, tile), tile);
|
||||
widgetManager.add(new TankWidget(this.widgetManager, 16, 16, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
|
||||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||
String name = StringUtil.localize("tile.for." + tile.getInventoryName());
|
||||
this.fontRendererObj.drawString(name, getCenteredOffset(name), 6, fontColor.get("gui.title"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) {
|
||||
super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY);
|
||||
|
||||
@@ -13,25 +13,17 @@ package forestry.factory.gui;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.gui.GuiForestry;
|
||||
import forestry.core.gui.GuiForestryTitled;
|
||||
import forestry.core.gui.widgets.TankWidget;
|
||||
import forestry.core.utils.StringUtil;
|
||||
import forestry.factory.gadgets.MachineRaintank;
|
||||
|
||||
public class GuiRaintank extends GuiForestry<MachineRaintank> {
|
||||
public class GuiRaintank extends GuiForestryTitled<MachineRaintank> {
|
||||
|
||||
public GuiRaintank(InventoryPlayer inventory, MachineRaintank tile) {
|
||||
super(Defaults.TEXTURE_PATH_GUI + "/raintank.png", new ContainerRaintank(inventory, tile), tile);
|
||||
widgetManager.add(new TankWidget(this.widgetManager, 53, 17, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
|
||||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||
String name = StringUtil.localize("tile.for." + tile.getInventoryName());
|
||||
this.fontRendererObj.drawString(name, getCenteredOffset(name), 6, fontColor.get("gui.title"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) {
|
||||
super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY);
|
||||
|
||||
@@ -13,25 +13,17 @@ package forestry.factory.gui;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.gui.GuiForestry;
|
||||
import forestry.core.gui.GuiForestryTitled;
|
||||
import forestry.core.gui.widgets.TankWidget;
|
||||
import forestry.core.utils.StringUtil;
|
||||
import forestry.factory.gadgets.MachineSqueezer;
|
||||
|
||||
public class GuiSqueezer extends GuiForestry<MachineSqueezer> {
|
||||
public class GuiSqueezer extends GuiForestryTitled<MachineSqueezer> {
|
||||
|
||||
public GuiSqueezer(InventoryPlayer inventory, MachineSqueezer tile) {
|
||||
super(Defaults.TEXTURE_PATH_GUI + "/squeezer.png", new ContainerSqueezer(inventory, tile), tile);
|
||||
widgetManager.add(new TankWidget(this.widgetManager, 85, 15, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
|
||||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||
String name = StringUtil.localize("tile.for." + tile.getInventoryName());
|
||||
this.fontRendererObj.drawString(name, getCenteredOffset(name), 6, fontColor.get("gui.title"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) {
|
||||
super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY);
|
||||
|
||||
@@ -13,12 +13,11 @@ package forestry.factory.gui;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.gui.GuiForestry;
|
||||
import forestry.core.gui.GuiForestryTitled;
|
||||
import forestry.core.gui.widgets.TankWidget;
|
||||
import forestry.core.utils.StringUtil;
|
||||
import forestry.factory.gadgets.MachineStill;
|
||||
|
||||
public class GuiStill extends GuiForestry<MachineStill> {
|
||||
public class GuiStill extends GuiForestryTitled<MachineStill> {
|
||||
|
||||
public GuiStill(InventoryPlayer inventory, MachineStill tile) {
|
||||
super(Defaults.TEXTURE_PATH_GUI + "/still.png", new ContainerStill(inventory, tile), tile);
|
||||
@@ -26,13 +25,6 @@ public class GuiStill extends GuiForestry<MachineStill> {
|
||||
widgetManager.add(new TankWidget(this.widgetManager, 125, 15, 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
|
||||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||
String name = StringUtil.localize("tile.for." + tile.getInventoryName());
|
||||
this.fontRendererObj.drawString(name, getCenteredOffset(name), 6, fontColor.get("gui.title"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) {
|
||||
super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY);
|
||||
|
||||
@@ -19,7 +19,7 @@ import net.minecraft.item.ItemStack;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.gui.GuiForestry;
|
||||
import forestry.core.gui.GuiForestryTitled;
|
||||
import forestry.core.gui.WidgetManager;
|
||||
import forestry.core.gui.widgets.Widget;
|
||||
import forestry.core.proxy.Proxies;
|
||||
@@ -28,7 +28,7 @@ import forestry.core.render.TextureManager;
|
||||
import forestry.core.utils.StringUtil;
|
||||
import forestry.factory.gadgets.TileWorktable;
|
||||
|
||||
public class GuiWorktable extends GuiForestry<TileWorktable> {
|
||||
public class GuiWorktable extends GuiForestryTitled<TileWorktable> {
|
||||
|
||||
private class MemorizedSlot extends Widget {
|
||||
|
||||
@@ -58,6 +58,7 @@ public class GuiWorktable extends GuiForestry<TileWorktable> {
|
||||
//RenderHelper.disableStandardItemLighting();
|
||||
|
||||
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
|
||||
if (worktable.getMemory().isLocked(slotNumber)) {
|
||||
manager.gui.setZLevel(110f);
|
||||
@@ -81,67 +82,46 @@ public class GuiWorktable extends GuiForestry<TileWorktable> {
|
||||
}
|
||||
}
|
||||
|
||||
private class BookSlot extends Widget {
|
||||
private class ClearWorktable extends Widget {
|
||||
|
||||
private final ItemStack BOOK = new ItemStack(Items.book);
|
||||
|
||||
public BookSlot(WidgetManager manager, int xPos, int yPos) {
|
||||
public ClearWorktable(WidgetManager manager, int xPos, int yPos) {
|
||||
super(manager, xPos, yPos);
|
||||
width = 7;
|
||||
height = 7;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(int startX, int startY) {
|
||||
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240, 240);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
manager.gui.drawItemStack(BOOK, startX + xPos, startY + yPos);
|
||||
|
||||
GL11.glPopAttrib();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getLegacyTooltip(EntityPlayer player) {
|
||||
return StringUtil.localize("gui.worktable.clear");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMouseClick(int mouseX, int mouseY, int mouseButton) {
|
||||
container.sendRecipeClick(mouseButton, 9);
|
||||
container.clearRecipe();
|
||||
}
|
||||
}
|
||||
private final TileWorktable worktable;
|
||||
protected ContainerWorktable container;
|
||||
|
||||
public GuiWorktable(EntityPlayer player, TileWorktable tile) {
|
||||
super(Defaults.TEXTURE_PATH_GUI + "/worktable.png", new ContainerWorktable(player, tile));
|
||||
super(Defaults.TEXTURE_PATH_GUI + "/worktable.png", new ContainerWorktable(player, tile), tile);
|
||||
|
||||
ySize = 218;
|
||||
worktable = tile;
|
||||
this.tile = tile;
|
||||
container = (ContainerWorktable) inventorySlots;
|
||||
|
||||
widgetManager.add(new BookSlot(widgetManager, 128, 38));
|
||||
final int spacing = 18;
|
||||
int slot = 0;
|
||||
for (int y = 0; y < 3; y++) {
|
||||
int yPos = 20 + (y * spacing);
|
||||
for (int x = 0; x < 3; x++) {
|
||||
int xPos = 110 + (x * spacing);
|
||||
widgetManager.add(new MemorizedSlot(widgetManager, xPos, yPos, slot));
|
||||
slot += 1;
|
||||
}
|
||||
}
|
||||
|
||||
widgetManager.add(new MemorizedSlot(widgetManager, 146, 20, 0));
|
||||
widgetManager.add(new MemorizedSlot(widgetManager, 146, 38, 1));
|
||||
widgetManager.add(new MemorizedSlot(widgetManager, 146, 56, 2));
|
||||
|
||||
widgetManager.add(new MemorizedSlot(widgetManager, 128, 56, 3));
|
||||
widgetManager.add(new MemorizedSlot(widgetManager, 110, 56, 4));
|
||||
|
||||
widgetManager.add(new MemorizedSlot(widgetManager, 110, 38, 5));
|
||||
widgetManager.add(new MemorizedSlot(widgetManager, 110, 20, 6));
|
||||
widgetManager.add(new MemorizedSlot(widgetManager, 128, 20, 7));
|
||||
widgetManager.add(new ClearWorktable(widgetManager, 66, 19));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
|
||||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||
String name = StringUtil.localize("tile.for." + tile.getInventoryName());
|
||||
this.fontRendererObj.drawString(name, getCenteredOffset(name), 6, fontColor.get("gui.title"));
|
||||
}
|
||||
}
|
||||
@@ -11,12 +11,16 @@
|
||||
package forestry.farming.gadgets;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import forestry.core.IItemTyped;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockSapling;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
@@ -29,7 +33,11 @@ import forestry.core.config.Defaults;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.farming.worldgen.WorldGenBigMushroom;
|
||||
|
||||
public class BlockMushroom extends BlockSapling {
|
||||
public class BlockMushroom extends BlockSapling implements IItemTyped {
|
||||
|
||||
public enum MushroomType {
|
||||
BROWN, RED;
|
||||
}
|
||||
|
||||
private final WorldGenerator[] generators;
|
||||
private final ItemStack[] drops;
|
||||
@@ -53,8 +61,9 @@ public class BlockMushroom extends BlockSapling {
|
||||
public ArrayList<ItemStack> getDrops(World world, int X, int Y, int Z, int metadata, int fortune) {
|
||||
ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
|
||||
|
||||
int type = metadata & 0x03;
|
||||
ret.add(drops[type]);
|
||||
MushroomType type = getTypeFromMeta(metadata);
|
||||
|
||||
ret.add(drops[type.ordinal()]);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -71,13 +80,13 @@ public class BlockMushroom extends BlockSapling {
|
||||
return;
|
||||
|
||||
int meta = world.getBlockMetadata(i, j, k);
|
||||
int type = meta & 0x03;
|
||||
MushroomType type = getTypeFromMeta(meta);
|
||||
int maturity = meta >> 2;
|
||||
|
||||
tickGermling(world, i, j, k, random, type, maturity);
|
||||
}
|
||||
|
||||
private void tickGermling(World world, int i, int j, int k, Random random, int type, int maturity) {
|
||||
private void tickGermling(World world, int i, int j, int k, Random random, MushroomType type, int maturity) {
|
||||
|
||||
int lightvalue = world.getBlockLightValue(i, j + 1, k);
|
||||
|
||||
@@ -87,7 +96,7 @@ public class BlockMushroom extends BlockSapling {
|
||||
if (maturity != 3) {
|
||||
maturity = 3;
|
||||
int matX = maturity << 2;
|
||||
int meta = (matX | type);
|
||||
int meta = (matX | type.ordinal());
|
||||
world.setBlockMetadataWithNotify(i, j, k, meta, Defaults.FLAG_BLOCK_SYNCH);
|
||||
} else if (lightvalue <= 7)
|
||||
func_149878_d(world, i, j, k, random);
|
||||
@@ -105,7 +114,22 @@ public class BlockMushroom extends BlockSapling {
|
||||
world.setBlock(i, j, k, this, type, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MushroomType getTypeFromMeta(int meta) {
|
||||
meta %= 3;
|
||||
if (meta >= MushroomType.values().length)
|
||||
return null;
|
||||
return MushroomType.values()[meta];
|
||||
}
|
||||
|
||||
/* ICONS */
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void getSubBlocks(Item item, CreativeTabs tab, List list) {
|
||||
list.add(new ItemStack(item, 1, 0));
|
||||
list.add(new ItemStack(item, 1, 1));
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister register) {
|
||||
@@ -114,11 +138,14 @@ public class BlockMushroom extends BlockSapling {
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public IIcon getIcon(int side, int meta) {
|
||||
int type = meta & 0x03;
|
||||
if (type > 0)
|
||||
MushroomType type = getTypeFromMeta(meta);
|
||||
|
||||
if (type == MushroomType.BROWN)
|
||||
return Blocks.brown_mushroom.getIcon(side, meta);
|
||||
else if (type == MushroomType.RED)
|
||||
return Blocks.red_mushroom.getIcon(side, meta);
|
||||
else
|
||||
return Blocks.brown_mushroom.getIcon(side, meta);
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -349,11 +349,6 @@ public abstract class TileFarm extends TileForestry implements IFarmComponent {
|
||||
public void removeListener(IFarmListener listener) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return "Farm";
|
||||
}
|
||||
|
||||
/* INTERACTION */
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer player) {
|
||||
|
||||
@@ -240,6 +240,11 @@ public class TileHatch extends TileFarm implements ISidedInventory {
|
||||
public void closeInventory() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return getUnlocalizedName();
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: just a specialsource workaround
|
||||
*/
|
||||
|
||||
@@ -148,7 +148,7 @@ public class GuiFarm extends GuiForestry<TileFarmPlain> {
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
|
||||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||
String title = StringUtil.localize("Farm");
|
||||
String title = StringUtil.localize("gui.farm.title");
|
||||
this.fontRendererObj.drawString(title, getCenteredOffset(title), 6, fontColor.get("gui.title"));
|
||||
}
|
||||
|
||||
|
||||
@@ -56,9 +56,9 @@ public class TriggerLowSoil extends Trigger {
|
||||
return false;
|
||||
|
||||
ItemStack filter;
|
||||
if (parameter == null || parameter.getItemStack() == null)
|
||||
filter = new ItemStack(Blocks.air, threshold, -1);
|
||||
else {
|
||||
if (parameter == null || parameter.getItemStack() == null) {
|
||||
filter = new ItemStack(Blocks.bedrock, threshold);
|
||||
} else {
|
||||
filter = parameter.getItemStack().copy();
|
||||
filter.stackSize = threshold;
|
||||
}
|
||||
|
||||
@@ -10,75 +10,19 @@
|
||||
******************************************************************************/
|
||||
package forestry.lepidopterology.gui;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import forestry.core.gui.ContainerAlyzer;
|
||||
import forestry.core.config.ForestryItem;
|
||||
import forestry.core.gui.ContainerItemInventory;
|
||||
import forestry.core.gui.slots.SlotCustom;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.lepidopterology.items.ItemButterflyGE;
|
||||
import forestry.lepidopterology.items.ItemFlutterlyzer.FlutterlyzerInventory;
|
||||
|
||||
public class ContainerFlutterlyzer extends ContainerItemInventory {
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
public class ContainerFlutterlyzer extends ContainerAlyzer {
|
||||
|
||||
FlutterlyzerInventory inventory;
|
||||
|
||||
public ContainerFlutterlyzer(InventoryPlayer inventoryplayer, FlutterlyzerInventory inventory) {
|
||||
super(inventory, inventoryplayer.player);
|
||||
|
||||
this.inventory = inventory;
|
||||
|
||||
// Energy
|
||||
this.addSlot(new SlotCustom(inventory, FlutterlyzerInventory.SLOT_ENERGY, 172, 8, new Object[] { ForestryItem.honeydew, ForestryItem.honeyDrop }));
|
||||
|
||||
// Bee to analyze
|
||||
this.addSlot(new SlotCustom(inventory, FlutterlyzerInventory.SLOT_SPECIMEN, 172, 26, new Object[] { ItemButterflyGE.class, Blocks.sapling }));
|
||||
|
||||
// Analyzed bee
|
||||
this.addSlot(new SlotCustom(inventory, FlutterlyzerInventory.SLOT_ANALYZE_1, 172, 57, new Object[] { ItemButterflyGE.class }));
|
||||
this.addSlot(new SlotCustom(inventory, FlutterlyzerInventory.SLOT_ANALYZE_2, 172, 75, new Object[] { ItemButterflyGE.class }));
|
||||
this.addSlot(new SlotCustom(inventory, FlutterlyzerInventory.SLOT_ANALYZE_3, 172, 93, new Object[] { ItemButterflyGE.class }));
|
||||
this.addSlot(new SlotCustom(inventory, FlutterlyzerInventory.SLOT_ANALYZE_4, 172, 111, new Object[] { ItemButterflyGE.class }));
|
||||
this.addSlot(new SlotCustom(inventory, FlutterlyzerInventory.SLOT_ANALYZE_5, 172, 129, new Object[] { ItemButterflyGE.class }));
|
||||
|
||||
// Player inventory
|
||||
for (int i1 = 0; i1 < 3; i1++)
|
||||
for (int l1 = 0; l1 < 9; l1++)
|
||||
addSecuredSlot(inventoryplayer, l1 + i1 * 9 + 9, 18 + l1 * 18, 156 + i1 * 18);
|
||||
// Player hotbar
|
||||
for (int j1 = 0; j1 < 9; j1++)
|
||||
addSecuredSlot(inventoryplayer, j1, 18 + j1 * 18, 214);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onContainerClosed(EntityPlayer entityplayer) {
|
||||
|
||||
if (!Proxies.common.isSimulating(entityplayer.worldObj))
|
||||
return;
|
||||
|
||||
// Last slot is the energy slot, so we don't save that one.
|
||||
for (int i = 0; i < inventory.getSizeInventory(); i++) {
|
||||
if (i == FlutterlyzerInventory.SLOT_ENERGY)
|
||||
continue;
|
||||
ItemStack stack = inventory.getStackInSlot(i);
|
||||
if (stack == null)
|
||||
continue;
|
||||
|
||||
Proxies.common.dropItemPlayer(entityplayer, stack);
|
||||
inventory.setInventorySlotContents(i, null);
|
||||
}
|
||||
|
||||
inventory.onGuiSaved(entityplayer);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isAcceptedItem(EntityPlayer player, ItemStack stack) {
|
||||
return true;
|
||||
super(inventoryplayer, inventory, new Object[] { ForestryItem.honeydew, ForestryItem.honeyDrop }, new Object[] { ItemButterflyGE.class });
|
||||
}
|
||||
|
||||
}
|
||||
@@ -45,8 +45,7 @@ public class GuiFlutterlyzer extends GuiAlyzer {
|
||||
super(AlleleManager.alleleRegistry.getSpeciesRoot("rootButterflies"), player,
|
||||
new ContainerFlutterlyzer(player.inventory, inventory), inventory, 1, inventory.getSizeInventory());
|
||||
|
||||
xSize = 196;
|
||||
ySize = 238;
|
||||
guiName = "gui.flutterlyzer";
|
||||
|
||||
ArrayList<ItemStack> butterflyList = new ArrayList<ItemStack>();
|
||||
((ItemButterflyGE) ForestryItem.butterflyGE.item()).addCreativeItems(butterflyList, false);
|
||||
@@ -97,35 +96,6 @@ public class GuiFlutterlyzer extends GuiAlyzer {
|
||||
|
||||
}
|
||||
|
||||
private void drawAnalyticsOverview() {
|
||||
|
||||
startPage();
|
||||
|
||||
newLine();
|
||||
String title = StringUtil.localize("gui.flutterlyzer").toUpperCase();
|
||||
drawCenteredLine(title, 8, 158);
|
||||
newLine();
|
||||
|
||||
fontRendererObj.drawSplitString(StringUtil.localize("gui.flutterlyzer.help"), (int) ((guiLeft + COLUMN_0 + 4) * (1 / factor)),
|
||||
(int) ((guiTop + 42) * (1 / factor)), (int) (158 * (1 / factor)), fontColor.get("gui.screen"));
|
||||
newLine();
|
||||
newLine();
|
||||
newLine();
|
||||
newLine();
|
||||
|
||||
drawLine(StringUtil.localize("gui.beealyzer.overview") + ":", COLUMN_0 + 4);
|
||||
newLine();
|
||||
drawLine("I : " + StringUtil.localize("gui.general"), COLUMN_0 + 4);
|
||||
newLine();
|
||||
drawLine("II : " + StringUtil.localize("gui.environment"), COLUMN_0 + 4);
|
||||
newLine();
|
||||
drawLine("III: " + StringUtil.localize("gui.produce"), COLUMN_0 + 4);
|
||||
newLine();
|
||||
drawLine("IV : " + StringUtil.localize("gui.evolution"), COLUMN_0 + 4);
|
||||
|
||||
endPage();
|
||||
}
|
||||
|
||||
private void drawAnalyticsPage1(IButterfly butterfly) {
|
||||
startPage(COLUMN_0, COLUMN_1, COLUMN_2);
|
||||
|
||||
|
||||
@@ -13,9 +13,9 @@ package forestry.lepidopterology.items;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.core.utils.AlyzerInventory;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.core.Tabs;
|
||||
import forestry.api.lepidopterology.IButterfly;
|
||||
@@ -27,21 +27,11 @@ import forestry.core.interfaces.IHintSource;
|
||||
import forestry.core.items.ItemInventoried;
|
||||
import forestry.core.network.GuiId;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.ItemInventory;
|
||||
import forestry.plugins.PluginLepidopterology;
|
||||
|
||||
public class ItemFlutterlyzer extends ItemInventoried {
|
||||
|
||||
public static class FlutterlyzerInventory extends ItemInventory implements IErrorSource, IHintSource {
|
||||
|
||||
public final static int SLOT_SPECIMEN = 0;
|
||||
public final static int SLOT_ANALYZE_1 = 1;
|
||||
public final static int SLOT_ANALYZE_2 = 2;
|
||||
public final static int SLOT_ANALYZE_3 = 3;
|
||||
public final static int SLOT_ANALYZE_4 = 4;
|
||||
public final static int SLOT_ANALYZE_5 = 6;
|
||||
public final static int SLOT_ENERGY = 5;
|
||||
EntityPlayer player;
|
||||
public static class FlutterlyzerInventory extends AlyzerInventory implements IErrorSource, IHintSource {
|
||||
|
||||
public FlutterlyzerInventory(EntityPlayer player) {
|
||||
super(ItemFlutterlyzer.class, 7);
|
||||
@@ -53,22 +43,6 @@ public class ItemFlutterlyzer extends ItemInventoried {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
|
||||
NBTTagList nbttaglist = new NBTTagList();
|
||||
for (int i = SLOT_ENERGY; i < SLOT_ENERGY + 1; i++) {
|
||||
if (inventoryStacks[i] != null) {
|
||||
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
|
||||
nbttagcompound1.setByte("Slot", (byte) i);
|
||||
inventoryStacks[i].writeToNBT(nbttagcompound1);
|
||||
nbttaglist.appendTag(nbttagcompound1);
|
||||
}
|
||||
}
|
||||
nbttagcompound.setTag("Items", nbttaglist);
|
||||
|
||||
}
|
||||
|
||||
private boolean isEnergy(ItemStack itemstack) {
|
||||
if (itemstack == null || itemstack.stackSize <= 0)
|
||||
return false;
|
||||
|
||||
@@ -12,7 +12,6 @@ package forestry.mail;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import forestry.api.mail.MailAddress;
|
||||
import net.minecraft.command.ICommand;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.command.WrongUsageException;
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* 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.mail;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public enum EnumAddressee {
|
||||
PLAYER, TRADER;
|
||||
|
||||
public static EnumAddressee fromString(String ident) {
|
||||
for(EnumAddressee addr : values()) {
|
||||
if(addr.toString().equals(ident))
|
||||
return addr;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String asString(EnumAddressee addressee) {
|
||||
return addressee.toString().toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import forestry.api.core.INBTTagable;
|
||||
import forestry.api.mail.ILetter;
|
||||
import forestry.api.mail.IStamps;
|
||||
import forestry.api.mail.MailAddress;
|
||||
import forestry.api.mail.IMailAddress;
|
||||
import forestry.core.utils.InventoryAdapter;
|
||||
import forestry.core.utils.StringUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -32,15 +32,15 @@ public class Letter implements ILetter, INBTTagable {
|
||||
|
||||
private boolean isProcessed = false;
|
||||
|
||||
private MailAddress sender;
|
||||
private MailAddress[] recipient;
|
||||
private IMailAddress sender;
|
||||
private IMailAddress[] recipient;
|
||||
|
||||
private String text;
|
||||
private InventoryAdapter inventory = new InventoryAdapter(22, "INV");
|
||||
|
||||
public Letter(MailAddress sender, MailAddress recipient) {
|
||||
public Letter(IMailAddress sender, IMailAddress recipient) {
|
||||
this.sender = sender;
|
||||
this.recipient = new MailAddress[] { recipient };
|
||||
this.recipient = new IMailAddress[] { recipient };
|
||||
}
|
||||
|
||||
public Letter(NBTTagCompound nbttagcompound) {
|
||||
@@ -191,7 +191,7 @@ public class Letter implements ILetter, INBTTagable {
|
||||
if (getRecipients().length <= 0)
|
||||
return false;
|
||||
|
||||
MailAddress recipient = getRecipients()[0];
|
||||
IMailAddress recipient = getRecipients()[0];
|
||||
if (recipient == null)
|
||||
return false;
|
||||
|
||||
@@ -202,36 +202,36 @@ public class Letter implements ILetter, INBTTagable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSender(MailAddress address) {
|
||||
public void setSender(IMailAddress address) {
|
||||
this.sender = address;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MailAddress getSender() {
|
||||
public IMailAddress getSender() {
|
||||
return sender;
|
||||
}
|
||||
|
||||
public void setRecipients(MailAddress[] recipients) {
|
||||
public void setRecipients(IMailAddress[] recipients) {
|
||||
this.recipient = recipients;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRecipient(MailAddress address) {
|
||||
public void setRecipient(IMailAddress address) {
|
||||
if (address == null)
|
||||
this.recipient = new MailAddress[] {};
|
||||
this.recipient = new IMailAddress[] {};
|
||||
else
|
||||
this.recipient = new MailAddress[] { address };
|
||||
this.recipient = new IMailAddress[] { address };
|
||||
}
|
||||
|
||||
@Override
|
||||
public MailAddress[] getRecipients() {
|
||||
public IMailAddress[] getRecipients() {
|
||||
return recipient;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipientString() {
|
||||
String recipientString = "";
|
||||
for (MailAddress address : recipient) {
|
||||
for (IMailAddress address : recipient) {
|
||||
if (recipientString.length() > 0)
|
||||
recipientString += ", ";
|
||||
recipientString += address.getName();
|
||||
|
||||
@@ -0,0 +1,163 @@
|
||||
/*******************************************************************************
|
||||
* 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.mail;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.UUID;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTUtil;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import forestry.api.core.INBTTagable;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.network.EntityNetData;
|
||||
import forestry.api.mail.EnumAddressee;
|
||||
import forestry.api.mail.IMailAddress;
|
||||
|
||||
public class MailAddress implements INBTTagable, IMailAddress {
|
||||
@EntityNetData
|
||||
private EnumAddressee type;
|
||||
@EntityNetData
|
||||
private GameProfile gameProfile; // gameProfile is a fake GameProfile for traders, and real for players
|
||||
|
||||
private static final MailAddress invalidAddress = new MailAddress();
|
||||
|
||||
public MailAddress() {
|
||||
this.type = EnumAddressee.INVALID;
|
||||
this.gameProfile = new GameProfile(new UUID(0,0), "");
|
||||
}
|
||||
|
||||
public MailAddress(GameProfile gameProfile) {
|
||||
if (gameProfile == null)
|
||||
throw new IllegalArgumentException("gameProfile must not be null");
|
||||
|
||||
this.type = EnumAddressee.PLAYER;
|
||||
this.gameProfile = gameProfile;
|
||||
}
|
||||
|
||||
public MailAddress(String name) {
|
||||
if (name == null)
|
||||
throw new IllegalArgumentException("name must not be null");
|
||||
|
||||
this.type = EnumAddressee.TRADER;
|
||||
this.gameProfile = new GameProfile(new UUID(0,0), name);
|
||||
}
|
||||
|
||||
public MailAddress(IMailAddress address) {
|
||||
this.type = address.getType();
|
||||
if (type == EnumAddressee.TRADER) {
|
||||
String name = address.getName();
|
||||
this.gameProfile = new GameProfile(new UUID(0, 0), name);
|
||||
} else if (type == EnumAddressee.PLAYER) {
|
||||
this.gameProfile = address.getPlayerProfile();
|
||||
}
|
||||
}
|
||||
|
||||
public EnumAddressee getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return gameProfile.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String name = getName().toLowerCase(Locale.ENGLISH);
|
||||
if (isPlayer()) {
|
||||
return type + "-" + name + "-" + gameProfile.getId();
|
||||
} else {
|
||||
return type + "-" + name;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (!(o instanceof MailAddress))
|
||||
return false;
|
||||
|
||||
MailAddress address = (MailAddress)o;
|
||||
return address.gameProfile.equals(gameProfile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return gameProfile.hashCode();
|
||||
}
|
||||
|
||||
public boolean isPlayer() {
|
||||
return type == EnumAddressee.PLAYER;
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
return type != EnumAddressee.INVALID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||
type = EnumAddressee.INVALID;
|
||||
if(nbttagcompound.hasKey("TP")) {
|
||||
String typeName = nbttagcompound.getString("TP");
|
||||
type = EnumAddressee.fromString(typeName);
|
||||
}
|
||||
|
||||
if (!isValid()) {
|
||||
gameProfile = invalidAddress.gameProfile;
|
||||
} else if(nbttagcompound.hasKey("profile")) {
|
||||
NBTTagCompound profileTag = nbttagcompound.getCompoundTag("profile");
|
||||
gameProfile = NBTUtil.func_152459_a(profileTag);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
nbttagcompound.setString("TP", type.toString());
|
||||
|
||||
if (gameProfile != null) {
|
||||
NBTTagCompound profileNbt = new NBTTagCompound();
|
||||
NBTUtil.func_152460_a(profileNbt, gameProfile);
|
||||
nbttagcompound.setTag("profile", profileNbt);
|
||||
}
|
||||
}
|
||||
|
||||
public static MailAddress loadFromNBT(NBTTagCompound nbttagcompound) {
|
||||
MailAddress address = new MailAddress();
|
||||
address.readFromNBT(nbttagcompound);
|
||||
return address;
|
||||
}
|
||||
|
||||
public EntityPlayer getPlayer(World world) {
|
||||
if (!this.isPlayer())
|
||||
return null;
|
||||
|
||||
return world.getPlayerEntityByName(this.gameProfile.getName());
|
||||
}
|
||||
|
||||
public boolean isClientPlayer(World world) {
|
||||
if (!this.isPlayer())
|
||||
return false;
|
||||
|
||||
EntityPlayer addressPlayer = this.getPlayer(world);
|
||||
EntityPlayer clientPlayer = Proxies.common.getPlayer();
|
||||
|
||||
return addressPlayer != null && clientPlayer != null && clientPlayer.equals(addressPlayer);
|
||||
}
|
||||
|
||||
public GameProfile getPlayerProfile() {
|
||||
if (!this.isPlayer())
|
||||
return null;
|
||||
return gameProfile;
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,6 @@
|
||||
******************************************************************************/
|
||||
package forestry.mail;
|
||||
|
||||
import forestry.api.mail.MailAddress;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -19,6 +18,7 @@ import net.minecraft.world.WorldSavedData;
|
||||
|
||||
import forestry.api.mail.ILetter;
|
||||
import forestry.api.mail.PostManager;
|
||||
import forestry.api.mail.IMailAddress;
|
||||
import forestry.core.utils.InventoryAdapter;
|
||||
|
||||
public class POBox extends WorldSavedData implements IInventory {
|
||||
@@ -26,10 +26,10 @@ public class POBox extends WorldSavedData implements IInventory {
|
||||
public static final String SAVE_NAME = "POBox_";
|
||||
public static final short SLOT_SIZE = 84;
|
||||
|
||||
private MailAddress address;
|
||||
private IMailAddress address;
|
||||
private final InventoryAdapter letters = new InventoryAdapter(SLOT_SIZE, "Letters");
|
||||
|
||||
public POBox(MailAddress address) {
|
||||
public POBox(IMailAddress address) {
|
||||
super(SAVE_NAME + address);
|
||||
if (!address.isPlayer()) {
|
||||
throw new IllegalArgumentException("POBox address must be a player");
|
||||
|
||||
@@ -12,7 +12,6 @@ package forestry.mail;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
|
||||
import forestry.api.mail.MailAddress;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
|
||||
@@ -24,7 +23,7 @@ import forestry.mail.gui.ContainerCatalogue;
|
||||
import forestry.mail.gui.ContainerLetter;
|
||||
import forestry.mail.gui.ContainerTradeName;
|
||||
import forestry.mail.network.PacketPOBoxInfo;
|
||||
import forestry.mail.network.PacketTradeInfo;
|
||||
import forestry.mail.network.PacketLetterInfo;
|
||||
import forestry.plugins.PluginMail;
|
||||
|
||||
public class PacketHandlerMail implements IPacketHandler {
|
||||
@@ -36,10 +35,10 @@ public class PacketHandlerMail implements IPacketHandler {
|
||||
|
||||
PacketUpdate packet;
|
||||
switch (packetID) {
|
||||
case PacketIds.TRADING_INFO:
|
||||
PacketTradeInfo packetT = new PacketTradeInfo();
|
||||
case PacketIds.LETTER_INFO:
|
||||
PacketLetterInfo packetT = new PacketLetterInfo();
|
||||
packetT.readData(data);
|
||||
onTradeInfo(packetT);
|
||||
onLetterInfo(packetT);
|
||||
break;
|
||||
case PacketIds.POBOX_INFO:
|
||||
PacketPOBoxInfo packetP = new PacketPOBoxInfo();
|
||||
@@ -70,11 +69,11 @@ public class PacketHandlerMail implements IPacketHandler {
|
||||
}
|
||||
}
|
||||
|
||||
private void onTradeInfo(PacketTradeInfo packet) {
|
||||
private void onLetterInfo(PacketLetterInfo packet) {
|
||||
|
||||
Container container = Proxies.common.getClientInstance().thePlayer.openContainer;
|
||||
if (container instanceof ContainerLetter) {
|
||||
((ContainerLetter) container).handleTradeInfoUpdate(packet);
|
||||
((ContainerLetter) container).handleLetterInfoUpdate(packet);
|
||||
} else if(container instanceof ContainerCatalogue) {
|
||||
((ContainerCatalogue) container).handleTradeInfoUpdate(packet);
|
||||
}
|
||||
|
||||
@@ -12,15 +12,12 @@ package forestry.mail;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldSavedData;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import forestry.api.mail.EnumPostage;
|
||||
import forestry.api.mail.ILetter;
|
||||
import forestry.api.mail.IPostOffice;
|
||||
@@ -28,8 +25,8 @@ import forestry.api.mail.IPostalCarrier;
|
||||
import forestry.api.mail.IPostalState;
|
||||
import forestry.api.mail.IStamps;
|
||||
import forestry.api.mail.ITradeStation;
|
||||
import forestry.api.mail.MailAddress;
|
||||
import forestry.api.mail.PostManager;
|
||||
import forestry.api.mail.IMailAddress;
|
||||
import forestry.core.config.ForestryItem;
|
||||
|
||||
public class PostOffice extends WorldSavedData implements IPostOffice {
|
||||
@@ -47,6 +44,10 @@ public class PostOffice extends WorldSavedData implements IPostOffice {
|
||||
super(s);
|
||||
}
|
||||
|
||||
public void setWorld(World world) {
|
||||
refreshActiveTradeStations(world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||
for (int i = 0; i < collectedPostage.length; i++) {
|
||||
@@ -63,18 +64,15 @@ public class PostOffice extends WorldSavedData implements IPostOffice {
|
||||
}
|
||||
|
||||
/* TRADE STATION MANAGMENT */
|
||||
private LinkedHashMap<MailAddress, ITradeStation> activeTradeStations;
|
||||
private LinkedHashMap<IMailAddress, ITradeStation> activeTradeStations;
|
||||
|
||||
@Override
|
||||
public LinkedHashMap<MailAddress, ITradeStation> getActiveTradeStations(World world) {
|
||||
if (activeTradeStations == null)
|
||||
refreshActiveTradeStations(world);
|
||||
|
||||
public LinkedHashMap<IMailAddress, ITradeStation> getActiveTradeStations(World world) {
|
||||
return this.activeTradeStations;
|
||||
}
|
||||
|
||||
private void refreshActiveTradeStations(World world) {
|
||||
activeTradeStations = new LinkedHashMap<MailAddress, ITradeStation>();
|
||||
activeTradeStations = new LinkedHashMap<IMailAddress, ITradeStation>();
|
||||
if (world == null || world.getSaveHandler() == null)
|
||||
return;
|
||||
File worldSave = world.getSaveHandler().getMapFileFromName("dummy");
|
||||
@@ -101,18 +99,12 @@ public class PostOffice extends WorldSavedData implements IPostOffice {
|
||||
|
||||
@Override
|
||||
public void registerTradeStation(ITradeStation trade) {
|
||||
if (activeTradeStations == null)
|
||||
return;
|
||||
|
||||
if (!activeTradeStations.containsKey(trade.getAddress()))
|
||||
activeTradeStations.put(trade.getAddress(), trade);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deregisterTradeStation(ITradeStation trade) {
|
||||
if (activeTradeStations == null)
|
||||
return;
|
||||
|
||||
activeTradeStations.remove(trade.getAddress());
|
||||
}
|
||||
|
||||
@@ -166,8 +158,8 @@ public class PostOffice extends WorldSavedData implements IPostOffice {
|
||||
return EnumDeliveryState.NOT_MAILABLE;
|
||||
|
||||
IPostalState state = EnumDeliveryState.NOT_MAILABLE;
|
||||
for (MailAddress address : letter.getRecipients()) {
|
||||
IPostalCarrier carrier = PostManager.postRegistry.getCarrier(address.getType());
|
||||
for (IMailAddress address : letter.getRecipients()) {
|
||||
IPostalCarrier carrier = PostManager.postRegistry.getCarrier(address.getType().toString());
|
||||
if (carrier == null)
|
||||
continue;
|
||||
state = carrier.deliverLetter(world, this, address, itemstack, doLodge);
|
||||
|
||||
@@ -25,8 +25,8 @@ import forestry.api.mail.IPostOffice;
|
||||
import forestry.api.mail.IPostRegistry;
|
||||
import forestry.api.mail.IPostalCarrier;
|
||||
import forestry.api.mail.ITradeStation;
|
||||
import forestry.api.mail.MailAddress;
|
||||
import forestry.api.mail.PostManager;
|
||||
import forestry.api.mail.IMailAddress;
|
||||
import forestry.core.config.ForestryItem;
|
||||
import forestry.mail.items.ItemLetter;
|
||||
import forestry.plugins.PluginMail;
|
||||
@@ -34,8 +34,8 @@ import forestry.plugins.PluginMail;
|
||||
public class PostRegistry implements IPostRegistry {
|
||||
|
||||
public static PostOffice cachedPostOffice;
|
||||
public static HashMap<MailAddress, POBox> cachedPOBoxes = new HashMap<MailAddress, POBox>();
|
||||
public static HashMap<MailAddress, ITradeStation> cachedTradeStations = new HashMap<MailAddress, ITradeStation>();
|
||||
public static HashMap<IMailAddress, POBox> cachedPOBoxes = new HashMap<IMailAddress, POBox>();
|
||||
public static HashMap<IMailAddress, ITradeStation> cachedTradeStations = new HashMap<IMailAddress, ITradeStation>();
|
||||
|
||||
/**
|
||||
* @param world the Minecraft world the PO box will be in
|
||||
@@ -43,11 +43,11 @@ public class PostRegistry implements IPostRegistry {
|
||||
* @return true if the passed address is valid for PO Boxes.
|
||||
*/
|
||||
@Override
|
||||
public boolean isValidPOBox(World world, MailAddress address) {
|
||||
public boolean isValidPOBox(World world, IMailAddress address) {
|
||||
return address.isPlayer() && address.getName().matches("^[a-zA-Z0-9]+$");
|
||||
}
|
||||
|
||||
public static POBox getPOBox(World world, MailAddress address) {
|
||||
public static POBox getPOBox(World world, IMailAddress address) {
|
||||
|
||||
if (cachedPOBoxes.containsKey(address))
|
||||
return cachedPOBoxes.get(address);
|
||||
@@ -58,7 +58,7 @@ public class PostRegistry implements IPostRegistry {
|
||||
return pobox;
|
||||
}
|
||||
|
||||
public static POBox getOrCreatePOBox(World world, MailAddress address) {
|
||||
public static POBox getOrCreatePOBox(World world, IMailAddress address) {
|
||||
POBox pobox = getPOBox(world, address);
|
||||
|
||||
if (pobox == null) {
|
||||
@@ -78,7 +78,7 @@ public class PostRegistry implements IPostRegistry {
|
||||
* @return true if the passed address can be an address for a trade station
|
||||
*/
|
||||
@Override
|
||||
public boolean isValidTradeAddress(World world, MailAddress address) {
|
||||
public boolean isValidTradeAddress(World world, IMailAddress address) {
|
||||
return !address.isPlayer() && address.getName().matches("^[a-zA-Z0-9]+$");
|
||||
}
|
||||
|
||||
@@ -88,12 +88,12 @@ public class PostRegistry implements IPostRegistry {
|
||||
* @return true if the trade address has not yet been used before.
|
||||
*/
|
||||
@Override
|
||||
public boolean isAvailableTradeAddress(World world, MailAddress address) {
|
||||
public boolean isAvailableTradeAddress(World world, IMailAddress address) {
|
||||
return getTradeStation(world, address) == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TradeStation getTradeStation(World world, MailAddress address) {
|
||||
public TradeStation getTradeStation(World world, IMailAddress address) {
|
||||
if (cachedTradeStations.containsKey(address))
|
||||
return (TradeStation)cachedTradeStations.get(address);
|
||||
|
||||
@@ -110,7 +110,7 @@ public class PostRegistry implements IPostRegistry {
|
||||
}
|
||||
|
||||
@Override
|
||||
public TradeStation getOrCreateTradeStation(World world, GameProfile owner, MailAddress address) {
|
||||
public TradeStation getOrCreateTradeStation(World world, GameProfile owner, IMailAddress address) {
|
||||
TradeStation trade = getTradeStation(world, address);
|
||||
|
||||
if (trade == null) {
|
||||
@@ -125,7 +125,7 @@ public class PostRegistry implements IPostRegistry {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteTradeStation(World world, MailAddress address) {
|
||||
public void deleteTradeStation(World world, IMailAddress address) {
|
||||
TradeStation trade = getTradeStation(world, address);
|
||||
if (trade == null)
|
||||
return;
|
||||
@@ -151,10 +151,22 @@ public class PostRegistry implements IPostRegistry {
|
||||
world.setItemData(PostOffice.SAVE_NAME, office);
|
||||
}
|
||||
|
||||
office.setWorld(world);
|
||||
|
||||
cachedPostOffice = office;
|
||||
return office;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMailAddress getMailAddress(GameProfile gameProfile) {
|
||||
return new MailAddress(gameProfile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMailAddress getMailAddress(String traderName) {
|
||||
return new MailAddress(traderName);
|
||||
}
|
||||
|
||||
/* CARRIER */
|
||||
private final HashMap<String, IPostalCarrier> carriers = new HashMap<String, IPostalCarrier>();
|
||||
|
||||
@@ -175,7 +187,7 @@ public class PostRegistry implements IPostRegistry {
|
||||
|
||||
/* LETTERS */
|
||||
@Override
|
||||
public ILetter createLetter(MailAddress sender, MailAddress recipient) {
|
||||
public ILetter createLetter(IMailAddress sender, IMailAddress recipient) {
|
||||
return new Letter(sender, recipient);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,8 +20,6 @@ import net.minecraft.world.World;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import forestry.core.render.TextureManager;
|
||||
import forestry.core.utils.StringUtil;
|
||||
import forestry.plugins.PluginMail;
|
||||
@@ -55,14 +53,14 @@ public class PostalCarrier implements IPostalCarrier {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPostalState deliverLetter(World world, IPostOffice office, MailAddress recipient, ItemStack letterstack, boolean doDeliver) {
|
||||
public IPostalState deliverLetter(World world, IPostOffice office, IMailAddress recipient, ItemStack letterstack, boolean doDeliver) {
|
||||
if(type == EnumAddressee.TRADER)
|
||||
return handleTradeLetter(world, office, recipient, letterstack, doDeliver);
|
||||
else
|
||||
return storeInPOBox(world, office, recipient, letterstack, doDeliver);
|
||||
}
|
||||
|
||||
private IPostalState handleTradeLetter(World world, IPostOffice office, MailAddress recipient, ItemStack letterstack, boolean doLodge) {
|
||||
private IPostalState handleTradeLetter(World world, IPostOffice office, IMailAddress recipient, ItemStack letterstack, boolean doLodge) {
|
||||
IPostalState state = EnumDeliveryState.NOT_MAILABLE;
|
||||
|
||||
ITradeStation trade = PostManager.postRegistry.getTradeStation(world, recipient);
|
||||
@@ -74,7 +72,7 @@ public class PostalCarrier implements IPostalCarrier {
|
||||
return state;
|
||||
}
|
||||
|
||||
private EnumDeliveryState storeInPOBox(World world, IPostOffice office, MailAddress recipient, ItemStack letterstack, boolean doLodge) {
|
||||
private EnumDeliveryState storeInPOBox(World world, IPostOffice office, IMailAddress recipient, ItemStack letterstack, boolean doLodge) {
|
||||
|
||||
POBox pobox = PostRegistry.getPOBox(world, recipient);
|
||||
if (pobox == null)
|
||||
|
||||
@@ -28,9 +28,9 @@ import forestry.api.mail.ILetter;
|
||||
import forestry.api.mail.IPostalState;
|
||||
import forestry.api.mail.IStamps;
|
||||
import forestry.api.mail.ITradeStation;
|
||||
import forestry.api.mail.MailAddress;
|
||||
import forestry.api.mail.PostManager;
|
||||
import forestry.api.mail.TradeStationInfo;
|
||||
import forestry.api.mail.IMailAddress;
|
||||
import forestry.core.config.ForestryItem;
|
||||
import forestry.core.utils.InventoryAdapter;
|
||||
import forestry.core.utils.StackUtils;
|
||||
@@ -40,26 +40,29 @@ public class TradeStation extends WorldSavedData implements ITradeStation, IInve
|
||||
|
||||
// / CONSTANTS
|
||||
public static final String SAVE_NAME = "TradePO_";
|
||||
public static final short SLOT_SIZE = 39;
|
||||
public static final short SLOT_TRADEGOOD = 0;
|
||||
public static final short SLOT_TRADEGOOD_COUNT = 1;
|
||||
public static final short SLOT_EXCHANGE_1 = 1;
|
||||
public static final short SLOT_EXCHANGE_COUNT = 4;
|
||||
public static final short SLOT_LETTERS_1 = 5;
|
||||
public static final short SLOT_LETTERS_COUNT = 6;
|
||||
public static final short SLOT_STAMPS_1 = 11;
|
||||
public static final short SLOT_STAMPS_COUNT = 4;
|
||||
public static final short SLOT_INPUTBUF_1 = 15;
|
||||
public static final short SLOT_OUTPUTBUF_1 = 27;
|
||||
public static final short SLOT_BUFFER_COUNT = 12;
|
||||
public static final short SLOT_RECEIVE_BUFFER = 15;
|
||||
public static final short SLOT_RECEIVE_BUFFER_COUNT = 15;
|
||||
public static final short SLOT_SEND_BUFFER = 30;
|
||||
public static final short SLOT_SEND_BUFFER_COUNT = 10;
|
||||
public static final short SLOT_SIZE = SLOT_TRADEGOOD_COUNT + SLOT_EXCHANGE_COUNT + SLOT_LETTERS_COUNT + SLOT_STAMPS_COUNT + SLOT_RECEIVE_BUFFER_COUNT + SLOT_SEND_BUFFER_COUNT;
|
||||
|
||||
// / MEMBER
|
||||
private GameProfile owner;
|
||||
private MailAddress address;
|
||||
private IMailAddress address;
|
||||
private boolean isVirtual = false;
|
||||
private boolean isInvalid = false;
|
||||
private final InventoryAdapter inventory = new InventoryAdapter(SLOT_SIZE, "INV");
|
||||
|
||||
// / CONSTRUCTORS
|
||||
public TradeStation(GameProfile owner, MailAddress address) {
|
||||
public TradeStation(GameProfile owner, IMailAddress address) {
|
||||
super(SAVE_NAME + address);
|
||||
if (address.isPlayer()) {
|
||||
throw new IllegalArgumentException("TradeStation address must not be a player");
|
||||
@@ -73,7 +76,7 @@ public class TradeStation extends WorldSavedData implements ITradeStation, IInve
|
||||
}
|
||||
|
||||
@Override
|
||||
public MailAddress getAddress() {
|
||||
public IMailAddress getAddress() {
|
||||
return this.address;
|
||||
}
|
||||
|
||||
@@ -160,7 +163,7 @@ public class TradeStation extends WorldSavedData implements ITradeStation, IInve
|
||||
|
||||
/* ILETTERHANDLER */
|
||||
@Override
|
||||
public IPostalState handleLetter(World world, MailAddress recipient, ItemStack letterstack, boolean doLodge) {
|
||||
public IPostalState handleLetter(World world, IMailAddress recipient, ItemStack letterstack, boolean doLodge) {
|
||||
|
||||
boolean sendOwnerNotice = doLodge && owner != null;
|
||||
|
||||
@@ -235,7 +238,7 @@ public class TradeStation extends WorldSavedData implements ITradeStation, IInve
|
||||
if (stack == null)
|
||||
continue;
|
||||
|
||||
inventory.tryAddStack(stack.copy(), SLOT_OUTPUTBUF_1, SLOT_BUFFER_COUNT, false);
|
||||
inventory.tryAddStack(stack.copy(), SLOT_RECEIVE_BUFFER, SLOT_RECEIVE_BUFFER_COUNT, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -275,7 +278,7 @@ public class TradeStation extends WorldSavedData implements ITradeStation, IInve
|
||||
|
||||
// How many orders are fillable?
|
||||
int itemCount = 0;
|
||||
for (ItemStack stack : inventory.getStacks(SLOT_INPUTBUF_1, SLOT_BUFFER_COUNT)) {
|
||||
for (ItemStack stack : inventory.getStacks(SLOT_SEND_BUFFER, SLOT_SEND_BUFFER_COUNT)) {
|
||||
if (stack != null && stack.isItemEqual(tradegood) && ItemStack.areItemStackTagsEqual(stack, tradegood))
|
||||
itemCount += stack.stackSize;
|
||||
}
|
||||
@@ -283,13 +286,20 @@ public class TradeStation extends WorldSavedData implements ITradeStation, IInve
|
||||
return (int) Math.floor(itemCount / tradegood.stackSize);
|
||||
}
|
||||
|
||||
public boolean canReceivePayment() {
|
||||
InventoryAdapter test = inventory.copy();
|
||||
ItemStack [] payment = inventory.getStacks(SLOT_EXCHANGE_1, SLOT_EXCHANGE_COUNT);
|
||||
|
||||
return test.tryAddStacksCopy(payment, SLOT_RECEIVE_BUFFER, SLOT_RECEIVE_BUFFER_COUNT, true);
|
||||
}
|
||||
|
||||
private int countStorablePayment(int max, ItemStack[] exchange) {
|
||||
|
||||
InventoryAdapter test = inventory.copy();
|
||||
int count = 0;
|
||||
|
||||
for (int i = 0; i < max; i++) {
|
||||
if (test.tryAddStacksCopy(exchange, true))
|
||||
if (test.tryAddStacksCopy(exchange, SLOT_RECEIVE_BUFFER, SLOT_RECEIVE_BUFFER_COUNT, true))
|
||||
count++;
|
||||
else
|
||||
break;
|
||||
@@ -302,7 +312,7 @@ public class TradeStation extends WorldSavedData implements ITradeStation, IInve
|
||||
|
||||
for (int j = 0; j < filled; j++) {
|
||||
int toRemove = inventory.getStackInSlot(SLOT_TRADEGOOD).stackSize;
|
||||
for (int i = SLOT_INPUTBUF_1; i < SLOT_INPUTBUF_1 + SLOT_BUFFER_COUNT; i++) {
|
||||
for (int i = SLOT_SEND_BUFFER; i < SLOT_SEND_BUFFER + SLOT_SEND_BUFFER_COUNT; i++) {
|
||||
ItemStack buffer = inventory.getStackInSlot(i);
|
||||
if (buffer == null)
|
||||
continue;
|
||||
|
||||
Loaded 100 of 128 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user