Compare commits

..
31 Commits
Author SHA1 Message Date
Alexdoru ffcc5f7102 [Memory-opti:runtime allocations] Reduce amount of NBTTagCompound created in TileEntityMetadata#getItemStack (#77) 2025-12-01 23:35:01 +01:00
Martin Robertz 4c619fd3b2 update 2025-10-01 18:48:17 +02:00
Glease 341fea50ba fix batched updates does not call window and machine packet listeners (#74) 2025-09-28 10:52:47 +02:00
Julia e6c67df077 Fix Slot Registration Crash (#73) 2025-09-25 15:46:12 +02:00
d24088ea4b Fix metadata error when using Scooporator MX200 Turbo (#69)
Co-authored-by: Wilhelm Schuster <[email protected]>
Co-authored-by: boubou19 <[email protected]>
2025-09-24 23:44:33 +02:00
Julia a2a57d1656 Batch Actions and Defer Registration of Slots (#72) 2025-09-24 23:25:39 +02:00
Julia 2e36fbcfcc Extract Magic String Constants in ContainerCraftGUI (#70) 2025-09-24 17:46:47 +02:00
Martin Robertz bd5bd5c153 update 2025-09-24 17:37:45 +02:00
Julia f324cb53db Fix Inventory List Crash (#71) 2025-09-24 17:29:33 +02:00
Julia c6815bebdf Cleanup ContainerCraftGUI (#68) 2025-09-23 17:46:40 -07:00
Julia 7ffa516892 Change recieve -> receive (#67) 2025-09-23 14:26:33 -07:00
Julia 311d618d53 Cleanup BinnieCorePacketID.java (#66) 2025-09-23 12:54:21 -07:00
Dream Master 9795aad66f update 2025-09-05 16:05:56 +02:00
Matthew Bentham ea7e2d7de4 Fix mutator not accepting items listed on the wiki (#65) 2025-09-05 09:44:41 +02:00
boubou19andAlexdoru 39f86c8b0c Speed up forge event registration (#64)
Co-authored-by: Alexdoru <[email protected]>
2025-07-18 22:22:10 +00:00
TotallyNotOndre 5b551eb8ec "fix" compartment tab name input field (#63) 2025-07-15 19:39:33 +02:00
Martin Robertz f497114579 update 2025-07-08 12:11:02 +02:00
Alexdoru ea547df4d0 Properly apply hunger effect (#62) 2025-07-07 21:42:49 +02:00
Ruling-0 39c9f1f6c6 Remove mutator mutation chance cap (#61) 2025-05-25 17:30:06 +02:00
Maya 4000763323 update 2025-05-07 10:39:29 -05:00
czerwonogrodzki 59e98dd290 Extend Lab Stand GUI width by 80 units (#60) 2025-05-07 10:38:14 -05:00
Maya c1ec3e5c8e Fix stained block hardness (#59) 2025-04-09 01:22:18 -05:00
Maya ac4b21b05e update 2025-04-08 14:24:47 -05:00
Niclas Klugmann 0e0ded5cc0 Revert 5x multiplier removal (#58) 2025-04-08 14:23:05 -05:00
Martin Robertz a1f54e7500 update 2025-01-16 21:59:06 +01:00
Astatine5985andMaya 5f1b5daa24 Isolator crash fix revision (#56)
Co-authored-by: Maya <[email protected]>
2025-01-16 16:50:35 +00:00
Martin Robertz 8d0fa2ebb5 update 2024-12-30 21:12:54 +01:00
glowredman 0db05cb60c Add Localization, Fix Carpentry Hammer / Master Carpentry Hammer Names being reverse (#57) 2024-12-30 21:11:13 +01:00
0265d70a53 Yeet custom config in favor of NHLib (#53)
Co-authored-by: Martin Robertz <[email protected]>
Co-authored-by: Maya <[email protected]>
2024-12-29 12:37:43 -06:00
Martin Robertz 32b7efcd15 update 2024-12-22 01:17:03 +01:00
Guillaume Mercier 7059206cb0 prevent npe and log bad requests (#55) 2024-12-21 10:35:14 -06:00
115 changed files with 1090 additions and 1648 deletions

No files matched your search

+6 -6
View File
@@ -1,12 +1,12 @@
// Add your dependencies here
dependencies {
api('com.github.GTNewHorizons:ForestryMC:4.9.20:dev')
implementation('com.github.GTNewHorizons:GTNHLib:0.5.23:dev')
api('com.github.GTNewHorizons:ForestryMC:4.10.17:dev')
implementation('com.github.GTNewHorizons:GTNHLib:0.7.0:dev')
devOnlyNonPublishable('com.github.GTNewHorizons:NotEnoughItems:2.6.53-GTNH:dev')
devOnlyNonPublishable('com.github.GTNewHorizons:NotEnoughItems:2.8.0-GTNH:dev')
compileOnly('com.github.GTNewHorizons:BuildCraft:7.1.39:api')
compileOnly('net.industrial-craft:industrialcraft-2:2.2.828-experimental:dev')
compileOnly("curse.maven:extrabiomesxl-60041:2273301")
compileOnly('com.github.GTNewHorizons:BuildCraft:7.1.44:api')
compileOnly('net.industrial-craft:industrialcraft-2:2.2.828-experimental:dev')
compileOnly("curse.maven:extrabiomesxl-60041:2273301")
}
+2 -2
View File
@@ -14,7 +14,7 @@ modId = BinnieCore
modGroup = binnie
# Whether to use modGroup as the maven publishing group.
# Due to a history of using JitPack, the default is com.github.GTNewHorizons for all mods.
# When false, com.github.GTNewHorizons is used.
useModGroupForPublishing = false
# Updates your build.gradle and settings.gradle automatically whenever an update is available.
@@ -151,7 +151,7 @@ modrinthProjectId =
# type can be one of [project, version],
# and the name is the Modrinth project or version slug/id of the other mod.
# Example: required-project:fplib;optional-project:gasstation;incompatible-project:gregtech
# Note: GTNH Mixins is automatically set as a required dependency if usesMixins = true
# Note: UniMixins is automatically set as a required dependency if usesMixins = true.
modrinthRelations =
# Publishing to CurseForge requires you to set the CURSEFORGE_TOKEN environment variable to one of your CurseForge API tokens.
Binary file not shown.
+1 -1
View File
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Vendored
+2 -3
View File
@@ -86,8 +86,7 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
@@ -206,7 +205,7 @@ fi
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.
+1 -1
View File
@@ -17,5 +17,5 @@ pluginManagement {
}
plugins {
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.30'
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.43'
}
-2
View File
@@ -8,14 +8,12 @@ import binnie.core.genetics.ManagerGenetics;
import binnie.core.item.ManagerItem;
import binnie.core.liquid.ManagerLiquid;
import binnie.core.machines.ManagerMachine;
import binnie.core.mod.config.ManagerConfig;
import binnie.core.resource.ManagerResource;
public final class Binnie {
public static List<ManagerBase> Managers = new ArrayList<>();
public static ManagerGenetics Genetics = new ManagerGenetics();
public static ManagerConfig Configuration = new ManagerConfig();
public static ManagerLiquid Liquid = new ManagerLiquid();
public static ManagerMachine Machine = new ManagerMachine();
public static ManagerItem Item = new ManagerItem();
+136 -133
View File
@@ -6,6 +6,7 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.player.BonemealEvent;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.event.world.BlockEvent;
@@ -92,6 +93,7 @@ public class Botany extends AbstractMod {
public Botany() {
Botany.instance = this;
MinecraftForge.EVENT_BUS.register(new EventHandler());
}
@Mod.EventHandler
@@ -142,118 +144,6 @@ public class Botany extends AbstractMod {
return PacketHandler.class;
}
@SubscribeEvent
public void onShearFlower(PlayerInteractEvent event) {
if (event.action != PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) {
return;
}
if (event.entityPlayer != null && event.entityPlayer.getHeldItem() != null
&& event.entityPlayer.getHeldItem().getItem() == Items.shears) {
TileEntity tile = event.world.getTileEntity(event.x, event.y, event.z);
if (tile instanceof TileEntityFlower tileFlower) {
tileFlower.onShear();
event.entityPlayer.getHeldItem().damageItem(1, event.entityPlayer);
}
}
if (event.entityPlayer != null && event.entityPlayer.getHeldItem() != null
&& event.entityPlayer.getHeldItem().getItem() == Botany.pollen) {
TileEntity tile = event.world.getTileEntity(event.x, event.y, event.z);
if (tile instanceof TileEntityFlower tileFlower) {
IFlower pollen = BotanyCore.getFlowerRoot().getMember(event.entityPlayer.getHeldItem());
if (pollen != null && tileFlower.canMateWith(pollen)) {
tileFlower.mateWith(pollen);
if (!event.entityPlayer.capabilities.isCreativeMode) {
ItemStack heldItem = event.entityPlayer.getHeldItem();
heldItem.stackSize--;
}
}
}
}
}
@SubscribeEvent
public void onFertiliseSoil(PlayerInteractEvent event) {
if (event.action != PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK || event.world == null) {
return;
}
if (event.entityPlayer == null || event.entityPlayer.getHeldItem() == null) {
return;
}
int y = event.y;
Block block = event.world.getBlock(event.x, y, event.z);
if (!Gardening.isSoil(block)) {
block = event.world.getBlock(event.x, --y, event.z);
}
if (!Gardening.isSoil(block)) {
return;
}
IBlockSoil soil = (IBlockSoil) block;
if (Gardening.isNutrientFertiliser(event.entityPlayer.getHeldItem())
&& soil.getType(event.world, event.x, y, event.z) != EnumSoilType.FLOWERBED) {
EnumSoilType type = soil.getType(event.world, event.x, y, event.z);
int next = Math.min(type.ordinal() + Gardening.getFertiliserStrength(event.entityPlayer.getHeldItem()), 2);
if (soil.fertilise(event.world, event.x, y, event.z, EnumSoilType.values()[next])
&& !event.entityPlayer.capabilities.isCreativeMode) {
ItemStack heldItem = event.entityPlayer.getHeldItem();
heldItem.stackSize--;
return;
}
}
if (Gardening.isAcidFertiliser(event.entityPlayer.getHeldItem())
&& soil.getPH(event.world, event.x, y, event.z) != EnumAcidity.ACID) {
EnumAcidity pH = soil.getPH(event.world, event.x, y, event.z);
int next = Math.max(pH.ordinal() - Gardening.getFertiliserStrength(event.entityPlayer.getHeldItem()), 0);
if (soil.setPH(event.world, event.x, y, event.z, EnumAcidity.values()[next])
&& !event.entityPlayer.capabilities.isCreativeMode) {
ItemStack heldItem2 = event.entityPlayer.getHeldItem();
heldItem2.stackSize--;
return;
}
}
if (Gardening.isAlkalineFertiliser(event.entityPlayer.getHeldItem())
&& soil.getPH(event.world, event.x, y, event.z) != EnumAcidity.ALKALINE) {
EnumAcidity pH = soil.getPH(event.world, event.x, y, event.z);
int next = Math.min(pH.ordinal() + Gardening.getFertiliserStrength(event.entityPlayer.getHeldItem()), 2);
if (soil.setPH(event.world, event.x, y, event.z, EnumAcidity.values()[next])
&& !event.entityPlayer.capabilities.isCreativeMode) {
ItemStack heldItem3 = event.entityPlayer.getHeldItem();
heldItem3.stackSize--;
return;
}
}
if (Gardening.isWeedkiller(event.entityPlayer.getHeldItem())
&& Gardening.addWeedKiller(event.world, event.x, y, event.z)
&& !event.entityPlayer.capabilities.isCreativeMode) {
ItemStack heldItem4 = event.entityPlayer.getHeldItem();
heldItem4.stackSize--;
}
}
@SubscribeEvent
public void plantVanilla(BlockEvent.PlaceEvent event) {
World world = event.world;
int x = event.x;
int y = event.y;
int z = event.z;
Block block = world.getBlock(x, y - 1, z);
if (!(block instanceof IBlockSoil)) {
return;
}
IFlower flower = BotanyCore.getFlowerRoot().getConversion(event.itemInHand);
if (flower != null) {
Gardening.plant(world, x, y, z, flower, event.player.getGameProfile());
}
}
@Deprecated
public void onPlantVanilla(PlayerInteractEvent event) {
if (!BinnieCore.proxy.isSimulating(event.world)
@@ -287,27 +177,6 @@ public class Botany extends AbstractMod {
}
}
@SubscribeEvent
public void onBonemeal(BonemealEvent event) {
Block block = event.world.getBlock(event.x, event.y, event.z);
if (Gardening.isSoil(block)) {
IBlockSoil soil = (IBlockSoil) block;
if (soil.fertilise(event.world, event.x, event.y, event.z, EnumSoilType.LOAM)) {
event.setResult(Event.Result.ALLOW);
}
}
TileEntity tile = event.world.getTileEntity(event.x, event.y, event.z);
if (tile instanceof TileEntityFlower && ((TileEntityFlower) tile).onBonemeal()) {
event.setResult(Event.Result.ALLOW);
}
}
@Override
public boolean isActive() {
return BinnieCore.isBotanyActive();
}
@Mod.EventHandler
public void onIMC(FMLInterModComms.IMCEvent event) {
for (FMLInterModComms.IMCMessage message : event.getMessages()) {
@@ -338,4 +207,138 @@ public class Botany extends AbstractMod {
super(Botany.instance);
}
}
public static class EventHandler {
@SubscribeEvent
public void onShearFlower(PlayerInteractEvent event) {
if (event.action != PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) {
return;
}
if (event.entityPlayer != null && event.entityPlayer.getHeldItem() != null
&& event.entityPlayer.getHeldItem().getItem() == Items.shears) {
TileEntity tile = event.world.getTileEntity(event.x, event.y, event.z);
if (tile instanceof TileEntityFlower tileFlower) {
tileFlower.onShear();
event.entityPlayer.getHeldItem().damageItem(1, event.entityPlayer);
}
}
if (event.entityPlayer != null && event.entityPlayer.getHeldItem() != null
&& event.entityPlayer.getHeldItem().getItem() == Botany.pollen) {
TileEntity tile = event.world.getTileEntity(event.x, event.y, event.z);
if (tile instanceof TileEntityFlower tileFlower) {
IFlower pollen = BotanyCore.getFlowerRoot().getMember(event.entityPlayer.getHeldItem());
if (pollen != null && tileFlower.canMateWith(pollen)) {
tileFlower.mateWith(pollen);
if (!event.entityPlayer.capabilities.isCreativeMode) {
ItemStack heldItem = event.entityPlayer.getHeldItem();
heldItem.stackSize--;
}
}
}
}
}
@SubscribeEvent
public void onFertiliseSoil(PlayerInteractEvent event) {
if (event.action != PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK || event.world == null) {
return;
}
if (event.entityPlayer == null || event.entityPlayer.getHeldItem() == null) {
return;
}
int y = event.y;
Block block = event.world.getBlock(event.x, y, event.z);
if (!Gardening.isSoil(block)) {
block = event.world.getBlock(event.x, --y, event.z);
}
if (!Gardening.isSoil(block)) {
return;
}
IBlockSoil soil = (IBlockSoil) block;
if (Gardening.isNutrientFertiliser(event.entityPlayer.getHeldItem())
&& soil.getType(event.world, event.x, y, event.z) != EnumSoilType.FLOWERBED) {
EnumSoilType type = soil.getType(event.world, event.x, y, event.z);
int next = Math
.min(type.ordinal() + Gardening.getFertiliserStrength(event.entityPlayer.getHeldItem()), 2);
if (soil.fertilise(event.world, event.x, y, event.z, EnumSoilType.values()[next])
&& !event.entityPlayer.capabilities.isCreativeMode) {
ItemStack heldItem = event.entityPlayer.getHeldItem();
heldItem.stackSize--;
return;
}
}
if (Gardening.isAcidFertiliser(event.entityPlayer.getHeldItem())
&& soil.getPH(event.world, event.x, y, event.z) != EnumAcidity.ACID) {
EnumAcidity pH = soil.getPH(event.world, event.x, y, event.z);
int next = Math
.max(pH.ordinal() - Gardening.getFertiliserStrength(event.entityPlayer.getHeldItem()), 0);
if (soil.setPH(event.world, event.x, y, event.z, EnumAcidity.values()[next])
&& !event.entityPlayer.capabilities.isCreativeMode) {
ItemStack heldItem2 = event.entityPlayer.getHeldItem();
heldItem2.stackSize--;
return;
}
}
if (Gardening.isAlkalineFertiliser(event.entityPlayer.getHeldItem())
&& soil.getPH(event.world, event.x, y, event.z) != EnumAcidity.ALKALINE) {
EnumAcidity pH = soil.getPH(event.world, event.x, y, event.z);
int next = Math
.min(pH.ordinal() + Gardening.getFertiliserStrength(event.entityPlayer.getHeldItem()), 2);
if (soil.setPH(event.world, event.x, y, event.z, EnumAcidity.values()[next])
&& !event.entityPlayer.capabilities.isCreativeMode) {
ItemStack heldItem3 = event.entityPlayer.getHeldItem();
heldItem3.stackSize--;
return;
}
}
if (Gardening.isWeedkiller(event.entityPlayer.getHeldItem())
&& Gardening.addWeedKiller(event.world, event.x, y, event.z)
&& !event.entityPlayer.capabilities.isCreativeMode) {
ItemStack heldItem4 = event.entityPlayer.getHeldItem();
heldItem4.stackSize--;
}
}
@SubscribeEvent
public void plantVanilla(BlockEvent.PlaceEvent event) {
World world = event.world;
int x = event.x;
int y = event.y;
int z = event.z;
Block block = world.getBlock(x, y - 1, z);
if (!(block instanceof IBlockSoil)) {
return;
}
IFlower flower = BotanyCore.getFlowerRoot().getConversion(event.itemInHand);
if (flower != null) {
Gardening.plant(world, x, y, z, flower, event.player.getGameProfile());
}
}
@SubscribeEvent
public void onBonemeal(BonemealEvent event) {
Block block = event.world.getBlock(event.x, event.y, event.z);
if (Gardening.isSoil(block)) {
IBlockSoil soil = (IBlockSoil) block;
if (soil.fertilise(event.world, event.x, event.y, event.z, EnumSoilType.LOAM)) {
event.setResult(Event.Result.ALLOW);
}
}
TileEntity tile = event.world.getTileEntity(event.x, event.y, event.z);
if (tile instanceof TileEntityFlower && ((TileEntityFlower) tile).onBonemeal()) {
event.setResult(Event.Result.ALLOW);
}
}
}
}
@@ -34,6 +34,7 @@ public class BlockStained extends Block implements IBlockMetadata {
public BlockStained() {
super(Material.glass);
setHardness(0.3f);
setCreativeTab(CreativeTabBotany.instance);
setBlockName("stained");
}
+4 -16
View File
@@ -6,9 +6,6 @@ import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.List;
import net.minecraftforge.common.MinecraftForge;
import binnie.Binnie;
import binnie.core.gui.IBinnieGUID;
import binnie.core.mod.parser.FieldParser;
import binnie.core.network.BinniePacketHandler;
@@ -30,10 +27,11 @@ public abstract class AbstractMod implements IPacketProvider, IInitializable {
fields = new LinkedHashSet<>();
modules = new ArrayList<>();
BinnieCore.registerMod(this);
MinecraftForge.EVENT_BUS.register(this);
}
public abstract boolean isActive();
public boolean isActive() {
return true;
}
@Override
public abstract String getChannel();
@@ -47,10 +45,6 @@ public abstract class AbstractMod implements IPacketProvider, IInitializable {
return new IBinnieGUID[0];
}
public Class<?>[] getConfigs() {
return new Class[0];
}
public abstract IProxyCore getProxy();
public abstract String getModID();
@@ -67,12 +61,6 @@ public abstract class AbstractMod implements IPacketProvider, IInitializable {
return;
}
if (getConfigs() != null) {
for (Class<?> cls : getConfigs()) {
Binnie.Configuration.registerConfiguration(cls, this);
}
}
getProxy().preInit();
for (IInitializable module : modules) {
module.preInit();
@@ -140,6 +128,6 @@ public abstract class AbstractMod implements IPacketProvider, IInitializable {
protected void addModule(IInitializable init) {
modules.add(init);
MinecraftForge.EVENT_BUS.register(init);
init.registerEventHandler();
}
}
+39 -47
View File
@@ -5,9 +5,9 @@ import java.util.List;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.Item;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.server.MinecraftServer;
import net.minecraftforge.client.event.TextureStitchEvent;
import net.minecraftforge.common.MinecraftForge;
import binnie.Binnie;
import binnie.core.block.MultipassBlockRenderer;
@@ -22,8 +22,6 @@ import binnie.core.liquid.FluidContainer;
import binnie.core.liquid.ItemFluidContainer;
import binnie.core.machines.MachineGroup;
import binnie.core.machines.storage.ModuleStorage;
import binnie.core.mod.config.ConfigurationMain;
import binnie.core.mod.config.ConfigurationMods;
import binnie.core.mod.parser.FieldParser;
import binnie.core.mod.parser.ItemParser;
import binnie.core.network.BinnieCorePacketID;
@@ -49,13 +47,16 @@ import forestry.api.core.ForestryEvent;
import forestry.plugins.PluginManager;
@Mod(
modid = "BinnieCore",
name = "Binnie Core",
modid = BinnieCore.CORE_MODID,
name = BinnieCore.CORE_MOD_NAME,
version = Tags.VERSION,
useMetadata = true,
dependencies = "after:Forestry@[4.2,),required-after:gtnhlib@[0.0.10,)")
public class BinnieCore extends AbstractMod {
public static final String CORE_MODID = "BinnieCore";
public static final String CORE_MOD_NAME = "Binnie Core";
@Mod.Instance("BinnieCore")
public static BinnieCore instance;
@@ -68,9 +69,12 @@ public class BinnieCore extends AbstractMod {
public static ItemGenesis genesis;
public static ItemFieldKit fieldKit;
public BinnieCore() {
MinecraftForge.EVENT_BUS.register(new EventHandler());
}
@Mod.EventHandler
public void preInit(FMLPreInitializationEvent event) {
Binnie.Configuration.registerConfiguration(ConfigurationMods.class, this);
for (ManagerBase baseManager : Binnie.Managers) {
addModule(baseManager);
}
@@ -134,20 +138,12 @@ public class BinnieCore extends AbstractMod {
return PluginManager.Module.ARBORICULTURE.isEnabled();
}
public static boolean isBotanyActive() {
return ConfigurationMods.botany;
}
public static boolean isGeneticsActive() {
return ConfigurationMods.genetics;
}
public static boolean isExtraBeesActive() {
return ConfigurationMods.extraBees && isApicultureActive();
return isApicultureActive();
}
public static boolean isExtraTreesActive() {
return ConfigurationMods.extraTrees && isArboricultureActive();
return isArboricultureActive();
}
@Override
@@ -169,23 +165,6 @@ public class BinnieCore extends AbstractMod {
return list;
}
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void handleSpeciesDiscovered(ForestryEvent.SpeciesDiscovered event) {
try {
EntityPlayerMP player = MinecraftServer.getServer().getConfigurationManager()
.func_152612_a(event.username.getName());
if (player == null) {
return;
}
event.tracker.synchToPlayer(player);
NBTTagCompound nbt = new NBTTagCompound();
nbt.setString("species", event.species.getUID());
} catch (Exception ex) {
// ignored
}
}
@Override
public String getChannel() {
return "BIN";
@@ -206,20 +185,6 @@ public class BinnieCore extends AbstractMod {
return BinnieCorePacketID.values();
}
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void handleTextureRemap(TextureStitchEvent.Pre event) {
if (event.map.getTextureType() == 0) {
Binnie.Liquid.reloadIcons(event.map);
}
Binnie.Resource.registerIcons(event.map, event.map.getTextureType());
}
@Override
public Class<?>[] getConfigs() {
return new Class[] { ConfigurationMain.class };
}
@Override
protected Class<? extends BinniePacketHandler> getPacketHandler() {
return PacketHandler.class;
@@ -236,4 +201,31 @@ public class BinnieCore extends AbstractMod {
super(instance);
}
}
public static class EventHandler {
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void handleSpeciesDiscovered(ForestryEvent.SpeciesDiscovered event) {
try {
EntityPlayerMP player = MinecraftServer.getServer().getConfigurationManager()
.func_152612_a(event.username.getName());
if (player == null) {
return;
}
event.tracker.synchToPlayer(player);
} catch (Exception ex) {
// ignored
}
}
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void handleTextureRemap(TextureStitchEvent.Pre event) {
if (event.map.getTextureType() == 0) {
Binnie.Liquid.reloadIcons(event.map);
}
Binnie.Resource.registerIcons(event.map, event.map.getTextureType());
}
}
}
@@ -7,4 +7,6 @@ public interface IInitializable {
void init();
void postInit();
default void registerEventHandler() {}
}
+1
View File
@@ -14,6 +14,7 @@ public class Mods {
public static final Mod botania = new Mod("Botania");
public static final Mod extraBiomes = new Mod("ExtrabiomesXL");
public static final Mod dreamcraft = new Mod("dreamcraft");
public static final Mod buildcraftCore = new Mod("BuildCraft|Core");
private static Item findItem(String modId, String name) {
Item stack = GameRegistry.findItem(modId, name);
@@ -76,12 +76,14 @@ public class TileEntityMetadata extends TileEntity {
}
public static ItemStack getItemStack(Block block, int damage) {
NBTTagCompound tag = new NBTTagCompound();
tag.setInteger("meta", damage);
ItemStack item = new ItemStack(block, 1, 0);
item.setItemDamage(Math.min(damage, 16387));
item.setTagCompound(tag);
if (0 <= damage && damage < Short.MAX_VALUE) {
item.setItemDamage(damage);
} else {
NBTTagCompound tag = new NBTTagCompound();
tag.setInteger("meta", damage);
item.setTagCompound(tag);
}
return item;
}
@@ -91,7 +91,7 @@ public interface IWidget {
void callEvent(Event event);
void recieveEvent(Event event);
void receiveEvent(Event event);
void onUpdateClient();
@@ -235,11 +235,11 @@ public class Widget implements IWidget {
@Override
public void callEvent(Event event) {
getSuperParent().recieveEvent(event);
getSuperParent().receiveEvent(event);
}
@Override
public void recieveEvent(Event event) {
public void receiveEvent(Event event) {
for (EventHandler handler : globalEventHandlers) {
if (handler.handles(event)) {
handler.onEvent(event);
@@ -248,7 +248,7 @@ public class Widget implements IWidget {
try {
for (IWidget child : getWidgets()) {
child.recieveEvent(event);
child.receiveEvent(event);
}
} catch (ConcurrentModificationException e) {
// ignored
@@ -12,6 +12,7 @@ import net.minecraft.init.Items;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import binnie.Binnie;
import binnie.core.AbstractMod;
@@ -33,6 +34,7 @@ import binnie.core.craftgui.resource.minecraft.CraftGUITexture;
import binnie.core.craftgui.resource.minecraft.PaddedTexture;
import binnie.core.craftgui.resource.minecraft.StandardTexture;
import binnie.core.machines.inventory.SlotValidator;
import binnie.core.network.packet.MessageCraftGUI;
import binnie.core.util.I18N;
import binnie.extrabees.core.ExtraBeeTexture;
import binnie.extrabees.gui.ExtraBeeGUITexture;
@@ -113,20 +115,26 @@ public class WindowFieldKit extends Window {
@Override
public void initialiseClient() {
final NBTTagList actions = new NBTTagList();
setTitle(getName());
CraftGUI.render.stylesheet(new StyleSheetPunnett());
getWindowInventory().createSlot(0);
getWindowInventory().createSlot(1);
setupValidators();
new ControlPlayerInventory(this);
new ControlPlayerInventory(this).create(actions);
IPoint handGlass = new IPoint(16.0f, 32.0f);
GlassControl = new ControlImage(
this,
handGlass.x(),
handGlass.y(),
new StandardTexture(0, 160, 96, 96, ExtraBeeTexture.GUIPunnett));
new ControlSlot(this, handGlass.x() + 54.0f, handGlass.y() + 26.0f).assign(InventoryType.Window, 0);
new ControlSlot(this, 208.0f, 8.0f).assign(InventoryType.Window, 1);
new ControlSlot(this, handGlass.x() + 54.0f, handGlass.y() + 26.0f).assign(actions, InventoryType.Window, 0);
new ControlSlot(this, 208.0f, 8.0f).assign(actions, InventoryType.Window, 1);
MessageCraftGUI.sendToServer(actions);
(text = new ControlText(this, new IPoint(232.0f, 13.0f), I18N.localise("binniecore.gui.tooltip.paper")))
.setColor(0x222222);
(text = new ControlText(this, new IArea(0.0f, 120.0f, w(), 24.0f), "", TextJustification.MIDDLE_CENTER))
@@ -285,8 +293,8 @@ public class WindowFieldKit extends Window {
}
@Override
public void recieveGuiNBT(Side side, EntityPlayer player, String name, NBTTagCompound nbt) {
super.recieveGuiNBT(side, player, name, nbt);
public void receiveGuiNBT(Side side, EntityPlayer player, String name, NBTTagCompound nbt) {
super.receiveGuiNBT(side, player, name, nbt);
if (side != Side.SERVER || !name.equals("analyse")) {
return;
}
@@ -63,7 +63,7 @@ public class WindowGenesis extends Window {
@Override
public void initialiseClient() {
new ControlPlayerInventory(this);
new ControlPlayerInventory(this).createAndRegister();
setTitle(getName());
ControlTabBar<BreedingSystem> tabSystems = new BreedingSystemControlTabBar();
@@ -175,8 +175,8 @@ public class WindowGenesis extends Window {
}
@Override
public void recieveGuiNBT(Side side, EntityPlayer player, String name, NBTTagCompound nbt) {
super.recieveGuiNBT(side, player, name, nbt);
public void receiveGuiNBT(Side side, EntityPlayer player, String name, NBTTagCompound nbt) {
super.receiveGuiNBT(side, player, name, nbt);
if (side == Side.SERVER && name.equals("genesis")) {
ItemStack stack = ItemStack.loadItemStackFromNBT(nbt);
InventoryPlayer playerInv = player.inventory;
@@ -1,5 +1,7 @@
package binnie.core.craftgui.minecraft;
import static net.minecraftforge.common.util.Constants.NBT.TAG_COMPOUND;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -7,12 +9,14 @@ import java.util.Map;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import com.mojang.authlib.GameProfile;
@@ -36,43 +40,71 @@ import cpw.mods.fml.relauncher.Side;
public class ContainerCraftGUI extends Container {
// Action type is one of the action constants below
public final static String ACTION_TYPE = "type";
// Action constants
public final static String ACTION_BATCH = "batch";
public final static String SLOT_REG = "slot-reg";
public final static String TANK_CLICK = "tank-click";
public final static String TANK_UPDATE = "tank-update-";
public final static String POWER_UPDATE = "power-update";
public final static String PROCESS_UPDATE = "process-update";
public final static String ERROR_UPDATE = "error-update";
public final static String MOUSE_OVER_SLOT = "mouse-over-slot";
public final static String SHIFT_CLICK_INFO = "shift-click-info";
// Error type is one of the error constants below
public final static String ERROR_TYPE = "type";
// Error constants
public static final byte CANNOT_WORK = (byte) 0;
public static final byte CANNOT_PROGRESS = (byte) 1;
// Slot constants
public static final String SLOT_TYPE = "t";
public static final String SLOT_INDEX = "i";
public static final String SLOT_NUMBER = "n";
// Uncategorized constants
public static final String ACTIONS = "actions";
private static final String USERNAME = "username";
private static final String SLOT_ID = "id";
private static final String SLOT = "slot";
private static final String SLOTS = "slots";
private static final String TANK = "tank";
private static final String ORIGIN = "origin";
private static final String NAME = "name";
private final Window window;
private final Map<String, NBTTagCompound> syncedNBT;
private final Map<String, NBTTagCompound> sentNBT;
private final Map<Integer, TankInfo> syncedTanks;
private PowerInfo syncedPower;
private ProcessInfo syncedProcess;
private int errorType;
private ErrorState error;
private int mousedOverSlotNumber;
private final Map<String, NBTTagCompound> syncedNBT = new HashMap<>();
private final Map<String, NBTTagCompound> sentNBT = new HashMap<>();
private final Map<Integer, TankInfo> syncedTanks = new HashMap<>();
private PowerInfo syncedPower = new PowerInfo();
private ProcessInfo syncedProcess = new ProcessInfo();
private int errorType = 0;
private ErrorState error = null;
private int mousedOverSlotNumber = -1;
public ContainerCraftGUI(Window window) {
this.window = window;
syncedNBT = new HashMap<>();
sentNBT = new HashMap<>();
syncedTanks = new HashMap<>();
syncedPower = new PowerInfo();
syncedProcess = new ProcessInfo();
errorType = 0;
error = null;
mousedOverSlotNumber = -1;
IMachine machine = Machine.getMachine(window.getInventory());
if (getSide() != Side.SERVER) {
return;
}
if (!window.isServer()) return;
// WARNING: The client side expects `ArrayList` and the server expects `ListMap`
inventoryItemStacks = new ListMap<>();
inventorySlots = new ListMap<>();
if (machine == null) {
return;
}
IInventory entityInventory = window.getInventory();
IMachine machine = Machine.getMachine(entityInventory);
if (machine == null) return;
GameProfile user = machine.getOwner();
if (user != null) {
NBTTagCompound nbt = new NBTTagCompound();
nbt.setString("username", user.getName());
sendNBTToClient("username", nbt);
}
if (user == null) return;
NBTTagCompound nbt = new NBTTagCompound();
nbt.setString(USERNAME, user.getName());
sendNBTToClient(USERNAME, nbt);
}
@Override
@@ -86,54 +118,47 @@ public class ContainerCraftGUI extends Container {
@Override
public Slot getSlot(int index) {
if (index < 0 || index >= inventorySlots.size()) {
return null;
}
return inventorySlots.get(index);
return index < 0 || index >= inventorySlots.size() ? null : inventorySlots.get(index);
}
@Override
public void putStackInSlot(int index, ItemStack stack) {
if (getSlot(index) != null) {
getSlot(index).putStack(stack);
}
final Slot slot = getSlot(index);
if (slot != null) slot.putStack(stack);
}
@Override
public void putStacksInSlots(ItemStack[] par1ArrayOfItemStack) {
for (int i = 0; i < par1ArrayOfItemStack.length; ++i) {
if (getSlot(i) != null) {
getSlot(i).putStack(par1ArrayOfItemStack[i]);
}
final Slot slot = getSlot(i);
if (slot != null) slot.putStack(par1ArrayOfItemStack[i]);
}
}
@Override
public void onContainerClosed(EntityPlayer player) {
super.onContainerClosed(player);
WindowInventory inventory = window.getWindowInventory();
for (int i = 0; i < inventory.getSizeInventory(); ++i) {
if (!inventory.dispenseOnClose(i)) {
continue;
}
WindowInventory windowInventory = window.getWindowInventory();
InventoryPlayer playerInventory = player.inventory;
ItemStack stack = inventory.getStackInSlot(i);
if (stack == null) {
continue;
}
for (int i = 0; i < windowInventory.getSizeInventory(); ++i) {
if (!windowInventory.dispenseOnClose(i)) continue;
stack = new TransferRequest(stack, player.inventory).transfer(true);
if (stack != null) {
player.dropPlayerItemWithRandomChoice(stack, false);
}
final ItemStack stack = windowInventory.getStackInSlot(i);
if (stack == null) continue;
final ItemStack newStack = new TransferRequest(stack, playerInventory).transfer(true);
if (newStack == null) continue;
player.dropPlayerItemWithRandomChoice(newStack, false);
}
}
@Override
public ItemStack slotClick(int slotNum, int mouseButton, int modifier, EntityPlayer player) {
Slot slot = getSlot(slotNum);
if (slot instanceof CustomSlot && ((CustomSlot) slot).handleClick()) {
((CustomSlot) slot).onSlotClick(this, mouseButton, modifier, player);
if (slot instanceof CustomSlot customSlot && customSlot.handleClick()) {
customSlot.onSlotClick(this, mouseButton, modifier, player);
return player.inventory.getItemStack();
}
return super.slotClick(slotNum, mouseButton, modifier, player);
@@ -151,45 +176,40 @@ public class ContainerCraftGUI extends Container {
}
sentNBT.clear();
}
IInventory inventory = window.getInventory();
return inventory == null || inventory.isUseableByPlayer(player);
IInventory entityInventory = window.getInventory();
return entityInventory == null || entityInventory.isUseableByPlayer(player);
}
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int slotID) {
return shiftClick(player, slotID);
shiftClick(player, slotID);
return null;
}
private ItemStack shiftClick(EntityPlayer player, int index) {
private void shiftClick(EntityPlayer player, int index) {
TransferRequest request = getShiftClickRequest(player, index);
if (request == null) {
return null;
}
if (request == null) return;
ItemStack stack = request.transfer(true);
Slot shiftClickedSlot = inventorySlots.get(index);
shiftClickedSlot.putStack(stack);
shiftClickedSlot.onSlotChanged();
return null;
}
private TransferRequest getShiftClickRequest(EntityPlayer player, int index) {
if (index < 0) {
return null;
}
if (index < 0) return null;
Slot shiftClickedSlot = (Slot) inventorySlots.get(index);
Slot shiftClickedSlot = inventorySlots.get(index);
ItemStack itemstack = null;
if (shiftClickedSlot.getHasStack()) {
itemstack = shiftClickedSlot.getStack().copy();
}
IInventory playerInventory = player.inventory;
IInventory containerInventory = window.getInventory();
IInventory entityInventory = window.getInventory();
IInventory windowInventory = window.getWindowInventory();
IInventory fromPlayer = (containerInventory == null) ? windowInventory : containerInventory;
IInventory fromPlayer = (entityInventory == null) ? windowInventory : entityInventory;
int[] target = new int[36];
for (int i = 0; i < 36; ++i) {
for (int i = 0; i < target.length; ++i) {
target[i] = i;
}
@@ -201,108 +221,116 @@ public class ContainerCraftGUI extends Container {
.setTargetSlots(target);
}
if (window instanceof IWindowAffectsShiftClick) {
((IWindowAffectsShiftClick) window).alterRequest(request);
if (window instanceof IWindowAffectsShiftClick iWindowAffectsShiftClick) {
iWindowAffectsShiftClick.alterRequest(request);
}
return request;
}
@SuppressWarnings("UnusedReturnValue")
public ItemStack tankClick(EntityPlayer player, int slotID) {
if (player.inventory.getItemStack() == null) {
return null;
}
if (player.inventory.getItemStack() == null) return null;
ItemStack heldItem = player.inventory.getItemStack().copy();
heldItem = new TransferRequest(heldItem, window.getInventory()).setOrigin(player.inventory)
.setTargetSlots(new int[0]).setTargetTanks(new int[] { slotID }).transfer(true);
IInventory entityInventory = window.getInventory();
heldItem = new TransferRequest(heldItem, entityInventory).setOrigin(player.inventory).setTargetSlots(new int[0])
.setTargetTanks(new int[] { slotID }).transfer(true);
player.inventory.setItemStack(heldItem);
if (player instanceof EntityPlayerMP) {
((EntityPlayerMP) player).updateHeldItem();
if (player instanceof EntityPlayerMP entityPlayerMP) {
entityPlayerMP.updateHeldItem();
}
return heldItem;
}
public boolean handleNBT(Side side, EntityPlayer player, String name, NBTTagCompound action) {
if (side == Side.SERVER) {
if (name.equals("tank-click")) {
tankClick(player, action.getByte("id"));
}
if (name.equals("slot-reg")) {
int type = action.getByte("t");
int index = action.getShort("i");
int slotNumber = action.getShort("n");
getOrCreateSlot(InventoryType.values()[type % 4], index, slotNumber);
public void handleNBT(Side side, EntityPlayer player, NBTTagCompound action) {
final String actionType = action.getString(ACTION_TYPE);
for (ICrafting crafterObject : crafters) {
crafterObject.sendContainerAndContentsToPlayer(this, getInventory());
if (side == Side.SERVER) {
switch (actionType) {
case TANK_CLICK -> tankClick(player, action.getByte(SLOT_ID));
case SLOT_REG -> {
final int slotType = action.getByte(SLOT_TYPE);
final int slotIndex = action.getShort(SLOT_INDEX);
final int slotNumber = action.getShort(SLOT_NUMBER);
createSlot(InventoryType.values()[slotType % 4], slotIndex, slotNumber);
for (ICrafting crafterObject : crafters) {
crafterObject.sendContainerAndContentsToPlayer(this, getInventory());
}
}
}
}
if (name.contains("tank-update")) {
onTankUpdate(action);
} else if (name.equals("power-update")) {
onPowerUpdate(action);
} else if (name.equals("process-update")) {
onProcessUpdate(action);
} else if (name.equals("error-update")) {
onErrorUpdate(action);
} else if (name.equals("mouse-over-slot")) {
onMouseOverSlot(player, action);
} else if (name.equals("shift-click-info")) {
onRecieveShiftClickHighlights(player, action);
switch (actionType) {
case POWER_UPDATE -> onPowerUpdate(action);
case PROCESS_UPDATE -> onProcessUpdate(action);
case ERROR_UPDATE -> onErrorUpdate(action);
case MOUSE_OVER_SLOT -> onMouseOverSlot(player, action);
case SHIFT_CLICK_INFO -> onReceiveShiftClickHighlights(action);
default -> {
if (actionType.contains(TANK_UPDATE)) onTankUpdate(action);
}
}
return false;
}
@Override
public void detectAndSendChanges() {
super.detectAndSendChanges();
ITankMachine tanks = Machine.getInterface(ITankMachine.class, window.getInventory());
IPoweredMachine powered = Machine.getInterface(IPoweredMachine.class, window.getInventory());
IErrorStateSource error = Machine.getInterface(IErrorStateSource.class, window.getInventory());
IProcess process = Machine.getInterface(IProcess.class, window.getInventory());
if (tanks != null && window.isServer()) {
for (int i = 0; i < tanks.getTankInfos().length; ++i) {
TankInfo tank = tanks.getTankInfos()[i];
if (!getTankInfo(i).equals(tank)) {
syncedNBT.put("tank-update-" + i, createTankNBT(i, tank));
syncedTanks.put(i, tank);
}
IInventory entityInventory = window.getInventory();
ITankMachine tanks = Machine.getInterface(ITankMachine.class, entityInventory);
IPoweredMachine powered = Machine.getInterface(IPoweredMachine.class, entityInventory);
IErrorStateSource error = Machine.getInterface(IErrorStateSource.class, entityInventory);
IProcess process = Machine.getInterface(IProcess.class, entityInventory);
if (window.isServer() && tanks != null) {
final TankInfo[] tankInfos = tanks.getTankInfos();
for (int i = 0; i < tankInfos.length; ++i) {
final TankInfo tank = tankInfos[i];
if (this.getTankInfo(i).equals(tank)) continue;
syncedNBT.put(TANK_UPDATE + i, createTankNBT(i, tank));
syncedTanks.put(i, tank);
}
}
if (powered != null && window.isServer()) {
syncedNBT.put("power-update", createPowerNBT(powered.getPowerInfo()));
}
if (process != null && window.isServer()) {
syncedNBT.put("process-update", createProcessNBT(process.getInfo()));
}
if (error != null && window.isServer()) {
syncedNBT.put("error-update", createErrorNBT(error));
if (window.isServer()) {
if (powered != null) syncedNBT.put(POWER_UPDATE, createPowerNBT(powered.getPowerInfo()));
if (process != null) syncedNBT.put(PROCESS_UPDATE, createProcessNBT(process.getInfo()));
if (error != null) syncedNBT.put(ERROR_UPDATE, createErrorNBT(error));
}
INetwork.SendGuiNBT machineSync = Machine.getInterface(INetwork.SendGuiNBT.class, window.getInventory());
if (machineSync != null) {
machineSync.sendGuiNBT(syncedNBT);
}
INetwork.SendGuiNBT machineSync = Machine.getInterface(INetwork.SendGuiNBT.class, entityInventory);
if (machineSync != null) machineSync.sendGuiNBT(syncedNBT);
Map<String, NBTTagCompound> sentThisTime = new HashMap<>();
for (Map.Entry<String, NBTTagCompound> nbt : syncedNBT.entrySet()) {
nbt.getValue().setString("type", nbt.getKey());
boolean shouldSend = true;
NBTTagCompound lastSent = sentNBT.get(nbt.getKey());
if (lastSent != null) {
shouldSend = !lastSent.equals(nbt.getValue());
}
NBTTagList actions = new NBTTagList();
if (shouldSend) {
for (Object crafter : crafters) {
if (crafter instanceof EntityPlayerMP playerMP) {
BinnieCore.proxy.sendToPlayer(new MessageContainerUpdate(nbt.getValue()), playerMP);
}
}
sentThisTime.put(nbt.getKey(), nbt.getValue());
for (Map.Entry<String, NBTTagCompound> entry : syncedNBT.entrySet()) {
final String actionType = entry.getKey();
final NBTTagCompound action = entry.getValue();
final NBTTagCompound actionPrev = sentNBT.get(actionType);
action.setString(ACTION_TYPE, actionType);
if (action.equals(actionPrev)) continue;
actions.appendTag(action);
sentThisTime.put(actionType, action);
}
NBTTagCompound actionsBatch = new NBTTagCompound();
actionsBatch.setString(ACTION_TYPE, ACTION_BATCH);
actionsBatch.setTag(ACTIONS, actions);
for (ICrafting crafter : crafters) {
if (crafter instanceof EntityPlayerMP playerMP) {
final MessageContainerUpdate packet = new MessageContainerUpdate(actionsBatch);
BinnieCore.proxy.sendToPlayer(packet, playerMP);
}
}
@@ -314,10 +342,10 @@ public class ContainerCraftGUI extends Container {
NBTTagCompound nbt = new NBTTagCompound();
ErrorState state = null;
if (error.canWork() != null) {
nbt.setByte("type", (byte) 0);
nbt.setByte(ERROR_TYPE, CANNOT_WORK);
state = error.canWork();
} else if (error.canProgress() != null) {
nbt.setByte("type", (byte) 1);
nbt.setByte(ERROR_TYPE, CANNOT_PROGRESS);
state = error.canProgress();
}
@@ -342,19 +370,20 @@ public class ContainerCraftGUI extends Container {
public NBTTagCompound createTankNBT(int tank, TankInfo tankInfo) {
NBTTagCompound nbt = new NBTTagCompound();
tankInfo.writeToNBT(nbt);
nbt.setByte("tank", (byte) tank);
nbt.setByte(TANK, (byte) tank);
return nbt;
}
public void onTankUpdate(NBTTagCompound nbt) {
int tankID = nbt.getByte("tank");
int tankID = nbt.getByte(TANK);
TankInfo tank = new TankInfo();
tank.readFromNBT(nbt);
syncedTanks.put(tankID, tank);
}
public void onProcessUpdate(NBTTagCompound nbt) {
(syncedProcess = new ProcessInfo()).readFromNBT(nbt);
syncedProcess = new ProcessInfo();
syncedProcess.readFromNBT(nbt);
}
public void onPowerUpdate(NBTTagCompound nbt) {
@@ -375,8 +404,8 @@ public class ContainerCraftGUI extends Container {
}
public void onErrorUpdate(NBTTagCompound nbt) {
errorType = nbt.getByte("type");
if (nbt.hasKey("name")) {
errorType = nbt.getByte(ERROR_TYPE);
if (nbt.hasKey(NAME)) {
error = new ErrorState("", "");
error.readFromNBT(nbt);
} else {
@@ -403,20 +432,18 @@ public class ContainerCraftGUI extends Container {
}
public void setMouseOverSlot(Slot slot) {
if (slot.slotNumber == mousedOverSlotNumber) {
return;
}
if (slot.slotNumber == mousedOverSlotNumber) return;
mousedOverSlotNumber = slot.slotNumber;
ControlSlot.highlighting.get(EnumHighlighting.SHIFT_CLICK).clear();
NBTTagCompound nbt = new NBTTagCompound();
nbt.setShort("slot", (short) slot.slotNumber);
window.sendClientAction("mouse-over-slot", nbt);
nbt.setShort(SLOT, (short) slot.slotNumber);
window.sendClientAction(MOUSE_OVER_SLOT, nbt);
}
private void onMouseOverSlot(EntityPlayer player, NBTTagCompound data) {
int slotnumber = data.getShort("slot");
TransferRequest request = getShiftClickRequest(player, slotnumber);
int slotNumber = data.getShort(SLOT);
TransferRequest request = getShiftClickRequest(player, slotNumber);
if (request == null) {
return;
}
@@ -424,8 +451,8 @@ public class ContainerCraftGUI extends Container {
request.transfer(false);
NBTTagCompound nbt = new NBTTagCompound();
List<Integer> slots = new ArrayList<>();
for (TransferRequest.TransferSlot tslot : request.getInsertedSlots()) {
Slot slot = getSlot(tslot.inventory, tslot.id);
for (TransferRequest.TransferSlot transferSlot : request.getInsertedSlots()) {
Slot slot = getSlot(transferSlot.inventory, transferSlot.id);
if (slot != null) {
slots.add(slot.slotNumber);
}
@@ -436,15 +463,15 @@ public class ContainerCraftGUI extends Container {
array[i] = slots.get(i);
}
nbt.setIntArray("slots", array);
nbt.setShort("origin", (short) slotnumber);
syncedNBT.put("shift-click-info", nbt);
nbt.setIntArray(SLOTS, array);
nbt.setShort(ORIGIN, (short) slotNumber);
syncedNBT.put(SHIFT_CLICK_INFO, nbt);
}
private void onRecieveShiftClickHighlights(EntityPlayer player, NBTTagCompound data) {
private void onReceiveShiftClickHighlights(NBTTagCompound data) {
ControlSlot.highlighting.get(EnumHighlighting.SHIFT_CLICK).clear();
for (int slotnumber : data.getIntArray("slots")) {
ControlSlot.highlighting.get(EnumHighlighting.SHIFT_CLICK).add(slotnumber);
for (int slotIndex : data.getIntArray(SLOTS)) {
ControlSlot.highlighting.get(EnumHighlighting.SHIFT_CLICK).add(slotIndex);
}
}
@@ -458,58 +485,50 @@ public class ContainerCraftGUI extends Container {
return null;
}
public void recieveNBT(Side side, EntityPlayer player, NBTTagCompound action) {
String name = action.getString("type");
if (handleNBT(side, player, name, action)) {
public void receiveNBT(Side side, EntityPlayer player, NBTTagCompound action) {
String actionType = action.getString(ACTION_TYPE);
if (actionType.equals(ACTION_BATCH)) {
NBTTagList actionsBatch = action.getTagList(ACTIONS, TAG_COMPOUND);
for (int i = 0; i < actionsBatch.tagCount(); i++) {
receiveNBT(side, player, actionsBatch.getCompoundTagAt(i));
}
return;
}
window.recieveGuiNBT(getSide(), player, name, action);
INetwork.RecieveGuiNBT machine = Machine.getInterface(INetwork.RecieveGuiNBT.class, window.getInventory());
if (machine != null) {
machine.recieveGuiNBT(getSide(), player, name, action);
}
handleNBT(side, player, action);
window.receiveGuiNBT(getSide(), player, actionType, action);
INetwork.ReceiveGuiNBT machine = Machine.getInterface(INetwork.ReceiveGuiNBT.class, window.getInventory());
if (machine == null) return;
machine.receiveGuiNBT(getSide(), player, actionType, action);
}
public Slot getOrCreateSlot(InventoryType type, int index) {
IInventory inventory = getInventory(type);
Slot slot = getSlot(inventory, index);
public Slot getOrCreateSlot(InventoryType inventoryType, int slotIndex) {
final IInventory inventory = getInventory(inventoryType);
Slot slot = getSlot(inventory, slotIndex);
if (slot == null) {
slot = new CustomSlot(inventory, index);
slot = new CustomSlot(inventory, slotIndex);
addSlotToContainer(slot);
}
NBTTagCompound nbt = new NBTTagCompound();
nbt.setByte("t", (byte) type.ordinal());
nbt.setShort("i", (short) index);
nbt.setShort("n", (short) slot.slotNumber);
window.sendClientAction("slot-reg", nbt);
return slot;
}
protected IInventory getInventory(InventoryType type) {
if (type == InventoryType.Machine) {
return window.getInventory();
}
if (type == InventoryType.Player) {
return window.getPlayer().inventory;
}
if (type == InventoryType.Window) {
return window.getWindowInventory();
}
return null;
return switch (type) {
case Machine -> window.getInventory();
case Player -> window.getPlayer().inventory;
case Window -> window.getWindowInventory();
default -> null;
};
}
private Slot getOrCreateSlot(InventoryType type, int index, int slotNumber) {
IInventory inventory = getInventory(type);
if (inventorySlots.get(slotNumber) != null) {
return null;
}
private void createSlot(InventoryType type, int index, int slotNumber) {
if (inventorySlots.get(slotNumber) != null) return;
IInventory inventory = getInventory(type);
Slot slot = new CustomSlot(inventory, index);
slot.slotNumber = slotNumber;
inventorySlots.add(slotNumber, slot);
inventoryItemStacks.add(slotNumber, null);
return slot;
}
}
@@ -48,7 +48,7 @@ import binnie.core.resource.ResourceType;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public abstract class Window extends TopLevelWidget implements INetwork.RecieveGuiNBT {
public abstract class Window extends TopLevelWidget implements INetwork.ReceiveGuiNBT {
protected float titleButtonLeft;
protected float titleButtonRight;
@@ -291,7 +291,7 @@ public abstract class Window extends TopLevelWidget implements INetwork.RecieveG
}
@Override
public void recieveGuiNBT(Side side, EntityPlayer player, String name, NBTTagCompound nbt) {
public void receiveGuiNBT(Side side, EntityPlayer player, String name, NBTTagCompound nbt) {
if (side == Side.CLIENT && name.equals("username")) {
float w = w();
float titleButtonRight = this.titleButtonRight + 16.0f;
@@ -1,7 +1,5 @@
package binnie.core.craftgui.minecraft.control;
import net.minecraft.inventory.IInventory;
import org.lwjgl.opengl.GL11;
import binnie.core.craftgui.CraftGUI;
@@ -17,8 +15,6 @@ import binnie.core.craftgui.minecraft.MinecraftTooltip;
import binnie.core.craftgui.minecraft.Window;
import binnie.core.craftgui.resource.minecraft.CraftGUITexture;
import binnie.core.machines.Machine;
import binnie.core.machines.TileEntityMachine;
import binnie.core.machines.power.IPoweredMachine;
import binnie.core.machines.power.IProcess;
import binnie.core.util.I18N;
@@ -34,17 +30,6 @@ public class ControlEnergyBar extends Control implements ITooltip {
addAttribute(WidgetAttribute.MOUSE_OVER);
}
// TODO unused method?
public IPoweredMachine getClientPower() {
IInventory inventory = Window.get(this).getInventory();
TileEntityMachine machine = (inventory instanceof TileEntityMachine) ? (TileEntityMachine) inventory : null;
if (machine == null) {
return null;
}
return machine.getMachine().getInterface(IPoweredMachine.class);
}
public float getPercentage() {
float percentage = 100.0f * getStoredEnergy() / getMaxEnergy();
if (percentage > 100.0f) {
@@ -3,9 +3,12 @@ package binnie.core.craftgui.minecraft.control;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.nbt.NBTTagList;
import binnie.core.craftgui.IWidget;
import binnie.core.craftgui.controls.core.Control;
import binnie.core.craftgui.minecraft.InventoryType;
import binnie.core.network.packet.MessageCraftGUI;
public class ControlPlayerInventory extends Control {
@@ -37,7 +40,6 @@ public class ControlPlayerInventory extends Control {
slots.add(slot2);
}
}
create();
}
public ControlPlayerInventory(IWidget parent) {
@@ -53,28 +55,28 @@ public class ControlPlayerInventory extends Control {
slots.add(slot);
}
}
create();
}
public void create() {
public ControlPlayerInventory create(NBTTagList actions) {
for (int row = 0; row < 3; ++row) {
for (int column = 0; column < 9; ++column) {
ControlSlot slot = slots.get(column + row * 9);
slot.assign(InventoryType.Player, 9 + column + row * 9);
slot.assign(actions, InventoryType.Player, 9 + column + row * 9);
}
}
for (int i1 = 0; i1 < 9; ++i1) {
ControlSlot slot2 = slots.get(27 + i1);
slot2.assign(InventoryType.Player, i1);
slot2.assign(actions, InventoryType.Player, i1);
}
return this;
}
public ControlSlot getSlot(int i) {
if (i < 0 || i >= slots.size()) {
return null;
}
return slots.get(i);
public ControlPlayerInventory createAndRegister() {
final NBTTagList actions = new NBTTagList();
create(actions);
MessageCraftGUI.sendToServer(actions);
return this;
}
}
@@ -1,5 +1,11 @@
package binnie.core.craftgui.minecraft.control;
import static binnie.core.craftgui.minecraft.ContainerCraftGUI.ACTION_TYPE;
import static binnie.core.craftgui.minecraft.ContainerCraftGUI.SLOT_INDEX;
import static binnie.core.craftgui.minecraft.ContainerCraftGUI.SLOT_NUMBER;
import static binnie.core.craftgui.minecraft.ContainerCraftGUI.SLOT_REG;
import static binnie.core.craftgui.minecraft.ContainerCraftGUI.SLOT_TYPE;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -10,6 +16,8 @@ import net.minecraft.client.multiplayer.PlayerControllerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.IIcon;
import binnie.core.craftgui.CraftGUI;
@@ -26,6 +34,7 @@ import binnie.core.craftgui.resource.minecraft.CraftGUITexture;
import binnie.core.machines.inventory.InventorySlot;
import binnie.core.machines.inventory.MachineSide;
import binnie.core.machines.inventory.SlotValidator;
import binnie.core.network.packet.MessageCraftGUI;
import binnie.core.util.I18N;
public class ControlSlot extends ControlSlotBase {
@@ -179,14 +188,28 @@ public class ControlSlot extends ControlSlotBase {
return null;
}
public ControlSlot assign(int index) {
return assign(InventoryType.Machine, index);
/// Assign a slot and register it immediately. Should be used when no other actions need to be sent.
@SuppressWarnings("UnusedReturnValue")
public ControlSlot assignAndRegister(InventoryType inventoryType, int slotIndex) {
final NBTTagList actions = new NBTTagList();
assign(actions, inventoryType, slotIndex);
MessageCraftGUI.sendToServer(actions);
return this;
}
public ControlSlot assign(InventoryType inventory, int index) {
if (slot == null) {
slot = ((Window) getSuperParent()).getContainer().getOrCreateSlot(inventory, index);
}
/// Assign a slot and defer registration using an `NBTTagList`.
/// Use in combination with {@link MessageCraftGUI#sendToServer(NBTTagList)}.
public ControlSlot assign(NBTTagList actions, InventoryType inventoryType, int slotIndex) {
if (slot == null) slot = ((Window) getSuperParent()).getContainer().getOrCreateSlot(inventoryType, slotIndex);
NBTTagCompound slotReg = new NBTTagCompound();
slotReg.setString(ACTION_TYPE, SLOT_REG);
slotReg.setByte(SLOT_TYPE, (byte) inventoryType.ordinal());
slotReg.setShort(SLOT_INDEX, (short) slotIndex);
slotReg.setShort(SLOT_NUMBER, (short) slot.slotNumber);
actions.appendTag(slotReg);
return this;
}
@@ -4,6 +4,8 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import net.minecraft.nbt.NBTTagList;
import binnie.core.craftgui.IWidget;
import binnie.core.craftgui.controls.core.Control;
import binnie.core.craftgui.minecraft.InventoryType;
@@ -26,15 +28,14 @@ public class ControlSlotArray extends Control implements Iterable<ControlSlot> {
return new ControlSlot(this, x, y);
}
public ControlSlotArray create(int[] index) {
return create(InventoryType.Machine, index);
}
public ControlSlotArray create(InventoryType type, int[] index) {
public ControlSlotArray create(NBTTagList actions, InventoryType inventoryType, int[] index) {
int i = 0;
for (ControlSlot slot : slots) {
slot.assign(type, index[i++]);
for (ControlSlot controlSlot : slots) {
final int slotIndex = index[i];
controlSlot.assign(actions, inventoryType, slotIndex);
i++;
}
return this;
}
@@ -57,7 +57,7 @@ public abstract class BreedingSystem implements IItemStackRepresentative {
public BreedingSystem() {
Binnie.Genetics.registerBreedingSystem(this);
MinecraftForge.EVENT_BUS.register(this);
MinecraftForge.EVENT_BUS.register(new EventHandler());
}
public String getChromosomeName(IChromosomeType chromo) {
@@ -294,13 +294,16 @@ public abstract class BreedingSystem implements IItemStackRepresentative {
public abstract Class<? extends IBreedingTracker> getTrackerClass();
@SubscribeEvent
public void onSyncBreedingTracker(ForestryEvent.SyncedBreedingTracker event) {
IBreedingTracker tracker = event.tracker;
if (!getTrackerClass().isInstance(tracker)) {
return;
public class EventHandler {
@SubscribeEvent
public void onSyncBreedingTracker(ForestryEvent.SyncedBreedingTracker event) {
IBreedingTracker tracker = event.tracker;
if (!getTrackerClass().isInstance(tracker)) {
return;
}
syncTracker(tracker);
}
syncTracker(tracker);
}
public void syncTracker(IBreedingTracker tracker) {
@@ -9,6 +9,7 @@ import java.util.Map;
import java.util.TreeSet;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.world.WorldEvent;
import binnie.Binnie;
@@ -58,9 +59,8 @@ public class ManagerGenetics extends ManagerBase {
if (BinnieCore.isLepidopteryActive()) {
mothBreedingSystem = new MothBreedingSystem();
}
if (BinnieCore.isBotanyActive()) {
flowerBreedingSystem = new FlowerBreedingSystem();
}
flowerBreedingSystem = new FlowerBreedingSystem();
}
@Override
@@ -68,6 +68,11 @@ public class ManagerGenetics extends ManagerBase {
refreshData();
}
@Override
public void registerEventHandler() {
MinecraftForge.EVENT_BUS.register(new EventHandler());
}
public ITreeRoot getTreeRoot() {
return (ITreeRoot) AlleleManager.alleleRegistry.getSpeciesRoot("rootTrees");
}
@@ -141,11 +146,6 @@ public class ManagerGenetics extends ManagerBase {
return (system == null) ? null : system.getConversion(stack);
}
@SubscribeEvent
public void onWorldLoad(WorldEvent.Load event) {
refreshData();
}
private void refreshData() {
loadAlleles();
for (BreedingSystem system : Binnie.Genetics.getActiveSystems()) {
@@ -220,4 +220,12 @@ public class ManagerGenetics extends ManagerBase {
return o1.getUID().compareTo(o2.getUID());
}
}
public class EventHandler {
@SubscribeEvent
public void onWorldLoad(WorldEvent.Load event) {
refreshData();
}
}
}
+34 -25
View File
@@ -6,6 +6,7 @@ import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import binnie.botany.Botany;
@@ -49,36 +50,44 @@ public class ModuleItems implements IInitializable {
new ItemStack(Items.dye, 1));
}
@SubscribeEvent
public void onUseFieldKit(PlayerInteractEvent event) {
if (!BinnieCore.isBotanyActive() || event.action != PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) {
return;
}
@Override
public void registerEventHandler() {
MinecraftForge.EVENT_BUS.register(new EventHandler());
}
EntityPlayer player = event.entityPlayer;
if (player != null && player.getHeldItem() != null
&& player.getHeldItem().getItem() == BinnieCore.fieldKit
&& player.isSneaking()) {
TileEntity tile = event.world.getTileEntity(event.x, event.y, event.z);
if (!(tile instanceof TileEntityFlower tileFlower)) {
public static class EventHandler {
@SubscribeEvent
public void onUseFieldKit(PlayerInteractEvent event) {
if (event.action != PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) {
return;
}
IFlower flower = tileFlower.getFlower();
if (flower == null) {
return;
}
EntityPlayer player = event.entityPlayer;
if (player != null && player.getHeldItem() != null
&& player.getHeldItem().getItem() == BinnieCore.fieldKit
&& player.isSneaking()) {
TileEntity tile = event.world.getTileEntity(event.x, event.y, event.z);
if (!(tile instanceof TileEntityFlower tileFlower)) {
return;
}
NBTTagCompound info = new NBTTagCompound();
info.setString("Species", flower.getGenome().getPrimary().getUID());
info.setString("Species2", flower.getGenome().getSecondary().getUID());
info.setFloat("Age", flower.getAge() / flower.getGenome().getLifespan());
info.setShort("Colour", (short) flower.getGenome().getPrimaryColor().getID());
info.setShort("Colour2", (short) flower.getGenome().getSecondaryColor().getID());
info.setBoolean("Wilting", flower.isWilted());
info.setBoolean("Flowered", flower.hasFlowered());
Botany.proxy.sendToPlayer(new MessageNBT(PacketID.FieldKit.ordinal(), info), event.entityPlayer);
event.entityPlayer.getHeldItem().damageItem(1, event.entityPlayer);
IFlower flower = tileFlower.getFlower();
if (flower == null) {
return;
}
NBTTagCompound info = new NBTTagCompound();
info.setString("Species", flower.getGenome().getPrimary().getUID());
info.setString("Species2", flower.getGenome().getSecondary().getUID());
info.setFloat("Age", flower.getAge() / flower.getGenome().getLifespan());
info.setShort("Colour", (short) flower.getGenome().getPrimaryColor().getID());
info.setShort("Colour2", (short) flower.getGenome().getSecondaryColor().getID());
info.setBoolean("Wilting", flower.isWilted());
info.setBoolean("Flowered", flower.hasFlowered());
Botany.proxy.sendToPlayer(new MessageNBT(PacketID.FieldKit.ordinal(), info), event.entityPlayer);
event.entityPlayer.getHeldItem().damageItem(1, event.entityPlayer);
}
}
}
}
@@ -5,6 +5,4 @@ import binnie.core.network.IOrdinaled;
public interface IMachineType extends IOrdinaled {
Class<? extends MachinePackage> getPackageClass();
boolean isActive();
}
@@ -277,16 +277,16 @@ public class Machine implements INetworkedEntity, INBTTagable, INetwork.TilePack
}
@Override
public void recieveGuiNBT(Side side, EntityPlayer player, String name, NBTTagCompound nbt) {
for (INetwork.RecieveGuiNBT recieve : getInterfaces(INetwork.RecieveGuiNBT.class)) {
recieve.recieveGuiNBT(side, player, name, nbt);
public void receiveGuiNBT(Side side, EntityPlayer player, String name, NBTTagCompound nbt) {
for (INetwork.ReceiveGuiNBT receive : getInterfaces(INetwork.ReceiveGuiNBT.class)) {
receive.receiveGuiNBT(side, player, name, nbt);
}
}
@Override
public void sendGuiNBT(Map<String, NBTTagCompound> nbts) {
for (INetwork.SendGuiNBT recieve : getInterfaces(INetwork.SendGuiNBT.class)) {
recieve.sendGuiNBT(nbts);
for (INetwork.SendGuiNBT receive : getInterfaces(INetwork.SendGuiNBT.class)) {
receive.sendGuiNBT(nbts);
}
}
}
@@ -50,7 +50,7 @@ public class MachineComponent implements INBTTagable {
return new MachinePayload(Binnie.Machine.getNetworkID(getClass()));
}
public void recieveData(MachinePayload payload) {}
public void receiveData(MachinePayload payload) {}
public MachineUtil getUtil() {
return getMachine().getMachineUtil();
@@ -31,14 +31,14 @@ public class MachineGroup {
this.blockName = blockName;
for (IMachineType type : types) {
if (type.getPackageClass() != null && type.isActive()) {
if (type.getPackageClass() != null) {
try {
MachinePackage pack = type.getPackageClass().newInstance();
pack.assignMetadata(type.ordinal());
pack.setActive(type.isActive());
pack.setActive(true);
addPackage(pack);
} catch (Exception e) {
throw new RuntimeException("Failed to create machine package " + type.toString(), e);
throw new RuntimeException("Failed to create machine package " + type, e);
}
}
}
@@ -49,7 +49,7 @@ public class ComponentChargedSlots extends MachineComponent implements INetwork.
}
@Override
public void recieveGuiNBT(Side side, EntityPlayer player, String name, NBTTagCompound nbt) {
public void receiveGuiNBT(Side side, EntityPlayer player, String name, NBTTagCompound nbt) {
if (!name.equals("slot-charges")) {
return;
}
@@ -1,233 +0,0 @@
package binnie.core.machines.inventory;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidTank;
import binnie.core.machines.Machine;
import binnie.core.machines.power.ITankMachine;
// TODO unused class?
public class TransferHandler {
public static ItemStack transfer(ItemStack item, IInventory origin, IInventory destination, boolean doAdd) {
ItemStack ret = transferItemToInventory(item, destination, doAdd);
if (destination instanceof ITankMachine) {
ret = transferContainerIntoTank(ret, origin, (ITankMachine) destination, doAdd);
ret = transferTankIntoContainer(ret, origin, (ITankMachine) destination, doAdd);
}
return ret;
}
public static ItemStack transferItemToInventory(ItemStack item, IInventory destination, boolean doAdd) {
if (item == null || destination == null) {
return item;
}
ItemStack addition = item.copy();
for (int i = 0; i < destination.getSizeInventory(); ++i) {
addition = transferToInventory(addition, destination, new int[] { i }, doAdd, false);
if (addition == null) {
return null;
}
}
return addition;
}
public static ItemStack transferToInventory(ItemStack item, IInventory destination, int[] targetSlots,
boolean doAdd, boolean ignoreValidation) {
for (int i : targetSlots) {
if (destination.isItemValidForSlot(i, item) || ignoreValidation) {
if (destination.getStackInSlot(i) == null) {
if (doAdd) {
destination.setInventorySlotContents(i, item.copy());
}
return null;
}
if (item.isStackable()) {
ItemStack merged = destination.getStackInSlot(i).copy();
ItemStack[] newStacks = mergeStacks(item.copy(), merged.copy());
item = newStacks[0];
if (doAdd) {
destination.setInventorySlotContents(i, newStacks[1]);
}
if (item == null) {
return null;
}
}
}
}
return item;
}
public static ItemStack[] mergeStacks(ItemStack itemstack, ItemStack merged) {
if (ItemStack.areItemStackTagsEqual(itemstack, merged) && itemstack.isItemEqual(merged)) {
int space = merged.getMaxStackSize() - merged.stackSize;
if (space > 0) {
if (itemstack.stackSize > space) {
itemstack.stackSize -= space;
merged.stackSize += space;
} else {
merged.stackSize += itemstack.stackSize;
itemstack = null;
}
}
}
return new ItemStack[] { itemstack, merged };
}
public static ItemStack transferContainerIntoTank(ItemStack item, IInventory origin, ITankMachine destination,
boolean doAdd) {
if (item == null) {
return null;
}
IFluidTank[] tanks = destination.getTanks();
ItemStack stack = item.copy();
for (int i = 0; i < tanks.length; ++i) {
stack = transferToTank(stack, origin, destination, i, doAdd);
}
return stack;
}
public static ItemStack transferTankIntoContainer(ItemStack item, IInventory origin, ITankMachine destination,
boolean doAdd) {
if (item == null) {
return null;
}
IFluidTank[] tanks = destination.getTanks();
ItemStack stack = item.copy();
for (int i = 0; i < tanks.length; ++i) {
stack = transferFromTank(stack, origin, destination, i, doAdd);
}
return stack;
}
public static ItemStack transferToTank(ItemStack item, IInventory origin, ITankMachine destination, int tankID,
boolean doAdd) {
if (item == null) {
return item;
}
FluidStack containerLiquid = null;
FluidContainerRegistry.FluidContainerData containerLiquidData = null;
for (FluidContainerRegistry.FluidContainerData data : FluidContainerRegistry
.getRegisteredFluidContainerData()) {
if (data.filledContainer.isItemEqual(item)) {
containerLiquidData = data;
containerLiquid = data.fluid.copy();
break;
}
}
if (containerLiquid == null) {
return item;
}
IFluidTank tank = destination.getTanks()[tankID];
IValidatedTankContainer validated = Machine.getInterface(IValidatedTankContainer.class, destination);
if (validated != null && !validated.isLiquidValidForTank(containerLiquid, tankID)) {
return item;
}
FluidStack largeAmountOfLiquid = containerLiquid.copy();
largeAmountOfLiquid.amount = tank.getCapacity();
int amountAdded = tank.fill(largeAmountOfLiquid, false);
int numberOfContainersToAdd = amountAdded / containerLiquid.amount;
if (numberOfContainersToAdd > item.stackSize) {
numberOfContainersToAdd = item.stackSize;
}
ItemStack copy;
ItemStack leftOverContainers = copy = item.copy();
copy.stackSize -= numberOfContainersToAdd;
if (leftOverContainers.stackSize <= 0) {
leftOverContainers = null;
}
ItemStack emptyContainers = containerLiquidData.emptyContainer.copy();
emptyContainers.stackSize = 0;
ItemStack itemStack = emptyContainers;
itemStack.stackSize += numberOfContainersToAdd;
if (emptyContainers.stackSize <= 0) {
emptyContainers = null;
}
ItemStack containersThatCantBeDumped = transferItemToInventory(emptyContainers, origin, false);
if (containersThatCantBeDumped != null) {
return item;
}
if (doAdd) {
FluidStack copy2;
FluidStack liquidToFillTank = copy2 = containerLiquid.copy();
copy2.amount *= numberOfContainersToAdd;
tank.fill(liquidToFillTank, true);
transferItemToInventory(emptyContainers, origin, true);
}
return leftOverContainers;
}
public static ItemStack transferFromTank(ItemStack item, IInventory origin, ITankMachine destination, int tankID,
boolean doAdd) {
if (item == null) {
return item;
}
IFluidTank tank = destination.getTanks()[tankID];
FluidStack liquidInTank = tank.getFluid();
if (liquidInTank == null) {
return item;
}
FluidContainerRegistry.FluidContainerData containerLiquidData = null;
for (FluidContainerRegistry.FluidContainerData data : FluidContainerRegistry
.getRegisteredFluidContainerData()) {
if (data.emptyContainer.isItemEqual(item) && liquidInTank.isFluidEqual(data.fluid)) {
containerLiquidData = data;
break;
}
}
if (containerLiquidData == null) {
return item;
}
int maximumExtractedLiquid = item.stackSize * containerLiquidData.fluid.amount;
FluidStack drainedLiquid = tank.drain(maximumExtractedLiquid, false);
int amountInTank = (drainedLiquid == null) ? 0 : drainedLiquid.amount;
int numberOfContainersToFill = amountInTank / containerLiquidData.fluid.amount;
if (numberOfContainersToFill > item.stackSize) {
numberOfContainersToFill = item.stackSize;
}
ItemStack copy;
ItemStack leftOverContainers = copy = item.copy();
copy.stackSize -= numberOfContainersToFill;
if (leftOverContainers.stackSize <= 0) {
leftOverContainers = null;
}
ItemStack filledContainers = containerLiquidData.filledContainer.copy();
filledContainers.stackSize = 0;
ItemStack itemStack = filledContainers;
itemStack.stackSize += numberOfContainersToFill;
if (filledContainers.stackSize <= 0) {
filledContainers = null;
}
ItemStack containersThatCantBeDumped = transferItemToInventory(filledContainers, origin, false);
if (containersThatCantBeDumped != null) {
return item;
}
if (doAdd) {
tank.drain(maximumExtractedLiquid, true);
transferItemToInventory(filledContainers, origin, true);
}
return leftOverContainers;
}
}
@@ -21,11 +21,11 @@ public interface INetwork {
void syncFromNBT(NBTTagCompound nbt);
}
interface RecieveGuiNBT {
interface ReceiveGuiNBT {
void recieveGuiNBT(Side side, EntityPlayer player, String name, NBTTagCompound nbt);
void receiveGuiNBT(Side side, EntityPlayer player, String name, NBTTagCompound nbt);
}
interface GuiNBT extends RecieveGuiNBT, SendGuiNBT {
interface GuiNBT extends ReceiveGuiNBT, SendGuiNBT {
}
}
@@ -32,11 +32,6 @@ enum Compartment implements IMachineType {
return clss;
}
@Override
public boolean isActive() {
return true;
}
public ItemStack get(int i) {
return new ItemStack(BinnieCore.packageCompartment.getBlock(), i, ordinal());
}
@@ -69,7 +69,7 @@ class ComponentCompartmentInventory extends ComponentInventorySlots implements I
}
@Override
public void recieveGuiNBT(Side side, EntityPlayer player, String name, NBTTagCompound nbt) {
public void receiveGuiNBT(Side side, EntityPlayer player, String name, NBTTagCompound nbt) {
if (name.equals("comp-tabs")) {
NBTTagList tags = nbt.getTagList("tabs", 10);
for (int i = 0; i < tags.tagCount(); ++i) {
@@ -15,6 +15,7 @@ import net.minecraft.init.Items;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import binnie.core.AbstractMod;
import binnie.core.BinnieCore;
@@ -42,6 +43,7 @@ import binnie.core.craftgui.geometry.Position;
import binnie.core.craftgui.minecraft.Dialog;
import binnie.core.craftgui.minecraft.EnumColor;
import binnie.core.craftgui.minecraft.IWindowAffectsShiftClick;
import binnie.core.craftgui.minecraft.InventoryType;
import binnie.core.craftgui.minecraft.MinecraftGUI;
import binnie.core.craftgui.minecraft.Window;
import binnie.core.craftgui.minecraft.control.ControlItemDisplay;
@@ -55,6 +57,7 @@ import binnie.core.craftgui.resource.minecraft.CraftGUITexture;
import binnie.core.craftgui.window.Panel;
import binnie.core.machines.Machine;
import binnie.core.machines.transfer.TransferRequest;
import binnie.core.network.packet.MessageCraftGUI;
import binnie.core.util.I18N;
import binnie.genetics.craftgui.WindowMachine;
import cpw.mods.fml.relauncher.Side;
@@ -187,7 +190,11 @@ public class WindowCompartment extends WindowMachine implements IWindowAffectsSh
for (int k = 0; k < inv.getPageSize(); ++k) {
slotsIDs[k] = i++;
}
new ControlSlotArray(thisPage, 8, 8, inv.getPageSize() / 5, 5).create(slotsIDs);
final NBTTagList actions = new NBTTagList();
new ControlSlotArray(thisPage, 8, 8, inv.getPageSize() / 5, 5)
.create(actions, InventoryType.Machine, slotsIDs);
MessageCraftGUI.sendToServer(actions);
}
x += compartmentPageWidth;
if (tabs2.length > 0) {
@@ -245,7 +252,7 @@ public class WindowCompartment extends WindowMachine implements IWindowAffectsSh
setSize(new IPoint(Math.max(32 + compartmentWidth, 252), h()));
controlCompartment.setPosition(new IPoint((w() - controlCompartment.w()) / 2.0f, controlCompartment.y()));
new ControlPlayerInventory(this, true);
new ControlPlayerInventory(this, true).createAndRegister();
ControlSlide slide = new ControlSlide(this, 0.0f, 134.0f, 136.0f, 92.0f, Position.LEFT);
slide.setLabel(I18N.localise("binniecore.machine.storage.tab.properties"));
slide.setSlide(false);
@@ -367,7 +374,7 @@ public class WindowCompartment extends WindowMachine implements IWindowAffectsSh
};
slotGrid = new Control(scroll, 1.0f, 1.0f, 108.0f, 18.0f);
scroll.setScrollableContent(slotGrid);
new ControlPlayerInventory(this, true);
new ControlPlayerInventory(this, true).createAndRegister();
new ControlTextEdit(this, 16.0f, 16.0f, 100.0f, 14.0f).addEventHandler(new EventTextEdit.Handler() {
@Override
@@ -459,8 +466,10 @@ public class WindowCompartment extends WindowMachine implements IWindowAffectsSh
slotGrid.deleteAllChildren();
slotGrid.setSize(new IPoint(width, height));
final NBTTagList actions = new NBTTagList();
for (int k : slotIds.keySet()) {
new ControlSlot(slotGrid, x, y).assign(k);
new ControlSlot(slotGrid, x, y).assign(actions, InventoryType.Machine, k);
x += 18;
if (x >= 108) {
x = 0;
@@ -468,6 +477,8 @@ public class WindowCompartment extends WindowMachine implements IWindowAffectsSh
}
}
MessageCraftGUI.sendToServer(actions);
while (y < 108 || x != 0) {
new ControlSlot(slotGrid, x, y);
x += 18;
@@ -488,14 +499,16 @@ public class WindowCompartment extends WindowMachine implements IWindowAffectsSh
public void updateTabs() {
CompartmentTab tab = getCurrentTab();
tabName.setValue(tab.getName());
if (!tabName.isFocused()) {
tabName.setValue(tab.getName());
}
tabIcon.setItemStack(tab.getIcon());
tabColour.setValue(tab.getColor());
}
@Override
public void recieveGuiNBT(Side side, EntityPlayer player, String name, NBTTagCompound nbt) {
super.recieveGuiNBT(side, player, name, nbt);
public void receiveGuiNBT(Side side, EntityPlayer player, String name, NBTTagCompound nbt) {
super.receiveGuiNBT(side, player, name, nbt);
if (name.equals("tab-change")) {
currentTab = nbt.getByte("i");
}
@@ -1,5 +0,0 @@
package binnie.core.machines.transfer;
// TODO unused class?
public class TransferHandler {
}
@@ -1,20 +0,0 @@
package binnie.core.mod.config;
import java.io.File;
import net.minecraftforge.common.config.Configuration;
import binnie.core.AbstractMod;
import binnie.core.BinnieCore;
public class BinnieConfiguration extends Configuration {
public AbstractMod mod;
private final String filename;
public BinnieConfiguration(String filename, AbstractMod mod) {
super(new File(BinnieCore.proxy.getDirectory(), filename));
this.mod = mod;
this.filename = filename;
}
}
@@ -1,15 +0,0 @@
package binnie.core.mod.config;
// TODO Why do we need this class?
class BinnieItemData {
private final int item;
private final BinnieConfiguration configFile;
private final String configKey;
public BinnieItemData(int item, BinnieConfiguration configFile, String configKey) {
this.item = item;
this.configFile = configFile;
this.configKey = configKey;
}
}
@@ -1,10 +0,0 @@
package binnie.core.mod.config;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@Retention(RetentionPolicy.RUNTIME)
public @interface ConfigFile {
String filename();
}
@@ -1,26 +0,0 @@
package binnie.core.mod.config;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.FIELD })
public @interface ConfigProperty {
String key();
String category() default "";
String[] comment() default {};
@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.ANNOTATION_TYPE })
@interface Type {
Class<? extends PropertyBase> propertyClass();
String category() default "general";
}
}
@@ -1,5 +0,0 @@
package binnie.core.mod.config;
@ConfigFile(filename = "/config/forestry/binniecore/main.conf")
public class ConfigurationMain {
}
@@ -1,21 +0,0 @@
package binnie.core.mod.config;
@ConfigFile(filename = "/config/forestry/binnie-mods.conf")
public class ConfigurationMods {
@ConfigProperty(key = "extraBees", comment = { "Enables the Extra Bees Mod." })
@PropBoolean
public static boolean extraBees = true;
@ConfigProperty(key = "extraTrees", comment = { "Enables the Extra Trees Mod." })
@PropBoolean
public static boolean extraTrees = true;
@ConfigProperty(key = "botany", comment = { "Enables the Botany Mod." })
@PropBoolean
public static boolean botany = true;
@ConfigProperty(key = "genetics", comment = { "Enables the Genetics Mod." })
@PropBoolean
public static boolean genetics = true;
}
@@ -1,71 +0,0 @@
package binnie.core.mod.config;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import net.minecraftforge.common.config.Configuration;
import binnie.core.AbstractMod;
import binnie.core.ManagerBase;
public class ManagerConfig extends ManagerBase {
private final Map<Class<?>, Configuration> configurations;
private final Map<AbstractMod, List<BinnieItemData>> itemIDs;
public ManagerConfig() {
configurations = new LinkedHashMap<>();
itemIDs = new HashMap<>();
}
public void registerConfiguration(Class<?> cls, AbstractMod mod) {
if (cls.isAnnotationPresent(ConfigFile.class)) {
loadConfiguration(cls, mod);
}
}
public void loadConfiguration(Class<?> cls, AbstractMod mod) {
try {
String filename = cls.getAnnotation(ConfigFile.class).filename();
BinnieConfiguration config = new BinnieConfiguration(filename, mod);
config.load();
for (Field field : cls.getFields()) {
if (field.isAnnotationPresent(ConfigProperty.class)) {
ConfigProperty propertyAnnot = field.getAnnotation(ConfigProperty.class);
for (Annotation annotation : field.getAnnotations()) {
if (annotation.annotationType().isAnnotationPresent(ConfigProperty.Type.class)) {
Class<?> propertyClass = annotation.annotationType()
.getAnnotation(ConfigProperty.Type.class).propertyClass();
// TODO what for?
PropertyBase property = (PropertyBase) propertyClass.getConstructor(
Field.class,
BinnieConfiguration.class,
ConfigProperty.class,
annotation.annotationType()).newInstance(
field,
config,
propertyAnnot,
annotation.annotationType().cast(annotation));
}
}
}
}
config.save();
configurations.put(cls, config);
} catch (Exception e) {
e.printStackTrace();
}
}
public void addItemID(Integer configValue, String configKey, BinnieConfiguration configFile) {
if (!itemIDs.containsKey(configFile.mod)) {
itemIDs.put(configFile.mod, new ArrayList<>());
}
itemIDs.get(configFile.mod).add(new BinnieItemData(configValue + 256, configFile, configKey));
}
}
@@ -1,35 +0,0 @@
package binnie.core.mod.config;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.reflect.Field;
import net.minecraftforge.common.config.Property;
@Retention(RetentionPolicy.RUNTIME)
@ConfigProperty.Type(propertyClass = PropBoolean.PropertyBoolean.class)
public @interface PropBoolean {
class PropertyBoolean extends PropertyBase<Boolean, PropBoolean> {
public PropertyBoolean(Field field, BinnieConfiguration file, ConfigProperty configProperty,
PropBoolean annotedProperty) throws IllegalArgumentException, IllegalAccessException {
super(field, file, configProperty, annotedProperty);
}
@Override
protected Property getProperty() {
return file.get(getCategory(), getKey(), defaultValue);
}
@Override
protected Boolean getConfigValue() {
return property.getBoolean(defaultValue);
}
@Override
protected void addComments() {
addComment("Default value is " + defaultValue + ".");
}
}
}
@@ -1,35 +0,0 @@
package binnie.core.mod.config;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.reflect.Field;
import net.minecraftforge.common.config.Property;
@Retention(RetentionPolicy.RUNTIME)
@ConfigProperty.Type(propertyClass = PropDouble.PropertyDouble.class)
public @interface PropDouble {
class PropertyDouble extends PropertyBase<Double, PropDouble> {
public PropertyDouble(Field field, BinnieConfiguration file, ConfigProperty configProperty,
PropDouble annotedProperty) throws IllegalArgumentException, IllegalAccessException {
super(field, file, configProperty, annotedProperty);
}
@Override
protected Property getProperty() {
return file.get(getCategory(), getKey(), defaultValue);
}
@Override
protected Double getConfigValue() {
return property.getDouble(defaultValue);
}
@Override
protected void addComments() {
addComment("Default value is " + defaultValue + ".");
}
}
}
@@ -1,35 +0,0 @@
package binnie.core.mod.config;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.reflect.Field;
import net.minecraftforge.common.config.Property;
@Retention(RetentionPolicy.RUNTIME)
@ConfigProperty.Type(propertyClass = PropInteger.PropertyInteger.class)
public @interface PropInteger {
class PropertyInteger extends PropertyBase<Integer, PropInteger> {
public PropertyInteger(Field field, BinnieConfiguration file, ConfigProperty configProperty,
PropInteger annotedProperty) throws IllegalArgumentException, IllegalAccessException {
super(field, file, configProperty, annotedProperty);
}
@Override
protected Property getProperty() {
return file.get(getCategory(), getKey(), defaultValue);
}
@Override
protected Integer getConfigValue() {
return property.getInt(defaultValue);
}
@Override
protected void addComments() {
addComment("Default value is " + defaultValue + ".");
}
}
}
@@ -1,40 +0,0 @@
package binnie.core.mod.config;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.reflect.Field;
import net.minecraftforge.common.config.Property;
@Retention(RetentionPolicy.RUNTIME)
@ConfigProperty.Type(propertyClass = PropPercentage.PropertyPercentage.class)
public @interface PropPercentage {
int upper() default 100;
int lower() default 0;
class PropertyPercentage extends PropertyBase<Integer, PropPercentage> {
public PropertyPercentage(Field field, BinnieConfiguration file, ConfigProperty configProperty,
PropPercentage annotedProperty) throws IllegalArgumentException, IllegalAccessException {
super(field, file, configProperty, annotedProperty);
}
@Override
protected Integer getConfigValue() {
return property.getInt(defaultValue);
}
@Override
protected void addComments() {
addComment("Default value is " + defaultValue + "%.");
addComment("Range is " + annotatedProperty.lower() + "-" + annotatedProperty.upper() + "%.");
}
@Override
protected Property getProperty() {
return file.get(getCategory(), getKey(), defaultValue);
}
}
}
@@ -1,71 +0,0 @@
package binnie.core.mod.config;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.common.config.Property;
public abstract class PropertyBase<ValueType, AnnotationType extends Annotation> {
protected Configuration file;
protected Property property;
protected ValueType defaultValue;
protected AnnotationType annotatedProperty;
private final ConfigProperty configProperty;
private final List<String> comments;
private final Field field;
protected PropertyBase(Field field, BinnieConfiguration file, ConfigProperty configProperty,
AnnotationType annotedProperty) throws IllegalArgumentException, IllegalAccessException {
comments = new ArrayList<>();
this.field = field;
this.file = file;
this.configProperty = configProperty;
annotatedProperty = annotedProperty;
defaultValue = getDefaultValue(field);
property = getProperty();
for (String comment : configProperty.comment()) {
addComment(comment);
}
addComments();
property.comment = getComment();
field.set(null, getConfigValue());
}
protected abstract Property getProperty();
protected abstract ValueType getConfigValue();
protected abstract void addComments();
protected String getCategory() {
return configProperty.category().isEmpty()
? annotatedProperty.annotationType().getAnnotation(ConfigProperty.Type.class).category()
: configProperty.category();
}
protected String getKey() {
return configProperty.key();
}
protected ValueType getDefaultValue(Field field) throws IllegalArgumentException, IllegalAccessException {
return (ValueType) field.get(null);
}
protected void addComment(String comment) {
comments.add(comment);
}
protected String getComment() {
StringBuilder comment = new StringBuilder();
for (String com : comments) {
comment.append(com).append(" ");
}
return comment.toString();
}
}
@@ -1,6 +1,7 @@
package binnie.core.network;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetHandlerPlayServer;
import net.minecraft.tileentity.TileEntity;
@@ -27,41 +28,71 @@ public enum BinnieCorePacketID implements IPacketID {
@Override
public void onMessage(MessageBinnie message, MessageContext context) {
if (this == BinnieCorePacketID.NetworkEntityUpdate) {
MessageUpdate packet = new MessageUpdate(message);
TileEntity tile = packet.getTileEntity(BinnieCore.proxy.getWorld());
if (tile instanceof INetworkedEntity) {
((INetworkedEntity) tile).readFromPacket(packet.payload);
switch (this) {
case NetworkEntityUpdate -> processNetworkEntityUpdate(message);
case TileMetadata -> processTileMetadata(message);
case CraftGUIAction -> processCraftGUIAction(message, context);
case TileDescriptionSync -> processTileDescriptionSync(message, context);
}
}
private static void processNetworkEntityUpdate(MessageBinnie message) {
final MessageUpdate packet = new MessageUpdate(message);
final TileEntity tile = packet.getTileEntity(BinnieCore.proxy.getWorld());
if (tile instanceof INetworkedEntity iNetworkedEntity) {
iNetworkedEntity.readFromPacket(packet.payload);
}
}
private static void processTileMetadata(MessageBinnie message) {
final MessageMetadata packet = new MessageMetadata(message);
final TileEntity tile = packet.getTileEntity(BinnieCore.proxy.getWorld());
if (tile instanceof TileEntityMetadata tileEntityMetadata) {
tileEntityMetadata.setTileMetadata(packet.meta, true);
}
}
private static void processCraftGUIAction(MessageBinnie message, MessageContext context) {
final MessageCraftGUI packet = new MessageCraftGUI(message);
final NBTTagCompound tagCompound = packet.getTagCompound();
if (tagCompound == null) return;
if (context.side == Side.CLIENT) {
final EntityPlayer player = BinnieCore.proxy.getPlayer();
if (player.openContainer instanceof ContainerCraftGUI gui) {
gui.receiveNBT(Side.CLIENT, player, tagCompound);
}
} else if (this == BinnieCorePacketID.TileMetadata) {
MessageMetadata packet = new MessageMetadata(message);
TileEntity tile = packet.getTileEntity(BinnieCore.proxy.getWorld());
if (tile instanceof TileEntityMetadata) {
((TileEntityMetadata) tile).setTileMetadata(packet.meta, true);
}
} else if (this == BinnieCorePacketID.CraftGUIAction) {
if (context.side == Side.CLIENT) {
MessageCraftGUI packet = new MessageCraftGUI(message);
EntityPlayer player = BinnieCore.proxy.getPlayer();
if (player.openContainer instanceof ContainerCraftGUI && packet.getTagCompound() != null) {
((ContainerCraftGUI) player.openContainer).recieveNBT(Side.CLIENT, player, packet.getTagCompound());
}
} else if (context.netHandler instanceof NetHandlerPlayServer) {
MessageCraftGUI packet = new MessageCraftGUI(message);
EntityPlayer player = ((NetHandlerPlayServer) context.netHandler).playerEntity;
if (player.openContainer instanceof ContainerCraftGUI && packet.getTagCompound() != null) {
((ContainerCraftGUI) player.openContainer).recieveNBT(Side.SERVER, player, packet.getTagCompound());
}
}
} else if (this == BinnieCorePacketID.TileDescriptionSync && context.side == Side.CLIENT) {
MessageTileNBT packet = new MessageTileNBT(message);
TileEntity tile = packet.getTarget(BinnieCore.proxy.getWorld());
if (tile != null && packet.getTagCompound() != null) {
IMachine machine = Machine.getMachine(tile);
if (machine instanceof INetwork.TilePacketSync tps) {
tps.syncFromNBT(packet.getTagCompound());
} else {
if (context.netHandler instanceof NetHandlerPlayServer server) {
final EntityPlayer player = server.playerEntity;
if (player.openContainer instanceof ContainerCraftGUI gui) {
gui.receiveNBT(Side.SERVER, player, tagCompound);
}
}
}
}
private static void processTileDescriptionSync(MessageBinnie message, MessageContext context) {
if (!context.side.isClient()) return;
final MessageTileNBT packet = new MessageTileNBT(message);
final NBTTagCompound tagCompound = packet.getTagCompound();
if (tagCompound == null) return;
final TileEntity tile = packet.getTarget(BinnieCore.proxy.getWorld());
if (tile == null) return;
final IMachine machine = Machine.getMachine(tile);
if (machine instanceof INetwork.TilePacketSync tps) {
tps.syncFromNBT(tagCompound);
}
}
}
@@ -1,9 +0,0 @@
package binnie.core.network.packet;
import net.minecraft.network.Packet;
// TODO unused interface?
public interface IPacket {
Packet getPacket();
}
@@ -1,15 +0,0 @@
package binnie.core.network.packet;
// TODO unused class?
public class IndexInPayload {
public int intIndex;
public int floatIndex;
public int stringIndex;
public IndexInPayload(int intIndex, int floatIndex, int stringIndex) {
this.intIndex = intIndex;
this.floatIndex = floatIndex;
this.stringIndex = stringIndex;
}
}
@@ -8,8 +8,4 @@ public class MessageContainerUpdate extends MessageCraftGUI {
super(nbt);
}
// TODO unused constructor?
public MessageContainerUpdate(MessageBinnie message) {
super(message);
}
}
@@ -3,7 +3,6 @@ package binnie.core.network.packet;
import java.io.IOException;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.world.World;
import io.netty.buffer.ByteBuf;
@@ -18,11 +17,6 @@ public class MessageCoordinates extends MessageBase {
super(message);
}
// TODO unused constructor?
public MessageCoordinates(int id, ChunkCoordinates coordinates) {
this(id, coordinates.posX, coordinates.posY, coordinates.posZ);
}
public MessageCoordinates(int id, int posX, int posY, int posZ) {
super(id);
this.posX = posX;
@@ -44,11 +38,6 @@ public class MessageCoordinates extends MessageBase {
posZ = data.readInt();
}
// TODO unused method?
public ChunkCoordinates getCoordinates() {
return new ChunkCoordinates(posX, posY, posZ);
}
public TileEntity getTileEntity(World world) {
return world.getTileEntity(posX, posY, posZ);
}
@@ -1,7 +1,13 @@
package binnie.core.network.packet;
import net.minecraft.nbt.NBTTagCompound;
import static binnie.core.craftgui.minecraft.ContainerCraftGUI.ACTIONS;
import static binnie.core.craftgui.minecraft.ContainerCraftGUI.ACTION_BATCH;
import static binnie.core.craftgui.minecraft.ContainerCraftGUI.ACTION_TYPE;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import binnie.core.BinnieCore;
import binnie.core.network.BinnieCorePacketID;
public class MessageCraftGUI extends MessageNBT {
@@ -13,4 +19,12 @@ public class MessageCraftGUI extends MessageNBT {
public MessageCraftGUI(NBTTagCompound action) {
super(BinnieCorePacketID.CraftGUIAction.ordinal(), action);
}
public static void sendToServer(NBTTagList actions) {
NBTTagCompound actionsBatch = new NBTTagCompound();
actionsBatch.setString(ACTION_TYPE, ACTION_BATCH);
actionsBatch.setTag(ACTIONS, actions);
final MessageCraftGUI packet = new MessageCraftGUI(actionsBatch);
BinnieCore.proxy.sendToServer(packet);
}
}
@@ -4,7 +4,6 @@ import java.io.IOException;
import java.nio.charset.StandardCharsets;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import binnie.core.network.INetworkedEntity;
import io.netty.buffer.ByteBuf;
@@ -75,8 +74,4 @@ public class MessageUpdate extends MessageCoordinates {
}
}
// TODO unused method?
public TileEntity getTarget(World world) {
return world.getTileEntity(posX, posY, posZ);
}
}
@@ -3,8 +3,6 @@ package binnie.core.network.packet;
import java.util.ArrayList;
import java.util.List;
import binnie.core.network.INetworkedEntity;
public class PacketPayload {
public List<Integer> intPayload;
@@ -17,12 +15,6 @@ public class PacketPayload {
stringPayload = new ArrayList<>();
}
// TODO unused constructor?
public PacketPayload(INetworkedEntity tile) {
this();
tile.writeToPacket(this);
}
public void addInteger(int a) {
intPayload.add(a);
}
@@ -47,16 +39,6 @@ public class PacketPayload {
return stringPayload.remove(0);
}
// TODO unused method
public void append(PacketPayload other) {
if (other == null) {
return;
}
intPayload.addAll(other.intPayload);
floatPayload.addAll(other.floatPayload);
stringPayload.addAll(other.stringPayload);
}
public boolean isEmpty() {
return intPayload.isEmpty() && floatPayload.isEmpty() && stringPayload.isEmpty();
}
@@ -20,7 +20,6 @@ import binnie.core.network.INetworkedEntity;
import binnie.core.network.packet.MessageUpdate;
import binnie.core.resource.BinnieResource;
import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.registry.GameRegistry;
public class BinnieProxy extends BinnieModProxy implements IBinnieProxy {
@@ -69,11 +68,6 @@ public class BinnieProxy extends BinnieModProxy implements IBinnieProxy {
return null;
}
// TODO unused method?
public void throwException(String message, Throwable e) {
FMLCommonHandler.instance().raiseException(e, message, true);
}
@Override
public Minecraft getMinecraftInstance() {
return null;
@@ -129,16 +123,6 @@ public class BinnieProxy extends BinnieModProxy implements IBinnieProxy {
return null;
}
// TODO unused method?
public void handleTextureRefresh(IIconRegister register, int type) {
// ignored
}
// TODO unused method?
public void handlePostTextureRefresh(IIconRegister register, int type) {
// ignored
}
public short getUniqueTextureUID() {
uniqueTextureUID++;
return uniqueTextureUID;
@@ -21,7 +21,6 @@ import net.minecraftforge.client.MinecraftForgeClient;
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;
import binnie.Binnie;
import binnie.core.craftgui.resource.minecraft.CraftGUIResourceManager;
import binnie.core.resource.BinnieResource;
import cpw.mods.fml.client.FMLClientHandler;
@@ -139,13 +138,6 @@ public class BinnieProxyClient extends BinnieProxy implements IBinnieProxy {
return Minecraft.getMinecraft().thePlayer;
}
// TODO unused method?
public void handlePreTextureRefresh(IIconRegister register, int type) {
if (type == 0) {
Binnie.Liquid.reloadIcons(register);
}
}
@Override
public void preInit() {
IResourceManager manager = Minecraft.getMinecraft().getResourceManager();
+17 -9
View File
@@ -4,6 +4,9 @@ import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.item.Item;
import com.gtnewhorizon.gtnhlib.config.ConfigException;
import com.gtnewhorizon.gtnhlib.config.ConfigurationManager;
import binnie.core.AbstractMod;
import binnie.core.BinnieCore;
import binnie.core.Tags;
@@ -11,8 +14,7 @@ import binnie.core.gui.IBinnieGUID;
import binnie.core.network.BinniePacketHandler;
import binnie.core.proxy.IProxyCore;
import binnie.extrabees.apiary.ModuleApiary;
import binnie.extrabees.config.ConfigurationMachines;
import binnie.extrabees.config.ConfigurationMain;
import binnie.extrabees.config.EBConfig;
import binnie.extrabees.core.ExtraBeeGUID;
import binnie.extrabees.core.ModuleCore;
import binnie.extrabees.genetics.ModuleGenetics;
@@ -27,13 +29,16 @@ import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
@Mod(
modid = "ExtraBees",
name = "Extra Bees",
modid = ExtraBees.EB_MODID,
name = ExtraBees.EB_MOD_NAME,
version = Tags.VERSION,
useMetadata = true,
dependencies = "after:BinnieCore")
public class ExtraBees extends AbstractMod {
public static final String EB_MODID = "ExtraBees";
public static final String EB_MOD_NAME = "Extra Bees";
@Mod.Instance("ExtraBees")
public static ExtraBees instance;
@@ -42,6 +47,14 @@ public class ExtraBees extends AbstractMod {
serverSide = "binnie.extrabees.proxy.ExtraBeesProxyServer")
public static ExtraBeesProxy proxy;
static {
try {
ConfigurationManager.registerConfig(EBConfig.class);
} catch (ConfigException e) {
throw new RuntimeException(e);
}
}
public static Block hive;
public static Material materialBeehive;
public static Block ectoplasm;
@@ -81,11 +94,6 @@ public class ExtraBees extends AbstractMod {
return ExtraBeeGUID.values();
}
@Override
public Class<?>[] getConfigs() {
return new Class[] { ConfigurationMain.class, ConfigurationMachines.class };
}
@Override
public IProxyCore getProxy() {
return ExtraBees.proxy;
@@ -1,10 +1,7 @@
package binnie.extrabees.apiary;
import net.minecraft.item.ItemStack;
import binnie.core.machines.Machine;
import binnie.core.machines.MachineComponent;
import forestry.api.apiculture.IBee;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeListener;
import forestry.api.apiculture.IBeeModifier;
@@ -61,21 +58,11 @@ public class ComponentBeeModifier extends MachineComponent implements IBeeModifi
return false;
}
// TODO unused method?
public void onQueenChange(ItemStack queen) {
// ignored
}
@Override
public void wearOutEquipment(int amount) {
// ignored
}
// TODO unused method?
public boolean onEggLaid(IBee queen) {
return false;
}
@Override
public float getGeneticDecay(IBeeGenome genome, float currentModifier) {
return 1.0f;
@@ -34,12 +34,12 @@ public class ModuleApiary implements IInitializable {
BinnieCore.proxy.createObject("binnie.core.machines.RendererMachine"));
ModuleApiary.blockComponent = machineGroup.getBlock();
AlvearyMutator.addMutationItem(new ItemStack(Blocks.soul_sand), 1.5f);
AlvearyMutator.addMutationItem(Mods.ic2.stack("UranFuel"), 8.0f);
AlvearyMutator.addMutationItem(Mods.ic2.stack("Plutonium"), 15.0f);
AlvearyMutator.addMutationItem(Mods.ic2.stack("smallPlutonium"), 9.0f);
AlvearyMutator.addMutationItem(Mods.ic2.stack("Uran235"), 10.0f);
AlvearyMutator.addMutationItem(Mods.ic2.stack("smallUran235"), 5.5f);
AlvearyMutator.addMutationItem(Mods.ic2.stack("Uran238"), 2.0f);
AlvearyMutator.addMutationItem(Mods.ic2.stack("itemUran"), 8.0f);
AlvearyMutator.addMutationItem(Mods.ic2.stack("itemPlutonium"), 15.0f);
AlvearyMutator.addMutationItem(Mods.ic2.stack("itemPlutoniumSmall"), 9.0f);
AlvearyMutator.addMutationItem(Mods.ic2.stack("itemUran235"), 10.0f);
AlvearyMutator.addMutationItem(Mods.ic2.stack("itemUran235small"), 5.5f);
AlvearyMutator.addMutationItem(Mods.ic2.stack("itemUran238"), 2.0f);
AlvearyMutator.addMutationItem(new ItemStack(Items.nether_star), 50.0f);
AlvearyMutator.addMutationItem(new ItemStack(Items.ender_pearl), 2.0f);
AlvearyMutator.addMutationItem(new ItemStack(Items.ender_eye), 4.0f);
@@ -46,11 +46,6 @@ public enum AlvearyMachine implements IMachineType {
return new ItemStack(ModuleApiary.blockComponent, size, ordinal());
}
@Override
public boolean isActive() {
return true;
}
public abstract static class AlvearyPackage extends MachinePackage {
protected BinnieResource machineTexture;
@@ -18,8 +18,7 @@ public class MutatorModifierComponent extends ComponentBeeModifier implements IB
return 1.0f;
}
float mult = AlvearyMutator.getMutationMult(getUtil().getStack(AlvearyMutator.SLOT_MUTATOR));
return Math.min(mult, 15.0f / currentModifier);
return AlvearyMutator.getMutationMult(getUtil().getStack(AlvearyMutator.SLOT_MUTATOR));
}
@Override
@@ -48,8 +48,8 @@ public class TransmissionModifierComponent extends ComponentBeeModifier implemen
}
for (IEnergyHandler handler : handlers) {
int recieved = handler.receiveEnergy(ForgeDirection.NORTH, output, false);
getUtil().getPoweredMachine().receiveEnergy(ForgeDirection.NORTH, -recieved, false);
int received = handler.receiveEnergy(ForgeDirection.NORTH, output, false);
getUtil().getPoweredMachine().receiveEnergy(ForgeDirection.NORTH, -received, false);
energy = getUtil().getPoweredMachine().getEnergyStored(ForgeDirection.NORTH);
if (energy <= 0) {
return;
@@ -1,24 +0,0 @@
package binnie.extrabees.config;
import binnie.core.mod.config.ConfigFile;
import binnie.core.mod.config.ConfigProperty;
import binnie.core.mod.config.PropDouble;
import binnie.core.mod.config.PropPercentage;
@ConfigFile(filename = "/config/forestry/extrabees/machines.conf")
public class ConfigurationMachines {
@ConfigProperty(
key = "isolatorConsumptionChance",
comment = { "Percentage chance of Isolator consuming bee, in x%." })
@PropPercentage
public static int isolatorConsumptionChance = 30;
@ConfigProperty(
key = "geneticErrorModifier",
comment = { "Modifier that changes how severe splicer/inoculator erros are.",
"0 would result in no errors, even for awful serums.",
"2.0 would result in twice as severe errors" })
@PropDouble
public static double geneticErrorModifier = 1.0;
}
@@ -1,30 +0,0 @@
package binnie.extrabees.config;
import binnie.core.mod.config.ConfigFile;
import binnie.core.mod.config.ConfigProperty;
import binnie.core.mod.config.PropBoolean;
import binnie.core.mod.config.PropInteger;
@ConfigFile(filename = "/config/forestry/extrabees/main.conf")
public class ConfigurationMain {
@ConfigProperty(key = "canQuarryMineHives")
@PropBoolean
public static boolean canQuarryMineHives = true;
@ConfigProperty(key = "waterHiveRate")
@PropInteger
public static int waterHiveRate = 1;
@ConfigProperty(key = "rockHiveRate")
@PropInteger
public static int rockHiveRate = 2;
@ConfigProperty(key = "netherHiveRate")
@PropInteger
public static int netherHiveRate = 2;
@ConfigProperty(key = "marbleHiveRate")
@PropInteger
public static int marbleHiveRate = 2;
}
@@ -0,0 +1,28 @@
package binnie.extrabees.config;
import static binnie.extrabees.ExtraBees.EB_MODID;
import com.gtnewhorizon.gtnhlib.config.Config;
@Config(modid = EB_MODID)
public class EBConfig {
@Config.DefaultBoolean(true)
@Config.RequiresMcRestart
public static boolean canQuarryMineHives;
@Config.Comment("Attempt to generate this many hives per chunk.")
@Config.RangeInt(min = 0)
@Config.DefaultInt(1)
public static int waterHiveRate;
@Config.Comment("Attempt to generate this many hives per chunk.")
@Config.RangeInt(min = 0)
@Config.DefaultInt(2)
public static int rockHiveRate;
@Config.Comment("Attempt to generate this many hives per chunk.")
@Config.RangeInt(min = 0)
@Config.DefaultInt(2)
public static int netherHiveRate;
}
@@ -0,0 +1,14 @@
package binnie.extrabees.config;
import static binnie.extrabees.ExtraBees.EB_MODID;
import com.gtnewhorizon.gtnhlib.config.Config;
@Config(modid = EB_MODID)
public class EBConfigMachines {
@Config.Comment("Percentage chance of Isolator consuming bee. 0 never consumes, 1 always does.")
@Config.RangeFloat(min = 0f, max = 1f)
@Config.DefaultFloat(0.05f)
public static float isolatorConsumptionChance;
}
@@ -389,34 +389,27 @@ public enum ExtraBeesEffect implements IAlleleBeeEffect {
}
private void onFoodEffect(IBeeGenome genome, IBeeHousing housing) {
for (EntityLivingBase entity : getEntities(EntityLivingBase.class, genome, housing)) {
if (entity instanceof EntityPlayer player) {
player.getFoodStats().addStats(2, 0.2f);
}
for (EntityPlayer player : getEntities(EntityPlayer.class, genome, housing)) {
player.getFoodStats().addStats(2, 0.2f);
}
}
private void onHungerEffect(IBeeGenome genome, IBeeHousing housing, World world) {
for (EntityLivingBase entity : getEntities(EntityLivingBase.class, genome, housing)) {
if (entity instanceof EntityPlayer player) {
if (world.rand.nextInt(4) < wearsItems(player)) {
continue;
}
player.getFoodStats().addExhaustion(4.0f);
player.addPotionEffect(new PotionEffect(Potion.hunger.id, 100));
for (EntityPlayer player : getEntities(EntityPlayer.class, genome, housing)) {
if (world.rand.nextInt(4) < wearsItems(player)) {
continue;
}
player.addExhaustion(4.0f);
player.addPotionEffect(new PotionEffect(Potion.hunger.id, 100));
}
}
private void onPotionEffect(IBeeGenome genome, IBeeHousing housing, World world, PotionEffect potion) {
for (EntityLivingBase entity : getEntities(EntityLivingBase.class, genome, housing)) {
if (entity instanceof EntityPlayer player) {
if (world.rand.nextInt(4) < wearsItems(player)) {
continue;
}
player.addPotionEffect(potion);
for (EntityPlayer player : getEntities(EntityPlayer.class, genome, housing)) {
if (world.rand.nextInt(4) < wearsItems(player)) {
continue;
}
player.addPotionEffect(potion);
}
}
@@ -611,13 +604,16 @@ public enum ExtraBeesEffect implements IAlleleBeeEffect {
public <T extends Entity> List<T> getEntities(Class<T> eClass, IBeeGenome genome, IBeeHousing housing) {
int[] area = genome.getTerritory();
int[] offset = { -Math.round(area[0] / 2f), -Math.round(area[1] / 2f), -Math.round(area[2] / 2f) };
int[] min = { housing.getCoordinates().posX + offset[0], housing.getCoordinates().posY + offset[1],
housing.getCoordinates().posZ + offset[2] };
int[] max = { housing.getCoordinates().posX + offset[0] + area[0],
housing.getCoordinates().posY + offset[1] + area[1],
housing.getCoordinates().posZ + offset[2] + area[2] };
AxisAlignedBB box = AxisAlignedBB.getBoundingBox(min[0], min[1], min[2], max[0], max[1], max[2]);
int offsetX = -Math.round(area[0] / 2f);
int offsetY = -Math.round(area[1] / 2f);
int offsetZ = -Math.round(area[2] / 2f);
int minX = housing.getCoordinates().posX + offsetX;
int minY = housing.getCoordinates().posY + offsetY;
int minZ = housing.getCoordinates().posZ + offsetZ;
int maxX = housing.getCoordinates().posX + offsetX + area[0];
int maxY = housing.getCoordinates().posY + offsetY + area[1];
int maxZ = housing.getCoordinates().posZ + offsetZ + area[2];
AxisAlignedBB box = AxisAlignedBB.getBoundingBox(minX, minY, minZ, maxX, maxY, maxZ);
return housing.getWorld().getEntitiesWithinAABB(eClass, box);
}
@@ -2,13 +2,16 @@ package binnie.extrabees.gui;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.nbt.NBTTagList;
import binnie.core.AbstractMod;
import binnie.core.craftgui.minecraft.InventoryType;
import binnie.core.craftgui.minecraft.Window;
import binnie.core.craftgui.minecraft.control.ControlPlayerInventory;
import binnie.core.craftgui.minecraft.control.ControlSlot;
import binnie.core.machines.Machine;
import binnie.core.machines.TileEntityMachine;
import binnie.core.network.packet.MessageCraftGUI;
import binnie.core.util.I18N;
import binnie.extrabees.ExtraBees;
import cpw.mods.fml.relauncher.Side;
@@ -33,9 +36,10 @@ public class WindowAlvearyFrame extends Window {
@Override
public void initialiseClient() {
setTitle(I18N.localise("extrabees.machine.alveay.frame"));
playerInventory = new ControlPlayerInventory(this);
ControlSlot slot = new ControlSlot(this, 79.0f, 30.0f);
slot.assign(0);
final NBTTagList actions = new NBTTagList();
playerInventory = new ControlPlayerInventory(this).create(actions);
new ControlSlot(this, 79.0f, 30.0f).assign(actions, InventoryType.Machine, 0);
MessageCraftGUI.sendToServer(actions);
}
@Override
@@ -2,13 +2,16 @@ package binnie.extrabees.gui;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.nbt.NBTTagList;
import binnie.core.AbstractMod;
import binnie.core.craftgui.minecraft.InventoryType;
import binnie.core.craftgui.minecraft.Window;
import binnie.core.craftgui.minecraft.control.ControlPlayerInventory;
import binnie.core.craftgui.minecraft.control.ControlSlotArray;
import binnie.core.machines.Machine;
import binnie.core.machines.TileEntityMachine;
import binnie.core.network.packet.MessageCraftGUI;
import binnie.core.util.I18N;
import binnie.extrabees.ExtraBees;
import binnie.extrabees.apiary.machine.hatchery.AlvearyHatchery;
@@ -33,10 +36,11 @@ public class WindowAlvearyHatchery extends Window {
@Override
public void initialiseClient() {
final NBTTagList actions = new NBTTagList();
setTitle(I18N.localise("extrabees.machine.alveay.hatchery"));
playerInventory = new ControlPlayerInventory(this);
ControlSlotArray slot = new ControlSlotArray(this, 43, 30, 5, 1);
slot.create(AlvearyHatchery.SLOT_LARVAE);
playerInventory = new ControlPlayerInventory(this).create(actions);
new ControlSlotArray(this, 43, 30, 5, 1).create(actions, InventoryType.Machine, AlvearyHatchery.SLOT_LARVAE);
MessageCraftGUI.sendToServer(actions);
}
@Override
@@ -3,17 +3,21 @@ package binnie.extrabees.gui;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagList;
import binnie.core.AbstractMod;
import binnie.core.craftgui.controls.ControlText;
import binnie.core.craftgui.geometry.IArea;
import binnie.core.craftgui.geometry.IPoint;
import binnie.core.craftgui.geometry.TextJustification;
import binnie.core.craftgui.minecraft.InventoryType;
import binnie.core.craftgui.minecraft.Window;
import binnie.core.craftgui.minecraft.control.ControlItemDisplay;
import binnie.core.craftgui.minecraft.control.ControlPlayerInventory;
import binnie.core.craftgui.minecraft.control.ControlSlot;
import binnie.core.machines.Machine;
import binnie.core.machines.TileEntityMachine;
import binnie.core.network.packet.MessageCraftGUI;
import binnie.core.util.I18N;
import binnie.extrabees.ExtraBees;
import binnie.extrabees.apiary.machine.mutator.AlvearyMutator;
@@ -38,17 +42,18 @@ public class WindowAlvearyMutator extends Window {
@Override
public void initialiseClient() {
final NBTTagList actions = new NBTTagList();
setTitle(I18N.localise("extrabees.machine.alveay.mutator"));
playerInventory = new ControlPlayerInventory(this);
ControlSlot slot = new ControlSlot(this, 79.0f, 30.0f);
slot.assign(AlvearyMutator.SLOT_MUTATOR);
playerInventory = new ControlPlayerInventory(this).create(actions);
new ControlSlot(this, 79.0f, 30.0f).assign(actions, InventoryType.Machine, AlvearyMutator.SLOT_MUTATOR);
new ControlText(
this,
new IArea(0.0f, 52.0f, w(), 16.0f),
I18N.localise("extrabees.machine.alveay.mutator.mutagens"),
TextJustification.MIDDLE_CENTER).setColor(0x555555);
int size = AlvearyMutator.getMutagens().size();
int w = size * 18;
int w = size * 17;
if (size <= 0) {
return;
@@ -58,9 +63,12 @@ public class WindowAlvearyMutator extends Window {
for (ItemStack stack : AlvearyMutator.getMutagens()) {
ControlItemDisplay display = new ControlItemDisplay(this, x, 66.0f);
display.setItemStack(stack);
display.setSize(new IPoint(14, 14));
display.hastooltip = true;
x += 18.0f;
x += 17.0f;
}
MessageCraftGUI.sendToServer(actions);
}
@Override
@@ -2,15 +2,18 @@ package binnie.extrabees.gui;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.nbt.NBTTagList;
import binnie.core.AbstractMod;
import binnie.core.craftgui.geometry.Position;
import binnie.core.craftgui.minecraft.InventoryType;
import binnie.core.craftgui.minecraft.Window;
import binnie.core.craftgui.minecraft.control.ControlEnergyBar;
import binnie.core.craftgui.minecraft.control.ControlPlayerInventory;
import binnie.core.craftgui.minecraft.control.ControlSlot;
import binnie.core.machines.Machine;
import binnie.core.machines.TileEntityMachine;
import binnie.core.network.packet.MessageCraftGUI;
import binnie.core.util.I18N;
import binnie.extrabees.ExtraBees;
import binnie.extrabees.apiary.machine.stimulator.AlvearyStimulator;
@@ -35,11 +38,12 @@ public class WindowAlvearyStimulator extends Window {
@Override
public void initialiseClient() {
final NBTTagList actions = new NBTTagList();
setTitle(I18N.localise("extrabees.machine.alveay.stimulator"));
playerInventory = new ControlPlayerInventory(this).create(actions);
new ControlSlot(this, 41.0f, 28.0f).assign(actions, InventoryType.Machine, AlvearyStimulator.SLOT_CIRCUIT);
new ControlEnergyBar(this, 75, 29, 60, 16, Position.LEFT);
ControlSlot slot = new ControlSlot(this, 41.0f, 28.0f);
slot.assign(AlvearyStimulator.SLOT_CIRCUIT);
playerInventory = new ControlPlayerInventory(this);
MessageCraftGUI.sendToServer(actions);
}
@Override
@@ -97,4 +97,9 @@ public class BlockExtraBeeHive extends Block {
}
return ret;
}
@Override
public int damageDropped(int meta) {
return meta;
}
}
@@ -1,5 +1,7 @@
package binnie.extrabees.worldgen;
import static binnie.core.Mods.buildcraftCore;
import java.util.Random;
import net.minecraft.world.World;
@@ -7,7 +9,7 @@ import net.minecraft.world.chunk.IChunkProvider;
import binnie.core.IInitializable;
import binnie.extrabees.ExtraBees;
import binnie.extrabees.config.ConfigurationMain;
import binnie.extrabees.config.EBConfig;
import binnie.extrabees.genetics.ExtraBeeDefinition;
import buildcraft.api.core.BuildCraftAPI;
import cpw.mods.fml.common.IWorldGenerator;
@@ -16,11 +18,6 @@ import forestry.apiculture.genetics.BeeDefinition;
public class ModuleGeneration implements IWorldGenerator, IInitializable {
protected static int waterRate = 2;
protected static int rockRate = 2;
protected static int netherRate = 2;
protected static int marbleRate = 2;
@Override
public void preInit() {
ExtraBees.materialBeehive = new MaterialBeehive();
@@ -30,11 +27,8 @@ public class ModuleGeneration implements IWorldGenerator, IInitializable {
@Override
public void init() {
ModuleGeneration.waterRate = ConfigurationMain.waterHiveRate;
ModuleGeneration.rockRate = ConfigurationMain.rockHiveRate;
ModuleGeneration.netherRate = ConfigurationMain.netherHiveRate;
GameRegistry.registerWorldGenerator(new ModuleGeneration(), 0);
if (!ConfigurationMain.canQuarryMineHives) {
if (!EBConfig.canQuarryMineHives && buildcraftCore.active()) {
BuildCraftAPI.softBlocks.add(ExtraBees.hive);
}
}
@@ -62,21 +56,21 @@ public class ModuleGeneration implements IWorldGenerator, IInitializable {
chunkX <<= 4;
chunkZ <<= 4;
for (int i = 0; i < ModuleGeneration.waterRate; ++i) {
for (int i = 0; i < EBConfig.waterHiveRate; ++i) {
int randPosX = chunkX + rand.nextInt(16);
int randPosY = rand.nextInt(50) + 20;
int randPosZ = chunkZ + rand.nextInt(16);
new WorldGenHiveWater().generate(world, rand, randPosX, randPosY, randPosZ);
}
for (int i = 0; i < ModuleGeneration.rockRate; ++i) {
for (int i = 0; i < EBConfig.rockHiveRate; ++i) {
int randPosX = chunkX + rand.nextInt(16);
int randPosY = rand.nextInt(50) + 20;
int randPosZ = chunkZ + rand.nextInt(16);
new WorldGenHiveRock().generate(world, rand, randPosX, randPosY, randPosZ);
}
for (int i = 0; i < ModuleGeneration.netherRate; ++i) {
for (int i = 0; i < EBConfig.netherHiveRate; ++i) {
int randPosX = chunkX + rand.nextInt(16);
int randPosY = rand.nextInt(50) + 20;
int randPosZ = chunkZ + rand.nextInt(16);
@@ -1,8 +1,14 @@
package binnie.extratrees;
import static binnie.extratrees.ExtraTrees.EB_MOD_NAME;
import static binnie.extratrees.ExtraTrees.ET_MODID;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import com.gtnewhorizon.gtnhlib.config.ConfigException;
import com.gtnewhorizon.gtnhlib.config.ConfigurationManager;
import binnie.core.AbstractMod;
import binnie.core.BinnieCore;
import binnie.core.Tags;
@@ -16,7 +22,7 @@ import binnie.extratrees.block.decor.BlockMultiFence;
import binnie.extratrees.carpentry.BlockCarpentry;
import binnie.extratrees.carpentry.BlockStainedDesign;
import binnie.extratrees.carpentry.ModuleCarpentry;
import binnie.extratrees.config.ConfigurationMain;
import binnie.extratrees.config.ETConfig;
import binnie.extratrees.core.ExtraTreesGUID;
import binnie.extratrees.core.ModuleCore;
import binnie.extratrees.genetics.ModuleGenetics;
@@ -31,19 +37,30 @@ import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
@Mod(
modid = "ExtraTrees",
name = "Extra Trees",
modid = ET_MODID,
name = EB_MOD_NAME,
version = Tags.VERSION,
useMetadata = true,
dependencies = "after:BinnieCore")
public class ExtraTrees extends AbstractMod {
public static final String ET_MODID = "ExtraTrees";
public static final String EB_MOD_NAME = "Extra Trees";
@Mod.Instance("ExtraTrees")
public static ExtraTrees instance;
@SidedProxy(clientSide = "binnie.extratrees.proxy.ProxyClient", serverSide = "binnie.extratrees.proxy.ProxyServer")
public static Proxy proxy;
static {
try {
ConfigurationManager.registerConfig(ETConfig.class);
} catch (ConfigException e) {
throw new RuntimeException(e);
}
}
public static Item itemDictionary;
public static Item itemDictionaryLepi;
public static Item itemMisc;
@@ -101,11 +118,6 @@ public class ExtraTrees extends AbstractMod {
return ExtraTreesGUID.values();
}
@Override
public Class<?>[] getConfigs() {
return new Class[] { ConfigurationMain.class };
}
@Override
public String getChannel() {
return "ET";
@@ -116,6 +128,7 @@ public class ExtraTrees extends AbstractMod {
return ExtraTrees.proxy;
}
// Concerningly, this isn't the same as the MODID
@Override
public String getModID() {
return "extratrees";
@@ -11,6 +11,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
@@ -40,36 +41,12 @@ public abstract class BlockDesign extends BlockMetadata implements IMultipassBlo
designSystem = system;
}
public static int getMetadata(int plank1, int plank2, int design) {
return plank1 + (plank2 << 9) + (design << 18);
public void registerHandler() {
MinecraftForge.EVENT_BUS.register(new EventHandler());
}
@SubscribeEvent
public void onClick(PlayerInteractEvent event) {
if (event.action != PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) {
return;
}
World world = event.entityPlayer.worldObj;
EntityPlayer player = event.entityPlayer;
int x = event.x;
int y = event.y;
int z = event.z;
if (!(world.getBlock(x, y, z) instanceof BlockDesign blockDesign)) {
return;
}
ItemStack item = player.getHeldItem();
if (item == null || !(item.getItem() instanceof IToolHammer)
|| !((IToolHammer) item.getItem()).isActive(item)) {
return;
}
DesignBlock carpentryBlock = blockDesign.getCarpentryBlock(world, x, y, z);
TileEntityMetadata tile = (TileEntityMetadata) world.getTileEntity(x, y, z);
carpentryBlock.rotate(event.face, item, player, world, x, y, z);
int meta = carpentryBlock.getBlockMetadata(blockDesign.getDesignSystem());
tile.setTileMetadata(meta, true);
public static int getMetadata(int plank1, int plank2, int design) {
return plank1 + (plank2 << 9) + (design << 18);
}
public abstract ItemStack getCreativeStack(IDesign design);
@@ -160,4 +137,35 @@ public abstract class BlockDesign extends BlockMetadata implements IMultipassBlo
public int getNumberOfPasses() {
return 2;
}
public static class EventHandler {
@SubscribeEvent
public void onClick(PlayerInteractEvent event) {
if (event.action != PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) {
return;
}
World world = event.entityPlayer.worldObj;
EntityPlayer player = event.entityPlayer;
int x = event.x;
int y = event.y;
int z = event.z;
if (!(world.getBlock(x, y, z) instanceof BlockDesign blockDesign)) {
return;
}
ItemStack item = player.getHeldItem();
if (item == null || !(item.getItem() instanceof IToolHammer)
|| !((IToolHammer) item.getItem()).isActive(item)) {
return;
}
DesignBlock carpentryBlock = blockDesign.getCarpentryBlock(world, x, y, z);
TileEntityMetadata tile = (TileEntityMetadata) world.getTileEntity(x, y, z);
carpentryBlock.rotate(event.face, item, player, world, x, y, z);
int meta = carpentryBlock.getBlockMetadata(blockDesign.getDesignSystem());
tile.setTileMetadata(meta, true);
}
}
}
@@ -2,7 +2,6 @@ package binnie.extratrees.carpentry;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.ForgeDirection;
import binnie.core.BinnieCore;
@@ -81,21 +80,18 @@ public class ModuleCarpentry implements IInitializable {
@Override
public void preInit() {
// spotless:off
ExtraTrees.blockCarpentry = new BlockCarpentry();
ExtraTrees.blockPanel = new BlockCarpentryPanel();
ExtraTrees.blockStained = new BlockStainedDesign();
GameRegistry.registerBlock(ExtraTrees.blockCarpentry, ItemMetadata.class, "carpentry");
GameRegistry.registerBlock(ExtraTrees.blockPanel, ItemMetadata.class, "panel");
GameRegistry.registerBlock(ExtraTrees.blockStained, ItemMetadata.class, "stainedglass");
BinnieCore.proxy.registerCustomItemRenderer(
Item.getItemFromBlock(ExtraTrees.blockCarpentry),
new MultipassItemRenderer());
BinnieCore.proxy.registerCustomItemRenderer(
Item.getItemFromBlock(ExtraTrees.blockStained),
new MultipassItemRenderer());
MinecraftForge.EVENT_BUS.register(ExtraTrees.blockCarpentry);
BinnieCore.proxy
.registerCustomItemRenderer(Item.getItemFromBlock(ExtraTrees.blockPanel), new MultipassItemRenderer());
BinnieCore.proxy.registerCustomItemRenderer(Item.getItemFromBlock(ExtraTrees.blockCarpentry), new MultipassItemRenderer());
BinnieCore.proxy.registerCustomItemRenderer(Item.getItemFromBlock(ExtraTrees.blockStained), new MultipassItemRenderer());
ExtraTrees.blockCarpentry.registerHandler();
BinnieCore.proxy.registerCustomItemRenderer(Item.getItemFromBlock(ExtraTrees.blockPanel), new MultipassItemRenderer());
// spotless:on
}
@Override
@@ -1,15 +0,0 @@
package binnie.extratrees.config;
import binnie.core.mod.config.ConfigFile;
import binnie.core.mod.config.ConfigProperty;
import binnie.core.mod.config.PropBoolean;
@ConfigFile(filename = "/config/forestry/extratrees/main.conf")
public class ConfigurationMain {
@ConfigProperty(
key = "lemon.citrus.family",
comment = { "Uses reflection to convert the Forestry lemon tree to the Citrus family." })
@PropBoolean
public static boolean alterLemon = true;
}
@@ -0,0 +1,14 @@
package binnie.extratrees.config;
import static binnie.extratrees.ExtraTrees.ET_MODID;
import com.gtnewhorizon.gtnhlib.config.Config;
@Config(modid = ET_MODID)
public class ETConfig {
@Config.Comment("Uses reflection to convert the Forestry lemon tree to the Citrus family.")
@Config.DefaultBoolean(true)
@Config.RequiresMcRestart
public static boolean alterLemon;
}
@@ -2,9 +2,11 @@ package binnie.extratrees.craftgui;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.nbt.NBTTagList;
import binnie.core.AbstractMod;
import binnie.core.craftgui.geometry.Position;
import binnie.core.craftgui.minecraft.InventoryType;
import binnie.core.craftgui.minecraft.Window;
import binnie.core.craftgui.minecraft.control.ControlEnergyBar;
import binnie.core.craftgui.minecraft.control.ControlErrorState;
@@ -12,6 +14,7 @@ import binnie.core.craftgui.minecraft.control.ControlLiquidTank;
import binnie.core.craftgui.minecraft.control.ControlPlayerInventory;
import binnie.core.craftgui.minecraft.control.ControlSlot;
import binnie.core.machines.Machine;
import binnie.core.network.packet.MessageCraftGUI;
import binnie.extratrees.ExtraTrees;
import binnie.extratrees.machines.lumbermill.Lumbermill;
import cpw.mods.fml.relauncher.Side;
@@ -38,15 +41,20 @@ public class WindowLumbermill extends Window {
@Override
public void initialiseClient() {
final NBTTagList actions = new NBTTagList();
setTitle(Machine.getMachine(getInventory()).getPackage().getDisplayName());
new ControlSlot(this, 42.0f, 43.0f).assign(Lumbermill.SLOT_WOOD);
new ControlSlot(this, 148.0f, 43.0f).assign(Lumbermill.SLOT_PLANKS);
new ControlSlot(this, 172.0f, 28.0f).assign(Lumbermill.SLOT_BARK);
new ControlSlot(this, 172.0f, 58.0f).assign(Lumbermill.SLOT_SAWDUST);
new ControlSlot(this, 42.0f, 43.0f).assign(actions, InventoryType.Machine, Lumbermill.SLOT_WOOD);
new ControlSlot(this, 148.0f, 43.0f).assign(actions, InventoryType.Machine, Lumbermill.SLOT_PLANKS);
new ControlSlot(this, 172.0f, 28.0f).assign(actions, InventoryType.Machine, Lumbermill.SLOT_BARK);
new ControlSlot(this, 172.0f, 58.0f).assign(actions, InventoryType.Machine, Lumbermill.SLOT_SAWDUST);
new ControlLumbermillProgress(this, 70.0f, 43.0f);
new ControlLiquidTank(this, 16, 32);
new ControlEnergyBar(this, 8, 112, 16, 60, Position.BOTTOM);
new ControlPlayerInventory(this);
new ControlPlayerInventory(this).create(actions);
new ControlErrorState(this, 95.0f, 73.0f);
MessageCraftGUI.sendToServer(actions);
}
}
@@ -2,6 +2,7 @@ package binnie.extratrees.craftgui;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.nbt.NBTTagList;
import binnie.core.AbstractMod;
import binnie.core.craftgui.controls.ControlText;
@@ -12,6 +13,7 @@ import binnie.core.craftgui.events.EventTextEdit;
import binnie.core.craftgui.geometry.IArea;
import binnie.core.craftgui.geometry.IPoint;
import binnie.core.craftgui.geometry.TextJustification;
import binnie.core.craftgui.minecraft.InventoryType;
import binnie.core.craftgui.minecraft.MinecraftGUI;
import binnie.core.craftgui.minecraft.Window;
import binnie.core.craftgui.minecraft.control.ControlErrorState;
@@ -19,6 +21,7 @@ import binnie.core.craftgui.minecraft.control.ControlPlayerInventory;
import binnie.core.craftgui.minecraft.control.ControlSlot;
import binnie.core.craftgui.window.Panel;
import binnie.core.machines.Machine;
import binnie.core.network.packet.MessageCraftGUI;
import binnie.core.util.I18N;
import binnie.extratrees.ExtraTrees;
import binnie.extratrees.machines.designer.Designer;
@@ -48,6 +51,8 @@ public class WindowWoodworker extends Window {
@Override
public void initialiseClient() {
final NBTTagList actions = new NBTTagList();
setTitle(Machine.getMachine(getInventory()).getPackage().getDisplayName());
new ControlText(
this,
@@ -58,18 +63,25 @@ public class WindowWoodworker extends Window {
textEdit = new ControlTextEdit(this, 188.0f, 178.0f, 118.0f, 12.0f);
ControlScrollableContent scroll = new ControlScrollableContent(this, 190.0f, 50.0f, 114.0f, 122.0f, 12.0f);
scroll.setScrollableContent(tileSelect = new ControlTileSelect(scroll, 0.0f, 0.0f));
new ControlPlayerInventory(this).setPosition(new IPoint(14.0f, 96.0f));
ControlPlayerInventory controlPlayerInventory = new ControlPlayerInventory(this);
controlPlayerInventory.setPosition(new IPoint(14.0f, 96.0f));
controlPlayerInventory.create(actions);
new ControlErrorState(this, 76.0f, 65.0f);
if (getInventory() != null) {
ControlSlot slotWood1 = new ControlSlot(this, 22.0f, 34.0f);
slotWood1.assign(Designer.DESIGN_1_SLOT);
slotWood1.assign(actions, InventoryType.Machine, Designer.DESIGN_1_SLOT);
ControlSlot slotWood2 = new ControlSlot(this, 62.0f, 34.0f);
slotWood2.assign(Designer.DESIGN_2_SLOT);
slotWood2.assign(actions, InventoryType.Machine, Designer.DESIGN_2_SLOT);
ControlSlot slotBeeswax = new ControlSlot(this, 42.0f, 64.0f);
slotBeeswax.assign(Designer.GLUE_SLOT);
slotBeeswax.assign(actions, InventoryType.Machine, Designer.GLUE_SLOT);
new ControlRecipeSlot(this, 112, 34);
}
MessageCraftGUI.sendToServer(actions);
}
@Override
@@ -17,7 +17,7 @@ import binnie.Binnie;
import binnie.core.util.I18N;
import binnie.extratrees.ExtraTrees;
import binnie.extratrees.block.FruitPod;
import binnie.extratrees.config.ConfigurationMain;
import binnie.extratrees.config.ETConfig;
import binnie.extratrees.item.Food;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@@ -254,7 +254,7 @@ public enum ExtraTreeFruitGene implements IAlleleFruit, IFruitProvider {
ExtraTreeFruitGene.Candlenut.addProduct(Food.Candlenut.get(1), 1.0f);
ExtraTreeFruitGene.Candlenut.setFamily(familyJungle);
if (ConfigurationMain.alterLemon) {
if (ETConfig.alterLemon) {
try {
IAlleleFruit lemon = (IAlleleFruit) AlleleManager.alleleRegistry.getAllele("forestry.fruitLemon");
FruitProviderNone prov = (FruitProviderNone) lemon.getProvider();
@@ -376,7 +376,7 @@ public enum ExtraTreeFruitGene implements IAlleleFruit, IFruitProvider {
float modeYieldMod = 1.0f;
for (Map.Entry<ItemStack, Float> entry2 : products.entrySet()) {
if (world.rand.nextFloat() <= genome.getYield() * modeYieldMod * entry2.getValue() * stage) {
if (world.rand.nextFloat() <= genome.getYield() * modeYieldMod * entry2.getValue() * 5.0f * stage) {
product2.add(entry2.getKey().copy());
}
}
@@ -1,7 +1,6 @@
package binnie.extratrees.genetics;
import java.awt.Color;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Map;
@@ -690,19 +689,6 @@ public enum ExtraTreeSpecies implements IAlleleTreeSpecies, IIconProvider, IGerm
.setFertility(EnumAllele.Saplings.LOW).setMaturation(EnumAllele.Maturation.SLOWER);
}
// TODO unused method?
static ItemStack getEBXLStack(String name) {
try {
Class elements = Class.forName("extrabiomes.lib.Element");
Method getElementMethod = elements.getMethod("valueOf", String.class);
Method getItemStack = elements.getMethod("get");
Object element = getElementMethod.invoke(null, "SAPLING_AUTUMN_YELLOW");
return (ItemStack) getItemStack.invoke(element);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
private ExtraTreeSpecies addFamily(IFruitFamily family) {
families.add(family);
return this;
@@ -7,7 +7,6 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import binnie.Binnie;
import binnie.core.BinnieCore;
import binnie.core.machines.IMachineType;
import binnie.core.machines.Machine;
import binnie.core.machines.MachineComponent;
@@ -43,14 +42,6 @@ public enum ExtraTreeMachine implements IMachineType {
return cls;
}
@Override
public boolean isActive() {
if (this == ExtraTreeMachine.Tileworker) {
return BinnieCore.isBotanyActive();
}
return true;
}
public ItemStack get(int i) {
return new ItemStack(ExtraTrees.blockMachine, i, ordinal());
}
@@ -93,7 +93,7 @@ public class WoodworkerRecipeComponent extends ComponentRecipe
}
@Override
public void recieveGuiNBT(Side side, EntityPlayer player, String name, NBTTagCompound nbt) {
public void receiveGuiNBT(Side side, EntityPlayer player, String name, NBTTagCompound nbt) {
if (name.equals("recipe")) {
InventoryPlayer playerInv = player.inventory;
ItemStack recipe = doRecipe(false);
+1 -2
View File
@@ -3,7 +3,6 @@ package binnie.genetics;
import net.minecraft.item.Item;
import binnie.core.AbstractMod;
import binnie.core.BinnieCore;
import binnie.core.Tags;
import binnie.core.gui.IBinnieGUID;
import binnie.core.machines.MachineGroup;
@@ -106,7 +105,7 @@ public class Genetics extends AbstractMod {
@Override
public boolean isActive() {
return BinnieCore.isGeneticsActive();
return true;
}
public static class PacketHandler extends BinniePacketHandler {
@@ -11,11 +11,7 @@ import cpw.mods.fml.relauncher.SideOnly;
public class GeneticsCreativeTab extends CreativeTabs {
public static CreativeTabs instance;
static {
GeneticsCreativeTab.instance = new GeneticsCreativeTab();
}
public static CreativeTabs instance = new GeneticsCreativeTab();
public GeneticsCreativeTab() {
super("Genetics");
@@ -1,7 +0,0 @@
package binnie.genetics.config;
import binnie.core.mod.config.ConfigFile;
@ConfigFile(filename = "/config/forestry/genetics/main.conf")
public class ConfigurationMain {
}
@@ -2,9 +2,11 @@ package binnie.genetics.craftgui;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.nbt.NBTTagList;
import binnie.core.AbstractMod;
import binnie.core.craftgui.geometry.Position;
import binnie.core.craftgui.minecraft.InventoryType;
import binnie.core.craftgui.minecraft.Window;
import binnie.core.craftgui.minecraft.control.ControlEnergyBar;
import binnie.core.craftgui.minecraft.control.ControlErrorState;
@@ -13,6 +15,7 @@ import binnie.core.craftgui.minecraft.control.ControlSlot;
import binnie.core.craftgui.minecraft.control.ControlSlotArray;
import binnie.core.craftgui.resource.Texture;
import binnie.core.craftgui.resource.minecraft.StandardTexture;
import binnie.core.network.packet.MessageCraftGUI;
import binnie.core.util.I18N;
import binnie.extrabees.core.ExtraBeeTexture;
import binnie.genetics.Genetics;
@@ -40,17 +43,23 @@ public class WindowAcclimatiser extends WindowMachine {
@Override
public void initialiseClient() {
super.initialiseClient();
final NBTTagList actions = new NBTTagList();
int x = 59;
int y = 32;
new ControlSlotArray(this, x, y, 2, 2).create(Acclimatiser.SLOT_RESERVE);
new ControlSlotArray(this, x, y, 2, 2).create(actions, InventoryType.Machine, Acclimatiser.SLOT_RESERVE);
x += 54;
new ControlSlot(this, x + 18, y).assign(Acclimatiser.SLOT_TARGET);
new ControlSlotArray(this, x, y + 18 + 18, 3, 1).create(Acclimatiser.SLOT_ACCLIMATISER);
new ControlSlot(this, x + 18, y).assign(actions, InventoryType.Machine, Acclimatiser.SLOT_TARGET);
new ControlSlotArray(this, x, y + 18 + 18, 3, 1)
.create(actions, InventoryType.Machine, Acclimatiser.SLOT_ACCLIMATISER);
x += 72;
new ControlSlotArray(this, x, y, 2, 2).create(Acclimatiser.SLOT_DONE);
new ControlSlotArray(this, x, y, 2, 2).create(actions, InventoryType.Machine, Acclimatiser.SLOT_DONE);
new ControlEnergyBar(this, 21, 115, 16, 60, Position.BOTTOM);
new ControlErrorState(this, 181.0f, 83.0f);
new ControlPlayerInventory(this);
new ControlPlayerInventory(this).create(actions);
MessageCraftGUI.sendToServer(actions);
}
@Override
@@ -2,10 +2,12 @@ package binnie.genetics.craftgui;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.nbt.NBTTagList;
import binnie.core.AbstractMod;
import binnie.core.craftgui.geometry.Position;
import binnie.core.craftgui.minecraft.GUIIcon;
import binnie.core.craftgui.minecraft.InventoryType;
import binnie.core.craftgui.minecraft.MinecraftGUI;
import binnie.core.craftgui.minecraft.Window;
import binnie.core.craftgui.minecraft.control.ControlEnergyBar;
@@ -19,6 +21,7 @@ import binnie.core.craftgui.minecraft.control.ControlSlotCharge;
import binnie.core.craftgui.resource.Texture;
import binnie.core.craftgui.resource.minecraft.StandardTexture;
import binnie.core.craftgui.window.Panel;
import binnie.core.network.packet.MessageCraftGUI;
import binnie.core.util.I18N;
import binnie.extrabees.core.ExtraBeeTexture;
import binnie.genetics.Genetics;
@@ -47,13 +50,16 @@ public class WindowAnalyser extends WindowMachine {
@Override
public void initialiseClient() {
super.initialiseClient();
final NBTTagList actions = new NBTTagList();
WindowAnalyser.progressBase = new StandardTexture(0, 51, 66, 40, GeneticsTexture.GUIProcess.getTexture());
WindowAnalyser.progress = new StandardTexture(66, 51, 66, 40, GeneticsTexture.GUIProcess.getTexture());
int x = 16;
int y = 32;
new ControlSlotArray(this, x, y, 2, 3).create(Analyser.SLOT_RESERVE);
new ControlSlotArray(this, x, y, 2, 3).create(actions, InventoryType.Machine, Analyser.SLOT_RESERVE);
x += 28;
new ControlSlot(this, x, y + 54 + 8).assign(13);
new ControlSlot(this, x, y + 54 + 8).assign(actions, InventoryType.Machine, 13);
new ControlSlotCharge(this, x + 20, y + 54 + 8, 13).setColor(10040319);
new ControlEnergyBar(this, x + 24 + 16, y + 54 + 8 + 1, 60, 16, Position.LEFT);
new ControlErrorState(this, x + 24 + 16 + 60 + 16, y + 54 + 8 + 1);
@@ -62,11 +68,13 @@ public class WindowAnalyser extends WindowMachine {
x += 56;
new Panel(this, x, y, 76.0f, 50.0f, MinecraftGUI.PanelType.Tinted);
new ControlProgress(this, x + 5, y + 5, WindowAnalyser.progressBase, WindowAnalyser.progress, Position.LEFT);
new ControlSlot(this, x + 38 - 9, y + 25 - 9).assign(Analyser.SLOT_TARGET);
new ControlSlot(this, x + 38 - 9, y + 25 - 9).assign(actions, InventoryType.Machine, Analyser.SLOT_TARGET);
new ControlIconDisplay(this, x + 76 + 2, y + 18, GUIIcon.ArrowRight.getIcon());
x += 96;
new ControlSlotArray(this, x, y, 2, 3).create(Analyser.SLOT_FINISHED);
new ControlPlayerInventory(this);
new ControlSlotArray(this, x, y, 2, 3).create(actions, InventoryType.Machine, Analyser.SLOT_FINISHED);
new ControlPlayerInventory(this).create(actions);
MessageCraftGUI.sendToServer(actions);
}
@Override
@@ -46,7 +46,7 @@ public class WindowGeneBank extends WindowMachine {
protected ControlGeneScroll genes;
public WindowGeneBank(EntityPlayer player, IInventory inventory, Side side, boolean isNEI) {
super(320, 224, player, inventory, side);
super(400, 224, player, inventory, side);
isNei = isNEI;
}
@@ -55,8 +55,8 @@ public class WindowGeneBank extends WindowMachine {
}
@Override
public void recieveGuiNBT(Side side, EntityPlayer player, String name, NBTTagCompound nbt) {
super.recieveGuiNBT(side, player, name, nbt);
public void receiveGuiNBT(Side side, EntityPlayer player, String name, NBTTagCompound nbt) {
super.receiveGuiNBT(side, player, name, nbt);
if (side != Side.SERVER || !name.equals("gene-select")) {
return;
}
@@ -97,10 +97,10 @@ public class WindowGeneBank extends WindowMachine {
int boxX;
int x = 16;
int y = 32;
new ControlPlayerInventory(this, x, y);
new ControlPlayerInventory(this, x, y).createAndRegister();
x += 124;
boxX = x;
int geneBoxWidth = 120;
int geneBoxWidth = 200;
new Panel(this, boxX + 24, 32.0f, geneBoxWidth, 120.0f, MinecraftGUI.PanelType.Black);
new Panel(this, boxX + 24 + geneBoxWidth, 32.0f, 14.0f, 120.0f, MinecraftGUI.PanelType.Gray);
ControlScrollableContent scroll = new ControlScrollableContent(
@@ -2,10 +2,12 @@ package binnie.genetics.craftgui;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.nbt.NBTTagList;
import binnie.core.AbstractMod;
import binnie.core.craftgui.geometry.Position;
import binnie.core.craftgui.minecraft.GUIIcon;
import binnie.core.craftgui.minecraft.InventoryType;
import binnie.core.craftgui.minecraft.Window;
import binnie.core.craftgui.minecraft.control.ControlEnergyBar;
import binnie.core.craftgui.minecraft.control.ControlErrorState;
@@ -18,6 +20,7 @@ import binnie.core.craftgui.minecraft.control.ControlSlotArray;
import binnie.core.craftgui.minecraft.control.ControlSlotCharge;
import binnie.core.craftgui.resource.Texture;
import binnie.core.craftgui.resource.minecraft.StandardTexture;
import binnie.core.network.packet.MessageCraftGUI;
import binnie.core.util.I18N;
import binnie.extrabees.core.ExtraBeeTexture;
import binnie.genetics.Genetics;
@@ -40,18 +43,21 @@ public class WindowGenepool extends WindowMachine {
@Override
public void initialiseClient() {
super.initialiseClient();
final NBTTagList actions = new NBTTagList();
int x = 16;
int y = 32;
new ControlLiquidTank(this, x, y).setTankID(Genepool.TANK_ETHANOL);
x += 26;
new ControlSlotArray(this, x, y + 3, 2, 3).create(Genepool.SLOT_RESERVE);
new ControlSlotArray(this, x, y + 3, 2, 3).create(actions, InventoryType.Machine, Genepool.SLOT_RESERVE);
x += 38;
new ControlIconDisplay(this, x, y + 22, GUIIcon.ArrowRight.getIcon());
x += 18;
new ControlSlot(this, x, y + 21).assign(Genepool.SLOT_BEE);
new ControlSlot(this, x, y + 21).assign(actions, InventoryType.Machine, Genepool.SLOT_BEE);
x += 18;
new ControlMachineProgress(this, x, y + 19, progressBase, progress, Position.LEFT);
@@ -59,10 +65,12 @@ public class WindowGenepool extends WindowMachine {
x += 130;
new ControlLiquidTank(this, x, y).setTankID(Genepool.TANK_DNA);
new ControlEnergyBar(this, 21, 115, 16, 60, Position.BOTTOM);
new ControlSlot(this, 121.0f, 82.0f).assign(Genepool.SLOT_ENZYME);
new ControlSlot(this, 121.0f, 82.0f).assign(actions, InventoryType.Machine, Genepool.SLOT_ENZYME);
new ControlSlotCharge(this, 143, 82, 7).setColor(0xefe8af);
new ControlErrorState(this, 181.0f, 83.0f);
new ControlPlayerInventory(this);
new ControlPlayerInventory(this).create(actions);
MessageCraftGUI.sendToServer(actions);
}
@Override
@@ -2,10 +2,12 @@ package binnie.genetics.craftgui;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.nbt.NBTTagList;
import binnie.core.AbstractMod;
import binnie.core.craftgui.geometry.Position;
import binnie.core.craftgui.minecraft.GUIIcon;
import binnie.core.craftgui.minecraft.InventoryType;
import binnie.core.craftgui.minecraft.Window;
import binnie.core.craftgui.minecraft.control.ControlEnergyBar;
import binnie.core.craftgui.minecraft.control.ControlErrorState;
@@ -17,6 +19,7 @@ import binnie.core.craftgui.minecraft.control.ControlSlot;
import binnie.core.craftgui.minecraft.control.ControlSlotArray;
import binnie.core.craftgui.resource.Texture;
import binnie.core.craftgui.resource.minecraft.StandardTexture;
import binnie.core.network.packet.MessageCraftGUI;
import binnie.core.util.I18N;
import binnie.genetics.Genetics;
import binnie.genetics.core.GeneticsTexture;
@@ -39,11 +42,14 @@ public class WindowIncubator extends WindowMachine {
@Override
public void initialiseClient() {
super.initialiseClient();
final NBTTagList actions = new NBTTagList();
int x = 16;
int y = 32;
new ControlLiquidTank(this, x, y).setTankID(Incubator.TANK_INPUT);
x += 26;
new ControlSlotArray(this, x, y + 3, 1, 3).create(Incubator.SLOT_QUEUE);
new ControlSlotArray(this, x, y + 3, 1, 3).create(actions, InventoryType.Machine, Incubator.SLOT_QUEUE);
x += 20;
new ControlIconDisplay(this, x, y + 3 + 10, GUIIcon.ArrowRight.getIcon());
x += 18;
@@ -54,17 +60,19 @@ public class WindowIncubator extends WindowMachine {
WindowIncubator.progressBase,
WindowIncubator.progress,
Position.LEFT);
new ControlSlot(this, x + 10, y + 3 + 10).assign(Incubator.SLOT_INCUBATOR);
new ControlSlot(this, x + 10, y + 3 + 10).assign(actions, InventoryType.Machine, Incubator.SLOT_INCUBATOR);
x += 40;
new ControlIconDisplay(this, x, y + 3 + 10, GUIIcon.ArrowRight.getIcon());
x += 18;
new ControlSlotArray(this, x, y + 3, 1, 3).create(Incubator.SLOT_OUTPUT);
new ControlSlotArray(this, x, y + 3, 1, 3).create(actions, InventoryType.Machine, Incubator.SLOT_OUTPUT);
x += 26;
new ControlLiquidTank(this, x, y).setTankID(Incubator.TANK_OUTPUT);
x += 34;
new ControlEnergyBar(this, x, y + 3, 16, 54, Position.BOTTOM);
new ControlErrorState(this, 91.0f, 82.0f);
new ControlPlayerInventory(this);
new ControlPlayerInventory(this).create(actions);
MessageCraftGUI.sendToServer(actions);
}
@Override
@@ -2,12 +2,14 @@ package binnie.genetics.craftgui;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.nbt.NBTTagList;
import binnie.core.AbstractMod;
import binnie.core.craftgui.geometry.CraftGUIUtil;
import binnie.core.craftgui.geometry.Position;
import binnie.core.craftgui.geometry.TextJustification;
import binnie.core.craftgui.minecraft.GUIIcon;
import binnie.core.craftgui.minecraft.InventoryType;
import binnie.core.craftgui.minecraft.Window;
import binnie.core.craftgui.minecraft.control.ControlEnergyBar;
import binnie.core.craftgui.minecraft.control.ControlErrorState;
@@ -19,6 +21,7 @@ import binnie.core.craftgui.minecraft.control.ControlSlot;
import binnie.core.craftgui.minecraft.control.ControlSlotArray;
import binnie.core.craftgui.resource.Texture;
import binnie.core.craftgui.resource.minecraft.StandardTexture;
import binnie.core.network.packet.MessageCraftGUI;
import binnie.core.util.I18N;
import binnie.genetics.Genetics;
import binnie.genetics.core.GeneticsTexture;
@@ -41,17 +44,22 @@ public class WindowInoculator extends WindowMachine {
@Override
public void initialiseClient() {
super.initialiseClient();
final NBTTagList actions = new NBTTagList();
int x = 16;
int y = 32;
new ControlLiquidTank(this, x, y + 18 + 16).setTankID(0);
CraftGUIUtil.horizontalGrid(
x,
y,
new ControlSlotArray(this, 0, 0, 2, 1).create(Inoculator.SLOT_SERUM_RESERVE),
new ControlSlotArray(this, 0, 0, 2, 1)
.create(actions, InventoryType.Machine, Inoculator.SLOT_SERUM_RESERVE),
new ControlIconDisplay(this, 0.0f, 0.0f, GUIIcon.ArrowRight.getIcon()),
new ControlSlot(this, 0.0f, 0.0f).assign(0),
new ControlSlot(this, 0.0f, 0.0f).assign(actions, InventoryType.Machine, 0),
new ControlIconDisplay(this, 0.0f, 0.0f, GUIIcon.ArrowRight.getIcon()),
new ControlSlotArray(this, 0, 0, 2, 1).create(Inoculator.SLOT_SERUM_EXPENDED));
new ControlSlotArray(this, 0, 0, 2, 1)
.create(actions, InventoryType.Machine, Inoculator.SLOT_SERUM_EXPENDED));
x += 18;
new ControlMachineProgress(
this,
@@ -68,12 +76,15 @@ public class WindowInoculator extends WindowMachine {
y,
TextJustification.MIDDLE_LEFT,
8.0f,
new ControlSlotArray(this, x, y, 4, 1).create(Inoculator.SLOT_RESERVE),
new ControlSlot(this, x, y + 18 + 8).assign(9),
new ControlSlotArray(this, x, y + 18 + 8 + 18 + 8, 4, 1).create(Inoculator.SLOT_FINISHED));
new ControlSlotArray(this, x, y, 4, 1).create(actions, InventoryType.Machine, Inoculator.SLOT_RESERVE),
new ControlSlot(this, x, y + 18 + 8).assign(actions, InventoryType.Machine, 9),
new ControlSlotArray(this, x, y + 18 + 8 + 18 + 8, 4, 1)
.create(actions, InventoryType.Machine, Inoculator.SLOT_FINISHED));
new ControlIconDisplay(this, x + 18, y + 18 + 2, GUIIcon.ArrowUpLeft.getIcon());
new ControlIconDisplay(this, x + 18, y + 18 + 18, GUIIcon.ArrowLeftDown.getIcon());
new ControlPlayerInventory(this);
new ControlPlayerInventory(this).create(actions);
MessageCraftGUI.sendToServer(actions);
}
@Override
@@ -2,10 +2,12 @@ package binnie.genetics.craftgui;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.nbt.NBTTagList;
import binnie.core.AbstractMod;
import binnie.core.craftgui.geometry.Position;
import binnie.core.craftgui.minecraft.GUIIcon;
import binnie.core.craftgui.minecraft.InventoryType;
import binnie.core.craftgui.minecraft.Window;
import binnie.core.craftgui.minecraft.control.ControlEnergyBar;
import binnie.core.craftgui.minecraft.control.ControlErrorState;
@@ -18,6 +20,7 @@ import binnie.core.craftgui.minecraft.control.ControlSlotArray;
import binnie.core.craftgui.minecraft.control.ControlSlotCharge;
import binnie.core.craftgui.resource.Texture;
import binnie.core.craftgui.resource.minecraft.StandardTexture;
import binnie.core.network.packet.MessageCraftGUI;
import binnie.core.util.I18N;
import binnie.extrabees.core.ExtraBeeTexture;
import binnie.genetics.Genetics;
@@ -40,30 +43,35 @@ public class WindowIsolator extends WindowMachine {
@Override
public void initialiseClient() {
super.initialiseClient();
final NBTTagList actions = new NBTTagList();
int x = 16;
int y = 32;
new ControlLiquidTank(this, x, y).setTankID(Isolator.TANK_ETHANOL);
x += 26;
new ControlSlotArray(this, x, y + 3, 1, 3).create(Isolator.SLOT_RESERVE);
new ControlSlotArray(this, x, y + 3, 1, 3).create(actions, InventoryType.Machine, Isolator.SLOT_RESERVE);
x += 20;
new ControlIconDisplay(this, x, y + 3 + 1, GUIIcon.ArrowRight.getIcon());
x += 18;
new ControlSlot(this, x, y + 3).assign(Isolator.SLOT_TARGET);
new ControlSlot(this, x, y + 36 + 3).assign(Isolator.SLOT_ENZYME);
new ControlSlot(this, x, y + 3).assign(actions, InventoryType.Machine, Isolator.SLOT_TARGET);
new ControlSlot(this, x, y + 36 + 3).assign(actions, InventoryType.Machine, Isolator.SLOT_ENZYME);
new ControlSlotCharge(this, x + 18 + 2, y + 36 + 3, 0).setColor(0xefe8af);
x += 18;
new ControlProgress(this, x, y + 3, WindowIsolator.ProgressBase, WindowIsolator.Progress, Position.LEFT);
x += 142;
new ControlSlot(this, x, y + 3).assign(Isolator.SLOT_RESULT);
new ControlSlot(this, x, y + 3 + 36).assign(Isolator.SLOT_SEQUENCER_VIAL);
new ControlSlot(this, x, y + 3).assign(actions, InventoryType.Machine, Isolator.SLOT_RESULT);
new ControlSlot(this, x, y + 3 + 36).assign(actions, InventoryType.Machine, Isolator.SLOT_SEQUENCER_VIAL);
new ControlIconDisplay(this, x + 1, y + 3 + 19, GUIIcon.ArrowUp.getIcon());
x += 20;
new ControlIconDisplay(this, x, y + 3 + 1, GUIIcon.ArrowRight.getIcon());
x += 18;
new ControlSlotArray(this, x, y + 3, 2, 3).create(Isolator.SLOT_FINISHED);
new ControlSlotArray(this, x, y + 3, 2, 3).create(actions, InventoryType.Machine, Isolator.SLOT_FINISHED);
new ControlEnergyBar(this, 260, 130, 16, 60, Position.BOTTOM);
new ControlErrorState(this, 153.0f, 81.0f);
new ControlPlayerInventory(this);
new ControlPlayerInventory(this).create(actions);
MessageCraftGUI.sendToServer(actions);
}
@Override
@@ -2,10 +2,12 @@ package binnie.genetics.craftgui;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.nbt.NBTTagList;
import binnie.core.AbstractMod;
import binnie.core.craftgui.geometry.Position;
import binnie.core.craftgui.minecraft.GUIIcon;
import binnie.core.craftgui.minecraft.InventoryType;
import binnie.core.craftgui.minecraft.Window;
import binnie.core.craftgui.minecraft.control.ControlEnergyBar;
import binnie.core.craftgui.minecraft.control.ControlErrorState;
@@ -18,6 +20,7 @@ import binnie.core.craftgui.minecraft.control.ControlSlotArray;
import binnie.core.craftgui.minecraft.control.ControlSlotCharge;
import binnie.core.craftgui.resource.Texture;
import binnie.core.craftgui.resource.minecraft.StandardTexture;
import binnie.core.network.packet.MessageCraftGUI;
import binnie.core.util.I18N;
import binnie.genetics.Genetics;
import binnie.genetics.core.GeneticsTexture;
@@ -45,23 +48,29 @@ public class WindowPolymeriser extends WindowMachine {
@Override
public void initialiseClient() {
super.initialiseClient();
final NBTTagList actions = new NBTTagList();
int x = 16;
int y = 38;
new ControlSlotArray(this, x, y, 1, 4).create(Polymeriser.SLOT_SERUM_RESERVE);
new ControlSlotArray(this, x, y, 1, 4).create(actions, InventoryType.Machine, Polymeriser.SLOT_SERUM_RESERVE);
new ControlIconDisplay(this, x + 18, y + 1, GUIIcon.ArrowRight.getIcon());
x += 34;
new ControlMachineProgress(this, x + 18, y - 6, progressBase, progress, Position.LEFT);
new ControlSlot(this, x, y).assign(Polymeriser.SLOT_SERUM);
new ControlSlot(this, x, y).assign(actions, InventoryType.Machine, Polymeriser.SLOT_SERUM);
new ControlLiquidTank(this, x, y + 18 + 16, true).setTankID(Polymeriser.TANK_BACTERIA);
new ControlLiquidTank(this, x, y + 18 + 16 + 18 + 8, true).setTankID(Polymeriser.TANK_DNA);
new ControlEnergyBar(this, x + 120, 96, 64, 16, Position.LEFT);
x += 40;
new ControlSlot(this, x + 30, y + 18 + 8).assign(Polymeriser.SLOT_GOLD);
new ControlSlot(this, x + 30, y + 18 + 8).assign(actions, InventoryType.Machine, Polymeriser.SLOT_GOLD);
new ControlSlotCharge(this, x + 30 + 20, y + 18 + 8, 1).setColor(0xffd800);
x += 138;
new ControlSlotArray(this, x, y + 9, 2, 2).create(Polymeriser.SLOT_SERUM_FINISHED);
new ControlSlotArray(this, x, y + 9, 2, 2)
.create(actions, InventoryType.Machine, Polymeriser.SLOT_SERUM_FINISHED);
new ControlErrorState(this, 244.0f, 97.0f);
new ControlPlayerInventory(this);
new ControlPlayerInventory(this).create(actions);
MessageCraftGUI.sendToServer(actions);
}
@Override
@@ -3,6 +3,7 @@ package binnie.genetics.craftgui;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.EnumChatFormatting;
import binnie.core.AbstractMod;
@@ -12,6 +13,7 @@ import binnie.core.craftgui.geometry.IArea;
import binnie.core.craftgui.geometry.Position;
import binnie.core.craftgui.geometry.TextJustification;
import binnie.core.craftgui.minecraft.GUIIcon;
import binnie.core.craftgui.minecraft.InventoryType;
import binnie.core.craftgui.minecraft.Window;
import binnie.core.craftgui.minecraft.control.ControlEnergyBar;
import binnie.core.craftgui.minecraft.control.ControlErrorState;
@@ -22,6 +24,7 @@ import binnie.core.craftgui.minecraft.control.ControlSlotArray;
import binnie.core.craftgui.minecraft.control.ControlSlotCharge;
import binnie.core.craftgui.resource.Texture;
import binnie.core.craftgui.resource.minecraft.StandardTexture;
import binnie.core.network.packet.MessageCraftGUI;
import binnie.core.util.I18N;
import binnie.extrabees.core.ExtraBeeTexture;
import binnie.genetics.Genetics;
@@ -49,18 +52,21 @@ public class WindowSequencer extends WindowMachine {
}
@Override
public void recieveGuiNBT(Side side, EntityPlayer player, String name, NBTTagCompound nbt) {
public void receiveGuiNBT(Side side, EntityPlayer player, String name, NBTTagCompound nbt) {
if (side == Side.CLIENT && name.equals("username")) {
slotText.setValue(
EnumChatFormatting.DARK_GRAY
+ I18N.localise("genetics.machine.sequencer.gui.sequensedBy", nbt.getString("username")));
}
super.recieveGuiNBT(side, player, name, nbt);
super.receiveGuiNBT(side, player, name, nbt);
}
@Override
public void initialiseClient() {
super.initialiseClient();
final NBTTagList actions = new NBTTagList();
int x = 16;
int y = 32;
CraftGUIUtil.horizontalGrid(
@@ -68,13 +74,13 @@ public class WindowSequencer extends WindowMachine {
y,
TextJustification.MIDDLE_CENTER,
2.0f,
new ControlSlotArray(this, 0, 0, 2, 2).create(Sequencer.SLOT_RESERVE),
new ControlSlotArray(this, 0, 0, 2, 2).create(actions, InventoryType.Machine, Sequencer.SLOT_RESERVE),
new ControlIconDisplay(this, 0.0f, 0.0f, GUIIcon.ArrowRight.getIcon()),
new ControlSequencerProgress(this, 0, 0),
new ControlIconDisplay(this, 0.0f, 0.0f, GUIIcon.ArrowRight.getIcon()),
new ControlSlot(this, 0.0f, 0.0f).assign(6));
new ControlSlot(this, 0.0f, 0.0f).assign(actions, InventoryType.Machine, 6));
ControlSlot slotTarget = new ControlSlot(this, x + 96, y + 16);
slotTarget.assign(5);
slotTarget.assign(actions, InventoryType.Machine, 5);
x = 34;
y = 92;
slotText = new ControlText(
@@ -84,14 +90,16 @@ public class WindowSequencer extends WindowMachine {
TextJustification.MIDDLE_CENTER);
y += 20;
ControlSlot slotDye = new ControlSlot(this, x, y);
slotDye.assign(0);
slotDye.assign(actions, InventoryType.Machine, 0);
x += 20;
new ControlSlotCharge(this, x, y, 0).setColor(16750848);
x += 32;
new ControlEnergyBar(this, x, y, 60, 16, Position.LEFT);
x += 92;
new ControlErrorState(this, x, y + 1);
new ControlPlayerInventory(this);
new ControlPlayerInventory(this).create(actions);
MessageCraftGUI.sendToServer(actions);
}
@Override
Loaded 100 of 115 files, more files were not shown because too many files have changed in this diff. Show more