diff options
Diffstat (limited to 'src/Java/gtPlusPlus/core/handler')
-rw-r--r-- | src/Java/gtPlusPlus/core/handler/BookHandler.java | 16 | ||||
-rw-r--r-- | src/Java/gtPlusPlus/core/handler/GuiHandler.java | 7 | ||||
-rw-r--r-- | src/Java/gtPlusPlus/core/handler/PacketHandler.java | 118 |
3 files changed, 92 insertions, 49 deletions
diff --git a/src/Java/gtPlusPlus/core/handler/BookHandler.java b/src/Java/gtPlusPlus/core/handler/BookHandler.java index d9d3efe680..57d371905f 100644 --- a/src/Java/gtPlusPlus/core/handler/BookHandler.java +++ b/src/Java/gtPlusPlus/core/handler/BookHandler.java @@ -22,6 +22,7 @@ public class BookHandler { public static BookTemplate book_ModularBauble; public static BookTemplate book_MultiMachineManual; public static BookTemplate book_NuclearManual; + public static BookTemplate book_MultiChemicalPlant; public static void run(){ @@ -179,6 +180,18 @@ public class BookHandler { "This structure is used to produce the Molten Salts required to run a Liquid Fluorine Thorium Reactor [LFTR]." }); + + book_MultiChemicalPlant = writeBookTemplate( + "book_Multi_ChemicalPlant", "Chemical Plant Manual", "Alkalus", + new String[] { + "This Multiblock, depending upon the mode used, can function as a variety of different machines. The idea behind this, was that most of these machines are rather niche compared to any others, as such, not used often.", + "To build, you need to construct a hollow 3x3x3 structure made from Multi-Use casings, With a minimum of 6. Any Casing position can be substituted out with an Input Hatch/Bus, an Output Hatch/Bus, Muffler, Maint. Hatch or Energy Injector Hatch.", + "The Mode can be set by using a Screwdriver on the controller block. Each mode allows the use of Numbered Circuits, to allow a different machine 'type' for each input bus.", + "[Metal Work] Mode A - Allows the multiblock to function as a Compressor, a Lathe or an Electro-Magnet. To allow a hatch to run in Compressor mode, insert a No. 20 circuit. For Lathe, use No. 21 and for Electro-Magnet use No. 22.", + "[Fluid Work] Mode B - Allows the multiblock to function as a Fermenter, a Fluid Extractor or an Extractor. To allow a hatch to run in Fermenter mode, insert a No. 20 circuit. For Fluid Extractor, use No. 21 and for Extractor use No. 22.", + "[Misc. Work] Mode C - Allows the multiblock to function as a Laser Engraver, an Autoclave or a Fluid Solidifier. To allow a hatch to run in Laser Engraver mode, insert a No. 20 circuit. For Autoclave, use No. 21 and for Solidifier use No. 22.", + }); + } @@ -189,6 +202,7 @@ public class BookHandler { public static ItemStack ItemBookWritten_ModularBaubles; public static ItemStack ItemBookWritten_MultiPowerStorage; public static ItemStack ItemBookWritten_MultiMachineManual; + public static ItemStack ItemBookWritten_MultiChemicalPlant; public static void runLater(){ ItemBookWritten_ThermalBoiler = ItemUtils.simpleMetaStack(ModItems.itemCustomBook, 0, 1); @@ -196,12 +210,14 @@ public class BookHandler { ItemBookWritten_ModularBaubles = ItemUtils.simpleMetaStack(ModItems.itemCustomBook, 2, 1); ItemBookWritten_MultiMachineManual = ItemUtils.simpleMetaStack(ModItems.itemCustomBook, 3, 1); ItemBookWritten_NuclearManual = ItemUtils.simpleMetaStack(ModItems.itemCustomBook, 4, 1); + ItemBookWritten_MultiChemicalPlant = ItemUtils.simpleMetaStack(ModItems.itemCustomBook, 5, 1); //Multiblock Manuals RecipeUtils.addShapelessGregtechRecipe(new ItemStack[]{ItemUtils.getSimpleStack(Items.writable_book), ItemUtils.getSimpleStack(Items.lava_bucket)}, ItemBookWritten_ThermalBoiler); RecipeUtils.addShapelessGregtechRecipe(new ItemStack[]{ItemUtils.getSimpleStack(Items.writable_book), ItemUtils.getItemStackOfAmountFromOreDict(CI.craftingToolWrench, 1)}, ItemBookWritten_MultiMachineManual); RecipeUtils.addShapelessGregtechRecipe(new ItemStack[]{ItemUtils.getSimpleStack(Items.writable_book), ItemUtils.getItemStackOfAmountFromOreDict("wireGt01Tin", 1)}, ItemBookWritten_MultiPowerStorage); RecipeUtils.addShapelessGregtechRecipe(new ItemStack[]{ItemUtils.getSimpleStack(Items.writable_book), ItemUtils.getItemStackOfAmountFromOreDict("dustUranium", 1)}, ItemBookWritten_NuclearManual); + RecipeUtils.addShapelessGregtechRecipe(new ItemStack[]{ItemUtils.getSimpleStack(Items.writable_book), ItemUtils.getItemStackOfAmountFromOreDict("wireGt01Copper", 1)}, ItemBookWritten_MultiChemicalPlant); } private static BookTemplate writeBookTemplate(String aMapping, String aTitle, String aAuthor, String[] aPages){ diff --git a/src/Java/gtPlusPlus/core/handler/GuiHandler.java b/src/Java/gtPlusPlus/core/handler/GuiHandler.java index 542403bbcb..827b7d5b8f 100644 --- a/src/Java/gtPlusPlus/core/handler/GuiHandler.java +++ b/src/Java/gtPlusPlus/core/handler/GuiHandler.java @@ -56,6 +56,7 @@ public class GuiHandler implements IGuiHandler { public static final int GUI15 = 14; // Pest Killer public static final int GUI16 = 15; // Round-Robinator public static final int GUI17 = 16; // Egg Box + public static final int GUI18 = 17; // Volumetric Flask Setter public static void init() { @@ -108,6 +109,8 @@ public class GuiHandler implements IGuiHandler { return new Container_RoundRobinator(player.inventory, (TileEntityRoundRobinator) te); } else if (ID == GUI17) { return new Container_EggBox(player.inventory, (TileEntityEggBox) te); + } else if (ID == GUI18) { + return new Container_VolumetricFlaskSetter(player.inventory, (TileEntityVolumetricFlaskSetter) te); } } @@ -172,7 +175,9 @@ public class GuiHandler implements IGuiHandler { return new GUI_RoundRobinator(player.inventory, (TileEntityRoundRobinator) te); } else if (ID == GUI17) { return new GUI_EggBox(player.inventory, (TileEntityEggBox) te); - } + } else if (ID == GUI18) { + return new GUI_VolumetricFlaskSetter(player.inventory, (TileEntityVolumetricFlaskSetter) te); + } } if (ID == GUI9) { diff --git a/src/Java/gtPlusPlus/core/handler/PacketHandler.java b/src/Java/gtPlusPlus/core/handler/PacketHandler.java index 2b9d424b32..382b82df29 100644 --- a/src/Java/gtPlusPlus/core/handler/PacketHandler.java +++ b/src/Java/gtPlusPlus/core/handler/PacketHandler.java @@ -1,69 +1,91 @@ package gtPlusPlus.core.handler; -import cpw.mods.fml.common.network.ByteBufUtils; import cpw.mods.fml.common.network.NetworkRegistry; -import cpw.mods.fml.common.network.simpleimpl.*; +import cpw.mods.fml.common.network.simpleimpl.IMessage; +import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper; import cpw.mods.fml.relauncher.Side; - +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.network.handler.AbstractClientMessageHandler; +import gtPlusPlus.core.network.packet.AbstractPacket; +import gtPlusPlus.core.network.packet.Packet_VolumetricFlaskGui; +import gtPlusPlus.core.network.packet.Packet_VolumetricFlaskGui2; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; -import io.netty.buffer.ByteBuf; - public class PacketHandler { - - public static SimpleNetworkWrapper packetLightning; - public PacketHandler(){ - packetLightning = NetworkRegistry.INSTANCE.newSimpleChannel("gtpp_Lightning"); - packetLightning.registerMessage(Packet_Lightning_Handler.class, Packet_Lightning.class, 0, Side.SERVER); + private static byte packetId = 0; + + private static final SimpleNetworkWrapper INSTANCE = NetworkRegistry.INSTANCE.newSimpleChannel(CORE.MODID); + + public static final void init() { + registerMessage(Packet_VolumetricFlaskGui.class, Packet_VolumetricFlaskGui.class); + registerMessage(Packet_VolumetricFlaskGui2.class, Packet_VolumetricFlaskGui2.class); } - - - /** - * Internal Packet Handlers - * @author Alkalus - * + * Registers a message and message handler */ + private static final void registerMessage(Class handlerClass, Class messageClass) { + Side side = AbstractClientMessageHandler.class.isAssignableFrom(handlerClass) ? Side.CLIENT : Side.SERVER; + registerMessage(handlerClass, messageClass, side); + } - private class Packet_Lightning implements IMessage{ - - public void sendTo(IMessage msg, EntityPlayerMP player){ - packetLightning.sendTo(msg, player); + private static final void registerMessage(Class handlerClass, Class messageClass, Side side) { + INSTANCE.registerMessage(handlerClass, messageClass, packetId++, side); + if (AbstractPacket.class.isInstance(messageClass.getClass())) { + AbstractPacket aPacket = ReflectionUtils.createNewInstanceFromConstructor(ReflectionUtils.getConstructor(messageClass, new Class[] {}), new Object[] {}); + if (aPacket != null) { + Logger.INFO("Registered Packet: "+aPacket.getPacketName()); + } } - - public void sendToServer(String string){ - packetLightning.sendToServer(new Packet_Lightning(string)); - } - - private String text; + } + + /** + * Send this message to the specified player. + * See {@link SimpleNetworkWrapper#sendTo(IMessage, EntityPlayerMP)} + */ + public static final void sendTo(IMessage message, EntityPlayerMP player) { + INSTANCE.sendTo(message, player); + } + + /** + * Send this message to everyone within a certain range of a point. + * See {@link SimpleNetworkWrapper#sendToDimension(IMessage, NetworkRegistry.TargetPoint)} + */ + public static final void sendToAllAround(IMessage message, NetworkRegistry.TargetPoint point) { + INSTANCE.sendToAllAround(message, point); + } - public Packet_Lightning(String text) { - this.text = text; - } + /** + * Sends a message to everyone within a certain range of the coordinates in the same dimension. + */ + public static final void sendToAllAround(IMessage message, int dimension, double x, double y, double z, double range) { + sendToAllAround(message, new NetworkRegistry.TargetPoint(dimension, x, y, z, range)); + } - @Override - public void fromBytes(ByteBuf buf) { - text = ByteBufUtils.readUTF8String(buf); // this class is very useful in general for writing more complex objects - } + /** + * Sends a message to everyone within a certain range of the player provided. + */ + public static final void sendToAllAround(IMessage message, EntityPlayer player, double range) { + sendToAllAround(message, player.worldObj.provider.dimensionId, player.posX, player.posY, player.posZ, range); + } - @Override - public void toBytes(ByteBuf buf) { - ByteBufUtils.writeUTF8String(buf, text); - } - + /** + * Send this message to everyone within the supplied dimension. + * See {@link SimpleNetworkWrapper#sendToDimension(IMessage, int)} + */ + public static final void sendToDimension(IMessage message, int dimensionId) { + INSTANCE.sendToDimension(message, dimensionId); } - - private class Packet_Lightning_Handler implements IMessageHandler<Packet_Lightning, IMessage>{ - @Override - public IMessage onMessage(Packet_Lightning message, MessageContext ctx) { - System.out.println(String.format("Received %s from %s", message.text, ctx.getServerHandler().playerEntity.getDisplayName())); - return null; // no response in this case - } - + /** + * Send this message to the server. + * See {@link SimpleNetworkWrapper#sendToServer(IMessage)} + */ + public static final void sendToServer(IMessage message) { + INSTANCE.sendToServer(message); } - - } |