Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5eaa087b2d | ||
|
|
277f97d86b | ||
|
|
376d83abc1 | ||
|
|
990e8158df | ||
|
|
73d95a043b | ||
|
|
ebfdf989cd | ||
|
|
414d7da5c0 | ||
|
|
01d40092f3 | ||
|
|
2c057d4854 | ||
|
|
96b8f60f87 | ||
|
|
a2a1f8eca9 | ||
|
|
f2e85073d3 | ||
|
|
0bd9a7978a | ||
|
|
e47fc90433 | ||
|
|
452064ef1d | ||
|
|
59c8c36520 | ||
|
|
ea1c4edae4 | ||
|
|
4c46626cdb | ||
|
|
d6fa8d8b74 | ||
|
|
704861b666 | ||
|
|
db25dcce48 | ||
|
|
4b364a93db | ||
|
|
a217884480 | ||
|
|
90f7c36a1e | ||
|
|
974e44f5cd | ||
|
|
bbb374cd5e | ||
|
|
3470c6c7d1 | ||
|
|
b1377d5642 | ||
|
|
b50910496e | ||
|
|
cc4b16e2a5 | ||
|
|
3b63133790 | ||
|
|
6d8d7110e1 | ||
|
|
98fa57844e | ||
|
|
adbb300523 | ||
|
|
839882b783 | ||
|
|
2635d036aa | ||
|
|
cf8f2f54c5 | ||
|
|
4844bc937b | ||
|
|
88f50d91e1 | ||
|
|
3bc6720dec | ||
|
|
1083f52a30 |
No files matched your search
@@ -0,0 +1,17 @@
|
|||||||
|
name: Optimize images
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
branches: [ master, main, release/** ]
|
||||||
|
paths:
|
||||||
|
- "**/*.png"
|
||||||
|
|
||||||
|
push:
|
||||||
|
branches: [ master, main, release/** ]
|
||||||
|
paths:
|
||||||
|
- "**/*.png"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
optimize-images:
|
||||||
|
uses: GTNewHorizons/GTNH-Actions-Workflows/.github/workflows/optimize-images.yml@master
|
||||||
|
secrets: inherit
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
How to submit a bug report to Forestry
|
|
||||||
====================================
|
|
||||||
Please make sure the bug has not already been reported by [searching the issues](https://github.com/ForestryMC/ForestryMC/issues?q=is%3Aissue).
|
|
||||||
|
|
||||||
If you can, see if the bug still happens with the latest unstable build.
|
|
||||||
[The latest unstable builds are available here](http://jenkins.ic2.player.to/job/Forestry_Dev/)
|
|
||||||
|
|
||||||
For crashes, you must post a link to the full crash report.
|
|
||||||
[gist.github.com](gist.github.com) or [pastebin.com](www.pastebin.com) are good places to upload them.
|
|
||||||
Full crash reports are located in [the minecraft data folder](http://hopper.minecraft.net/help/finding-minecraft-data-folder/), in "crash-reports".
|
|
||||||
|
|
||||||
Thank you for reporting bugs!
|
|
||||||
|
|
||||||
How to contribute to Forestry
|
|
||||||
====================================
|
|
||||||
|
|
||||||
### Contributor License Agreement
|
|
||||||
|
|
||||||
Before pull requests can be accepted, the contributor needs to sign a contributor license agreement. (Essentially giving a license for using his code and/or media and for re-licensing it, for details read the agreement linked below.)
|
|
||||||
|
|
||||||
### How do I sign?
|
|
||||||
|
|
||||||
To keep the hassle for everyone involved to a minimum, Forestry uses CLAHub to manage the agreements. To get started, <a href="https://www.clahub.com/agreements/ForestryMC/ForestryMC">sign the Contributor License Agreement</a>.
|
|
||||||
|
|
||||||
### Why is this needed?
|
|
||||||
|
|
||||||
Without CLAs it at some point becomes essentially impossible to change the license of a project which accepts contributions from third parties. Without an explicit agreement every contributor would still own the copyright to his code. So as long as it (or parts of it) remain in the code base, he would have to agree to every license change. If enough time has passed, there may be dozens, perhaps even hundreds of contributors involved and it will be very hard to track down each and every one of them and get them to agree on a new license.
|
|
||||||
|
|
||||||
This would make it impossible to change the license to a more permissive one at a later date, so the code would be locked into CC BY-NC-ND 3.0 until it passes into the public domain about a hundred years from now. This situation is to be avoided and that’s why you are being bothered with this CLA.
|
|
||||||
@@ -1,11 +1,14 @@
|
|||||||
// Add your dependencies here
|
// Add your dependencies here
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
api("com.github.GTNewHorizons:GTNHLib:0.9.54:dev")
|
||||||
api('curse.maven:cofh-lib-220333:2388748')
|
api('curse.maven:cofh-lib-220333:2388748')
|
||||||
compileOnlyApi('com.github.GTNewHorizons:Angelica:1.0.0-beta68a:api')
|
compileOnlyApi('com.github.GTNewHorizons:Angelica:2.1.19:api')
|
||||||
devOnlyNonPublishable('com.github.GTNewHorizons:NotEnoughItems:2.8.70-GTNH:dev')
|
devOnlyNonPublishable('com.github.GTNewHorizons:NotEnoughItems:2.8.107-GTNH:dev')
|
||||||
compileOnly('com.github.GTNewHorizons:inventory-tweaks:1.7.1:api')
|
compileOnly('com.github.GTNewHorizons:inventory-tweaks:1.7.1:api')
|
||||||
compileOnly('com.github.GTNewHorizons:BuildCraft:7.1.55:api')
|
compileOnly('com.github.GTNewHorizons:BuildCraft:7.1.57:api')
|
||||||
compileOnly('net.industrial-craft:industrialcraft-2:2.2.828-experimental:dev')
|
compileOnly('net.industrial-craft:industrialcraft-2:2.2.828-experimental:dev')
|
||||||
compileOnly('curse.maven:craftguide-75557:2459320')
|
compileOnly('curse.maven:craftguide-75557:2459320')
|
||||||
|
compileOnly('com.github.GTNewHorizons:Postea:1.4.0-mu:dev')
|
||||||
|
devOnlyNonPublishable('net.xonich.mc:NoHotbarNeeded:0.0.3:dev')
|
||||||
}
|
}
|
||||||
@@ -1,12 +1,12 @@
|
|||||||
#This file is generated by updateDaemonJvm
|
#This file is generated by updateDaemonJvm
|
||||||
toolchainUrl.FREE_BSD.AARCH64=https\://api.foojay.io/disco/v3.0/ids/df211d3c3eefdc408b462041881bc575/redirect
|
toolchainUrl.FREE_BSD.AARCH64=https\://api.foojay.io/disco/v3.0/ids/1630f7ebef05444cb27a2709ea0249b3/redirect
|
||||||
toolchainUrl.FREE_BSD.X86_64=https\://api.foojay.io/disco/v3.0/ids/93aeea858331bd6bb00ba94759830234/redirect
|
toolchainUrl.FREE_BSD.X86_64=https\://api.foojay.io/disco/v3.0/ids/fa1e318c287360478e3c83a9a3ef1007/redirect
|
||||||
toolchainUrl.LINUX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/df211d3c3eefdc408b462041881bc575/redirect
|
toolchainUrl.LINUX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/1630f7ebef05444cb27a2709ea0249b3/redirect
|
||||||
toolchainUrl.LINUX.X86_64=https\://api.foojay.io/disco/v3.0/ids/93aeea858331bd6bb00ba94759830234/redirect
|
toolchainUrl.LINUX.X86_64=https\://api.foojay.io/disco/v3.0/ids/fa1e318c287360478e3c83a9a3ef1007/redirect
|
||||||
toolchainUrl.MAC_OS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/3426ffcaa54c3f62406beb1f1ab8b179/redirect
|
toolchainUrl.MAC_OS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/c2dd35c9d0aaf0ba6ad0791320f99dfc/redirect
|
||||||
toolchainUrl.MAC_OS.X86_64=https\://api.foojay.io/disco/v3.0/ids/f636c800fdb3f9ae33f019dfa048ba72/redirect
|
toolchainUrl.MAC_OS.X86_64=https\://api.foojay.io/disco/v3.0/ids/e5810bd7fd1f8a586644409d395a7e55/redirect
|
||||||
toolchainUrl.UNIX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/df211d3c3eefdc408b462041881bc575/redirect
|
toolchainUrl.UNIX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/1630f7ebef05444cb27a2709ea0249b3/redirect
|
||||||
toolchainUrl.UNIX.X86_64=https\://api.foojay.io/disco/v3.0/ids/93aeea858331bd6bb00ba94759830234/redirect
|
toolchainUrl.UNIX.X86_64=https\://api.foojay.io/disco/v3.0/ids/fa1e318c287360478e3c83a9a3ef1007/redirect
|
||||||
toolchainUrl.WINDOWS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/3cd7045fca9a72cd9bc7d14a385e594c/redirect
|
toolchainUrl.WINDOWS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/7b3c4877c0749019e6805bb61e421497/redirect
|
||||||
toolchainUrl.WINDOWS.X86_64=https\://api.foojay.io/disco/v3.0/ids/0ef34dd9312b12d61ba1b8e66126d140/redirect
|
toolchainUrl.WINDOWS.X86_64=https\://api.foojay.io/disco/v3.0/ids/8e1d9ee5d0f13e442218f6884a306da1/redirect
|
||||||
toolchainVersion=25
|
toolchainVersion=25
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.3.1-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.0-bin.zip
|
||||||
networkTimeout=10000
|
networkTimeout=10000
|
||||||
validateDistributionUrl=true
|
validateDistributionUrl=true
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
|||||||
@@ -57,7 +57,7 @@
|
|||||||
# Darwin, MinGW, and NonStop.
|
# Darwin, MinGW, and NonStop.
|
||||||
#
|
#
|
||||||
# (3) This script is generated from the Groovy template
|
# (3) This script is generated from the Groovy template
|
||||||
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
# https://github.com/gradle/gradle/blob/b631911858264c0b6e4d6603d677ff5218766cee/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||||
# within the Gradle project.
|
# within the Gradle project.
|
||||||
#
|
#
|
||||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
// Add any additional repositiroes for your dependencies here
|
// Add any additional repositiroes for your dependencies here
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
|
mavenLocal()
|
||||||
}
|
}
|
||||||
@@ -17,7 +17,7 @@ pluginManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id 'com.gtnewhorizons.gtnhsettingsconvention' version '2.0.20'
|
id 'com.gtnewhorizons.gtnhsettingsconvention' version '2.0.24'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -57,12 +57,14 @@ import forestry.plugins.PluginManager;
|
|||||||
name = Constants.MOD,
|
name = Constants.MOD,
|
||||||
version = Constants.VERSION,
|
version = Constants.VERSION,
|
||||||
guiFactory = "forestry.core.config.ForestryGuiConfigFactory",
|
guiFactory = "forestry.core.config.ForestryGuiConfigFactory",
|
||||||
dependencies = "required-after:Forge@[10.13.4.1566,);" + "after:Buildcraft|Core@[6.1.7,);"
|
dependencies = "required-after:Forge@[10.13.4.1566,);" + "required-after:gtnhlib@[0.9.41,);"
|
||||||
|
+ "after:Buildcraft|Core@[6.1.7,);"
|
||||||
+ "after:ExtrabiomesXL;"
|
+ "after:ExtrabiomesXL;"
|
||||||
+ "after:BiomesOPlenty;"
|
+ "after:BiomesOPlenty;"
|
||||||
+ "after:IC2@[2.0.140,);"
|
+ "after:IC2@[2.0.140,);"
|
||||||
+ "after:Natura@[2.2.0,);"
|
+ "after:Natura@[2.2.0,);"
|
||||||
+ "after:HardcoreEnderExpansion;")
|
+ "after:HardcoreEnderExpansion;"
|
||||||
|
+ "after:postea@[1.4.0,);")
|
||||||
public class Forestry {
|
public class Forestry {
|
||||||
|
|
||||||
@Mod.Instance(Constants.MOD)
|
@Mod.Instance(Constants.MOD)
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package forestry.api.apiculture;
|
||||||
|
|
||||||
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
|
public interface IArmorApiaristMulti extends IArmorApiarist {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called to determine how many pieces an armor "counts for". For instance, if this returns 4, the single piece will
|
||||||
|
* act as full protection.
|
||||||
|
*
|
||||||
|
* @param entity Entity being attacked
|
||||||
|
* @param armor Armor item
|
||||||
|
* @param cause Optional cause of attack, such as a bee effect identifier
|
||||||
|
* @return Amount of effective protected slots
|
||||||
|
*/
|
||||||
|
default int getProtectionCount(EntityLivingBase entity, ItemStack armor, String cause) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
package forestry.api.multiblock;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
|
public interface IFarmFertilizerRegistry {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a list of all fertilizer stacks in the registry.
|
||||||
|
*
|
||||||
|
* @return The current fertilizer registry.
|
||||||
|
*/
|
||||||
|
Collection<ItemStack> getFertilizers();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a new fertilizer to the registry.
|
||||||
|
*
|
||||||
|
* @apiNote The stack size doesn't matter it always consumes 1.
|
||||||
|
* @apiNote You can use OreDictionary.WILDCARD_VALUE to specific that any meta of the item will be ok.
|
||||||
|
*
|
||||||
|
* @param itemstack The item to add to the registry.
|
||||||
|
*/
|
||||||
|
void addFertilizer(ItemStack itemstack);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes a fertilizer from the fretilizer registry.
|
||||||
|
*
|
||||||
|
* @param itemstack The item to remove from the registry.
|
||||||
|
*/
|
||||||
|
void removeFertilizer(ItemStack itemstack);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if an item is a usable multi-farm fertilizer.
|
||||||
|
*
|
||||||
|
* @param itemstack - The stack to check with.
|
||||||
|
* @return True if the item is a fertilizer item.
|
||||||
|
*/
|
||||||
|
boolean isFertilizer(ItemStack itemstack);
|
||||||
|
}
|
||||||
@@ -8,4 +8,6 @@ package forestry.api.multiblock;
|
|||||||
public class MultiblockManager {
|
public class MultiblockManager {
|
||||||
|
|
||||||
public static IMultiblockLogicFactory logicFactory;
|
public static IMultiblockLogicFactory logicFactory;
|
||||||
|
|
||||||
|
public static IFarmFertilizerRegistry farmFertilizerRegistry;
|
||||||
}
|
}
|
||||||
@@ -15,26 +15,20 @@ import net.minecraft.item.ItemStack;
|
|||||||
|
|
||||||
import forestry.api.apiculture.IArmorApiarist;
|
import forestry.api.apiculture.IArmorApiarist;
|
||||||
import forestry.api.apiculture.IArmorApiaristHelper;
|
import forestry.api.apiculture.IArmorApiaristHelper;
|
||||||
|
import forestry.api.apiculture.IArmorApiaristMulti;
|
||||||
|
|
||||||
public class ArmorApiaristHelper implements IArmorApiaristHelper {
|
public class ArmorApiaristHelper implements IArmorApiaristHelper {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isArmorApiarist(ItemStack stack, EntityLivingBase entity, String cause, boolean doProtect) {
|
public boolean isArmorApiarist(ItemStack stack, EntityLivingBase entity, String cause, boolean doProtect) {
|
||||||
if (stack == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Item item = stack.getItem();
|
if (stack == null || !(stack.getItem() instanceof IArmorApiarist armor)) return false;
|
||||||
if (!(item instanceof IArmorApiarist)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
IArmorApiarist armorApiarist = (IArmorApiarist) item;
|
|
||||||
try {
|
try {
|
||||||
return armorApiarist.protectEntity(entity, stack, cause, doProtect);
|
return armor.protectEntity(entity, stack, cause, doProtect);
|
||||||
} catch (Throwable ignored) { // protectEntity is new to the API and may not be implemented by the armor
|
} catch (Throwable ignored) { // protectEntity is new to the API and may not be implemented by the armor
|
||||||
if (entity instanceof EntityPlayer) {
|
if (entity instanceof EntityPlayer) {
|
||||||
return armorApiarist.protectPlayer((EntityPlayer) entity, stack, cause, doProtect);
|
return armor.protectPlayer((EntityPlayer) entity, stack, cause, doProtect);
|
||||||
} else {
|
} else {
|
||||||
return true; // fallback on assuming IArmorApiarist will protect the entity
|
return true; // fallback on assuming IArmorApiarist will protect the entity
|
||||||
}
|
}
|
||||||
@@ -48,11 +42,13 @@ public class ArmorApiaristHelper implements IArmorApiaristHelper {
|
|||||||
for (int i = 1; i <= 4; i++) {
|
for (int i = 1; i <= 4; i++) {
|
||||||
ItemStack armorItem = entity.getEquipmentInSlot(i);
|
ItemStack armorItem = entity.getEquipmentInSlot(i);
|
||||||
if (isArmorApiarist(armorItem, entity, cause, doProtect)) {
|
if (isArmorApiarist(armorItem, entity, cause, doProtect)) {
|
||||||
count++;
|
Item item = armorItem.getItem();
|
||||||
|
if (item instanceof IArmorApiaristMulti am) count += am.getProtectionCount(entity, armorItem, cause);
|
||||||
|
else count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return count;
|
return Math.min(count, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -573,7 +573,7 @@ public class Bee extends IndividualLiving implements IBee {
|
|||||||
}
|
}
|
||||||
// / Secondary Products
|
// / Secondary Products
|
||||||
for (Map.Entry<ItemStack, Float> entry : secondary.getProductChances().entrySet()) {
|
for (Map.Entry<ItemStack, Float> entry : secondary.getProductChances().entrySet()) {
|
||||||
if (housing.getWorld().rand.nextFloat() < getFinalChance(entry.getValue() / 2, speed, prodModifier, 1f)) {
|
if (housing.getWorld().rand.nextFloat() < getFinalChance(entry.getValue() / 2f, speed, prodModifier, 1f)) {
|
||||||
products.add(entry.getKey().copy());
|
products.add(entry.getKey().copy());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import forestry.api.core.Tabs;
|
|||||||
import forestry.apiculture.gui.GuiBeealyzer;
|
import forestry.apiculture.gui.GuiBeealyzer;
|
||||||
import forestry.apiculture.inventory.ItemInventoryBeealyzer;
|
import forestry.apiculture.inventory.ItemInventoryBeealyzer;
|
||||||
import forestry.core.gui.ContainerAlyzer;
|
import forestry.core.gui.ContainerAlyzer;
|
||||||
|
import forestry.core.inventory.ItemLocation;
|
||||||
import forestry.core.items.ItemWithGui;
|
import forestry.core.items.ItemWithGui;
|
||||||
|
|
||||||
public class ItemBeealyzer extends ItemWithGui {
|
public class ItemBeealyzer extends ItemWithGui {
|
||||||
@@ -24,13 +25,13 @@ public class ItemBeealyzer extends ItemWithGui {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getGui(EntityPlayer player, ItemStack heldItem, int data) {
|
public Object getGui(EntityPlayer player, ItemStack heldItem, int data, ItemLocation loc) {
|
||||||
ItemInventoryBeealyzer inventory = new ItemInventoryBeealyzer(player, heldItem);
|
ItemInventoryBeealyzer inventory = new ItemInventoryBeealyzer(player, heldItem);
|
||||||
return new GuiBeealyzer(player, inventory);
|
return new GuiBeealyzer(player, inventory);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getContainer(EntityPlayer player, ItemStack heldItem, int data) {
|
public Object getContainer(EntityPlayer player, ItemStack heldItem, int data, ItemLocation loc) {
|
||||||
ItemInventoryBeealyzer inventory = new ItemInventoryBeealyzer(player, heldItem);
|
ItemInventoryBeealyzer inventory = new ItemInventoryBeealyzer(player, heldItem);
|
||||||
return new ContainerAlyzer(inventory, player);
|
return new ContainerAlyzer(inventory, player);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import forestry.apiculture.gui.ContainerHabitatLocator;
|
|||||||
import forestry.apiculture.gui.GuiHabitatLocator;
|
import forestry.apiculture.gui.GuiHabitatLocator;
|
||||||
import forestry.apiculture.inventory.ItemInventoryHabitatLocator;
|
import forestry.apiculture.inventory.ItemInventoryHabitatLocator;
|
||||||
import forestry.apiculture.render.TextureHabitatLocator;
|
import forestry.apiculture.render.TextureHabitatLocator;
|
||||||
|
import forestry.core.inventory.ItemLocation;
|
||||||
import forestry.core.items.ItemWithGui;
|
import forestry.core.items.ItemWithGui;
|
||||||
import forestry.core.utils.StringUtil;
|
import forestry.core.utils.StringUtil;
|
||||||
|
|
||||||
@@ -81,12 +82,12 @@ public class ItemHabitatLocator extends ItemWithGui {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getGui(EntityPlayer player, ItemStack heldItem, int data) {
|
public Object getGui(EntityPlayer player, ItemStack heldItem, int data, ItemLocation loc) {
|
||||||
return new GuiHabitatLocator(player, new ItemInventoryHabitatLocator(player, heldItem));
|
return new GuiHabitatLocator(player, new ItemInventoryHabitatLocator(player, heldItem));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getContainer(EntityPlayer player, ItemStack heldItem, int data) {
|
public Object getContainer(EntityPlayer player, ItemStack heldItem, int data, ItemLocation loc) {
|
||||||
return new ContainerHabitatLocator(player, new ItemInventoryHabitatLocator(player, heldItem));
|
return new ContainerHabitatLocator(player, new ItemInventoryHabitatLocator(player, heldItem));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -15,6 +15,7 @@ import forestry.api.core.Tabs;
|
|||||||
import forestry.apiculture.gui.ContainerImprinter;
|
import forestry.apiculture.gui.ContainerImprinter;
|
||||||
import forestry.apiculture.gui.GuiImprinter;
|
import forestry.apiculture.gui.GuiImprinter;
|
||||||
import forestry.apiculture.inventory.ItemInventoryImprinter;
|
import forestry.apiculture.inventory.ItemInventoryImprinter;
|
||||||
|
import forestry.core.inventory.ItemLocation;
|
||||||
import forestry.core.items.ItemWithGui;
|
import forestry.core.items.ItemWithGui;
|
||||||
|
|
||||||
public class ItemImprinter extends ItemWithGui {
|
public class ItemImprinter extends ItemWithGui {
|
||||||
@@ -24,12 +25,12 @@ public class ItemImprinter extends ItemWithGui {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getGui(EntityPlayer player, ItemStack heldItem, int data) {
|
public Object getGui(EntityPlayer player, ItemStack heldItem, int data, ItemLocation loc) {
|
||||||
return new GuiImprinter(player.inventory, new ItemInventoryImprinter(player, heldItem));
|
return new GuiImprinter(player.inventory, new ItemInventoryImprinter(player, heldItem));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getContainer(EntityPlayer player, ItemStack heldItem, int data) {
|
public Object getContainer(EntityPlayer player, ItemStack heldItem, int data, ItemLocation loc) {
|
||||||
return new ContainerImprinter(player.inventory, new ItemInventoryImprinter(player, heldItem));
|
return new ContainerImprinter(player.inventory, new ItemInventoryImprinter(player, heldItem));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -111,6 +111,14 @@ public class AlvearyController extends RectangularMultiblockControllerBase
|
|||||||
this.readFromNBT(data);
|
this.readFromNBT(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void detachBlock(IMultiblockComponent part, boolean chunkUnloading) {
|
||||||
|
if (!chunkUnloading) {
|
||||||
|
inventory.dumpInventoryIntoWorld(this.worldObj, part.getCoordinates());
|
||||||
|
}
|
||||||
|
super.detachBlock(part, chunkUnloading);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onBlockAdded(IMultiblockComponent newPart) {
|
protected void onBlockAdded(IMultiblockComponent newPart) {
|
||||||
if (newPart instanceof IAlvearyComponent) {
|
if (newPart instanceof IAlvearyComponent) {
|
||||||
@@ -159,8 +167,6 @@ public class AlvearyController extends RectangularMultiblockControllerBase
|
|||||||
activeComponents.remove(oldPart);
|
activeComponents.remove(oldPart);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inventory.dumpInventoryIntoWorld(this.worldObj, oldPart.getCoordinates());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -250,8 +256,9 @@ public class AlvearyController extends RectangularMultiblockControllerBase
|
|||||||
|
|
||||||
private float applyChange(float base, float currentChange, float extraChange, float boundaryDown,
|
private float applyChange(float base, float currentChange, float extraChange, float boundaryDown,
|
||||||
float boundaryUp) {
|
float boundaryUp) {
|
||||||
float boundedNewChange = Math.max(boundaryDown, Math.min(base + currentChange + (extraChange * 20), boundaryUp))
|
float boundedNewChange = Math.round(
|
||||||
- base;
|
(Math.max(boundaryDown, Math.min(base + currentChange + (extraChange * 20), boundaryUp)) - base) * 100)
|
||||||
|
/ 100.0f;
|
||||||
if (extraChange > 0) {
|
if (extraChange > 0) {
|
||||||
return Math.max(currentChange, boundedNewChange);
|
return Math.max(currentChange, boundedNewChange);
|
||||||
} else {
|
} else {
|
||||||
@@ -355,12 +362,13 @@ public class AlvearyController extends RectangularMultiblockControllerBase
|
|||||||
@Override
|
@Override
|
||||||
public float getExactTemperature() {
|
public float getExactTemperature() {
|
||||||
ChunkCoordinates coords = getReferenceCoord();
|
ChunkCoordinates coords = getReferenceCoord();
|
||||||
return getBiome().getFloatTemperature(coords.posX, coords.posY, coords.posZ) + tempChange;
|
return Math.round((getBiome().getFloatTemperature(coords.posX, coords.posY, coords.posZ) + tempChange) * 100)
|
||||||
|
/ 100.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getExactHumidity() {
|
public float getExactHumidity() {
|
||||||
return getBiome().rainfall + humidChange;
|
return Math.round((getBiome().rainfall + humidChange) * 100) / 100.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,145 +0,0 @@
|
|||||||
package forestry.arboriculture;
|
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.block.BlockLeaves;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
|
|
||||||
/** Based on vanilla leaf decay, but accepts leaves that are connected further from a trunk */
|
|
||||||
public abstract class LeafDecayHelper {
|
|
||||||
|
|
||||||
private static final short SUSTAINS_LEAVES = 0;
|
|
||||||
private static final short NOT_SUSTAINS_LEAVES = -1;
|
|
||||||
private static final short IS_LEAVES = -2;
|
|
||||||
private static int[] leafDecayValues;
|
|
||||||
|
|
||||||
public static void leafDecay(BlockLeaves leaves, World world, int x, int y, int z) {
|
|
||||||
if (world.isRemote) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int leafMeta = world.getBlockMetadata(x, y, z);
|
|
||||||
|
|
||||||
if ((leafMeta & 8) != 0 && (leafMeta & 4) == 0) {
|
|
||||||
byte radius = 4;
|
|
||||||
byte yArrayMult = 32;
|
|
||||||
int xArrayMult = yArrayMult * yArrayMult;
|
|
||||||
int arrayOffset = yArrayMult / 2;
|
|
||||||
|
|
||||||
if (leafDecayValues == null) {
|
|
||||||
leafDecayValues = new int[yArrayMult * yArrayMult * yArrayMult];
|
|
||||||
}
|
|
||||||
|
|
||||||
int radius1 = radius + 1;
|
|
||||||
if (world.checkChunksExist(x - radius1, y - radius1, z - radius1, x + radius1, y + radius1, z + radius1)) {
|
|
||||||
for (int xOffset = -radius; xOffset <= radius; ++xOffset) {
|
|
||||||
for (int yOffset = -radius; yOffset <= radius; ++yOffset) {
|
|
||||||
for (int zOffset = -radius; zOffset <= radius; ++zOffset) {
|
|
||||||
Block block = world.getBlock(x + xOffset, y + yOffset, z + zOffset);
|
|
||||||
|
|
||||||
if (!block.canSustainLeaves(world, x + xOffset, y + yOffset, z + zOffset)) {
|
|
||||||
if (block.isLeaves(world, x + xOffset, y + yOffset, z + zOffset)) {
|
|
||||||
leafDecayValues[(xOffset + arrayOffset) * xArrayMult
|
|
||||||
+ (yOffset + arrayOffset) * yArrayMult
|
|
||||||
+ zOffset
|
|
||||||
+ arrayOffset] = IS_LEAVES;
|
|
||||||
} else {
|
|
||||||
leafDecayValues[(xOffset + arrayOffset) * xArrayMult
|
|
||||||
+ (yOffset + arrayOffset) * yArrayMult
|
|
||||||
+ zOffset
|
|
||||||
+ arrayOffset] = NOT_SUSTAINS_LEAVES;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
leafDecayValues[(xOffset + arrayOffset) * xArrayMult
|
|
||||||
+ (yOffset + arrayOffset) * yArrayMult
|
|
||||||
+ zOffset
|
|
||||||
+ arrayOffset] = SUSTAINS_LEAVES;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int sustainedValue = 1; sustainedValue <= 8; ++sustainedValue) {
|
|
||||||
for (int xOffset = -radius; xOffset <= radius; ++xOffset) {
|
|
||||||
for (int yOffset = -radius; yOffset <= radius; ++yOffset) {
|
|
||||||
for (int zOffset = -radius; zOffset <= radius; ++zOffset) {
|
|
||||||
if (leafDecayValues[(xOffset + arrayOffset) * xArrayMult
|
|
||||||
+ (yOffset + arrayOffset) * yArrayMult
|
|
||||||
+ zOffset
|
|
||||||
+ arrayOffset] == sustainedValue - 1) {
|
|
||||||
if (leafDecayValues[(xOffset + arrayOffset - 1) * xArrayMult
|
|
||||||
+ (yOffset + arrayOffset) * yArrayMult
|
|
||||||
+ zOffset
|
|
||||||
+ arrayOffset] == IS_LEAVES) {
|
|
||||||
leafDecayValues[(xOffset + arrayOffset - 1) * xArrayMult
|
|
||||||
+ (yOffset + arrayOffset) * yArrayMult
|
|
||||||
+ zOffset
|
|
||||||
+ arrayOffset] = sustainedValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (leafDecayValues[(xOffset + arrayOffset + 1) * xArrayMult
|
|
||||||
+ (yOffset + arrayOffset) * yArrayMult
|
|
||||||
+ zOffset
|
|
||||||
+ arrayOffset] == IS_LEAVES) {
|
|
||||||
leafDecayValues[(xOffset + arrayOffset + 1) * xArrayMult
|
|
||||||
+ (yOffset + arrayOffset) * yArrayMult
|
|
||||||
+ zOffset
|
|
||||||
+ arrayOffset] = sustainedValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (leafDecayValues[(xOffset + arrayOffset) * xArrayMult
|
|
||||||
+ (yOffset + arrayOffset - 1) * yArrayMult
|
|
||||||
+ zOffset
|
|
||||||
+ arrayOffset] == IS_LEAVES) {
|
|
||||||
leafDecayValues[(xOffset + arrayOffset) * xArrayMult
|
|
||||||
+ (yOffset + arrayOffset - 1) * yArrayMult
|
|
||||||
+ zOffset
|
|
||||||
+ arrayOffset] = sustainedValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (leafDecayValues[(xOffset + arrayOffset) * xArrayMult
|
|
||||||
+ (yOffset + arrayOffset + 1) * yArrayMult
|
|
||||||
+ zOffset
|
|
||||||
+ arrayOffset] == IS_LEAVES) {
|
|
||||||
leafDecayValues[(xOffset + arrayOffset) * xArrayMult
|
|
||||||
+ (yOffset + arrayOffset + 1) * yArrayMult
|
|
||||||
+ zOffset
|
|
||||||
+ arrayOffset] = sustainedValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (leafDecayValues[(xOffset + arrayOffset) * xArrayMult
|
|
||||||
+ (yOffset + arrayOffset) * yArrayMult
|
|
||||||
+ (zOffset + arrayOffset - 1)] == IS_LEAVES) {
|
|
||||||
leafDecayValues[(xOffset + arrayOffset) * xArrayMult
|
|
||||||
+ (yOffset + arrayOffset) * yArrayMult
|
|
||||||
+ (zOffset + arrayOffset - 1)] = sustainedValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (leafDecayValues[(xOffset + arrayOffset) * xArrayMult
|
|
||||||
+ (yOffset + arrayOffset) * yArrayMult
|
|
||||||
+ zOffset
|
|
||||||
+ arrayOffset
|
|
||||||
+ 1] == IS_LEAVES) {
|
|
||||||
leafDecayValues[(xOffset + arrayOffset) * xArrayMult
|
|
||||||
+ (yOffset + arrayOffset) * yArrayMult
|
|
||||||
+ zOffset
|
|
||||||
+ arrayOffset
|
|
||||||
+ 1] = sustainedValue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int sustainValue = leafDecayValues[(arrayOffset * xArrayMult) + (arrayOffset * yArrayMult) + arrayOffset];
|
|
||||||
|
|
||||||
if (sustainValue >= 0) {
|
|
||||||
world.setBlockMetadataWithNotify(x, y, z, leafMeta & -9, 4); // stop trying to decay
|
|
||||||
} else {
|
|
||||||
leaves.dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), 0);
|
|
||||||
world.setBlockToAir(x, y, z);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -34,6 +34,7 @@ import net.minecraft.world.IBlockAccess;
|
|||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
|
import com.gtnewhorizon.gtnhlib.blocks.util.BFSLeafDecay;
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
@@ -48,7 +49,6 @@ import forestry.api.core.Tabs;
|
|||||||
import forestry.api.lepidopterology.ButterflyManager;
|
import forestry.api.lepidopterology.ButterflyManager;
|
||||||
import forestry.api.lepidopterology.EnumFlutterType;
|
import forestry.api.lepidopterology.EnumFlutterType;
|
||||||
import forestry.api.lepidopterology.IButterfly;
|
import forestry.api.lepidopterology.IButterfly;
|
||||||
import forestry.arboriculture.LeafDecayHelper;
|
|
||||||
import forestry.arboriculture.genetics.TreeDefinition;
|
import forestry.arboriculture.genetics.TreeDefinition;
|
||||||
import forestry.arboriculture.items.ItemBlockLeaves;
|
import forestry.arboriculture.items.ItemBlockLeaves;
|
||||||
import forestry.arboriculture.render.TextureLeaves;
|
import forestry.arboriculture.render.TextureLeaves;
|
||||||
@@ -230,7 +230,12 @@ public class BlockForestryLeaves extends BlockNewLeaf implements ITileEntityProv
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
LeafDecayHelper.leafDecay(this, world, x, y, z);
|
if (!world.isRemote) {
|
||||||
|
final int meta = world.getBlockMetadata(x, y, z);
|
||||||
|
if ((meta & 8) != 0 && (meta & 4) == 0) {
|
||||||
|
BFSLeafDecay.handleDecayChecked(this, world, x, y, z, meta, 4);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// check leaves tile again because they can decay in super.updateTick
|
// check leaves tile again because they can decay in super.updateTick
|
||||||
if (tileLeaves.isInvalid()) {
|
if (tileLeaves.isInvalid()) {
|
||||||
|
|||||||
@@ -36,29 +36,29 @@ public class BlockFruitPod extends BlockCocoa {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static TileFruitPod getPodTile(IBlockAccess world, int x, int y, int z) {
|
public static TileFruitPod getPodTile(IBlockAccess world, int x, int y, int z) {
|
||||||
TileEntity tile = world.getTileEntity(x, y, z);
|
final TileEntity tile = world.getTileEntity(x, y, z);
|
||||||
if (!(tile instanceof TileFruitPod)) {
|
if (tile instanceof TileFruitPod) {
|
||||||
return null;
|
return (TileFruitPod) tile;
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
return (TileFruitPod) tile;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateTick(World world, int x, int y, int z, Random rand) {
|
public void updateTick(World world, int x, int y, int z, Random rand) {
|
||||||
|
if (!world.checkChunksExist(x - 1, y, z - 1, x + 1, y, z + 1)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!canBlockStay(world, x, y, z)) {
|
if (!canBlockStay(world, x, y, z)) {
|
||||||
dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), 0);
|
final int meta = world.getBlockMetadata(x, y, z);
|
||||||
|
this.dropBlockAsItem(world, x, y, z, meta, 0);
|
||||||
world.setBlockToAir(x, y, z);
|
world.setBlockToAir(x, y, z);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
TileFruitPod tile = getPodTile(world, x, y, z);
|
final TileFruitPod tile = getPodTile(world, x, y, z);
|
||||||
if (tile == null) {
|
if (tile != null) {
|
||||||
return;
|
tile.onBlockTick();
|
||||||
}
|
}
|
||||||
|
|
||||||
tile.onBlockTick();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
|
|||||||
@@ -16,8 +16,8 @@ import net.minecraft.block.material.Material;
|
|||||||
import net.minecraft.client.particle.EffectRenderer;
|
import net.minecraft.client.particle.EffectRenderer;
|
||||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||||
import net.minecraft.creativetab.CreativeTabs;
|
import net.minecraft.creativetab.CreativeTabs;
|
||||||
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.init.Blocks;
|
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
@@ -72,7 +72,7 @@ public class BlockSlab extends net.minecraft.block.BlockSlab implements IWoodTyp
|
|||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
@Override
|
@Override
|
||||||
public IIcon getIcon(int side, int meta) {
|
public IIcon getIcon(int side, int meta) {
|
||||||
return IconProviderWood.getPlankIcon(EnumWoodType.LARCH);
|
return IconProviderWood.getPlankIcon(EnumWoodType.VALUES[meta]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -84,7 +84,8 @@ public class BlockSlab extends net.minecraft.block.BlockSlab implements IWoodTyp
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ItemStack createStackedBlock(int meta) {
|
protected ItemStack createStackedBlock(int meta) {
|
||||||
return new ItemStack(Blocks.wooden_slab, 2, meta & 7);
|
Item item = Item.getItemFromBlock(this);
|
||||||
|
return item != null ? new ItemStack(item, 2, 0) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -107,6 +108,18 @@ public class BlockSlab extends net.minecraft.block.BlockSlab implements IWoodTyp
|
|||||||
return new TileWood();
|
return new TileWood();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) {
|
||||||
|
// Special case for double slabs placed by building mods (e.g., MatterManipulator)
|
||||||
|
if (stack == null) return;
|
||||||
|
int damage = stack.getItemDamage();
|
||||||
|
if (damage < 0 || damage >= EnumWoodType.VALUES.length) return;
|
||||||
|
TileWood tile = TileWood.getWoodTile(world, x, y, z);
|
||||||
|
if (tile != null) {
|
||||||
|
tile.setWoodType(EnumWoodType.VALUES[damage]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* PROPERTIES */
|
/* PROPERTIES */
|
||||||
@Override
|
@Override
|
||||||
public final ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) {
|
public final ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) {
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ public class ItemRegistryArboriculture extends ItemRegistry {
|
|||||||
OreDictionary.registerOre("treeSapling", sapling.getWildcard());
|
OreDictionary.registerOre("treeSapling", sapling.getWildcard());
|
||||||
|
|
||||||
pollenFertile = registerItem(new ItemGermlingGE(EnumGermlingType.POLLEN), "pollenFertile");
|
pollenFertile = registerItem(new ItemGermlingGE(EnumGermlingType.POLLEN), "pollenFertile");
|
||||||
|
OreDictionary.registerOre("itemPollenFertile", pollenFertile.getWildcard());
|
||||||
treealyzer = registerItem(new ItemTreealyzer(), "treealyzer");
|
treealyzer = registerItem(new ItemTreealyzer(), "treealyzer");
|
||||||
grafter = registerItem(new ItemGrafter(4), "grafter");
|
grafter = registerItem(new ItemGrafter(4), "grafter");
|
||||||
grafterProven = registerItem(new ItemGrafter(149), "grafterProven");
|
grafterProven = registerItem(new ItemGrafter(149), "grafterProven");
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import forestry.api.core.Tabs;
|
|||||||
import forestry.arboriculture.gui.GuiTreealyzer;
|
import forestry.arboriculture.gui.GuiTreealyzer;
|
||||||
import forestry.arboriculture.inventory.ItemInventoryTreealyzer;
|
import forestry.arboriculture.inventory.ItemInventoryTreealyzer;
|
||||||
import forestry.core.gui.ContainerAlyzer;
|
import forestry.core.gui.ContainerAlyzer;
|
||||||
|
import forestry.core.inventory.ItemLocation;
|
||||||
import forestry.core.items.ItemWithGui;
|
import forestry.core.items.ItemWithGui;
|
||||||
|
|
||||||
public class ItemTreealyzer extends ItemWithGui {
|
public class ItemTreealyzer extends ItemWithGui {
|
||||||
@@ -24,12 +25,12 @@ public class ItemTreealyzer extends ItemWithGui {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getGui(EntityPlayer player, ItemStack heldItem, int data) {
|
public Object getGui(EntityPlayer player, ItemStack heldItem, int data, ItemLocation loc) {
|
||||||
return new GuiTreealyzer(player, new ItemInventoryTreealyzer(player, heldItem));
|
return new GuiTreealyzer(player, new ItemInventoryTreealyzer(player, heldItem));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getContainer(EntityPlayer player, ItemStack heldItem, int data) {
|
public Object getContainer(EntityPlayer player, ItemStack heldItem, int data, ItemLocation loc) {
|
||||||
return new ContainerAlyzer(new ItemInventoryTreealyzer(player, heldItem), player);
|
return new ContainerAlyzer(new ItemInventoryTreealyzer(player, heldItem), player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -95,8 +95,7 @@ public class TileWood extends TileEntity implements IStreamable {
|
|||||||
EnumWoodType woodType = wood.getWoodType();
|
EnumWoodType woodType = wood.getWoodType();
|
||||||
|
|
||||||
int amount = 1;
|
int amount = 1;
|
||||||
if (block instanceof BlockSlab) {
|
if (block instanceof BlockSlab blockSlab) {
|
||||||
BlockSlab blockSlab = (BlockSlab) block;
|
|
||||||
if (blockSlab.isDoubleSlab()) {
|
if (blockSlab.isDoubleSlab()) {
|
||||||
amount = 2;
|
amount = 2;
|
||||||
block = PluginArboriculture.blocks.slabs;
|
block = PluginArboriculture.blocks.slabs;
|
||||||
@@ -104,6 +103,7 @@ public class TileWood extends TileEntity implements IStreamable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ItemStack itemStack = new ItemStack(block, amount);
|
ItemStack itemStack = new ItemStack(block, amount);
|
||||||
|
if (itemStack.getItem() == null) return null;
|
||||||
ItemBlockWood.saveToItemStack(woodType, itemStack);
|
ItemBlockWood.saveToItemStack(woodType, itemStack);
|
||||||
return itemStack;
|
return itemStack;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,31 +84,26 @@ public class BlockSoil extends Block implements IItemTyped {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateTick(World world, int i, int j, int k, Random random) {
|
public void updateTick(World world, int x, int y, int z, Random random) {
|
||||||
if (world.isRemote) {
|
if (world.isRemote) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int meta = world.getBlockMetadata(i, j, k);
|
int meta = world.getBlockMetadata(x, y, z);
|
||||||
|
|
||||||
SoilType type = getTypeFromMeta(meta);
|
SoilType type = getTypeFromMeta(meta);
|
||||||
|
|
||||||
if (type == SoilType.HUMUS) {
|
if (type == SoilType.HUMUS) {
|
||||||
updateTickHumus(world, i, j, k);
|
if (world.checkChunksExist(x - 1, y + 1, z - 1, x + 1, y + 1, z + 1)) {
|
||||||
|
if (isEnrooted(world, x, y, z)) {
|
||||||
|
degradeSoil(world, x, y, z);
|
||||||
|
}
|
||||||
|
}
|
||||||
} else if (type == SoilType.BOG_EARTH) {
|
} else if (type == SoilType.BOG_EARTH) {
|
||||||
updateTickBogEarth(world, i, j, k);
|
if (world.checkChunksExist(x - 2, y, z - 2, x + 2, y, z + 2)) {
|
||||||
}
|
if (isMoistened(world, x, y, z)) {
|
||||||
}
|
matureBog(world, x, y, z);
|
||||||
|
}
|
||||||
private static void updateTickHumus(World world, int i, int j, int k) {
|
}
|
||||||
if (isEnrooted(world, i, j, k)) {
|
|
||||||
degradeSoil(world, i, j, k);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void updateTickBogEarth(World world, int i, int j, int k) {
|
|
||||||
if (isMoistened(world, i, j, k)) {
|
|
||||||
matureBog(world, i, j, k);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,7 +117,6 @@ public class BlockSoil extends Block implements IItemTyped {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,7 +150,6 @@ public class BlockSoil extends Block implements IItemTyped {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isMoistened(World world, int x, int y, int z) {
|
private static boolean isMoistened(World world, int x, int y, int z) {
|
||||||
|
|
||||||
for (int i = -2; i < 3; i++) {
|
for (int i = -2; i < 3; i++) {
|
||||||
for (int j = -2; j < 3; j++) {
|
for (int j = -2; j < 3; j++) {
|
||||||
Block block = world.getBlock(x + i, y, z + j);
|
Block block = world.getBlock(x + i, y, z + j);
|
||||||
@@ -165,7 +158,6 @@ public class BlockSoil extends Block implements IItemTyped {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -193,7 +193,7 @@ public class BlockForestryFluid extends BlockFluidClassic {
|
|||||||
super.updateTick(world, x, y, z, rand);
|
super.updateTick(world, x, y, z, rand);
|
||||||
|
|
||||||
// Start fires if the fluid is lava-like
|
// Start fires if the fluid is lava-like
|
||||||
if (getMaterial() == Material.lava) {
|
if (getMaterial() == Material.lava && world.checkChunksExist(x - 4, y, z - 4, x + 4, y, z + 4)) {
|
||||||
int rangeUp = rand.nextInt(3);
|
int rangeUp = rand.nextInt(3);
|
||||||
|
|
||||||
for (int i = 0; i < rangeUp; ++i) {
|
for (int i = 0; i < rangeUp; ++i) {
|
||||||
|
|||||||
@@ -202,7 +202,8 @@ public abstract class Genome implements IGenome {
|
|||||||
private static IChromosome[] getChromosomes(NBTTagCompound genomeNBT, ISpeciesRoot speciesRoot) {
|
private static IChromosome[] getChromosomes(NBTTagCompound genomeNBT, ISpeciesRoot speciesRoot) {
|
||||||
|
|
||||||
NBTTagList chromosomesNBT = genomeNBT.getTagList("Chromosomes", 10);
|
NBTTagList chromosomesNBT = genomeNBT.getTagList("Chromosomes", 10);
|
||||||
IChromosome[] chromosomes = new IChromosome[speciesRoot.getDefaultTemplate().length];
|
IAllele[] defaultTemplate = speciesRoot.getDefaultTemplate();
|
||||||
|
IChromosome[] chromosomes = new IChromosome[defaultTemplate.length];
|
||||||
|
|
||||||
for (int i = 0; i < chromosomesNBT.tagCount(); i++) {
|
for (int i = 0; i < chromosomesNBT.tagCount(); i++) {
|
||||||
NBTTagCompound chromosomeNBT = chromosomesNBT.getCompoundTagAt(i);
|
NBTTagCompound chromosomeNBT = chromosomesNBT.getCompoundTagAt(i);
|
||||||
@@ -213,7 +214,7 @@ public abstract class Genome implements IGenome {
|
|||||||
chromosomes[chromosomeOrdinal] = chromosome;
|
chromosomes[chromosomeOrdinal] = chromosome;
|
||||||
|
|
||||||
if (Config.clearInvalidChromosomes) {
|
if (Config.clearInvalidChromosomes) {
|
||||||
IAllele template = speciesRoot.getDefaultTemplate()[chromosomeOrdinal];
|
IAllele template = defaultTemplate[chromosomeOrdinal];
|
||||||
Class<? extends IAllele> chromosomeClass = speciesRoot.getKaryotype()[chromosomeOrdinal]
|
Class<? extends IAllele> chromosomeClass = speciesRoot.getKaryotype()[chromosomeOrdinal]
|
||||||
.getAlleleClass();
|
.getAlleleClass();
|
||||||
if (chromosome.overrideInvalidAlleles(template, chromosomeClass)) {
|
if (chromosome.overrideInvalidAlleles(template, chromosomeClass)) {
|
||||||
|
|||||||
@@ -32,6 +32,10 @@ public class MutationConditionRequiresResource implements IMutationCondition {
|
|||||||
blockRequired = new ItemStack(block, 1, meta);
|
blockRequired = new ItemStack(block, 1, meta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ItemStack getBlockRequired() {
|
||||||
|
return blockRequired.copy();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getChance(World world, int x, int y, int z, IAllele allele0, IAllele allele1, IGenome genome0,
|
public float getChance(World world, int x, int y, int z, IAllele allele0, IAllele allele1, IGenome genome0,
|
||||||
IGenome genome1, IClimateProvider climate) {
|
IGenome genome1, IClimateProvider climate) {
|
||||||
|
|||||||
@@ -39,6 +39,10 @@ public class MutationConditionRequiresResourceOreDict implements IMutationCondit
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getOreDictId() {
|
||||||
|
return oreDictId;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getChance(World world, int x, int y, int z, IAllele allele0, IAllele allele1, IGenome genome0,
|
public float getChance(World world, int x, int y, int z, IAllele allele0, IAllele allele1, IGenome genome0,
|
||||||
IGenome genome1, IClimateProvider climate) {
|
IGenome genome1, IClimateProvider climate) {
|
||||||
|
|||||||
@@ -36,8 +36,7 @@ public abstract class ContainerForestry extends Container {
|
|||||||
// Player inventory
|
// Player inventory
|
||||||
for (int row = 0; row < 3; row++) {
|
for (int row = 0; row < 3; row++) {
|
||||||
for (int column = 0; column < 9; column++) {
|
for (int column = 0; column < 9; column++) {
|
||||||
addSlotToContainer(
|
addNormalSlot(playerInventory, column + row * 9 + 9, xInv + column * 18, yInv + row * 18);
|
||||||
new Slot(playerInventory, column + row * 9 + 9, xInv + column * 18, yInv + row * 18));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Player hotbar
|
// Player hotbar
|
||||||
@@ -46,6 +45,10 @@ public abstract class ContainerForestry extends Container {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void addNormalSlot(InventoryPlayer playerInventory, int slot, int x, int y) {
|
||||||
|
addSlotToContainer(new Slot(playerInventory, slot, x, y));
|
||||||
|
}
|
||||||
|
|
||||||
protected void addHotbarSlot(InventoryPlayer playerInventory, int slot, int x, int y) {
|
protected void addHotbarSlot(InventoryPlayer playerInventory, int slot, int x, int y) {
|
||||||
addSlotToContainer(new Slot(playerInventory, slot, x, y));
|
addSlotToContainer(new Slot(playerInventory, slot, x, y));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,17 @@ public abstract class ContainerItemInventory<I extends ItemInventory> extends Co
|
|||||||
addPlayerInventory(playerInventory, xInv, yInv);
|
addPlayerInventory(playerInventory, xInv, yInv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void addNormalSlot(InventoryPlayer playerInventory, int slot, int x, int y) {
|
||||||
|
ItemStack stackInSlot = playerInventory.getStackInSlot(slot);
|
||||||
|
|
||||||
|
if (inventory.isParentItemInventory(stackInSlot)) {
|
||||||
|
addSlotToContainer(new SlotLocked(playerInventory, slot, x, y));
|
||||||
|
} else {
|
||||||
|
addSlotToContainer(new Slot(playerInventory, slot, x, y));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void addHotbarSlot(InventoryPlayer playerInventory, int slot, int x, int y) {
|
protected void addHotbarSlot(InventoryPlayer playerInventory, int slot, int x, int y) {
|
||||||
ItemStack stackInSlot = playerInventory.getStackInSlot(slot);
|
ItemStack stackInSlot = playerInventory.getStackInSlot(slot);
|
||||||
|
|||||||
@@ -8,6 +8,10 @@
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package forestry.core.gui;
|
package forestry.core.gui;
|
||||||
|
|
||||||
|
import static forestry.core.inventory.ItemLocation.Type.PLAYER_INVENTORY;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
@@ -18,6 +22,7 @@ import net.minecraft.world.World;
|
|||||||
|
|
||||||
import cpw.mods.fml.common.network.IGuiHandler;
|
import cpw.mods.fml.common.network.IGuiHandler;
|
||||||
import forestry.api.core.ForestryAPI;
|
import forestry.api.core.ForestryAPI;
|
||||||
|
import forestry.core.inventory.ItemLocation;
|
||||||
|
|
||||||
public class GuiHandler implements IGuiHandler {
|
public class GuiHandler implements IGuiHandler {
|
||||||
|
|
||||||
@@ -39,6 +44,20 @@ public class GuiHandler implements IGuiHandler {
|
|||||||
entityplayer.openGui(ForestryAPI.instance, guiData, entityplayer.worldObj, 0, 0, 0);
|
entityplayer.openGui(ForestryAPI.instance, guiData, entityplayer.worldObj, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Opens gui for item placed in player's inventory.
|
||||||
|
*
|
||||||
|
* @param entityPlayer Player.
|
||||||
|
* @param guiHandler GUI handler for item.
|
||||||
|
* @param data Data for item.
|
||||||
|
* @param invSlotIdx Index or slot in player inventory should be in range [0, 40).
|
||||||
|
*/
|
||||||
|
public static void openGui(EntityPlayer entityPlayer, IGuiHandlerItem guiHandler, short data, int invSlotIdx) {
|
||||||
|
assert invSlotIdx >= 0 && invSlotIdx < 40 : "Incorrect inventory index is used: " + invSlotIdx;
|
||||||
|
int guiData = encodeGuiData(guiHandler, data, invSlotIdx);
|
||||||
|
entityPlayer.openGui(ForestryAPI.instance, guiData, entityPlayer.worldObj, 0, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
public static void openGui(EntityPlayer entityplayer, IGuiHandlerTile guiHandler) {
|
public static void openGui(EntityPlayer entityplayer, IGuiHandlerTile guiHandler) {
|
||||||
openGui(entityplayer, guiHandler, (short) 0);
|
openGui(entityplayer, guiHandler, (short) 0);
|
||||||
}
|
}
|
||||||
@@ -56,8 +75,32 @@ public class GuiHandler implements IGuiHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static int encodeGuiData(IGuiHandlerForestry guiHandler, short data) {
|
private static int encodeGuiData(IGuiHandlerForestry guiHandler, short data) {
|
||||||
|
return encodeGuiData(guiHandler, data, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encodes data required for GUI handler to function properly. Because of minecraft implementation we are limited to
|
||||||
|
* 32 bits.
|
||||||
|
*
|
||||||
|
* @param guiHandler GUI handler.
|
||||||
|
* @param data High bits which were encoded by GUI handler.
|
||||||
|
* @param invSlotIdx Slot index in the player's inventory should be in range [0,40).
|
||||||
|
* @return Encoded data.
|
||||||
|
*/
|
||||||
|
private static int encodeGuiData(IGuiHandlerForestry guiHandler, short data, int invSlotIdx) {
|
||||||
|
// inventory slot idx will be encoded in third byte
|
||||||
|
// player inventory has 40 slots which means that we need 6 bits to encode all values.
|
||||||
|
// first 2 bits are reserved for type currently values 0(heldItem) and 1(item inventory) have meaning,
|
||||||
|
// 2 and 3 are reserved for possible extension.
|
||||||
|
if (invSlotIdx < -1 || invSlotIdx >= 40) {
|
||||||
|
throw new IllegalArgumentException("Inventory slot index should be in range [-1, 40)");
|
||||||
|
}
|
||||||
|
|
||||||
|
int invData = invSlotIdx == -1 ? 0 : (0x40 | invSlotIdx);
|
||||||
|
|
||||||
GuiId guiId = GuiIdRegistry.getGuiIdForGuiHandler(guiHandler);
|
GuiId guiId = GuiIdRegistry.getGuiIdForGuiHandler(guiHandler);
|
||||||
return data << 16 | guiId.getId();
|
|
||||||
|
return data << 16 | invData << 8 | guiId.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static GuiId decodeGuiID(int guiData) {
|
private static GuiId decodeGuiID(int guiData) {
|
||||||
@@ -69,8 +112,24 @@ public class GuiHandler implements IGuiHandler {
|
|||||||
return (short) (guiId >> 16);
|
return (short) (guiId >> 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static int decodeInvSlotIdx(int guiData) {
|
||||||
|
boolean invEncoded = (0x00_00_40_00 & guiData) != 0;
|
||||||
|
|
||||||
|
return invEncoded ? (guiData & 0x00_00_3F_00) >> 8 : -1;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getClientGuiElement(int guiData, EntityPlayer player, World world, int x, int y, int z) {
|
public Object getClientGuiElement(int guiData, EntityPlayer player, World world, int x, int y, int z) {
|
||||||
|
return getGuiElement(false, guiData, player, world, x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getServerGuiElement(int guiData, EntityPlayer player, World world, int x, int y, int z) {
|
||||||
|
return getGuiElement(true, guiData, player, world, x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
private @Nullable Object getGuiElement(boolean isServerSide, int guiData, EntityPlayer player, World world, int x,
|
||||||
|
int y, int z) {
|
||||||
GuiId guiId = decodeGuiID(guiData);
|
GuiId guiId = decodeGuiID(guiData);
|
||||||
if (guiId == null) {
|
if (guiId == null) {
|
||||||
return null;
|
return null;
|
||||||
@@ -79,11 +138,25 @@ public class GuiHandler implements IGuiHandler {
|
|||||||
|
|
||||||
switch (guiId.getGuiType()) {
|
switch (guiId.getGuiType()) {
|
||||||
case Item: {
|
case Item: {
|
||||||
ItemStack heldItem = player.getCurrentEquippedItem();
|
int slotIdx = decodeInvSlotIdx(guiData);
|
||||||
|
ItemStack heldItem;
|
||||||
|
ItemLocation loc;
|
||||||
|
if (slotIdx == -1) {
|
||||||
|
heldItem = player.getCurrentEquippedItem();
|
||||||
|
loc = ItemLocation.HELD_BY_PLAYER;
|
||||||
|
} else {
|
||||||
|
heldItem = player.inventory.getStackInSlot(slotIdx);
|
||||||
|
loc = new ItemLocation(PLAYER_INVENTORY, slotIdx);
|
||||||
|
}
|
||||||
|
|
||||||
if (heldItem != null) {
|
if (heldItem != null) {
|
||||||
Item item = heldItem.getItem();
|
Item item = heldItem.getItem();
|
||||||
if (guiId.getGuiHandlerClass().isInstance(item)) {
|
if (guiId.getGuiHandlerClass().isInstance(item)) {
|
||||||
return ((IGuiHandlerItem) item).getGui(player, heldItem, data);
|
if (isServerSide) {
|
||||||
|
return ((IGuiHandlerItem) item).getContainer(player, heldItem, data, loc);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ((IGuiHandlerItem) item).getGui(player, heldItem, data, loc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -91,6 +164,9 @@ public class GuiHandler implements IGuiHandler {
|
|||||||
case Tile: {
|
case Tile: {
|
||||||
TileEntity tileEntity = world.getTileEntity(x, y, z);
|
TileEntity tileEntity = world.getTileEntity(x, y, z);
|
||||||
if (guiId.getGuiHandlerClass().isInstance(tileEntity)) {
|
if (guiId.getGuiHandlerClass().isInstance(tileEntity)) {
|
||||||
|
if (isServerSide) {
|
||||||
|
return ((IGuiHandlerTile) tileEntity).getContainer(player, data);
|
||||||
|
}
|
||||||
return ((IGuiHandlerTile) tileEntity).getGui(player, data);
|
return ((IGuiHandlerTile) tileEntity).getGui(player, data);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -98,6 +174,9 @@ public class GuiHandler implements IGuiHandler {
|
|||||||
case Entity: {
|
case Entity: {
|
||||||
Entity entity = world.getEntityByID(x);
|
Entity entity = world.getEntityByID(x);
|
||||||
if (guiId.getGuiHandlerClass().isInstance(entity)) {
|
if (guiId.getGuiHandlerClass().isInstance(entity)) {
|
||||||
|
if (isServerSide) {
|
||||||
|
return ((IGuiHandlerEntity) entity).getContainer(player, data);
|
||||||
|
}
|
||||||
return ((IGuiHandlerEntity) entity).getGui(player, data);
|
return ((IGuiHandlerEntity) entity).getGui(player, data);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -105,41 +184,4 @@ public class GuiHandler implements IGuiHandler {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getServerGuiElement(int guiData, EntityPlayer player, World world, int x, int y, int z) {
|
|
||||||
GuiId guiId = decodeGuiID(guiData);
|
|
||||||
if (guiId == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
short data = decodeGuiData(guiData);
|
|
||||||
|
|
||||||
switch (guiId.getGuiType()) {
|
|
||||||
case Item: {
|
|
||||||
ItemStack heldItem = player.getCurrentEquippedItem();
|
|
||||||
if (heldItem != null) {
|
|
||||||
Item item = heldItem.getItem();
|
|
||||||
if (guiId.getGuiHandlerClass().isInstance(item)) {
|
|
||||||
return ((IGuiHandlerItem) item).getContainer(player, heldItem, data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case Tile: {
|
|
||||||
TileEntity tileEntity = world.getTileEntity(x, y, z);
|
|
||||||
if (guiId.getGuiHandlerClass().isInstance(tileEntity)) {
|
|
||||||
return ((IGuiHandlerTile) tileEntity).getContainer(player, data);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case Entity: {
|
|
||||||
Entity entity = world.getEntityByID(x);
|
|
||||||
if (guiId.getGuiHandlerClass().isInstance(entity)) {
|
|
||||||
return ((IGuiHandlerEntity) entity).getContainer(player, data);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -119,6 +119,13 @@ public class GuiIdRegistry {
|
|||||||
classMap.put(tileGuiHandlerClass, guiId);
|
classMap.put(tileGuiHandlerClass, guiId);
|
||||||
idMap.put(guiId.getId(), guiId);
|
idMap.put(guiId.getId(), guiId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (idMap.size() > 256) {
|
||||||
|
// see {@link GuiHandler.encodeGuiData(forestry.core.gui.IGuiHandlerForestry, short, int)}
|
||||||
|
throw new IllegalStateException(
|
||||||
|
"Current implementation can't have more than different 256 GUI handlers "
|
||||||
|
+ "because its id is coded by 8 bits");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GuiId getGuiIdForGuiHandler(IGuiHandlerForestry guiHandler) {
|
public static GuiId getGuiIdForGuiHandler(IGuiHandlerForestry guiHandler) {
|
||||||
|
|||||||
@@ -11,9 +11,11 @@ package forestry.core.gui;
|
|||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
|
import forestry.core.inventory.ItemLocation;
|
||||||
|
|
||||||
public interface IGuiHandlerItem extends IGuiHandlerForestry {
|
public interface IGuiHandlerItem extends IGuiHandlerForestry {
|
||||||
|
|
||||||
Object getGui(EntityPlayer player, ItemStack heldItem, int data);
|
Object getGui(EntityPlayer player, ItemStack heldItem, int data, ItemLocation loc);
|
||||||
|
|
||||||
Object getContainer(EntityPlayer player, ItemStack heldItem, int data);
|
Object getContainer(EntityPlayer player, ItemStack heldItem, int data, ItemLocation loc);
|
||||||
}
|
}
|
||||||
@@ -28,11 +28,17 @@ public abstract class ItemInventory implements IInventory, IFilterSlotDelegate {
|
|||||||
private final EntityPlayer player;
|
private final EntityPlayer player;
|
||||||
private final ItemStack parent;
|
private final ItemStack parent;
|
||||||
private final ItemStack[] inventoryStacks;
|
private final ItemStack[] inventoryStacks;
|
||||||
|
private final ItemLocation location;
|
||||||
|
|
||||||
public ItemInventory(EntityPlayer player, int size, ItemStack parent) {
|
public ItemInventory(EntityPlayer player, int size, ItemStack parent) {
|
||||||
|
this(player, size, parent, ItemLocation.UNKNOWN);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemInventory(EntityPlayer player, int size, ItemStack parent, ItemLocation loc) {
|
||||||
this.player = player;
|
this.player = player;
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
this.inventoryStacks = new ItemStack[size];
|
this.inventoryStacks = new ItemStack[size];
|
||||||
|
this.location = loc;
|
||||||
|
|
||||||
setUID(); // Set a uid to identify the itemstack on SMP
|
setUID(); // Set a uid to identify the itemstack on SMP
|
||||||
|
|
||||||
@@ -79,20 +85,31 @@ public abstract class ItemInventory implements IInventory, IFilterSlotDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isParentItemEquipped() {
|
public boolean isParentItemEquipped() {
|
||||||
return isSameItemInventory(player.getCurrentEquippedItem(), parent);
|
return switch (location.type()) {
|
||||||
|
case HELD_BY_PLAYER, UNKNOWN -> isSameItemInventory(player.getCurrentEquippedItem(), parent);
|
||||||
|
case PLAYER_INVENTORY -> isSameItemInventory(player.inventory.getStackInSlot(location.slotIdx()), parent);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntityPlayer getPlayer() {
|
public EntityPlayer getPlayer() {
|
||||||
return player;
|
return player;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ItemLocation getLocation() {
|
||||||
|
return location;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isParentItemInventory(ItemStack itemStack) {
|
public boolean isParentItemInventory(ItemStack itemStack) {
|
||||||
ItemStack parent = getParent();
|
ItemStack parent = getParent();
|
||||||
return isSameItemInventory(parent, itemStack);
|
return isSameItemInventory(parent, itemStack);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ItemStack getParent() {
|
protected ItemStack getParent() {
|
||||||
ItemStack equipped = player.getCurrentEquippedItem();
|
ItemStack equipped = switch (location.type()) {
|
||||||
|
case HELD_BY_PLAYER, UNKNOWN -> player.getCurrentEquippedItem();
|
||||||
|
case PLAYER_INVENTORY -> player.inventory.getStackInSlot(location.slotIdx());
|
||||||
|
};
|
||||||
|
|
||||||
if (isSameItemInventory(equipped, parent)) {
|
if (isSameItemInventory(equipped, parent)) {
|
||||||
return equipped;
|
return equipped;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package forestry.core.inventory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Location of items in inventory.
|
||||||
|
*/
|
||||||
|
public class ItemLocation {
|
||||||
|
|
||||||
|
public enum Type {
|
||||||
|
UNKNOWN,
|
||||||
|
HELD_BY_PLAYER,
|
||||||
|
PLAYER_INVENTORY
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final ItemLocation UNKNOWN = new ItemLocation(Type.UNKNOWN, -1);
|
||||||
|
public static final ItemLocation HELD_BY_PLAYER = new ItemLocation(Type.HELD_BY_PLAYER, -1);
|
||||||
|
|
||||||
|
private final Type type;
|
||||||
|
private final int slotIdx;
|
||||||
|
|
||||||
|
public ItemLocation(Type type, int slotIdx) {
|
||||||
|
this.type = type;
|
||||||
|
this.slotIdx = slotIdx;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Type type() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int slotIdx() {
|
||||||
|
return slotIdx;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,16 +15,17 @@ import forestry.core.circuits.ContainerSolderingIron;
|
|||||||
import forestry.core.circuits.GuiSolderingIron;
|
import forestry.core.circuits.GuiSolderingIron;
|
||||||
import forestry.core.circuits.ISolderingIron;
|
import forestry.core.circuits.ISolderingIron;
|
||||||
import forestry.core.inventory.ItemInventorySolderingIron;
|
import forestry.core.inventory.ItemInventorySolderingIron;
|
||||||
|
import forestry.core.inventory.ItemLocation;
|
||||||
|
|
||||||
public class ItemSolderingIron extends ItemWithGui implements ISolderingIron {
|
public class ItemSolderingIron extends ItemWithGui implements ISolderingIron {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getGui(EntityPlayer player, ItemStack heldItem, int data) {
|
public Object getGui(EntityPlayer player, ItemStack heldItem, int data, ItemLocation loc) {
|
||||||
return new GuiSolderingIron(player, new ItemInventorySolderingIron(player, heldItem));
|
return new GuiSolderingIron(player, new ItemInventorySolderingIron(player, heldItem));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getContainer(EntityPlayer player, ItemStack heldItem, int data) {
|
public Object getContainer(EntityPlayer player, ItemStack heldItem, int data, ItemLocation loc) {
|
||||||
return new ContainerSolderingIron(player, new ItemInventorySolderingIron(player, heldItem));
|
return new ContainerSolderingIron(player, new ItemInventorySolderingIron(player, heldItem));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -33,7 +33,7 @@ public abstract class ItemWithGui extends ItemForestry implements IGuiHandlerIte
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void openGui(EntityPlayer entityplayer) {
|
protected void openGui(EntityPlayer entityplayer) {
|
||||||
GuiHandler.openGui(entityplayer, this);
|
GuiHandler.openGui(entityplayer, this, (short) 0, entityplayer.inventory.currentItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ public enum PacketIdServer implements IPacketId {
|
|||||||
BEE_LOGIC_ACTIVE_ENTITY_REQUEST,
|
BEE_LOGIC_ACTIVE_ENTITY_REQUEST,
|
||||||
|
|
||||||
// Factory
|
// Factory
|
||||||
WORKTABLE_NEI_SELECT,
|
NEI_SELECT,
|
||||||
|
|
||||||
// Mail
|
// Mail
|
||||||
LETTER_INFO_REQUEST,
|
LETTER_INFO_REQUEST,
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import codechicken.nei.api.IOverlayHandler;
|
|||||||
import codechicken.nei.api.IStackPositioner;
|
import codechicken.nei.api.IStackPositioner;
|
||||||
import codechicken.nei.recipe.IRecipeHandler;
|
import codechicken.nei.recipe.IRecipeHandler;
|
||||||
import forestry.core.proxy.Proxies;
|
import forestry.core.proxy.Proxies;
|
||||||
import forestry.factory.network.packets.PacketWorktableNEISelect;
|
import forestry.factory.network.packets.PacketNEISelect;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author bdew
|
* @author bdew
|
||||||
@@ -40,9 +40,25 @@ public class CustomOverlayHandler implements IOverlayHandler {
|
|||||||
this.forceShift = forceShift;
|
this.forceShift = forceShift;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean requireShiftForOverlayRecipe() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void overlayRecipe(GuiContainer cont, IRecipeHandler recipe, int recipeIndex, boolean shift) {
|
public void overlayRecipe(GuiContainer cont, IRecipeHandler recipe, int recipeIndex, boolean shift) {
|
||||||
List<PositionedStack> ingr = recipe.getIngredientStacks(recipeIndex);
|
int offsetX = 25;
|
||||||
|
int offsetY = 6;
|
||||||
|
int gridSpacing = 18;
|
||||||
|
List<PositionedStack> ingr;
|
||||||
|
if (recipe instanceof IGridRecipeHandler gridHandler) {
|
||||||
|
offsetX = gridHandler.getGridStartX();
|
||||||
|
offsetY = gridHandler.getGridStartY();
|
||||||
|
gridSpacing = gridHandler.getGridSpacing();
|
||||||
|
ingr = gridHandler.getGridStacks(recipeIndex);
|
||||||
|
} else {
|
||||||
|
ingr = recipe.getIngredientStacks(recipeIndex);
|
||||||
|
}
|
||||||
|
|
||||||
if (shift || forceShift) {
|
if (shift || forceShift) {
|
||||||
NBTTagList stacksnbt = new NBTTagList();
|
NBTTagList stacksnbt = new NBTTagList();
|
||||||
@@ -50,8 +66,8 @@ public class CustomOverlayHandler implements IOverlayHandler {
|
|||||||
for (PositionedStack pstack : ingr) {
|
for (PositionedStack pstack : ingr) {
|
||||||
if (pstack != null) {
|
if (pstack != null) {
|
||||||
// This is back-asswards but i don't see a better way :(
|
// This is back-asswards but i don't see a better way :(
|
||||||
int x = (pstack.relx - 25) / 18;
|
int x = (pstack.relx - offsetX) / gridSpacing;
|
||||||
int y = (pstack.rely - 6) / 18;
|
int y = (pstack.rely - offsetY) / gridSpacing;
|
||||||
|
|
||||||
ItemStack stack = pstack.item;
|
ItemStack stack = pstack.item;
|
||||||
NBTTagCompound stacknbt = stack.writeToNBT(new NBTTagCompound());
|
NBTTagCompound stacknbt = stack.writeToNBT(new NBTTagCompound());
|
||||||
@@ -68,7 +84,7 @@ public class CustomOverlayHandler implements IOverlayHandler {
|
|||||||
NBTTagCompound data = new NBTTagCompound();
|
NBTTagCompound data = new NBTTagCompound();
|
||||||
data.setTag("stacks", stacksnbt);
|
data.setTag("stacks", stacksnbt);
|
||||||
|
|
||||||
Proxies.net.sendToServer(new PacketWorktableNEISelect(data));
|
Proxies.net.sendToServer(new PacketNEISelect(data));
|
||||||
} else {
|
} else {
|
||||||
IStackPositioner positioner = new OffsetPositioner(xOffs, yOffs);
|
IStackPositioner positioner = new OffsetPositioner(xOffs, yOffs);
|
||||||
LayoutManager.overlayRenderer = new DefaultOverlayRenderer(ingr, positioner);
|
LayoutManager.overlayRenderer = new DefaultOverlayRenderer(ingr, positioner);
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package forestry.core.recipes.nei;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import codechicken.nei.PositionedStack;
|
||||||
|
|
||||||
|
public interface IGridRecipeHandler {
|
||||||
|
|
||||||
|
int getGridStartX();
|
||||||
|
|
||||||
|
int getGridStartY();
|
||||||
|
|
||||||
|
int getGridSpacing();
|
||||||
|
|
||||||
|
List<PositionedStack> getGridStacks(int recipeIndex);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -19,6 +19,8 @@ import forestry.api.arboriculture.TreeManager;
|
|||||||
import forestry.api.lepidopterology.ButterflyManager;
|
import forestry.api.lepidopterology.ButterflyManager;
|
||||||
import forestry.api.lepidopterology.EnumFlutterType;
|
import forestry.api.lepidopterology.EnumFlutterType;
|
||||||
import forestry.core.utils.Log;
|
import forestry.core.utils.Log;
|
||||||
|
import forestry.factory.gui.GuiCarpenter;
|
||||||
|
import forestry.factory.gui.GuiFabricator;
|
||||||
import forestry.factory.gui.GuiWorktable;
|
import forestry.factory.gui.GuiWorktable;
|
||||||
import forestry.factory.recipes.nei.NEIHandlerBottler;
|
import forestry.factory.recipes.nei.NEIHandlerBottler;
|
||||||
import forestry.factory.recipes.nei.NEIHandlerCarpenter;
|
import forestry.factory.recipes.nei.NEIHandlerCarpenter;
|
||||||
@@ -46,6 +48,8 @@ public class NEIIntegrationConfig implements IConfigureNEI {
|
|||||||
|
|
||||||
CustomOverlayHandler handler = new CustomOverlayHandler(-14, 14, true);
|
CustomOverlayHandler handler = new CustomOverlayHandler(-14, 14, true);
|
||||||
API.registerGuiOverlayHandler(GuiWorktable.class, handler, "crafting");
|
API.registerGuiOverlayHandler(GuiWorktable.class, handler, "crafting");
|
||||||
|
API.registerGuiOverlayHandler(GuiCarpenter.class, handler, "forestry.carpenter");
|
||||||
|
API.registerGuiOverlayHandler(GuiFabricator.class, handler, "forestry.fabricator");
|
||||||
|
|
||||||
API.addSubset(
|
API.addSubset(
|
||||||
"Forestry.Bees.Princesses",
|
"Forestry.Bees.Princesses",
|
||||||
|
|||||||
@@ -23,18 +23,19 @@ import net.minecraft.nbt.NBTTagList;
|
|||||||
*/
|
*/
|
||||||
public class SetRecipeCommandHandler {
|
public class SetRecipeCommandHandler {
|
||||||
|
|
||||||
private final Class<? extends Container> containerClass;
|
private final Class<? extends Container>[] containerClasses;
|
||||||
private final Class<? extends Slot> slotClass;
|
private final Class<? extends Slot> slotClass;
|
||||||
|
|
||||||
public SetRecipeCommandHandler(Class<? extends Container> containerClass, Class<? extends Slot> slotClass) {
|
public SetRecipeCommandHandler(Class<? extends Container>[] containerClasses, Class<? extends Slot> slotClass) {
|
||||||
this.containerClass = containerClass;
|
this.containerClasses = containerClasses;
|
||||||
this.slotClass = slotClass;
|
this.slotClass = slotClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handle(NBTTagCompound data, EntityPlayerMP player) {
|
public void handle(NBTTagCompound data, EntityPlayerMP player) {
|
||||||
NBTTagList stacks = data.getTagList("stacks", 10);
|
NBTTagList stacks = data.getTagList("stacks", 10);
|
||||||
Container cont = player.openContainer;
|
Container cont = player.openContainer;
|
||||||
if (!containerClass.isInstance(cont)) {
|
|
||||||
|
if (!isContainerClassCorrect(cont)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,17 +44,20 @@ public class SetRecipeCommandHandler {
|
|||||||
NBTTagCompound itemdata = stacks.getCompoundTagAt(i);
|
NBTTagCompound itemdata = stacks.getCompoundTagAt(i);
|
||||||
stmap.put(itemdata.getInteger("slot"), ItemStack.loadItemStackFromNBT(itemdata));
|
stmap.put(itemdata.getInteger("slot"), ItemStack.loadItemStackFromNBT(itemdata));
|
||||||
}
|
}
|
||||||
for (Object slotobj : cont.inventorySlots) {
|
for (Slot slot : cont.inventorySlots) {
|
||||||
if (!slotClass.isInstance(slotobj)) {
|
if (!slotClass.isInstance(slot)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
slot.putStack(stmap.getOrDefault(slot.getSlotIndex(), null));
|
||||||
Slot slot = (Slot) slotobj;
|
|
||||||
if (stmap.containsKey(slot.getSlotIndex())) {
|
|
||||||
slot.putStack(stmap.get(slot.getSlotIndex()));
|
|
||||||
} else {
|
|
||||||
slot.putStack(null);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isContainerClassCorrect(Container cont) {
|
||||||
|
for (Class<? extends Container> containerClass : containerClasses) {
|
||||||
|
if (containerClass.isInstance(cont)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -60,8 +60,6 @@ public class RenderAnalyzer extends TileEntitySpecialRenderer implements IBlockR
|
|||||||
|
|
||||||
private void render(ItemStack itemstack, World world, ForgeDirection orientation, double x, double y, double z) {
|
private void render(ItemStack itemstack, World world, ForgeDirection orientation, double x, double y, double z) {
|
||||||
|
|
||||||
dummyEntityItem.worldObj = world;
|
|
||||||
|
|
||||||
model.render(orientation, (float) x, (float) y, (float) z);
|
model.render(orientation, (float) x, (float) y, (float) z);
|
||||||
if (itemstack == null) {
|
if (itemstack == null) {
|
||||||
return;
|
return;
|
||||||
@@ -72,13 +70,18 @@ public class RenderAnalyzer extends TileEntitySpecialRenderer implements IBlockR
|
|||||||
GL11.glTranslatef((float) x, (float) y, (float) z);
|
GL11.glTranslatef((float) x, (float) y, (float) z);
|
||||||
GL11.glTranslatef(0.5f, 0.2f, 0.5f);
|
GL11.glTranslatef(0.5f, 0.2f, 0.5f);
|
||||||
GL11.glScalef(renderScale, renderScale, renderScale);
|
GL11.glScalef(renderScale, renderScale, renderScale);
|
||||||
dummyEntityItem.setEntityItemStack(itemstack);
|
|
||||||
|
|
||||||
if (world.getTotalWorldTime() != lastTick) {
|
try {
|
||||||
lastTick = world.getTotalWorldTime();
|
dummyEntityItem.worldObj = world;
|
||||||
dummyEntityItem.onUpdate();
|
dummyEntityItem.setEntityItemStack(itemstack);
|
||||||
|
if (world.getTotalWorldTime() != lastTick) {
|
||||||
|
lastTick = world.getTotalWorldTime();
|
||||||
|
dummyEntityItem.onUpdate();
|
||||||
|
}
|
||||||
|
customRenderItem.doRender(dummyEntityItem, 0, 0, 0, 0, 0);
|
||||||
|
} finally {
|
||||||
|
dummyEntityItem.worldObj = null;
|
||||||
}
|
}
|
||||||
customRenderItem.doRender(dummyEntityItem, 0, 0, 0, 0, 0);
|
|
||||||
GL11.glPopMatrix();
|
GL11.glPopMatrix();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -22,8 +22,6 @@ import forestry.core.tiles.TileMill;
|
|||||||
|
|
||||||
public class RenderMill extends TileEntitySpecialRenderer implements IBlockRenderer {
|
public class RenderMill extends TileEntitySpecialRenderer implements IBlockRenderer {
|
||||||
|
|
||||||
private final ModelBase model = new ModelBase() {};
|
|
||||||
|
|
||||||
private enum Textures {
|
private enum Textures {
|
||||||
PEDESTAL,
|
PEDESTAL,
|
||||||
EXTENSION,
|
EXTENSION,
|
||||||
@@ -41,6 +39,7 @@ public class RenderMill extends TileEntitySpecialRenderer implements IBlockRende
|
|||||||
private final ModelRenderer blade2;
|
private final ModelRenderer blade2;
|
||||||
|
|
||||||
public RenderMill() {
|
public RenderMill() {
|
||||||
|
ModelBase model = new ModelBase() {};
|
||||||
pedestal = new ModelRenderer(model, 0, 0);
|
pedestal = new ModelRenderer(model, 0, 0);
|
||||||
pedestal.addBox(-8F, -8F, -8F, 16, 1, 16);
|
pedestal.addBox(-8F, -8F, -8F, 16, 1, 16);
|
||||||
pedestal.rotationPointX = 8;
|
pedestal.rotationPointX = 8;
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
package forestry.core.utils;
|
||||||
|
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
|
||||||
|
import com.gtnewhorizons.postea.api.CustomDataReplacementManager;
|
||||||
|
|
||||||
|
import cpw.mods.fml.common.Loader;
|
||||||
|
|
||||||
|
/// Used to provide custom save data (like mail boxes) to Postea's versioned transformers.
|
||||||
|
///
|
||||||
|
/// These transformers allow other mods to change saved data based on their own version stamps. This compat flags,
|
||||||
|
/// to those transformers, the times they should fire. [#transform] is used before consuming data, so the transformer
|
||||||
|
/// can run, and [#stamp] is used for fresh data to ensure the transformer can add a stamp of its current version.
|
||||||
|
public final class PosteaCompat {
|
||||||
|
|
||||||
|
private static final boolean POSTEA = Loader.isModLoaded("postea");
|
||||||
|
|
||||||
|
private PosteaCompat() {}
|
||||||
|
|
||||||
|
/// Transforms a root read from disk in place; call before consuming it.
|
||||||
|
public static void transform(String storageId, NBTTagCompound root) {
|
||||||
|
if (POSTEA) Impl.transform(storageId, root);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A copy of the stamps on a root read from disk, or null when it carries none or Postea is absent. Call after
|
||||||
|
/// [#transform].
|
||||||
|
public static NBTTagCompound savedStamps(NBTTagCompound root) {
|
||||||
|
return POSTEA ? Impl.savedStamps(root) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Stamps a freshly built root about to be written to disk, keeping the stamps in `carried` (from [#savedStamps])
|
||||||
|
/// for transformers not registered now. `carried` may be null.
|
||||||
|
public static void stamp(NBTTagCompound root, NBTTagCompound carried) {
|
||||||
|
if (POSTEA) Impl.stamp(root, carried);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final class Impl {
|
||||||
|
|
||||||
|
static void transform(String storageId, NBTTagCompound root) {
|
||||||
|
CustomDataReplacementManager.transform(storageId, root);
|
||||||
|
}
|
||||||
|
|
||||||
|
static NBTTagCompound savedStamps(NBTTagCompound root) {
|
||||||
|
return CustomDataReplacementManager.savedStamps(root);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void stamp(NBTTagCompound root, NBTTagCompound carried) {
|
||||||
|
CustomDataReplacementManager.stamp(root, carried);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -118,7 +118,7 @@ public class GuiWorktable extends GuiForestryTitled<ContainerWorktable, TileWork
|
|||||||
|
|
||||||
GL11.glDisable(GL11.GL_LIGHTING);
|
GL11.glDisable(GL11.GL_LIGHTING);
|
||||||
GL11.glTranslatef(0, 0, 150);
|
GL11.glTranslatef(0, 0, 150);
|
||||||
drawRect(left, top, left + 16, top + 16, 0x88ff0000);
|
drawRect(left, top, left + 16, top + 16, 0x88000000 | getFontColor().get("gui.worktable.missing"));
|
||||||
GL11.glTranslatef(0, 0, -150);
|
GL11.glTranslatef(0, 0, -150);
|
||||||
GL11.glEnable(GL11.GL_LIGHTING);
|
GL11.glEnable(GL11.GL_LIGHTING);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,15 +9,15 @@
|
|||||||
package forestry.factory.network;
|
package forestry.factory.network;
|
||||||
|
|
||||||
import forestry.core.network.PacketRegistry;
|
import forestry.core.network.PacketRegistry;
|
||||||
|
import forestry.factory.network.packets.PacketNEISelect;
|
||||||
import forestry.factory.network.packets.PacketWorktableMemoryUpdate;
|
import forestry.factory.network.packets.PacketWorktableMemoryUpdate;
|
||||||
import forestry.factory.network.packets.PacketWorktableNEISelect;
|
|
||||||
import forestry.factory.network.packets.PacketWorktableRecipeUpdate;
|
import forestry.factory.network.packets.PacketWorktableRecipeUpdate;
|
||||||
|
|
||||||
public class PacketRegistryFactory extends PacketRegistry {
|
public class PacketRegistryFactory extends PacketRegistry {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerPackets() {
|
public void registerPackets() {
|
||||||
registerServerPacket(new PacketWorktableNEISelect());
|
registerServerPacket(new PacketNEISelect());
|
||||||
|
|
||||||
registerClientPacket(new PacketWorktableMemoryUpdate());
|
registerClientPacket(new PacketWorktableMemoryUpdate());
|
||||||
registerClientPacket(new PacketWorktableRecipeUpdate());
|
registerClientPacket(new PacketWorktableRecipeUpdate());
|
||||||
|
|||||||
@@ -19,27 +19,29 @@ import forestry.core.network.IForestryPacketServer;
|
|||||||
import forestry.core.network.PacketIdServer;
|
import forestry.core.network.PacketIdServer;
|
||||||
import forestry.core.network.packets.PacketNBT;
|
import forestry.core.network.packets.PacketNBT;
|
||||||
import forestry.core.recipes.nei.SetRecipeCommandHandler;
|
import forestry.core.recipes.nei.SetRecipeCommandHandler;
|
||||||
|
import forestry.factory.gui.ContainerCarpenter;
|
||||||
|
import forestry.factory.gui.ContainerFabricator;
|
||||||
import forestry.factory.gui.ContainerWorktable;
|
import forestry.factory.gui.ContainerWorktable;
|
||||||
|
|
||||||
public class PacketWorktableNEISelect extends PacketNBT implements IForestryPacketServer {
|
public class PacketNEISelect extends PacketNBT implements IForestryPacketServer {
|
||||||
|
|
||||||
private static final SetRecipeCommandHandler worktableNEISelectHandler = new SetRecipeCommandHandler(
|
private static final SetRecipeCommandHandler neiSelectHandler = new SetRecipeCommandHandler(
|
||||||
ContainerWorktable.class,
|
new Class[] { ContainerWorktable.class, ContainerCarpenter.class, ContainerFabricator.class },
|
||||||
SlotCraftMatrix.class);
|
SlotCraftMatrix.class);
|
||||||
|
|
||||||
public PacketWorktableNEISelect() {}
|
public PacketNEISelect() {}
|
||||||
|
|
||||||
public PacketWorktableNEISelect(NBTTagCompound nbttagcompound) {
|
public PacketNEISelect(NBTTagCompound nbttagcompound) {
|
||||||
super(nbttagcompound);
|
super(nbttagcompound);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPacketData(DataInputStreamForestry data, EntityPlayerMP player) throws IOException {
|
public void onPacketData(DataInputStreamForestry data, EntityPlayerMP player) throws IOException {
|
||||||
worktableNEISelectHandler.handle(getTagCompound(), player);
|
neiSelectHandler.handle(getTagCompound(), player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PacketIdServer getPacketId() {
|
public PacketIdServer getPacketId() {
|
||||||
return PacketIdServer.WORKTABLE_NEI_SELECT;
|
return PacketIdServer.NEI_SELECT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -11,6 +11,7 @@ package forestry.factory.recipes.nei;
|
|||||||
import java.awt.Point;
|
import java.awt.Point;
|
||||||
import java.awt.Rectangle;
|
import java.awt.Rectangle;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||||
@@ -24,13 +25,14 @@ import codechicken.nei.api.API;
|
|||||||
import forestry.api.recipes.ICarpenterRecipe;
|
import forestry.api.recipes.ICarpenterRecipe;
|
||||||
import forestry.api.recipes.IDescriptiveRecipe;
|
import forestry.api.recipes.IDescriptiveRecipe;
|
||||||
import forestry.api.recipes.RecipeManagers;
|
import forestry.api.recipes.RecipeManagers;
|
||||||
|
import forestry.core.recipes.nei.IGridRecipeHandler;
|
||||||
import forestry.core.recipes.nei.NEIUtils;
|
import forestry.core.recipes.nei.NEIUtils;
|
||||||
import forestry.core.recipes.nei.PositionedFluidTank;
|
import forestry.core.recipes.nei.PositionedFluidTank;
|
||||||
import forestry.core.recipes.nei.RecipeHandlerBase;
|
import forestry.core.recipes.nei.RecipeHandlerBase;
|
||||||
import forestry.core.utils.StringUtil;
|
import forestry.core.utils.StringUtil;
|
||||||
import forestry.factory.gui.GuiCarpenter;
|
import forestry.factory.gui.GuiCarpenter;
|
||||||
|
|
||||||
public class NEIHandlerCarpenter extends RecipeHandlerBase {
|
public class NEIHandlerCarpenter extends RecipeHandlerBase implements IGridRecipeHandler {
|
||||||
|
|
||||||
private static Class<? extends GuiContainer> guiClass;
|
private static Class<? extends GuiContainer> guiClass;
|
||||||
|
|
||||||
@@ -40,11 +42,35 @@ public class NEIHandlerCarpenter extends RecipeHandlerBase {
|
|||||||
API.setGuiOffset(guiClass, 5, 14);
|
API.setGuiOffset(guiClass, 5, 14);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getGridStartX() {
|
||||||
|
return 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getGridStartY() {
|
||||||
|
return 6;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getGridSpacing() {
|
||||||
|
return 18;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<PositionedStack> getGridStacks(int recipeIndex) {
|
||||||
|
if (arecipes.get(recipeIndex) instanceof CachedCarpenterRecipe recipe) {
|
||||||
|
return recipe.inputs.subList(0, recipe.ingredientCount);
|
||||||
|
}
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
public class CachedCarpenterRecipe extends CachedBaseRecipe {
|
public class CachedCarpenterRecipe extends CachedBaseRecipe {
|
||||||
|
|
||||||
public List<PositionedStack> inputs = new ArrayList<>();
|
public List<PositionedStack> inputs = new ArrayList<>();
|
||||||
public PositionedFluidTank tank;
|
public PositionedFluidTank tank;
|
||||||
public PositionedStack output;
|
public PositionedStack output;
|
||||||
|
public int ingredientCount;
|
||||||
|
|
||||||
public CachedCarpenterRecipe(ICarpenterRecipe recipe, boolean genPerms) {
|
public CachedCarpenterRecipe(ICarpenterRecipe recipe, boolean genPerms) {
|
||||||
IDescriptiveRecipe irecipe = recipe.getCraftingGridRecipe();
|
IDescriptiveRecipe irecipe = recipe.getCraftingGridRecipe();
|
||||||
@@ -78,6 +104,7 @@ public class NEIHandlerCarpenter extends RecipeHandlerBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setIngredients(int width, int height, Object[] items) {
|
public void setIngredients(int width, int height, Object[] items) {
|
||||||
|
ingredientCount = 0;
|
||||||
for (int x = 0; x < width; x++) {
|
for (int x = 0; x < width; x++) {
|
||||||
for (int y = 0; y < height; y++) {
|
for (int y = 0; y < height; y++) {
|
||||||
Object item = items[y * width + x];
|
Object item = items[y * width + x];
|
||||||
@@ -89,9 +116,14 @@ public class NEIHandlerCarpenter extends RecipeHandlerBase {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
PositionedStack stack = new PositionedStack(item, 5 + x * 18, 6 + y * 18, false);
|
PositionedStack stack = new PositionedStack(
|
||||||
|
item,
|
||||||
|
getGridStartX() + x * getGridSpacing(),
|
||||||
|
getGridStartY() + y * getGridSpacing(),
|
||||||
|
false);
|
||||||
stack.setMaxSize(1);
|
stack.setMaxSize(1);
|
||||||
this.inputs.add(stack);
|
this.inputs.add(stack);
|
||||||
|
ingredientCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ package forestry.factory.recipes.nei;
|
|||||||
import java.awt.Point;
|
import java.awt.Point;
|
||||||
import java.awt.Rectangle;
|
import java.awt.Rectangle;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -27,6 +28,7 @@ import codechicken.nei.recipe.GuiRecipe;
|
|||||||
import forestry.api.recipes.IFabricatorRecipe;
|
import forestry.api.recipes.IFabricatorRecipe;
|
||||||
import forestry.api.recipes.IFabricatorSmeltingRecipe;
|
import forestry.api.recipes.IFabricatorSmeltingRecipe;
|
||||||
import forestry.api.recipes.RecipeManagers;
|
import forestry.api.recipes.RecipeManagers;
|
||||||
|
import forestry.core.recipes.nei.IGridRecipeHandler;
|
||||||
import forestry.core.recipes.nei.NEIUtils;
|
import forestry.core.recipes.nei.NEIUtils;
|
||||||
import forestry.core.recipes.nei.PositionedFluidTank;
|
import forestry.core.recipes.nei.PositionedFluidTank;
|
||||||
import forestry.core.recipes.nei.RecipeHandlerBase;
|
import forestry.core.recipes.nei.RecipeHandlerBase;
|
||||||
@@ -34,7 +36,30 @@ import forestry.core.utils.StringUtil;
|
|||||||
import forestry.factory.gui.GuiFabricator;
|
import forestry.factory.gui.GuiFabricator;
|
||||||
import forestry.factory.recipes.FabricatorSmeltingRecipeManager;
|
import forestry.factory.recipes.FabricatorSmeltingRecipeManager;
|
||||||
|
|
||||||
public class NEIHandlerFabricator extends RecipeHandlerBase {
|
public class NEIHandlerFabricator extends RecipeHandlerBase implements IGridRecipeHandler {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getGridStartX() {
|
||||||
|
return 62;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getGridStartY() {
|
||||||
|
return 6;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getGridSpacing() {
|
||||||
|
return 18;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<PositionedStack> getGridStacks(int recipeIndex) {
|
||||||
|
if (arecipes.get(recipeIndex) instanceof CachedFabricatorRecipe recipe) {
|
||||||
|
return recipe.inputs.subList(0, recipe.ingredientCount);
|
||||||
|
}
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
public class CachedFabricatorRecipe extends CachedBaseRecipe {
|
public class CachedFabricatorRecipe extends CachedBaseRecipe {
|
||||||
|
|
||||||
@@ -42,6 +67,7 @@ public class NEIHandlerFabricator extends RecipeHandlerBase {
|
|||||||
public PositionedFluidTank tank;
|
public PositionedFluidTank tank;
|
||||||
public List<PositionedStack> inputs = new ArrayList<>();
|
public List<PositionedStack> inputs = new ArrayList<>();
|
||||||
public PositionedStack output;
|
public PositionedStack output;
|
||||||
|
public int ingredientCount;
|
||||||
|
|
||||||
public CachedFabricatorRecipe(IFabricatorRecipe recipe, boolean genPerms) {
|
public CachedFabricatorRecipe(IFabricatorRecipe recipe, boolean genPerms) {
|
||||||
if (recipe.getLiquid() != null) {
|
if (recipe.getLiquid() != null) {
|
||||||
@@ -78,6 +104,7 @@ public class NEIHandlerFabricator extends RecipeHandlerBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setIngredients(int width, int height, Object[] items) {
|
public void setIngredients(int width, int height, Object[] items) {
|
||||||
|
ingredientCount = 0;
|
||||||
for (int x = 0; x < width; x++) {
|
for (int x = 0; x < width; x++) {
|
||||||
for (int y = 0; y < height; y++) {
|
for (int y = 0; y < height; y++) {
|
||||||
Object item = items[y * width + x];
|
Object item = items[y * width + x];
|
||||||
@@ -89,9 +116,14 @@ public class NEIHandlerFabricator extends RecipeHandlerBase {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
PositionedStack stack = new PositionedStack(item, 62 + x * 18, 6 + y * 18, false);
|
PositionedStack stack = new PositionedStack(
|
||||||
|
item,
|
||||||
|
getGridStartX() + x * getGridSpacing(),
|
||||||
|
getGridStartY() + y * getGridSpacing(),
|
||||||
|
false);
|
||||||
stack.setMaxSize(1);
|
stack.setMaxSize(1);
|
||||||
this.inputs.add(stack);
|
this.inputs.add(stack);
|
||||||
|
ingredientCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,51 +72,54 @@ public class BlockMushroom extends BlockSapling implements IItemTyped {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateTick(World world, int i, int j, int k, Random random) {
|
public void updateTick(World world, int x, int y, int z, Random random) {
|
||||||
|
|
||||||
if (world.isRemote) {
|
if (world.isRemote) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int meta = world.getBlockMetadata(i, j, k);
|
final int meta = world.getBlockMetadata(x, y, z);
|
||||||
MushroomType type = getTypeFromMeta(meta);
|
final MushroomType type = getTypeFromMeta(meta);
|
||||||
int maturity = meta >> 2;
|
final int maturity = meta >> 2;
|
||||||
|
|
||||||
tickGermling(world, i, j, k, random, type, maturity);
|
tickGermling(world, x, y, z, random, type, maturity);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void tickGermling(World world, int i, int j, int k, Random random, MushroomType type, int maturity) {
|
private void tickGermling(World world, int x, int y, int z, Random random, MushroomType type, int maturity) {
|
||||||
|
|
||||||
int lightvalue = world.getBlockLightValue(i, j + 1, k);
|
|
||||||
|
|
||||||
if (random.nextInt(2) != 0) {
|
if (random.nextInt(2) != 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (maturity != 3) {
|
if (maturity != 3) {
|
||||||
maturity = 3;
|
maturity = 3;
|
||||||
int matX = maturity << 2;
|
final int matX = maturity << 2;
|
||||||
int meta = (matX | type.ordinal());
|
final int meta = (matX | type.ordinal());
|
||||||
world.setBlockMetadataWithNotify(i, j, k, meta, Constants.FLAG_BLOCK_SYNCH);
|
world.setBlockMetadataWithNotify(x, y, z, meta, Constants.FLAG_BLOCK_SYNCH);
|
||||||
} else if (lightvalue <= 7) {
|
} else {
|
||||||
func_149878_d(world, i, j, k, random);
|
if (world.checkChunksExist(x - 1, y, z - 1, x + 1, y, z + 1)) {
|
||||||
|
final int lightvalue = world.getBlockLightValue(x, y + 1, z);
|
||||||
|
if (lightvalue <= 7) {
|
||||||
|
func_149878_d(world, x, y, z, random);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void func_149878_d(World world, int i, int j, int k, Random random) {
|
public void func_149878_d(World world, int x, int y, int z, Random random) {
|
||||||
MushroomType type = getTypeFromMeta(world.getBlockMetadata(i, j, k));
|
MushroomType type = getTypeFromMeta(world.getBlockMetadata(x, y, z));
|
||||||
|
|
||||||
world.setBlockToAir(i, j, k);
|
world.setBlockToAir(x, y, z);
|
||||||
if (!generators[type.ordinal()].generate(world, random, i, j, k)) {
|
if (!generators[type.ordinal()].generate(world, random, x, y, z)) {
|
||||||
world.setBlock(i, j, k, this, type.ordinal(), 0);
|
world.setBlock(x, y, z, this, type.ordinal(), 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MushroomType getTypeFromMeta(int meta) {
|
public MushroomType getTypeFromMeta(int meta) {
|
||||||
meta %= MushroomType.values().length;
|
return switch (meta % 2) {
|
||||||
return MushroomType.values()[meta];
|
case 0 -> MushroomType.BROWN;
|
||||||
|
case 1 -> MushroomType.RED;
|
||||||
|
default -> throw new IllegalStateException("Unexpected value: " + meta);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ICONS */
|
/* ICONS */
|
||||||
@@ -135,15 +138,10 @@ public class BlockMushroom extends BlockSapling implements IItemTyped {
|
|||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
@Override
|
@Override
|
||||||
public IIcon getIcon(int side, int meta) {
|
public IIcon getIcon(int side, int meta) {
|
||||||
MushroomType type = getTypeFromMeta(meta);
|
final MushroomType type = getTypeFromMeta(meta);
|
||||||
|
return switch (type) {
|
||||||
switch (type) {
|
case BROWN -> Blocks.brown_mushroom.getIcon(side, meta);
|
||||||
case BROWN:
|
case RED -> Blocks.red_mushroom.getIcon(side, meta);
|
||||||
return Blocks.brown_mushroom.getIcon(side, meta);
|
};
|
||||||
case RED:
|
|
||||||
return Blocks.red_mushroom.getIcon(side, meta);
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
package forestry.farming.multiblock;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
|
import forestry.api.multiblock.IFarmFertilizerRegistry;
|
||||||
|
import forestry.core.utils.ItemStackUtil;
|
||||||
|
|
||||||
|
public class FarmFertilizerRegistry implements IFarmFertilizerRegistry {
|
||||||
|
|
||||||
|
// the current list isn't big enough to require a hash map, and is faster as a list.
|
||||||
|
private final List<ItemStack> fertilizers = new ArrayList<>(5);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<ItemStack> getFertilizers() {
|
||||||
|
return fertilizers;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addFertilizer(ItemStack itemstack) {
|
||||||
|
// maybe throw warn? but could also be nice to leave as no warn for easier/cleaner optional mod dependencies
|
||||||
|
if (itemstack == null || itemstack.getItem() == null || itemstack.stackSize <= 0) return;
|
||||||
|
fertilizers.add(itemstack);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeFertilizer(ItemStack itemstack) {
|
||||||
|
// maybe throw warn? but could also be nice to leave as no warn for easier/cleaner optional mod dependencies
|
||||||
|
if (itemstack == null || itemstack.getItem() == null) return;
|
||||||
|
fertilizers.removeIf(fert -> {
|
||||||
|
// in stack first so it wild card can be used for a wild-card clear.
|
||||||
|
return ItemStackUtil.isIdenticalItem(itemstack, fert);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isFertilizer(ItemStack itemstack) {
|
||||||
|
if (itemstack == null) return false;
|
||||||
|
for (ItemStack fert : this.fertilizers) {
|
||||||
|
// fert first to allow for wild card checks
|
||||||
|
if (ItemStackUtil.isIdenticalItem(fert, itemstack)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,7 +12,6 @@ import java.util.Deque;
|
|||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.inventory.IInventory;
|
import net.minecraft.inventory.IInventory;
|
||||||
import net.minecraft.item.Item;
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.fluids.Fluid;
|
import net.minecraftforge.fluids.Fluid;
|
||||||
@@ -21,6 +20,7 @@ import forestry.api.farming.FarmDirection;
|
|||||||
import forestry.api.farming.IFarmInventory;
|
import forestry.api.farming.IFarmInventory;
|
||||||
import forestry.api.farming.IFarmLogic;
|
import forestry.api.farming.IFarmLogic;
|
||||||
import forestry.api.farming.IFarmable;
|
import forestry.api.farming.IFarmable;
|
||||||
|
import forestry.api.multiblock.MultiblockManager;
|
||||||
import forestry.core.fluids.FluidHelper;
|
import forestry.core.fluids.FluidHelper;
|
||||||
import forestry.core.fluids.TankManager;
|
import forestry.core.fluids.TankManager;
|
||||||
import forestry.core.inventory.InventoryAdapterRestricted;
|
import forestry.core.inventory.InventoryAdapterRestricted;
|
||||||
@@ -28,9 +28,6 @@ import forestry.core.inventory.wrappers.InventoryMapper;
|
|||||||
import forestry.core.utils.InventoryUtil;
|
import forestry.core.utils.InventoryUtil;
|
||||||
import forestry.core.utils.PlayerUtil;
|
import forestry.core.utils.PlayerUtil;
|
||||||
import forestry.core.utils.SlotUtil;
|
import forestry.core.utils.SlotUtil;
|
||||||
import forestry.plugins.PluginCore;
|
|
||||||
import forestry.plugins.PluginManager;
|
|
||||||
import ic2.api.item.IC2Items;
|
|
||||||
|
|
||||||
public class InventoryFarm extends InventoryAdapterRestricted implements IFarmInventory {
|
public class InventoryFarm extends InventoryAdapterRestricted implements IFarmInventory {
|
||||||
|
|
||||||
@@ -134,18 +131,8 @@ public class InventoryFarm extends InventoryAdapterRestricted implements IFarmIn
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean acceptsAsFertilizer(ItemStack itemstack) {
|
public boolean acceptsAsFertilizer(ItemStack itemstack) {
|
||||||
if (itemstack == null) {
|
// check if it's a fertilizer
|
||||||
return false;
|
return MultiblockManager.farmFertilizerRegistry.isFertilizer(itemstack);
|
||||||
}
|
|
||||||
Item item = itemstack.getItem();
|
|
||||||
if (PluginManager.Module.INDUSTRIALCRAFT.isEnabled()) {
|
|
||||||
Item ic2fert = IC2Items.getItem("fertilizer").getItem();
|
|
||||||
if (ic2fert == item) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return PluginCore.items.fertilizerCompound == item;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ package forestry.food.items;
|
|||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
|
import forestry.core.inventory.ItemLocation;
|
||||||
import forestry.core.items.ItemWithGui;
|
import forestry.core.items.ItemWithGui;
|
||||||
import forestry.food.gui.ContainerInfuser;
|
import forestry.food.gui.ContainerInfuser;
|
||||||
import forestry.food.gui.GuiInfuser;
|
import forestry.food.gui.GuiInfuser;
|
||||||
@@ -19,12 +20,12 @@ import forestry.food.inventory.ItemInventoryInfuser;
|
|||||||
public class ItemInfuser extends ItemWithGui {
|
public class ItemInfuser extends ItemWithGui {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getGui(EntityPlayer player, ItemStack heldItem, int data) {
|
public Object getGui(EntityPlayer player, ItemStack heldItem, int data, ItemLocation loc) {
|
||||||
return new GuiInfuser(player.inventory, new ItemInventoryInfuser(player, heldItem));
|
return new GuiInfuser(player.inventory, new ItemInventoryInfuser(player, heldItem));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getContainer(EntityPlayer player, ItemStack heldItem, int data) {
|
public Object getContainer(EntityPlayer player, ItemStack heldItem, int data, ItemLocation loc) {
|
||||||
return new ContainerInfuser(player.inventory, new ItemInventoryInfuser(player, heldItem));
|
return new ContainerInfuser(player.inventory, new ItemInventoryInfuser(player, heldItem));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -307,8 +307,7 @@ public class EntityButterfly extends EntityCreature implements IEntityButterfly
|
|||||||
size = genome.getSize();
|
size = genome.getSize();
|
||||||
setSize(size, 0.4f);
|
setSize(size, 0.4f);
|
||||||
species = genome.getPrimary();
|
species = genome.getPrimary();
|
||||||
|
if (worldObj != null && !worldObj.isRemote) {
|
||||||
if (!worldObj.isRemote) {
|
|
||||||
dataWatcher.updateObject(DATAWATCHER_ID_SIZE, (int) (size * 100));
|
dataWatcher.updateObject(DATAWATCHER_ID_SIZE, (int) (size * 100));
|
||||||
dataWatcher.updateObject(DATAWATCHER_ID_SPECIES, species.getUID());
|
dataWatcher.updateObject(DATAWATCHER_ID_SPECIES, species.getUID());
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import net.minecraft.item.ItemStack;
|
|||||||
|
|
||||||
import forestry.api.core.Tabs;
|
import forestry.api.core.Tabs;
|
||||||
import forestry.core.gui.ContainerAlyzer;
|
import forestry.core.gui.ContainerAlyzer;
|
||||||
|
import forestry.core.inventory.ItemLocation;
|
||||||
import forestry.core.items.ItemWithGui;
|
import forestry.core.items.ItemWithGui;
|
||||||
import forestry.lepidopterology.gui.GuiFlutterlyzer;
|
import forestry.lepidopterology.gui.GuiFlutterlyzer;
|
||||||
import forestry.lepidopterology.inventory.ItemInventoryFlutterlyzer;
|
import forestry.lepidopterology.inventory.ItemInventoryFlutterlyzer;
|
||||||
@@ -24,12 +25,12 @@ public class ItemFlutterlyzer extends ItemWithGui {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getGui(EntityPlayer player, ItemStack heldItem, int data) {
|
public Object getGui(EntityPlayer player, ItemStack heldItem, int data, ItemLocation loc) {
|
||||||
return new GuiFlutterlyzer(player, new ItemInventoryFlutterlyzer(player, heldItem));
|
return new GuiFlutterlyzer(player, new ItemInventoryFlutterlyzer(player, heldItem));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getContainer(EntityPlayer player, ItemStack heldItem, int data) {
|
public Object getContainer(EntityPlayer player, ItemStack heldItem, int data, ItemLocation loc) {
|
||||||
return new ContainerAlyzer(new ItemInventoryFlutterlyzer(player, heldItem), player);
|
return new ContainerAlyzer(new ItemInventoryFlutterlyzer(player, heldItem), player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -25,13 +25,8 @@ import forestry.lepidopterology.entities.EntityButterfly;
|
|||||||
|
|
||||||
public class RenderButterflyItem implements IItemRenderer {
|
public class RenderButterflyItem implements IItemRenderer {
|
||||||
|
|
||||||
private final ModelButterfly model;
|
|
||||||
private EntityButterfly entity;
|
private EntityButterfly entity;
|
||||||
|
|
||||||
public RenderButterflyItem() {
|
|
||||||
model = new ModelButterfly();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static float getWingYaw(IButterfly butterfly) {
|
private static float getWingYaw(IButterfly butterfly) {
|
||||||
float wingYaw = 1f;
|
float wingYaw = 1f;
|
||||||
|
|
||||||
@@ -72,18 +67,12 @@ public class RenderButterflyItem implements IItemRenderer {
|
|||||||
|
|
||||||
private IButterfly initButterfly(ItemStack item) {
|
private IButterfly initButterfly(ItemStack item) {
|
||||||
IButterfly butterfly = ButterflyManager.butterflyRoot.getMember(item);
|
IButterfly butterfly = ButterflyManager.butterflyRoot.getMember(item);
|
||||||
if (butterfly == null) {
|
|
||||||
butterfly = ButterflyManager.butterflyRoot
|
|
||||||
.templateAsIndividual(ButterflyManager.butterflyRoot.getDefaultTemplate());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (entity == null) {
|
if (entity == null) {
|
||||||
entity = new EntityButterfly(Proxies.common.getRenderWorld(), butterfly, 0, 0, 0);
|
entity = new EntityButterfly(null, butterfly, 0, 0, 0);
|
||||||
} else {
|
} else {
|
||||||
entity.setIndividual(butterfly);
|
entity.setIndividual(butterfly);
|
||||||
}
|
}
|
||||||
|
return entity.getButterfly();
|
||||||
return butterfly;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void renderButterflyItem(IButterfly butterfly, float translateX, float translateY, float translateZ) {
|
private void renderButterflyItem(IButterfly butterfly, float translateX, float translateY, float translateZ) {
|
||||||
@@ -111,7 +100,12 @@ public class RenderButterflyItem implements IItemRenderer {
|
|||||||
entity.rotationPitch = 0;
|
entity.rotationPitch = 0;
|
||||||
entity.rotationYawHead = entity.rotationYaw;
|
entity.rotationYawHead = entity.rotationYaw;
|
||||||
|
|
||||||
RenderManager.instance.renderEntityWithPosYaw(entity, 0.0D, 0.0D, 0.0D, 0.0F, 1.0f);
|
try {
|
||||||
|
entity.setWorld(Proxies.common.getRenderWorld());
|
||||||
|
RenderManager.instance.renderEntityWithPosYaw(entity, 0.0D, 0.0D, 0.0D, 0.0F, 1.0f);
|
||||||
|
} finally {
|
||||||
|
entity.setWorld(null);
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
GL11.glTranslatef(translateX, translateY, translateZ);
|
GL11.glTranslatef(translateX, translateY, translateZ);
|
||||||
@@ -119,14 +113,19 @@ public class RenderButterflyItem implements IItemRenderer {
|
|||||||
GL11.glScalef(-2.0f, 2.0f, 2.0f);
|
GL11.glScalef(-2.0f, 2.0f, 2.0f);
|
||||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||||
GL11.glRotatef(-135.0F, 0.0F, 1.0F, 0.0F);
|
GL11.glRotatef(-135.0F, 0.0F, 1.0F, 0.0F);
|
||||||
GL11.glRotatef(-((float) Math.atan((double) (pitch / 40.0F))) * 20.0F, 1.0F, 0.0F, 0.0F);
|
GL11.glRotatef(-((float) Math.atan(pitch / 40.0F)) * 20.0F, 1.0F, 0.0F, 0.0F);
|
||||||
|
|
||||||
entity.renderYawOffset = (float) Math.atan((double) (yaw / 40.0F)) * 20.0F;
|
entity.renderYawOffset = (float) Math.atan(yaw / 40.0F) * 20.0F;
|
||||||
entity.rotationYaw = (float) Math.atan((double) (yaw / 40.0F)) * 40.0F;
|
entity.rotationYaw = (float) Math.atan(yaw / 40.0F) * 40.0F;
|
||||||
entity.rotationPitch = -((float) Math.atan((double) (pitch / 40.0F))) * 20.0F;
|
entity.rotationPitch = -((float) Math.atan(pitch / 40.0F)) * 20.0F;
|
||||||
entity.rotationYawHead = entity.rotationYaw;
|
entity.rotationYawHead = entity.rotationYaw;
|
||||||
|
|
||||||
RenderManager.instance.renderEntityWithPosYaw(entity, 0.0D, 0.0D, 0.0D, 0.0F, getWingYaw(butterfly));
|
try {
|
||||||
|
entity.setWorld(Proxies.common.getRenderWorld());
|
||||||
|
RenderManager.instance.renderEntityWithPosYaw(entity, 0.0D, 0.0D, 0.0D, 0.0F, getWingYaw(butterfly));
|
||||||
|
} finally {
|
||||||
|
entity.setWorld(null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GL11.glPopMatrix();
|
GL11.glPopMatrix();
|
||||||
@@ -160,8 +159,12 @@ public class RenderButterflyItem implements IItemRenderer {
|
|||||||
entity.rotationPitch = 0;
|
entity.rotationPitch = 0;
|
||||||
entity.rotationYawHead = entity.rotationYaw;
|
entity.rotationYawHead = entity.rotationYaw;
|
||||||
|
|
||||||
RenderManager.instance.renderEntityWithPosYaw(entity, 0.0D, 0.0D, 0.0D, 0.0F, getWingYaw(butterfly));
|
try {
|
||||||
|
entity.setWorld(Proxies.common.getRenderWorld());
|
||||||
|
RenderManager.instance.renderEntityWithPosYaw(entity, 0.0D, 0.0D, 0.0D, 0.0F, getWingYaw(butterfly));
|
||||||
|
} finally {
|
||||||
|
entity.setWorld(null);
|
||||||
|
}
|
||||||
GL11.glPopMatrix();
|
GL11.glPopMatrix();
|
||||||
RenderHelper.disableStandardItemLighting();
|
RenderHelper.disableStandardItemLighting();
|
||||||
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
|
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
|
||||||
@@ -173,39 +176,27 @@ public class RenderButterflyItem implements IItemRenderer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
|
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
|
||||||
switch (type) {
|
return switch (type) {
|
||||||
case ENTITY:
|
case ENTITY, EQUIPPED, EQUIPPED_FIRST_PERSON, INVENTORY -> true;
|
||||||
case EQUIPPED:
|
default -> false;
|
||||||
case EQUIPPED_FIRST_PERSON:
|
};
|
||||||
case INVENTORY:
|
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
|
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
|
||||||
switch (helper) {
|
return switch (helper) {
|
||||||
case ENTITY_BOBBING:
|
case ENTITY_BOBBING, ENTITY_ROTATION -> false;
|
||||||
case ENTITY_ROTATION:
|
default -> true;
|
||||||
return false;
|
};
|
||||||
default:
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
|
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case ENTITY:
|
case ENTITY:
|
||||||
renderButterflyItem(initButterfly(item), 0f, -0.5f, 0f);
|
renderButterflyItem(initButterfly(item), 0f, -0.5f, 0f);
|
||||||
break;
|
break;
|
||||||
case EQUIPPED:
|
case EQUIPPED, EQUIPPED_FIRST_PERSON:
|
||||||
renderButterflyItem(initButterfly(item), 0.5f, -0.9f, 1.0f);
|
|
||||||
break;
|
|
||||||
case EQUIPPED_FIRST_PERSON:
|
|
||||||
renderButterflyItem(initButterfly(item), 0.5f, -0.9f, 1.0f);
|
renderButterflyItem(initButterfly(item), 0.5f, -0.9f, 1.0f);
|
||||||
break;
|
break;
|
||||||
case INVENTORY:
|
case INVENTORY:
|
||||||
|
|||||||
@@ -25,16 +25,22 @@ import forestry.plugins.PluginMail;
|
|||||||
public class LetterProperties {
|
public class LetterProperties {
|
||||||
|
|
||||||
private enum State {
|
private enum State {
|
||||||
|
|
||||||
FRESH,
|
FRESH,
|
||||||
STAMPED,
|
STAMPED,
|
||||||
OPENED,
|
OPENED,
|
||||||
EMPTIED
|
EMPTIED;
|
||||||
|
|
||||||
|
public static final State[] VALUES = values();
|
||||||
}
|
}
|
||||||
|
|
||||||
private enum Size {
|
private enum Size {
|
||||||
|
|
||||||
EMPTY,
|
EMPTY,
|
||||||
SMALL,
|
SMALL,
|
||||||
BIG
|
BIG;
|
||||||
|
|
||||||
|
public static final Size[] VALUES = values();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ItemStack createStampedLetterStack(ILetter letter) {
|
public static ItemStack createStampedLetterStack(ILetter letter) {
|
||||||
@@ -98,8 +104,8 @@ public class LetterProperties {
|
|||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static void getSubItems(Item item, CreativeTabs tab, @SuppressWarnings("rawtypes") List list) {
|
public static void getSubItems(Item item, CreativeTabs tab, @SuppressWarnings("rawtypes") List list) {
|
||||||
for (State state : State.values()) {
|
for (State state : State.VALUES) {
|
||||||
for (Size size : Size.values()) {
|
for (Size size : Size.VALUES) {
|
||||||
int meta = encodeMeta(state, size);
|
int meta = encodeMeta(state, size);
|
||||||
ItemStack letter = new ItemStack(item, 1, meta);
|
ItemStack letter = new ItemStack(item, 1, meta);
|
||||||
list.add(letter);
|
list.add(letter);
|
||||||
@@ -117,7 +123,7 @@ public class LetterProperties {
|
|||||||
|
|
||||||
private static State getState(int meta) {
|
private static State getState(int meta) {
|
||||||
int ordinal = meta & 0x0f;
|
int ordinal = meta & 0x0f;
|
||||||
State[] values = State.values();
|
State[] values = State.VALUES;
|
||||||
if (ordinal >= values.length) {
|
if (ordinal >= values.length) {
|
||||||
ordinal = 0;
|
ordinal = 0;
|
||||||
}
|
}
|
||||||
@@ -126,7 +132,7 @@ public class LetterProperties {
|
|||||||
|
|
||||||
private static Size getSize(int meta) {
|
private static Size getSize(int meta) {
|
||||||
int ordinal = meta >> 4;
|
int ordinal = meta >> 4;
|
||||||
Size[] values = Size.values();
|
Size[] values = Size.VALUES;
|
||||||
if (ordinal >= values.length) {
|
if (ordinal >= values.length) {
|
||||||
ordinal = 0;
|
ordinal = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,53 @@
|
|||||||
|
package forestry.mail;
|
||||||
|
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.world.WorldSavedData;
|
||||||
|
|
||||||
|
import forestry.core.utils.PosteaCompat;
|
||||||
|
|
||||||
|
/// A mail storage in the world's `MapStorage`, with saved item stacks migrated through Postea under the storage id
|
||||||
|
/// `forestry:<mapName>`.
|
||||||
|
///
|
||||||
|
/// `MapStorage` swallows load exceptions and keeps the half-read storage. A storage whose migration failed is never
|
||||||
|
/// saved. [PostRegistry] rethrows the failure instead of serving the storage.
|
||||||
|
public abstract class MailSavedData extends WorldSavedData {
|
||||||
|
|
||||||
|
private RuntimeException loadFailure;
|
||||||
|
private NBTTagCompound savedStamps;
|
||||||
|
|
||||||
|
protected MailSavedData(String mapName) {
|
||||||
|
super(mapName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final void readFromNBT(NBTTagCompound root) {
|
||||||
|
try {
|
||||||
|
PosteaCompat.transform("forestry:" + mapName, root);
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
loadFailure = e;
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
savedStamps = PosteaCompat.savedStamps(root);
|
||||||
|
readData(root);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final void writeToNBT(NBTTagCompound root) {
|
||||||
|
writeData(root);
|
||||||
|
PosteaCompat.stamp(root, savedStamps);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isDirty() {
|
||||||
|
return loadFailure == null && super.isDirty();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Throws the exception that failed this storage's migration, if one did.
|
||||||
|
void throwIfLoadFailed() {
|
||||||
|
if (loadFailure != null) throw loadFailure;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract void readData(NBTTagCompound root);
|
||||||
|
|
||||||
|
protected abstract void writeData(NBTTagCompound root);
|
||||||
|
}
|
||||||
@@ -12,7 +12,6 @@ import net.minecraft.entity.player.EntityPlayer;
|
|||||||
import net.minecraft.inventory.IInventory;
|
import net.minecraft.inventory.IInventory;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.world.WorldSavedData;
|
|
||||||
|
|
||||||
import forestry.api.mail.ILetter;
|
import forestry.api.mail.ILetter;
|
||||||
import forestry.api.mail.IMailAddress;
|
import forestry.api.mail.IMailAddress;
|
||||||
@@ -20,7 +19,7 @@ import forestry.api.mail.PostManager;
|
|||||||
import forestry.core.inventory.InventoryAdapter;
|
import forestry.core.inventory.InventoryAdapter;
|
||||||
import forestry.core.utils.InventoryUtil;
|
import forestry.core.utils.InventoryUtil;
|
||||||
|
|
||||||
public class POBox extends WorldSavedData implements IInventory {
|
public class POBox extends MailSavedData implements IInventory {
|
||||||
|
|
||||||
public static final String SAVE_NAME = "POBox_";
|
public static final String SAVE_NAME = "POBox_";
|
||||||
public static final short SLOT_SIZE = 84;
|
public static final short SLOT_SIZE = 84;
|
||||||
@@ -41,7 +40,7 @@ public class POBox extends WorldSavedData implements IInventory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
protected void readData(NBTTagCompound nbttagcompound) {
|
||||||
if (nbttagcompound.hasKey("address")) {
|
if (nbttagcompound.hasKey("address")) {
|
||||||
this.address = MailAddress.loadFromNBT(nbttagcompound.getCompoundTag("address"));
|
this.address = MailAddress.loadFromNBT(nbttagcompound.getCompoundTag("address"));
|
||||||
}
|
}
|
||||||
@@ -49,7 +48,7 @@ public class POBox extends WorldSavedData implements IInventory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
protected void writeData(NBTTagCompound nbttagcompound) {
|
||||||
if (this.address != null) {
|
if (this.address != null) {
|
||||||
NBTTagCompound nbt = new NBTTagCompound();
|
NBTTagCompound nbt = new NBTTagCompound();
|
||||||
this.address.writeToNBT(nbt);
|
this.address.writeToNBT(nbt);
|
||||||
|
|||||||
@@ -158,6 +158,8 @@ public class PostOffice extends WorldSavedData implements IPostOffice {
|
|||||||
return EnumDeliveryState.NOT_MAILABLE;
|
return EnumDeliveryState.NOT_MAILABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
loadDeliveryTargets(world, letter, doLodge);
|
||||||
|
|
||||||
IPostalState state = EnumDeliveryState.NOT_MAILABLE;
|
IPostalState state = EnumDeliveryState.NOT_MAILABLE;
|
||||||
for (IMailAddress address : letter.getRecipients()) {
|
for (IMailAddress address : letter.getRecipients()) {
|
||||||
IPostalCarrier carrier = PostManager.postRegistry.getCarrier(address.getType());
|
IPostalCarrier carrier = PostManager.postRegistry.getCarrier(address.getType());
|
||||||
@@ -180,6 +182,16 @@ public class PostOffice extends WorldSavedData implements IPostOffice {
|
|||||||
return EnumDeliveryState.OK;
|
return EnumDeliveryState.OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Loads every storage a delivery of `letter` writes to, so a storage whose migration failed throws before the
|
||||||
|
/// delivery changes anything.
|
||||||
|
private static void loadDeliveryTargets(World world, ILetter letter, boolean doLodge) {
|
||||||
|
for (IMailAddress recipient : letter.getRecipients()) {
|
||||||
|
if (PostRegistry.loadMailStorage(world, recipient) instanceof TradeStation trade) {
|
||||||
|
trade.loadTradeTargets(world, letter, doLodge);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void collectPostage(ItemStack[] stamps) {
|
public void collectPostage(ItemStack[] stamps) {
|
||||||
for (ItemStack stamp : stamps) {
|
for (ItemStack stamp : stamps) {
|
||||||
|
|||||||
@@ -57,11 +57,20 @@ public class PostRegistry implements IPostRegistry {
|
|||||||
|
|
||||||
POBox pobox = (POBox) world.loadItemData(POBox.class, POBox.SAVE_NAME + address);
|
POBox pobox = (POBox) world.loadItemData(POBox.class, POBox.SAVE_NAME + address);
|
||||||
if (pobox != null) {
|
if (pobox != null) {
|
||||||
|
pobox.throwIfLoadFailed();
|
||||||
cachedPOBoxes.put(address, pobox);
|
cachedPOBoxes.put(address, pobox);
|
||||||
}
|
}
|
||||||
return pobox;
|
return pobox;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The post box or trade station at `address`, or null when none exists or the trade station is invalid.
|
||||||
|
static MailSavedData loadMailStorage(World world, IMailAddress address) {
|
||||||
|
if (address == null) return null;
|
||||||
|
if (address.isPlayer()) return getPOBox(world, address);
|
||||||
|
if (address.isTrader()) return (TradeStation) PostManager.postRegistry.getTradeStation(world, address);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public static POBox getOrCreatePOBox(World world, IMailAddress address) {
|
public static POBox getOrCreatePOBox(World world, IMailAddress address) {
|
||||||
POBox pobox = getPOBox(world, address);
|
POBox pobox = getPOBox(world, address);
|
||||||
|
|
||||||
@@ -111,6 +120,9 @@ public class PostRegistry implements IPostRegistry {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TradeStation trade = (TradeStation) world.loadItemData(TradeStation.class, TradeStation.SAVE_NAME + address);
|
TradeStation trade = (TradeStation) world.loadItemData(TradeStation.class, TradeStation.SAVE_NAME + address);
|
||||||
|
if (trade != null) {
|
||||||
|
trade.throwIfLoadFailed();
|
||||||
|
}
|
||||||
|
|
||||||
// Only existing and valid mail orders are returned
|
// Only existing and valid mail orders are returned
|
||||||
if (trade != null && trade.isValid()) {
|
if (trade != null && trade.isValid()) {
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ import net.minecraft.item.ItemStack;
|
|||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.nbt.NBTUtil;
|
import net.minecraft.nbt.NBTUtil;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.WorldSavedData;
|
|
||||||
|
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
|
|
||||||
@@ -37,7 +36,7 @@ import forestry.mail.inventory.InventoryTradeStation;
|
|||||||
import forestry.mail.items.EnumStampDefinition;
|
import forestry.mail.items.EnumStampDefinition;
|
||||||
import forestry.plugins.PluginMail;
|
import forestry.plugins.PluginMail;
|
||||||
|
|
||||||
public class TradeStation extends WorldSavedData implements ITradeStation, IInventoryAdapter {
|
public class TradeStation extends MailSavedData implements ITradeStation, IInventoryAdapter {
|
||||||
|
|
||||||
public static final String SAVE_NAME = "TradePO_";
|
public static final String SAVE_NAME = "TradePO_";
|
||||||
public static final short SLOT_TRADEGOOD = 0;
|
public static final short SLOT_TRADEGOOD = 0;
|
||||||
@@ -85,7 +84,7 @@ public class TradeStation extends WorldSavedData implements ITradeStation, IInve
|
|||||||
|
|
||||||
// / SAVING & LOADING
|
// / SAVING & LOADING
|
||||||
@Override
|
@Override
|
||||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
protected void readData(NBTTagCompound nbttagcompound) {
|
||||||
if (nbttagcompound.hasKey("owner")) {
|
if (nbttagcompound.hasKey("owner")) {
|
||||||
owner = NBTUtil.func_152459_a(nbttagcompound.getCompoundTag("owner"));
|
owner = NBTUtil.func_152459_a(nbttagcompound.getCompoundTag("owner"));
|
||||||
}
|
}
|
||||||
@@ -100,7 +99,7 @@ public class TradeStation extends WorldSavedData implements ITradeStation, IInve
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
protected void writeData(NBTTagCompound nbttagcompound) {
|
||||||
if (owner != null) {
|
if (owner != null) {
|
||||||
NBTTagCompound nbt = new NBTTagCompound();
|
NBTTagCompound nbt = new NBTTagCompound();
|
||||||
NBTUtil.func_152460_a(nbt, owner);
|
NBTUtil.func_152460_a(nbt, owner);
|
||||||
@@ -172,9 +171,10 @@ public class TradeStation extends WorldSavedData implements ITradeStation, IInve
|
|||||||
@Override
|
@Override
|
||||||
public IPostalState handleLetter(World world, IMailAddress recipient, ItemStack letterstack, boolean doLodge) {
|
public IPostalState handleLetter(World world, IMailAddress recipient, ItemStack letterstack, boolean doLodge) {
|
||||||
|
|
||||||
boolean sendOwnerNotice = doLodge && owner != null;
|
boolean sendOwnerNotice = sendsOwnerNotice(doLodge);
|
||||||
|
|
||||||
ILetter letter = PostManager.postRegistry.getLetter(letterstack);
|
ILetter letter = PostManager.postRegistry.getLetter(letterstack);
|
||||||
|
loadTradeTargets(world, letter, doLodge);
|
||||||
|
|
||||||
if (!isVirtual() && !hasPaper(sendOwnerNotice ? 2 : 1)) {
|
if (!isVirtual() && !hasPaper(sendOwnerNotice ? 2 : 1)) {
|
||||||
return EnumStationState.INSUFFICIENT_PAPER;
|
return EnumStationState.INSUFFICIENT_PAPER;
|
||||||
@@ -310,6 +310,19 @@ public class TradeStation extends WorldSavedData implements ITradeStation, IInve
|
|||||||
return EnumDeliveryState.OK;
|
return EnumDeliveryState.OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Loads the storages a trade with `letter` delivers to: the sender's, and the owner's post box when the trade
|
||||||
|
/// sends an owner notice.
|
||||||
|
void loadTradeTargets(World world, ILetter letter, boolean doLodge) {
|
||||||
|
PostRegistry.loadMailStorage(world, letter.getSender());
|
||||||
|
if (sendsOwnerNotice(doLodge)) {
|
||||||
|
PostRegistry.getPOBox(world, new MailAddress(owner));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean sendsOwnerNotice(boolean doLodge) {
|
||||||
|
return doLodge && owner != null;
|
||||||
|
}
|
||||||
|
|
||||||
/* TRADE LOGIC */
|
/* TRADE LOGIC */
|
||||||
private int countFillableOrders(int max, ItemStack tradegood) {
|
private int countFillableOrders(int max, ItemStack tradegood) {
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ package forestry.mail.items;
|
|||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
|
import forestry.core.inventory.ItemLocation;
|
||||||
import forestry.core.items.ItemWithGui;
|
import forestry.core.items.ItemWithGui;
|
||||||
import forestry.mail.gui.ContainerCatalogue;
|
import forestry.mail.gui.ContainerCatalogue;
|
||||||
import forestry.mail.gui.GuiCatalogue;
|
import forestry.mail.gui.GuiCatalogue;
|
||||||
@@ -18,12 +19,12 @@ import forestry.mail.gui.GuiCatalogue;
|
|||||||
public class ItemCatalogue extends ItemWithGui {
|
public class ItemCatalogue extends ItemWithGui {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getGui(EntityPlayer player, ItemStack heldItem, int data) {
|
public Object getGui(EntityPlayer player, ItemStack heldItem, int data, ItemLocation loc) {
|
||||||
return new GuiCatalogue(player);
|
return new GuiCatalogue(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getContainer(EntityPlayer player, ItemStack heldItem, int data) {
|
public Object getContainer(EntityPlayer player, ItemStack heldItem, int data, ItemLocation loc) {
|
||||||
return new ContainerCatalogue(player);
|
return new ContainerCatalogue(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -23,6 +23,7 @@ import net.minecraft.world.World;
|
|||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
import forestry.api.mail.ILetter;
|
import forestry.api.mail.ILetter;
|
||||||
|
import forestry.core.inventory.ItemLocation;
|
||||||
import forestry.core.items.ItemWithGui;
|
import forestry.core.items.ItemWithGui;
|
||||||
import forestry.core.utils.StringUtil;
|
import forestry.core.utils.StringUtil;
|
||||||
import forestry.mail.Letter;
|
import forestry.mail.Letter;
|
||||||
@@ -87,12 +88,12 @@ public class ItemLetter extends ItemWithGui {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getGui(EntityPlayer player, ItemStack heldItem, int data) {
|
public Object getGui(EntityPlayer player, ItemStack heldItem, int data, ItemLocation loc) {
|
||||||
return new GuiLetter(player, new ItemInventoryLetter(player, heldItem));
|
return new GuiLetter(player, new ItemInventoryLetter(player, heldItem));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getContainer(EntityPlayer player, ItemStack heldItem, int data) {
|
public Object getContainer(EntityPlayer player, ItemStack heldItem, int data, ItemLocation loc) {
|
||||||
return new ContainerLetter(player, new ItemInventoryLetter(player, heldItem));
|
return new ContainerLetter(player, new ItemInventoryLetter(player, heldItem));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -55,6 +55,7 @@ import forestry.core.recipes.RecipeUtil;
|
|||||||
import forestry.core.tiles.MachineDefinition;
|
import forestry.core.tiles.MachineDefinition;
|
||||||
import forestry.core.utils.ClimateUtil;
|
import forestry.core.utils.ClimateUtil;
|
||||||
import forestry.core.utils.ForestryModEnvWarningCallable;
|
import forestry.core.utils.ForestryModEnvWarningCallable;
|
||||||
|
import forestry.farming.multiblock.FarmFertilizerRegistry;
|
||||||
|
|
||||||
@Plugin(
|
@Plugin(
|
||||||
pluginID = "Core",
|
pluginID = "Core",
|
||||||
@@ -85,6 +86,7 @@ public class PluginCore extends ForestryPlugin {
|
|||||||
AlleleHelper.instance = new AlleleHelper();
|
AlleleHelper.instance = new AlleleHelper();
|
||||||
|
|
||||||
MultiblockManager.logicFactory = new MultiblockLogicFactory();
|
MultiblockManager.logicFactory = new MultiblockLogicFactory();
|
||||||
|
MultiblockManager.farmFertilizerRegistry = new FarmFertilizerRegistry();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import net.minecraft.init.Items;
|
|||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraftforge.oredict.OreDictionary;
|
||||||
|
|
||||||
import cpw.mods.fml.common.SidedProxy;
|
import cpw.mods.fml.common.SidedProxy;
|
||||||
import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage;
|
import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage;
|
||||||
@@ -30,6 +31,7 @@ import forestry.api.circuits.CircuitSocketType;
|
|||||||
import forestry.api.circuits.ICircuitLayout;
|
import forestry.api.circuits.ICircuitLayout;
|
||||||
import forestry.api.farming.Farmables;
|
import forestry.api.farming.Farmables;
|
||||||
import forestry.api.farming.IFarmable;
|
import forestry.api.farming.IFarmable;
|
||||||
|
import forestry.api.multiblock.MultiblockManager;
|
||||||
import forestry.core.circuits.Circuit;
|
import forestry.core.circuits.Circuit;
|
||||||
import forestry.core.circuits.CircuitLayout;
|
import forestry.core.circuits.CircuitLayout;
|
||||||
import forestry.core.config.Constants;
|
import forestry.core.config.Constants;
|
||||||
@@ -402,5 +404,8 @@ public class PluginFarming extends ForestryPlugin {
|
|||||||
layoutManual,
|
layoutManual,
|
||||||
PluginCore.items.tubes.get(EnumElectronTube.LAPIS, 1),
|
PluginCore.items.tubes.get(EnumElectronTube.LAPIS, 1),
|
||||||
Circuit.farmCocoaManual);
|
Circuit.farmCocoaManual);
|
||||||
|
|
||||||
|
MultiblockManager.farmFertilizerRegistry
|
||||||
|
.addFertilizer(new ItemStack(PluginCore.items.fertilizerCompound, 1, OreDictionary.WILDCARD_VALUE));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -32,6 +32,7 @@ import forestry.api.core.ForestryAPI;
|
|||||||
import forestry.api.farming.Farmables;
|
import forestry.api.farming.Farmables;
|
||||||
import forestry.api.fuels.EngineBronzeFuel;
|
import forestry.api.fuels.EngineBronzeFuel;
|
||||||
import forestry.api.fuels.FuelManager;
|
import forestry.api.fuels.FuelManager;
|
||||||
|
import forestry.api.multiblock.MultiblockManager;
|
||||||
import forestry.api.recipes.RecipeManagers;
|
import forestry.api.recipes.RecipeManagers;
|
||||||
import forestry.api.storage.BackpackManager;
|
import forestry.api.storage.BackpackManager;
|
||||||
import forestry.api.storage.IBackpackDefinition;
|
import forestry.api.storage.IBackpackDefinition;
|
||||||
@@ -94,6 +95,7 @@ public class PluginIC2 extends ForestryPlugin {
|
|||||||
private static ItemStack silver;
|
private static ItemStack silver;
|
||||||
private static ItemStack brass;
|
private static ItemStack brass;
|
||||||
private static ItemStack uuMatter;
|
private static ItemStack uuMatter;
|
||||||
|
private static ItemStack fertilizer;
|
||||||
|
|
||||||
public static ItemStack resin;
|
public static ItemStack resin;
|
||||||
public static ItemStack rubberwood;
|
public static ItemStack rubberwood;
|
||||||
@@ -162,11 +164,13 @@ public class PluginIC2 extends ForestryPlugin {
|
|||||||
brass = IC2Items.getItem("bronzeIngot");
|
brass = IC2Items.getItem("bronzeIngot");
|
||||||
|
|
||||||
uran238 = IC2Items.getItem("Uran238");
|
uran238 = IC2Items.getItem("Uran238");
|
||||||
|
fertilizer = IC2Items.getItem("fertilizer");
|
||||||
|
|
||||||
Circuit.farmRubberManual = new CircuitFarmLogic("manualRubber", FarmLogicRubber.class);
|
Circuit.farmRubberManual = new CircuitFarmLogic("manualRubber", FarmLogicRubber.class);
|
||||||
|
|
||||||
ICircuitLayout layoutEngineTin = new CircuitLayout("engine.tin", CircuitSocketType.ELECTRIC_ENGINE);
|
ICircuitLayout layoutEngineTin = new CircuitLayout("engine.tin", CircuitSocketType.ELECTRIC_ENGINE);
|
||||||
ChipsetManager.circuitRegistry.registerLayout(layoutEngineTin);
|
ChipsetManager.circuitRegistry.registerLayout(layoutEngineTin);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -378,6 +382,10 @@ public class PluginIC2 extends ForestryPlugin {
|
|||||||
'V',
|
'V',
|
||||||
Blocks.piston);
|
Blocks.piston);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (PluginManager.Module.FARMING.isEnabled() && fertilizer != null) {
|
||||||
|
MultiblockManager.farmFertilizerRegistry.addFertilizer(fertilizer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import net.minecraft.item.ItemStack;
|
|||||||
|
|
||||||
import forestry.core.gui.ContainerItemInventory;
|
import forestry.core.gui.ContainerItemInventory;
|
||||||
import forestry.core.gui.slots.SlotFilteredInventory;
|
import forestry.core.gui.slots.SlotFilteredInventory;
|
||||||
|
import forestry.core.inventory.ItemLocation;
|
||||||
import forestry.storage.inventory.ItemInventoryBackpack;
|
import forestry.storage.inventory.ItemInventoryBackpack;
|
||||||
|
|
||||||
public class ContainerBackpack extends ContainerItemInventory<ItemInventoryBackpack> {
|
public class ContainerBackpack extends ContainerItemInventory<ItemInventoryBackpack> {
|
||||||
@@ -39,9 +40,9 @@ public class ContainerBackpack extends ContainerItemInventory<ItemInventoryBackp
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ContainerBackpack(EntityPlayer player, Size size, ItemStack parent) {
|
public ContainerBackpack(EntityPlayer player, Size size, ItemStack parent, ItemLocation loc) {
|
||||||
super(
|
super(
|
||||||
new ItemInventoryBackpack(player, size.getSize(), parent),
|
new ItemInventoryBackpack(player, size.getSize(), parent, loc),
|
||||||
player.inventory,
|
player.inventory,
|
||||||
8,
|
8,
|
||||||
11 + size.startY + size.rows * 18);
|
11 + size.startY + size.rows * 18);
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import net.minecraft.item.ItemStack;
|
|||||||
|
|
||||||
import forestry.api.storage.IBackpackDefinition;
|
import forestry.api.storage.IBackpackDefinition;
|
||||||
import forestry.core.inventory.ItemInventory;
|
import forestry.core.inventory.ItemInventory;
|
||||||
|
import forestry.core.inventory.ItemLocation;
|
||||||
import forestry.storage.items.ItemBackpack;
|
import forestry.storage.items.ItemBackpack;
|
||||||
|
|
||||||
public class ItemInventoryBackpack extends ItemInventory {
|
public class ItemInventoryBackpack extends ItemInventory {
|
||||||
@@ -13,7 +14,11 @@ public class ItemInventoryBackpack extends ItemInventory {
|
|||||||
private final IBackpackDefinition backpackDefinition;
|
private final IBackpackDefinition backpackDefinition;
|
||||||
|
|
||||||
public ItemInventoryBackpack(EntityPlayer player, int size, ItemStack parent) {
|
public ItemInventoryBackpack(EntityPlayer player, int size, ItemStack parent) {
|
||||||
super(player, size, parent);
|
this(player, size, parent, ItemLocation.UNKNOWN);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemInventoryBackpack(EntityPlayer player, int size, ItemStack parent, ItemLocation location) {
|
||||||
|
super(player, size, parent, location);
|
||||||
|
|
||||||
if (parent == null) {
|
if (parent == null) {
|
||||||
throw new IllegalArgumentException("Parent cannot be null.");
|
throw new IllegalArgumentException("Parent cannot be null.");
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import net.minecraft.item.ItemStack;
|
|||||||
|
|
||||||
import forestry.core.gui.GuiHandler;
|
import forestry.core.gui.GuiHandler;
|
||||||
import forestry.core.gui.IPagedInventory;
|
import forestry.core.gui.IPagedInventory;
|
||||||
|
import forestry.core.inventory.ItemLocation;
|
||||||
import forestry.storage.items.ItemBackpackNaturalist;
|
import forestry.storage.items.ItemBackpackNaturalist;
|
||||||
|
|
||||||
public class ItemInventoryBackpackPaged extends ItemInventoryBackpack implements IPagedInventory {
|
public class ItemInventoryBackpackPaged extends ItemInventoryBackpack implements IPagedInventory {
|
||||||
@@ -20,13 +21,18 @@ public class ItemInventoryBackpackPaged extends ItemInventoryBackpack implements
|
|||||||
private final ItemBackpackNaturalist backpackNaturalist;
|
private final ItemBackpackNaturalist backpackNaturalist;
|
||||||
|
|
||||||
public ItemInventoryBackpackPaged(EntityPlayer player, int size, ItemStack itemstack,
|
public ItemInventoryBackpackPaged(EntityPlayer player, int size, ItemStack itemstack,
|
||||||
ItemBackpackNaturalist backpackNaturalist) {
|
ItemBackpackNaturalist backpackNaturalist, ItemLocation loc) {
|
||||||
super(player, size, itemstack);
|
super(player, size, itemstack, loc);
|
||||||
this.backpackNaturalist = backpackNaturalist;
|
this.backpackNaturalist = backpackNaturalist;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void flipPage(EntityPlayer player, short page) {
|
public void flipPage(EntityPlayer player, short page) {
|
||||||
GuiHandler.openGui(player, backpackNaturalist, page);
|
ItemLocation loc = getLocation();
|
||||||
|
if (loc.type() == ItemLocation.Type.PLAYER_INVENTORY) {
|
||||||
|
GuiHandler.openGui(player, backpackNaturalist, page, loc.slotIdx());
|
||||||
|
} else {
|
||||||
|
GuiHandler.openGui(player, backpackNaturalist, page);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -13,6 +13,7 @@ import java.util.Locale;
|
|||||||
|
|
||||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
import net.minecraft.inventory.IInventory;
|
import net.minecraft.inventory.IInventory;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
@@ -20,7 +21,9 @@ import net.minecraft.util.IIcon;
|
|||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
import net.xonich.mc.nohotbarneeded.api.ActivatableFromInventoryServerSide;
|
||||||
|
|
||||||
|
import cpw.mods.fml.common.Optional;
|
||||||
import cpw.mods.fml.common.eventhandler.Event;
|
import cpw.mods.fml.common.eventhandler.Event;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
@@ -31,6 +34,7 @@ import forestry.core.config.Config;
|
|||||||
import forestry.core.config.Constants;
|
import forestry.core.config.Constants;
|
||||||
import forestry.core.gui.GuiHandler;
|
import forestry.core.gui.GuiHandler;
|
||||||
import forestry.core.inventory.ItemInventory;
|
import forestry.core.inventory.ItemInventory;
|
||||||
|
import forestry.core.inventory.ItemLocation;
|
||||||
import forestry.core.inventory.wrappers.IInvSlot;
|
import forestry.core.inventory.wrappers.IInvSlot;
|
||||||
import forestry.core.inventory.wrappers.InventoryIterator;
|
import forestry.core.inventory.wrappers.InventoryIterator;
|
||||||
import forestry.core.items.ItemWithGui;
|
import forestry.core.items.ItemWithGui;
|
||||||
@@ -44,7 +48,10 @@ import forestry.storage.gui.GuiBackpack;
|
|||||||
import forestry.storage.gui.GuiBackpackT2;
|
import forestry.storage.gui.GuiBackpackT2;
|
||||||
import forestry.storage.inventory.ItemInventoryBackpack;
|
import forestry.storage.inventory.ItemInventoryBackpack;
|
||||||
|
|
||||||
public class ItemBackpack extends ItemWithGui {
|
@Optional.Interface(
|
||||||
|
iface = "net.xonich.mc.nohotbarneeded.api.ActivatableFromInventoryServerSide",
|
||||||
|
modid = "nohotbarneeded")
|
||||||
|
public class ItemBackpack extends ItemWithGui implements ActivatableFromInventoryServerSide {
|
||||||
|
|
||||||
private final IBackpackDefinition definition;
|
private final IBackpackDefinition definition;
|
||||||
private final EnumBackpackType type;
|
private final EnumBackpackType type;
|
||||||
@@ -65,7 +72,7 @@ public class ItemBackpack extends ItemWithGui {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void openGui(EntityPlayer entityplayer) {
|
protected void openGui(EntityPlayer entityplayer) {
|
||||||
GuiHandler.openGui(entityplayer, this, (short) type.ordinal());
|
GuiHandler.openGui(entityplayer, this, (short) type.ordinal(), entityplayer.inventory.currentItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -318,32 +325,32 @@ public class ItemBackpack extends ItemWithGui {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getGui(EntityPlayer player, ItemStack heldItem, int data) {
|
public Object getGui(EntityPlayer player, ItemStack heldItem, int data, ItemLocation loc) {
|
||||||
if (data > EnumBackpackType.values().length) {
|
if (data >= EnumBackpackType.values().length) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
EnumBackpackType type = EnumBackpackType.values()[data];
|
EnumBackpackType type = EnumBackpackType.values()[data];
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case T1:
|
case T1:
|
||||||
return new GuiBackpack(new ContainerBackpack(player, ContainerBackpack.Size.DEFAULT, heldItem));
|
return new GuiBackpack(new ContainerBackpack(player, ContainerBackpack.Size.DEFAULT, heldItem, loc));
|
||||||
case T2:
|
case T2:
|
||||||
return new GuiBackpackT2(new ContainerBackpack(player, ContainerBackpack.Size.T2, heldItem));
|
return new GuiBackpackT2(new ContainerBackpack(player, ContainerBackpack.Size.T2, heldItem, loc));
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getContainer(EntityPlayer player, ItemStack heldItem, int data) {
|
public Object getContainer(EntityPlayer player, ItemStack heldItem, int data, ItemLocation loc) {
|
||||||
if (data > EnumBackpackType.values().length) {
|
if (data >= EnumBackpackType.values().length) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
EnumBackpackType type = EnumBackpackType.values()[data];
|
EnumBackpackType type = EnumBackpackType.values()[data];
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case T1:
|
case T1:
|
||||||
return new ContainerBackpack(player, ContainerBackpack.Size.DEFAULT, heldItem);
|
return new ContainerBackpack(player, ContainerBackpack.Size.DEFAULT, heldItem, loc);
|
||||||
case T2:
|
case T2:
|
||||||
return new ContainerBackpack(player, ContainerBackpack.Size.T2, heldItem);
|
return new ContainerBackpack(player, ContainerBackpack.Size.T2, heldItem, loc);
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -361,4 +368,10 @@ public class ItemBackpack extends ItemWithGui {
|
|||||||
public boolean showDurabilityBar(final ItemStack stack) {
|
public boolean showDurabilityBar(final ItemStack stack) {
|
||||||
return Config.showBackpackDurability && ItemInventory.getOccupiedSlotCount(stack) > 0;
|
return Config.showBackpackDurability && ItemInventory.getOccupiedSlotCount(stack) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Optional.Method(modid = "nohotbarneeded")
|
||||||
|
public void activateFromInventory(EntityPlayerMP player, int slotIdx) {
|
||||||
|
GuiHandler.openGui(player, this, (short) type.ordinal(), slotIdx);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -9,14 +9,17 @@
|
|||||||
package forestry.storage.items;
|
package forestry.storage.items;
|
||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
|
import cpw.mods.fml.common.Optional;
|
||||||
import forestry.api.genetics.ISpeciesRoot;
|
import forestry.api.genetics.ISpeciesRoot;
|
||||||
import forestry.api.storage.EnumBackpackType;
|
import forestry.api.storage.EnumBackpackType;
|
||||||
import forestry.api.storage.IBackpackDefinition;
|
import forestry.api.storage.IBackpackDefinition;
|
||||||
import forestry.core.config.Constants;
|
import forestry.core.config.Constants;
|
||||||
import forestry.core.gui.GuiHandler;
|
import forestry.core.gui.GuiHandler;
|
||||||
import forestry.core.gui.GuiNaturalistInventory;
|
import forestry.core.gui.GuiNaturalistInventory;
|
||||||
|
import forestry.core.inventory.ItemLocation;
|
||||||
import forestry.storage.gui.ContainerNaturalistBackpack;
|
import forestry.storage.gui.ContainerNaturalistBackpack;
|
||||||
import forestry.storage.inventory.ItemInventoryBackpackPaged;
|
import forestry.storage.inventory.ItemInventoryBackpackPaged;
|
||||||
|
|
||||||
@@ -31,27 +34,35 @@ public class ItemBackpackNaturalist extends ItemBackpack {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void openGui(EntityPlayer entityplayer) {
|
protected void openGui(EntityPlayer entityplayer) {
|
||||||
GuiHandler.openGui(entityplayer, this);
|
GuiHandler.openGui(entityplayer, this, (short) 0, entityplayer.inventory.currentItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getGui(EntityPlayer player, ItemStack heldItem, int page) {
|
public Object getGui(EntityPlayer player, ItemStack heldItem, int page, ItemLocation loc) {
|
||||||
ItemInventoryBackpackPaged inventory = new ItemInventoryBackpackPaged(
|
ItemInventoryBackpackPaged inventory = new ItemInventoryBackpackPaged(
|
||||||
player,
|
player,
|
||||||
Constants.SLOTS_BACKPACK_APIARIST,
|
Constants.SLOTS_BACKPACK_APIARIST,
|
||||||
heldItem,
|
heldItem,
|
||||||
this);
|
this,
|
||||||
|
loc);
|
||||||
ContainerNaturalistBackpack container = new ContainerNaturalistBackpack(player, inventory, page);
|
ContainerNaturalistBackpack container = new ContainerNaturalistBackpack(player, inventory, page);
|
||||||
return new GuiNaturalistInventory(speciesRoot, player, container, inventory, page, 5);
|
return new GuiNaturalistInventory(speciesRoot, player, container, inventory, page, 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getContainer(EntityPlayer player, ItemStack heldItem, int page) {
|
public Object getContainer(EntityPlayer player, ItemStack heldItem, int page, ItemLocation loc) {
|
||||||
ItemInventoryBackpackPaged inventory = new ItemInventoryBackpackPaged(
|
ItemInventoryBackpackPaged inventory = new ItemInventoryBackpackPaged(
|
||||||
player,
|
player,
|
||||||
Constants.SLOTS_BACKPACK_APIARIST,
|
Constants.SLOTS_BACKPACK_APIARIST,
|
||||||
heldItem,
|
heldItem,
|
||||||
this);
|
this,
|
||||||
|
loc);
|
||||||
return new ContainerNaturalistBackpack(player, inventory, page);
|
return new ContainerNaturalistBackpack(player, inventory, page);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Optional.Method(modid = "nohotbarneeded")
|
||||||
|
public void activateFromInventory(EntityPlayerMP player, int slotIdx) {
|
||||||
|
GuiHandler.openGui(player, this, /* page */(short) 0, slotIdx);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -10,6 +10,7 @@ gui.screen=ffffff
|
|||||||
gui.table.header=ababab
|
gui.table.header=ababab
|
||||||
gui.table.row=ababab
|
gui.table.row=ababab
|
||||||
gui.book=000000
|
gui.book=000000
|
||||||
|
gui.worktable.missing=ff0000
|
||||||
|
|
||||||
gui.beealyzer.binomial=14d50b
|
gui.beealyzer.binomial=14d50b
|
||||||
gui.beealyzer.recessive=3687ec
|
gui.beealyzer.recessive=3687ec
|
||||||
|
|||||||
@@ -501,10 +501,10 @@ tile.for.log1=原木
|
|||||||
tile.for.log2=原木
|
tile.for.log2=原木
|
||||||
tile.for.log3=原木
|
tile.for.log3=原木
|
||||||
tile.for.log4=原木
|
tile.for.log4=原木
|
||||||
tile.for.planks=木材
|
tile.for.planks.name=木材
|
||||||
tile.for.slabs1=木材ハーフブロック
|
tile.for.slabs1=木材ハーフブロック
|
||||||
tile.for.slabs2=木材ハーフブロック
|
tile.for.slabs2=木材ハーフブロック
|
||||||
tile.for.fences=フェンス
|
tile.for.fences.name=フェンス
|
||||||
tile.harvester.0=伐採機
|
tile.harvester.0=伐採機
|
||||||
tile.harvester.1=収穫機
|
tile.harvester.1=収穫機
|
||||||
tile.harvester.2=ゴムの木収穫機
|
tile.harvester.2=ゴムの木収穫機
|
||||||
@@ -757,9 +757,11 @@ tile.candle.dyed.stump=Unlit Dyed Candle
|
|||||||
tile.candle.lit=Lit Candle
|
tile.candle.lit=Lit Candle
|
||||||
tile.candle.dyed.lit=Lit Dyed Candle
|
tile.candle.dyed.lit=Lit Dyed Candle
|
||||||
tile.stump.0=Candle Stump
|
tile.stump.0=Candle Stump
|
||||||
tile.for.apiculture.0=Apiary
|
tile.for.apiculture.name=養蜂箱
|
||||||
tile.for.apiculture.1=Apiarist's Chest
|
tile.for.apiculture.0.name=養蜂箱
|
||||||
tile.for.apiculture.2=Bee House
|
tile.for.apicultureChest.name=養蜂家のチェスト
|
||||||
|
tile.for.apicultureChest.0.name=養蜂家のチェスト
|
||||||
|
tile.for.apiculture.2.name=ビーハウス
|
||||||
item.for.beeQueenGE.name=Unknown Queen
|
item.for.beeQueenGE.name=Unknown Queen
|
||||||
|
|
||||||
####################
|
####################
|
||||||
@@ -808,7 +810,7 @@ tile.log=Wood
|
|||||||
tile.planks=Wood Planks
|
tile.planks=Wood Planks
|
||||||
tile.slab=Wood Slab
|
tile.slab=Wood Slab
|
||||||
tile.fences=Fence
|
tile.fences=Fence
|
||||||
tile.for.stairs=Stairs
|
tile.for.stairs.name=階段
|
||||||
wood.0=Larch
|
wood.0=Larch
|
||||||
wood.1=Teak
|
wood.1=Teak
|
||||||
wood.2=Acacia
|
wood.2=Acacia
|
||||||
@@ -833,7 +835,8 @@ wood.20=Pine
|
|||||||
wood.21=Plum
|
wood.21=Plum
|
||||||
wood.22=Maple
|
wood.22=Maple
|
||||||
wood.23=Citrus
|
wood.23=Citrus
|
||||||
tile.for.arboriculture.0=Arborist's Chest
|
tile.for.arboriculture.name=樹医のチェスト
|
||||||
|
tile.for.arboriculture.0.name=樹医のチェスト
|
||||||
|
|
||||||
####################
|
####################
|
||||||
# FARMING
|
# FARMING
|
||||||
@@ -906,7 +909,8 @@ item.butterfly=Butterfly
|
|||||||
item.moth=Moth
|
item.moth=Moth
|
||||||
item.flutterlyzer=Flutterlyzer
|
item.flutterlyzer=Flutterlyzer
|
||||||
storage.backpack.lepidopterist=Lepidopterist's Backpack
|
storage.backpack.lepidopterist=Lepidopterist's Backpack
|
||||||
tile.for.lepidopterology.0=Lepidopterist's Chest
|
tile.for.lepidopterology.name=鱗翅類学者のチェスト
|
||||||
|
tile.for.lepidopterology.0.name=鱗翅類学者のチェスト
|
||||||
|
|
||||||
####################
|
####################
|
||||||
# MAIL
|
# MAIL
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 411 B After Width: | Height: | Size: 408 B |
|
Before Width: | Height: | Size: 228 B After Width: | Height: | Size: 227 B |
|
Before Width: | Height: | Size: 447 B After Width: | Height: | Size: 445 B |
|
Before Width: | Height: | Size: 231 B After Width: | Height: | Size: 228 B |
|
Before Width: | Height: | Size: 212 B After Width: | Height: | Size: 207 B |
|
Before Width: | Height: | Size: 467 B After Width: | Height: | Size: 424 B |
|
Before Width: | Height: | Size: 324 B After Width: | Height: | Size: 319 B |
|
Before Width: | Height: | Size: 243 B After Width: | Height: | Size: 236 B |
|
Before Width: | Height: | Size: 346 B After Width: | Height: | Size: 345 B |
|
Before Width: | Height: | Size: 355 B After Width: | Height: | Size: 349 B |
|
Before Width: | Height: | Size: 362 B After Width: | Height: | Size: 359 B |
|
Before Width: | Height: | Size: 210 B After Width: | Height: | Size: 209 B |
|
Before Width: | Height: | Size: 332 B After Width: | Height: | Size: 326 B |
|
Before Width: | Height: | Size: 245 B After Width: | Height: | Size: 232 B |
|
Before Width: | Height: | Size: 362 B After Width: | Height: | Size: 359 B |
|
Before Width: | Height: | Size: 239 B After Width: | Height: | Size: 233 B |
|
Before Width: | Height: | Size: 384 B After Width: | Height: | Size: 379 B |
|
Before Width: | Height: | Size: 375 B After Width: | Height: | Size: 371 B |
|
Before Width: | Height: | Size: 318 B After Width: | Height: | Size: 312 B |
|
Before Width: | Height: | Size: 240 B After Width: | Height: | Size: 228 B |
|
Before Width: | Height: | Size: 221 B After Width: | Height: | Size: 219 B |
|
Before Width: | Height: | Size: 181 B After Width: | Height: | Size: 179 B |