diff --git a/api/buildcraft/api/tablet/ITablet.java b/api/buildcraft/api/tablet/ITablet.java new file mode 100644 index 00000000..0d7779c5 --- /dev/null +++ b/api/buildcraft/api/tablet/ITablet.java @@ -0,0 +1,13 @@ +package buildcraft.api.tablet; + +import net.minecraft.nbt.NBTTagCompound; +import cpw.mods.fml.relauncher.Side; + +public interface ITablet { + Side getSide(); + void refreshScreen(TabletBitmap data); + int getScreenWidth(); + int getScreenHeight(); + void launchProgram(String name); + void sendMessage(NBTTagCompound compound); +} diff --git a/api/buildcraft/api/tablet/TabletAPI.java b/api/buildcraft/api/tablet/TabletAPI.java new file mode 100644 index 00000000..cb32a52e --- /dev/null +++ b/api/buildcraft/api/tablet/TabletAPI.java @@ -0,0 +1,20 @@ +package buildcraft.api.tablet; + +import java.util.HashMap; +import java.util.Map; + +public class TabletAPI { + private TabletAPI() { + + } + + private static final Map programs = new HashMap(); + + public static void registerProgram(TabletProgramFactory factory) { + programs.put(factory.getName(), factory); + } + + public static TabletProgramFactory getProgram(String name) { + return programs.get(name); + } +} diff --git a/api/buildcraft/api/tablet/TabletBitmap.java b/api/buildcraft/api/tablet/TabletBitmap.java new file mode 100644 index 00000000..a4bf1e3b --- /dev/null +++ b/api/buildcraft/api/tablet/TabletBitmap.java @@ -0,0 +1,55 @@ +package buildcraft.api.tablet; + +public class TabletBitmap { + public final int width, height; + protected int[] data; + + public TabletBitmap(int width, int height) { + this.width = width; + this.height = height; + this.data = new int[width * height]; + } + + public TabletBitmap(ITablet tablet) { + this(tablet.getScreenWidth(), tablet.getScreenHeight()); + } + + public int[] getData() { + return data; + } + + public int get(int x, int y) { + if (x < 0 || y < 0 || x >= width || y >= height) { + return 0; + } + return data[y * width + x]; + } + + public void set(int x, int y, int shade) { + if (x < 0 || y < 0 || x >= width || y >= height) { + return; + } + data[y * width + x] = shade; + } + + public void set(int x, int y, TabletBitmap bitmap) { + for (int i = 0; i < bitmap.height; i++) { + if (i >= height) { + break; + } + for (int h = 0; h < bitmap.width; h++) { + if (h >= width) { + break; + } + set(x + h, y + i, bitmap.get(h, i)); + } + } + } + + @Override + public TabletBitmap clone() { + TabletBitmap cloned = new TabletBitmap(this.width, this.height); + cloned.data = this.data.clone(); + return cloned; + } +} diff --git a/api/buildcraft/api/tablet/TabletProgram.java b/api/buildcraft/api/tablet/TabletProgram.java new file mode 100644 index 00000000..68377e81 --- /dev/null +++ b/api/buildcraft/api/tablet/TabletProgram.java @@ -0,0 +1,17 @@ +package buildcraft.api.tablet; + +import net.minecraft.nbt.NBTTagCompound; + +public abstract class TabletProgram { + public void tick(float time) { + + } + + public boolean hasEnded() { + return false; + } + + public void receiveMessage(NBTTagCompound compound) { + + } +} diff --git a/api/buildcraft/api/tablet/TabletProgramFactory.java b/api/buildcraft/api/tablet/TabletProgramFactory.java new file mode 100644 index 00000000..69a7ed23 --- /dev/null +++ b/api/buildcraft/api/tablet/TabletProgramFactory.java @@ -0,0 +1,23 @@ +package buildcraft.api.tablet; + +import net.minecraft.nbt.NBTTagCompound; +import cpw.mods.fml.relauncher.Side; + +public abstract class TabletProgramFactory { + /** + * Create an instance of the tablet program specified by this Factory. + * + * Both parameters are mutable and can be edited freely; however, the + * NBTTagCompound will only be synchronized after you leave the program. + * + * Please note that the program runs client-side SOLELY. For server-side + * queries, you must implement a custom communications protocol. + * @param tablet + * @return An instance of the TabletProgram. + */ + public abstract TabletProgram create(ITablet tablet); + + public abstract String getName(); + + public abstract TabletBitmap getIcon(); +} diff --git a/api/buildcraft/api/tablet/TabletTicker.java b/api/buildcraft/api/tablet/TabletTicker.java new file mode 100644 index 00000000..823d1548 --- /dev/null +++ b/api/buildcraft/api/tablet/TabletTicker.java @@ -0,0 +1,38 @@ +package buildcraft.api.tablet; + +/** + * Utility class for capturing tablet ticks every X seconds. + */ +public class TabletTicker { + private final float tickTime; + private float time = 0.0F; + private int ticked = 0; + + public TabletTicker(float tickTime) { + this.tickTime = tickTime; + } + + public void add(float time) { + this.time += time; + + while (this.time >= tickTime) { + this.time -= tickTime; + ticked++; + } + } + + public int getTicks() { + return ticked; + } + + public boolean tick() { + boolean oldTicked = ticked > 0; + ticked = 0; + return oldTicked; + } + + public void reset() { + ticked = 0; + time = 0; + } +} diff --git a/api/buildcraft/api/tablet/package-info.java b/api/buildcraft/api/tablet/package-info.java new file mode 100644 index 00000000..5f510e73 --- /dev/null +++ b/api/buildcraft/api/tablet/package-info.java @@ -0,0 +1,12 @@ +/** + * Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. + * Please check the contents of the license, which should be located + * as "LICENSE.API" in the BuildCraft source code distribution. + */ +@API(apiVersion = "1.0", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|tablet") +package buildcraft.api.tablet; +import cpw.mods.fml.common.API; + diff --git a/common/buildcraft/core/IItemPipe.java b/api/buildcraft/api/transport/IItemPipe.java similarity index 93% rename from common/buildcraft/core/IItemPipe.java rename to api/buildcraft/api/transport/IItemPipe.java index 720d7f7e..f5f76677 100644 --- a/common/buildcraft/core/IItemPipe.java +++ b/api/buildcraft/api/transport/IItemPipe.java @@ -6,7 +6,7 @@ * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ -package buildcraft.core; +package buildcraft.api.transport; /** * To be implemented by the real item pipe in Transport mod, but leaves knowledge for classes that do not have direct dependency on transport. diff --git a/buildcraft_resources/assets/buildcraftcore/textures/gui/tablet.png b/buildcraft_resources/assets/buildcraftcore/textures/gui/tablet.png new file mode 100644 index 00000000..d24ad52d Binary files /dev/null and b/buildcraft_resources/assets/buildcraftcore/textures/gui/tablet.png differ diff --git a/common/buildcraft/BuildCraftCore.java b/common/buildcraft/BuildCraftCore.java index 37d34420..b7aa43f0 100644 --- a/common/buildcraft/BuildCraftCore.java +++ b/common/buildcraft/BuildCraftCore.java @@ -35,7 +35,9 @@ import cpw.mods.fml.common.event.FMLInterModComms; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.event.FMLServerStartingEvent; +import cpw.mods.fml.common.event.FMLServerStoppingEvent; import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.PlayerEvent; import cpw.mods.fml.common.network.NetworkRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -60,6 +62,7 @@ import buildcraft.api.statements.ITriggerExternal; import buildcraft.api.statements.ITriggerInternal; import buildcraft.api.statements.StatementManager; import buildcraft.api.statements.StatementParameterItemStack; +import buildcraft.api.tablet.TabletAPI; import buildcraft.api.tiles.IControllable; import buildcraft.core.AchievementManager; import buildcraft.core.BCCreativeTab; @@ -78,6 +81,8 @@ import buildcraft.core.ItemList; import buildcraft.core.ItemMapLocation; import buildcraft.core.ItemPaintbrush; import buildcraft.core.ItemSpring; +import buildcraft.core.network.PacketHandlerCore; +import buildcraft.core.tablet.ItemTablet; import buildcraft.core.ItemWrench; import buildcraft.core.SchematicEngine; import buildcraft.core.SpringPopulate; @@ -121,6 +126,10 @@ import buildcraft.core.statements.TriggerInventory; import buildcraft.core.statements.TriggerInventoryLevel; import buildcraft.core.statements.TriggerMachine; import buildcraft.core.statements.TriggerRedstoneInput; +import buildcraft.core.tablet.PacketTabletMessage; +import buildcraft.core.tablet.TabletProgramMenuFactory; +import buildcraft.core.tablet.manager.TabletManagerClient; +import buildcraft.core.tablet.manager.TabletManagerServer; @Mod(name = "BuildCraft", version = Version.VERSION, useMetadata = false, modid = "BuildCraft|Core", acceptedMinecraftVersions = "[1.7.10,1.8)", dependencies = "required-after:Forge@[10.13.2.1236,)", guiFactory = "buildcraft.core.config.ConfigManager") public class BuildCraftCore extends BuildCraftMod { @@ -128,6 +137,7 @@ public class BuildCraftCore extends BuildCraftMod { public static BuildCraftCore instance; public static final boolean NONRELEASED_BLOCKS = true; + public static final boolean TABLET_TESTING = false; public static enum RenderMode { Full, NoDynamic @@ -159,6 +169,7 @@ public class BuildCraftCore extends BuildCraftMod { public static Item debuggerItem; public static Item paintbrushItem; public static ItemList listItem; + public static ItemTablet tabletItem; @SideOnly(Side.CLIENT) public static IIcon redLaserTexture; @SideOnly(Side.CLIENT) @@ -300,6 +311,12 @@ public class BuildCraftCore extends BuildCraftMod { paintbrushItem = (new ItemPaintbrush()).setUnlocalizedName("paintbrush"); CoreProxy.proxy.registerItem(paintbrushItem); + if (TABLET_TESTING) { + tabletItem = new ItemTablet(); + tabletItem.setUnlocalizedName("tablet"); + CoreProxy.proxy.registerItem(tabletItem); + } + buildToolBlock = new BlockBuildTool(); buildToolBlock.setBlockName("buildToolBlock"); CoreProxy.proxy.registerBlock(buildToolBlock); @@ -321,10 +338,13 @@ public class BuildCraftCore extends BuildCraftMod { public void init(FMLInitializationEvent evt) { BuildCraftAPI.proxy = CoreProxy.proxy; - channels = NetworkRegistry.INSTANCE.newChannel - (DefaultProps.NET_CHANNEL_NAME + "-CORE", new ChannelHandler(), new PacketHandler()); + ChannelHandler coreChannelHandler = new ChannelHandler(); + coreChannelHandler.registerPacketType(PacketTabletMessage.class); - achievementManager = new AchievementManager(); + channels = NetworkRegistry.INSTANCE.newChannel + (DefaultProps.NET_CHANNEL_NAME + "-CORE", coreChannelHandler, new PacketHandlerCore()); + + achievementManager = new AchievementManager("BuildCraft"); FMLCommonHandler.instance().bus().register(achievementManager); woodenGearAchievement = achievementManager.registerAchievement(new Achievement("achievement.woodenGear", "woodenGearAchievement", 0, 0, woodenGearItem, null)); @@ -368,6 +388,13 @@ public class BuildCraftCore extends BuildCraftMod { CoreProxy.proxy.initializeEntityRendering(); NetworkRegistry.INSTANCE.registerGuiHandler(instance, new CoreGuiHandler()); + + FMLCommonHandler.instance().bus().register(TabletManagerClient.INSTANCE); + FMLCommonHandler.instance().bus().register(TabletManagerServer.INSTANCE); + MinecraftForge.EVENT_BUS.register(TabletManagerClient.INSTANCE); + MinecraftForge.EVENT_BUS.register(TabletManagerServer.INSTANCE); + + TabletAPI.registerProgram(new TabletProgramMenuFactory()); } @Mod.EventHandler @@ -416,6 +443,12 @@ public class BuildCraftCore extends BuildCraftMod { event.registerServerCommand(new CommandBuildCraft()); } + @Mod.EventHandler + public void serverStopping(FMLServerStoppingEvent event) { + TabletManagerClient.INSTANCE.onServerStopping(); + TabletManagerServer.INSTANCE.onServerStopping(); + } + @SubscribeEvent @SideOnly(Side.CLIENT) public void textureHook(TextureStitchEvent.Pre event) { diff --git a/common/buildcraft/BuildCraftTransport.java b/common/buildcraft/BuildCraftTransport.java index 464fc1f4..a837d26b 100644 --- a/common/buildcraft/BuildCraftTransport.java +++ b/common/buildcraft/BuildCraftTransport.java @@ -194,6 +194,7 @@ public class BuildCraftTransport extends BuildCraftMod { public static int pipeFluidsBaseFlowRate; public static boolean facadeTreatBlacklistAsWhitelist; public static boolean additionalWaterproofingRecipe; + public static boolean facadeForceNonLaserReicpe; public static BlockGenericPipe genericPipeBlock; public static BlockFilteredBuffer filteredBufferBlock; @@ -325,6 +326,7 @@ public class BuildCraftTransport extends BuildCraftMod { JavaTools.surroundWithQuotes(Block.blockRegistry.getNameForObject(BuildCraftTransport.filteredBufferBlock)), }, "What block types should be blacklisted from being a facade?", ConfigManager.RestartRequirement.GAME); BuildCraftCore.mainConfigManager.register("general.pipes.facadeBlacklistAsWhitelist", false, "Should the blacklist be treated as a whitelist instead?", ConfigManager.RestartRequirement.GAME); + BuildCraftCore.mainConfigManager.register("general.pipes.facadeNoLaserRecipe", false, "Should non-laser (crafting table) facade recipes be forced?", ConfigManager.RestartRequirement.GAME); reloadConfig(ConfigManager.RestartRequirement.GAME); @@ -562,6 +564,7 @@ public class BuildCraftTransport extends BuildCraftMod { additionalWaterproofingRecipe = BuildCraftCore.mainConfigManager.get("general.pipes.slimeballWaterproofRecipe").getBoolean(); debugPrintFacadeList = BuildCraftCore.mainConfigManager.get("debug.printFacadeList").getBoolean(); pipeFluidsBaseFlowRate = BuildCraftCore.mainConfigManager.get("general.pipes.baseFluidRate").getInt(); + facadeForceNonLaserReicpe = BuildCraftCore.mainConfigManager.get("general.pipes.facadeNoLaserRecipe").getBoolean(); reloadConfig(ConfigManager.RestartRequirement.WORLD); } else if (restartType == ConfigManager.RestartRequirement.WORLD) { @@ -664,6 +667,9 @@ public class BuildCraftTransport extends BuildCraftMod { GameRegistry.addRecipe(facadeItem.new FacadeRecipe()); RecipeSorter.register("facadeTurningHelper", ItemFacade.FacadeRecipe.class, RecipeSorter.Category.SHAPELESS, ""); + // Pipe Plug + GameRegistry.addShapelessRecipe(new ItemStack(plugItem, 4), "I", 'I', new ItemStack(pipeStructureCobblestone)); + if (Loader.isModLoaded("BuildCraft|Silicon")) { loadSiliconRecipes(); } else { @@ -677,9 +683,6 @@ public class BuildCraftTransport extends BuildCraftMod { BCLog.logger.warn("**********************************************"); // Alternate recipes - // Pipe Plug - GameRegistry.addShapelessRecipe(new ItemStack(plugItem, 4), "I", 'I', new ItemStack(pipeStructureCobblestone)); - // Lenses, Filters for (int i = 0; i < 16; i++) { String dye = ColorUtils.getOreDictionaryName(15 - i); @@ -698,10 +701,6 @@ public class BuildCraftTransport extends BuildCraftMod { private static void loadSiliconRecipes() { GameRegistry.addShapelessRecipe(new ItemStack(gateCopier, 1), new ItemStack(BuildCraftCore.wrenchItem), Chipset.RED.getStack(1)); - // Pipe Plug - BuildcraftRecipeRegistry.assemblyTable.addRecipe("buildcraft:pipePlug", 10000, new ItemStack(plugItem, 8), - new ItemStack(pipeStructureCobblestone)); - // PIPE WIRE BuildcraftRecipeRegistry.assemblyTable.addRecipe("buildcraft:redWire", 5000, PipeWire.RED.getStack(8), "dyeRed", "dustRedstone", "ingotIron"); @@ -736,7 +735,7 @@ public class BuildCraftTransport extends BuildCraftMod { // REVERSAL RECIPE BuildcraftRecipeRegistry.integrationTable.addRecipe(new GateLogicSwapRecipe("buildcraft:gateSwap")); - // FACADE + // PHASED FACADE BuildcraftRecipeRegistry.integrationTable.addRecipe(new AdvancedFacadeRecipe("buildcraft:advancedFacade")); } diff --git a/common/buildcraft/builders/TileArchitect.java b/common/buildcraft/builders/TileArchitect.java index ef46d1eb..1529988c 100644 --- a/common/buildcraft/builders/TileArchitect.java +++ b/common/buildcraft/builders/TileArchitect.java @@ -27,7 +27,7 @@ import buildcraft.api.core.Position; import buildcraft.builders.blueprints.RecursiveBlueprintReader; import buildcraft.core.Box; import buildcraft.core.Box.Kind; -import buildcraft.core.IBoxProvider; +import buildcraft.core.internal.IBoxProvider; import buildcraft.core.LaserData; import buildcraft.core.blueprints.BlueprintReadConfiguration; import buildcraft.core.lib.block.TileBuildCraft; diff --git a/common/buildcraft/builders/TileConstructionMarker.java b/common/buildcraft/builders/TileConstructionMarker.java index d835f207..ef98fb8b 100755 --- a/common/buildcraft/builders/TileConstructionMarker.java +++ b/common/buildcraft/builders/TileConstructionMarker.java @@ -21,7 +21,7 @@ import buildcraft.BuildCraftCore; import buildcraft.api.core.Position; import buildcraft.core.Box; import buildcraft.core.Box.Kind; -import buildcraft.core.IBoxProvider; +import buildcraft.core.internal.IBoxProvider; import buildcraft.core.LaserData; import buildcraft.core.blueprints.Blueprint; import buildcraft.core.blueprints.BlueprintBase; diff --git a/common/buildcraft/builders/urbanism/TileUrbanist.java b/common/buildcraft/builders/urbanism/TileUrbanist.java index 772ced0d..e6d01ad7 100755 --- a/common/buildcraft/builders/urbanism/TileUrbanist.java +++ b/common/buildcraft/builders/urbanism/TileUrbanist.java @@ -22,7 +22,7 @@ import cpw.mods.fml.relauncher.Side; import buildcraft.BuildCraftCore; import buildcraft.core.Box; import buildcraft.core.Box.Kind; -import buildcraft.core.IBoxesProvider; +import buildcraft.core.internal.IBoxesProvider; import buildcraft.core.lib.block.TileBuildCraft; import buildcraft.core.lib.network.Packet; import buildcraft.core.lib.network.command.CommandWriter; diff --git a/common/buildcraft/core/AchievementManager.java b/common/buildcraft/core/AchievementManager.java index 958734b6..7ed83a4c 100644 --- a/common/buildcraft/core/AchievementManager.java +++ b/common/buildcraft/core/AchievementManager.java @@ -9,8 +9,8 @@ import net.minecraftforge.common.AchievementPage; public class AchievementManager { public AchievementPage page; - public AchievementManager() { - page = new AchievementPage("BuildCraft"); + public AchievementManager(String name) { + page = new AchievementPage(name); AchievementPage.registerAchievementPage(page); } diff --git a/common/buildcraft/core/Box.java b/common/buildcraft/core/Box.java index 949e6acd..db268fb4 100644 --- a/common/buildcraft/core/Box.java +++ b/common/buildcraft/core/Box.java @@ -351,7 +351,6 @@ public class Box implements IBox, ISerializable { @Override public double distanceTo(BlockIndex index) { - return Math.sqrt(distanceToSquared(index)); } @@ -376,7 +375,7 @@ public class Box implements IBox, ISerializable { @Override public void readData(ByteBuf stream) { - kind = Kind.values()[stream.readByte()]; + byte flags = stream.readByte(); xMin = stream.readInt(); yMin = stream.readShort(); zMin = stream.readInt(); @@ -384,21 +383,20 @@ public class Box implements IBox, ISerializable { yMax = stream.readShort(); zMax = stream.readInt(); - byte flags = stream.readByte(); - initialized = (flags & 1) != 0; - isVisible = (flags & 2) != 0; + kind = Kind.values()[flags & 31]; + initialized = (flags & 64) != 0; + isVisible = (flags & 32) != 0; } @Override public void writeData(ByteBuf stream) { - stream.writeByte(kind.ordinal()); + stream.writeByte((initialized ? 64 : 0) | (isVisible ? 32 : 0) | kind.ordinal()); stream.writeInt(xMin); stream.writeShort(yMin); stream.writeInt(zMin); stream.writeInt(xMax); stream.writeShort(yMax); stream.writeInt(zMax); - stream.writeByte((initialized ? 1 : 0) | (isVisible ? 2 : 0)); } } diff --git a/common/buildcraft/core/CoreGuiHandler.java b/common/buildcraft/core/CoreGuiHandler.java index 14c78ef4..3bd633e0 100755 --- a/common/buildcraft/core/CoreGuiHandler.java +++ b/common/buildcraft/core/CoreGuiHandler.java @@ -21,7 +21,6 @@ public class CoreGuiHandler implements IGuiHandler { if (id == GuiIds.LIST) { return new GuiList(player); } - return null; } @@ -30,7 +29,6 @@ public class CoreGuiHandler implements IGuiHandler { if (id == GuiIds.LIST) { return new ContainerList(player); } - return null; } } diff --git a/common/buildcraft/core/GuiIds.java b/common/buildcraft/core/GuiIds.java index 7346beb6..188ba539 100644 --- a/common/buildcraft/core/GuiIds.java +++ b/common/buildcraft/core/GuiIds.java @@ -18,6 +18,7 @@ public final class GuiIds { public static final int MAP = 15; public static final int REQUESTER = 16; public static final int LIST = 17; + public static final int TABLET = 18; public static final int ENGINE_IRON = 20; public static final int ENGINE_STONE = 21; diff --git a/common/buildcraft/core/builders/TileAbstractBuilder.java b/common/buildcraft/core/builders/TileAbstractBuilder.java index 7aa3e621..1fa7e54a 100755 --- a/common/buildcraft/core/builders/TileAbstractBuilder.java +++ b/common/buildcraft/core/builders/TileAbstractBuilder.java @@ -21,7 +21,7 @@ import net.minecraftforge.fluids.FluidStack; import buildcraft.BuildCraftCore; import buildcraft.api.blueprints.BuilderAPI; import buildcraft.api.blueprints.ITileBuilder; -import buildcraft.core.IBoxProvider; +import buildcraft.core.internal.IBoxProvider; import buildcraft.core.LaserData; import buildcraft.core.lib.RFBattery; import buildcraft.core.lib.block.TileBuildCraft; diff --git a/common/buildcraft/core/IBoxProvider.java b/common/buildcraft/core/internal/IBoxProvider.java similarity index 85% rename from common/buildcraft/core/IBoxProvider.java rename to common/buildcraft/core/internal/IBoxProvider.java index 26fb32f0..bb54f307 100755 --- a/common/buildcraft/core/IBoxProvider.java +++ b/common/buildcraft/core/internal/IBoxProvider.java @@ -6,8 +6,9 @@ * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ -package buildcraft.core; +package buildcraft.core.internal; +import buildcraft.core.Box; public interface IBoxProvider { Box getBox(); diff --git a/common/buildcraft/core/IBoxesProvider.java b/common/buildcraft/core/internal/IBoxesProvider.java similarity index 86% rename from common/buildcraft/core/IBoxesProvider.java rename to common/buildcraft/core/internal/IBoxesProvider.java index 845186cb..b7bb614b 100755 --- a/common/buildcraft/core/IBoxesProvider.java +++ b/common/buildcraft/core/internal/IBoxesProvider.java @@ -6,9 +6,10 @@ * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ -package buildcraft.core; +package buildcraft.core.internal; import java.util.ArrayList; +import buildcraft.core.Box; public interface IBoxesProvider { ArrayList getBoxes(); diff --git a/common/buildcraft/core/IDropControlInventory.java b/common/buildcraft/core/internal/IDropControlInventory.java similarity index 91% rename from common/buildcraft/core/IDropControlInventory.java rename to common/buildcraft/core/internal/IDropControlInventory.java index d32b459a..a57308b9 100644 --- a/common/buildcraft/core/IDropControlInventory.java +++ b/common/buildcraft/core/internal/IDropControlInventory.java @@ -6,7 +6,7 @@ * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ -package buildcraft.core; +package buildcraft.core.internal; public interface IDropControlInventory { boolean doDrop(); diff --git a/common/buildcraft/core/IFramePipeConnection.java b/common/buildcraft/core/internal/IFramePipeConnection.java similarity index 93% rename from common/buildcraft/core/IFramePipeConnection.java rename to common/buildcraft/core/internal/IFramePipeConnection.java index d1ab1125..b9a52079 100644 --- a/common/buildcraft/core/IFramePipeConnection.java +++ b/common/buildcraft/core/internal/IFramePipeConnection.java @@ -6,7 +6,7 @@ * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ -package buildcraft.core; +package buildcraft.core.internal; import net.minecraft.world.IBlockAccess; diff --git a/common/buildcraft/core/lib/engines/BlockEngineBase.java b/common/buildcraft/core/lib/engines/BlockEngineBase.java index 9dece5e0..573214fb 100644 --- a/common/buildcraft/core/lib/engines/BlockEngineBase.java +++ b/common/buildcraft/core/lib/engines/BlockEngineBase.java @@ -24,7 +24,7 @@ import cpw.mods.fml.common.FMLCommonHandler; import net.minecraftforge.common.util.ForgeDirection; import buildcraft.BuildCraftCore; import buildcraft.api.events.BlockInteractionEvent; -import buildcraft.core.IItemPipe; +import buildcraft.api.transport.IItemPipe; import buildcraft.core.lib.block.BlockBuildCraft; import buildcraft.core.lib.render.ICustomHighlight; diff --git a/common/buildcraft/core/lib/render/DynamicTexturePaletted.java b/common/buildcraft/core/lib/render/DynamicTextureBC.java old mode 100755 new mode 100644 similarity index 55% rename from common/buildcraft/core/lib/render/DynamicTexturePaletted.java rename to common/buildcraft/core/lib/render/DynamicTextureBC.java index 31cf4dfb..e4b0f373 --- a/common/buildcraft/core/lib/render/DynamicTexturePaletted.java +++ b/common/buildcraft/core/lib/render/DynamicTextureBC.java @@ -1,39 +1,35 @@ -/** - * Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team - * http://www.mod-buildcraft.com - * - * BuildCraft is distributed under the terms of the Minecraft Mod Public - * License 1.0, or MMPL. Please check the contents of the license located in - * http://www.mod-buildcraft.com/MMPL-1.0.txt - */ package buildcraft.core.lib.render; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.texture.DynamicTexture; +import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -public class DynamicTexturePaletted { - - public int width, height; +public class DynamicTextureBC { + public final int width, height; public int[] colorMap; @SideOnly(Side.CLIENT) - private DynamicTexture dynamicTexture; + protected DynamicTexture dynamicTexture; - public DynamicTexturePaletted(int iWidth, int iHeight) { + public DynamicTextureBC(int iWidth, int iHeight) { width = iWidth; height = iHeight; - colorMap = new int[iWidth * iHeight]; + if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) { + createDynamicTexture(); + } else { + colorMap = new int[iWidth * iHeight]; + } } @SideOnly(Side.CLIENT) - public void createDynamicTexture() { + private void createDynamicTexture() { dynamicTexture = new DynamicTexture(width, height); colorMap = dynamicTexture.getTextureData(); } - public void setColor(int index, double r, double g, double b, double a) { + public void setColord(int index, double r, double g, double b, double a) { int i = (int) (a * 255.0F); int j = (int) (r * 255.0F); int k = (int) (g * 255.0F); @@ -41,37 +37,42 @@ public class DynamicTexturePaletted { colorMap[index] = i << 24 | j << 16 | k << 8 | l; } - public void setColor(int x, int y, double r, double g, double b, double a) { - int i = (int) (a * 255.0F); - int j = (int) (r * 255.0F); - int k = (int) (g * 255.0F); - int l = (int) (b * 255.0F); - colorMap[x + y * width] = i << 24 | j << 16 | k << 8 | l; + public void setColord(int x, int y, double r, double g, double b, double a) { + setColord(x + y * width, r, g, b, a); + } + + public void setColori(int index, int r, int g, int b, int a) { + colorMap[index] = (a & 255) << 24 | (r & 255) << 16 | (g & 255) << 8 | (b & 255); + } + + public void setColori(int x, int y, int r, int g, int b, int a) { + setColori(x + y * width, r, g, b, a); } public void setColor(int x, int y, int color) { - colorMap[x + y * height] = 255 << 24 | color; + colorMap[x + y * width] = color; } public void setColor(int x, int y, int color, float alpha) { int a = (int) (alpha * 255.0F); - colorMap[x + y * height] = a << 24 | color; + colorMap[x + y * width] = a << 24 | color; } @SideOnly(Side.CLIENT) - public void drawMap(int screenX, int screenY, float zLevel) { - drawMap(screenX, screenY, zLevel, 0, 0, width, height); - } - - @SideOnly(Side.CLIENT) - public void updateDynamicTexture() { + public void updateTexture() { dynamicTexture.updateDynamicTexture(); } + @SideOnly(Side.CLIENT) - public void drawMap(int screenX, int screenY, float zLevel, int clipX, int clipY, int clipWidth, int clipHeight) { - dynamicTexture.updateDynamicTexture(); + public void draw(int screenX, int screenY, float zLevel) { + draw(screenX, screenY, zLevel, 0, 0, width, height); + } + + @SideOnly(Side.CLIENT) + public void draw(int screenX, int screenY, float zLevel, int clipX, int clipY, int clipWidth, int clipHeight) { + updateTexture(); float f = 1F / width; float f1 = 1F / height; diff --git a/common/buildcraft/core/lib/utils/Utils.java b/common/buildcraft/core/lib/utils/Utils.java index 145355d5..ace0ab9b 100644 --- a/common/buildcraft/core/lib/utils/Utils.java +++ b/common/buildcraft/core/lib/utils/Utils.java @@ -36,8 +36,8 @@ import buildcraft.api.transport.IInjectable; import buildcraft.api.transport.IPipeTile; import buildcraft.core.CompatHooks; import buildcraft.core.DefaultProps; -import buildcraft.core.IDropControlInventory; -import buildcraft.core.IFramePipeConnection; +import buildcraft.core.internal.IDropControlInventory; +import buildcraft.core.internal.IFramePipeConnection; import buildcraft.core.LaserData; import buildcraft.core.LaserKind; import buildcraft.core.lib.EntityBlock; diff --git a/common/buildcraft/core/network/PacketHandlerCore.java b/common/buildcraft/core/network/PacketHandlerCore.java new file mode 100644 index 00000000..463d860a --- /dev/null +++ b/common/buildcraft/core/network/PacketHandlerCore.java @@ -0,0 +1,46 @@ +package buildcraft.core.network; + +import io.netty.channel.ChannelHandlerContext; +import net.minecraft.client.Minecraft; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.network.INetHandler; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.network.NetworkRegistry; +import cpw.mods.fml.relauncher.Side; +import buildcraft.BuildCraftCore; +import buildcraft.core.lib.network.Packet; +import buildcraft.core.lib.network.PacketHandler; +import buildcraft.core.proxy.CoreProxy; +import buildcraft.core.tablet.PacketTabletMessage; +import buildcraft.core.tablet.TabletBase; +import buildcraft.core.tablet.manager.TabletManagerClient; +import buildcraft.core.tablet.manager.TabletManagerServer; + +public class PacketHandlerCore extends PacketHandler { + @Override + protected void channelRead0(ChannelHandlerContext ctx, Packet packet) { + super.channelRead0(ctx, packet); + INetHandler netHandler = ctx.channel().attr(NetworkRegistry.NET_HANDLER).get(); + EntityPlayer player = CoreProxy.proxy.getPlayerFromNetHandler(netHandler); + + switch (packet.getID()) { + case PacketIds.TABLET_MESSAGE: { + if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) { + handleTabletClient((PacketTabletMessage) packet); + } else { + handleTabletServer(player, (PacketTabletMessage) packet); + } + } break; + } + } + + private void handleTabletClient(PacketTabletMessage packet) { + TabletBase tablet = TabletManagerClient.INSTANCE.get().getTablet(); + tablet.receiveMessage(packet.getTag()); + } + + private void handleTabletServer(EntityPlayer player, PacketTabletMessage packet) { + TabletBase tablet = TabletManagerServer.INSTANCE.get(player); + tablet.receiveMessage(packet.getTag()); + } +} diff --git a/common/buildcraft/core/network/PacketIds.java b/common/buildcraft/core/network/PacketIds.java index 7ef2a2b5..8c1d5c1b 100644 --- a/common/buildcraft/core/network/PacketIds.java +++ b/common/buildcraft/core/network/PacketIds.java @@ -21,7 +21,7 @@ public final class PacketIds { public static final int DIAMOND_PIPE_SELECT = 31; public static final int EMERALD_PIPE_SELECT = 32; - public static final int REFINERY_FILTER_SET = 50; + public static final int TABLET_MESSAGE = 40; public static final int ADVANCED_WORKBENCH_SETSLOT = 70; diff --git a/common/buildcraft/core/render/RenderBoxProvider.java b/common/buildcraft/core/render/RenderBoxProvider.java index c59efd9c..4a084594 100755 --- a/common/buildcraft/core/render/RenderBoxProvider.java +++ b/common/buildcraft/core/render/RenderBoxProvider.java @@ -14,8 +14,8 @@ import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; import buildcraft.core.Box; -import buildcraft.core.IBoxProvider; -import buildcraft.core.IBoxesProvider; +import buildcraft.core.internal.IBoxProvider; +import buildcraft.core.internal.IBoxesProvider; public class RenderBoxProvider extends TileEntitySpecialRenderer { diff --git a/common/buildcraft/core/tablet/GuiTablet.java b/common/buildcraft/core/tablet/GuiTablet.java new file mode 100644 index 00000000..5a2f57b6 --- /dev/null +++ b/common/buildcraft/core/tablet/GuiTablet.java @@ -0,0 +1,146 @@ +package buildcraft.core.tablet; + +import java.util.Date; +import org.lwjgl.input.Mouse; +import org.lwjgl.opengl.GL11; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.ResourceLocation; +import buildcraft.api.tablet.TabletBitmap; +import buildcraft.core.lib.render.DynamicTextureBC; +import buildcraft.core.tablet.manager.TabletManagerClient; +import buildcraft.core.tablet.manager.TabletThread; + +public class GuiTablet extends GuiScreen { + private static final boolean ENABLE_HIGHLIGHT = false; + + private static final int[] PALETTE = new int[]{ + 0x00000000, 0x1c000000, 0x30000000, 0x48000000, + 0x60000000, 0x78000000, 0x9a000000, 0xbc000000 + }; + private static final ResourceLocation TEXTURE = new ResourceLocation("buildcraftcore", "textures/gui/tablet.png"); + private static final int X_SIZE = 142; + private static final int Y_SIZE = 180; + private final DynamicTextureBC display; + private final EntityPlayer player; + private final TabletThread tabletThread; + private final TabletClient tablet; + private int guiLeft, guiTop; + private long lastDate; + private float GL_SCALE = 1.0f; + private int buttonState = 1; + + public GuiTablet(EntityPlayer player) { + super(); + + this.tabletThread = TabletManagerClient.INSTANCE.get(); + this.tablet = (TabletClient) tabletThread.getTablet(); + this.lastDate = (new Date()).getTime(); + this.player = player; + this.display = new DynamicTextureBC(tablet.getScreenWidth(), tablet.getScreenHeight()); + + tablet.updateGui(0.0F, this, true); + } + + @Override + public boolean doesGuiPauseGame() { + return false; + } + + @Override + public void initGui() { + super.initGui(); + // recalculate width/height + int oldScale = mc.gameSettings.guiScale; + ScaledResolution realRes = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight); + mc.gameSettings.guiScale = realRes.getScaleFactor() == 1 ? 2 : (realRes.getScaleFactor() & (~1)); + ScaledResolution currentRes = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight); + mc.gameSettings.guiScale = oldScale; + + GL_SCALE = (float) (currentRes.getScaledWidth_double() / realRes.getScaledWidth_double()); + + this.guiLeft = (currentRes.getScaledWidth() - X_SIZE) / 2; + this.guiTop = (currentRes.getScaledHeight() - Y_SIZE) / 2; + } + + public void bindTexture(ResourceLocation texture) { + Minecraft.getMinecraft().renderEngine.bindTexture(texture); + } + + public void copyDisplay(TabletBitmap display) { + for (int j = 0; j < display.height; j++) { + for (int i = 0; i < display.width; i++) { + this.display.setColor(i, j, PALETTE[display.get(i, j) & 7]); + } + } + } + + @Override + public void updateScreen() { + long date = (new Date()).getTime(); + float time = (float) (date - lastDate) / 1000.0F; + tabletThread.tick(time); + lastDate = date; + tablet.updateGui(time, this, false); + } + + private boolean isButton(int mx, int my) { + return mx >= (guiLeft + 65) && my >= (guiTop + 167) && mx < (guiLeft + 65 + 18) && my < (guiTop + 167 + 8); + } + + @Override + public void handleMouseInput() { + int x = (int) (Mouse.getEventX() * this.width / this.mc.displayWidth * GL_SCALE); + int y = (int) ((this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1) * GL_SCALE); + int k = Mouse.getEventButton(); + + if (k == 0) { + if (Mouse.getEventButtonState()) { + if (isButton(x, y)) { + buttonState = 2; + } + } else if (buttonState == 2) { + if (isButton(x, y)) { + buttonState = ENABLE_HIGHLIGHT ? 0 : 1; + System.out.println("PRESS"); + } else { + buttonState = 1; + } + } + } else if (ENABLE_HIGHLIGHT && k == -1 && buttonState != 2) { + if (isButton(x, y)) { + buttonState = 0; + } else { + buttonState = 1; + } + } + } + + @Override + public void drawScreen(int fmx, int fmy, float p) { + this.drawDefaultBackground(); + + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glPushMatrix(); + GL11.glScalef(1.0F / GL_SCALE, 1.0F / GL_SCALE, 1.0F / GL_SCALE); + + bindTexture(TEXTURE); + drawTexturedModalRect(guiLeft, guiTop, 0, 0, X_SIZE, Y_SIZE); + drawTexturedModalRect(guiLeft + 65, guiTop + 167, 142, 147 + (buttonState * 10), 18, 8); + + GL11.glPushAttrib(GL11.GL_ENABLE_BIT); + GL11.glEnable(GL11.GL_BLEND); + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); + + GL11.glScalef(0.5F, 0.5F, 0.5F); + display.draw((guiLeft + 10 + 1) * 2, (guiTop + 8 + 1) * 2, zLevel); + + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST); + GL11.glDisable(GL11.GL_BLEND); + GL11.glPopAttrib(); + + GL11.glPopMatrix(); + } +} diff --git a/common/buildcraft/core/tablet/ItemTablet.java b/common/buildcraft/core/tablet/ItemTablet.java new file mode 100644 index 00000000..c34df5b8 --- /dev/null +++ b/common/buildcraft/core/tablet/ItemTablet.java @@ -0,0 +1,24 @@ +package buildcraft.core.tablet; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import cpw.mods.fml.common.FMLCommonHandler; +import buildcraft.BuildCraftCore; +import buildcraft.core.GuiIds; +import buildcraft.core.lib.items.ItemBuildCraft; +import buildcraft.core.lib.utils.NBTUtils; +import buildcraft.core.tablet.manager.TabletManagerServer; + +public class ItemTablet extends ItemBuildCraft { + @Override + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { + if (world.isRemote) { + FMLCommonHandler.instance().showGuiScreen(new GuiTablet(player)); + } else { + TabletManagerServer.INSTANCE.get(player); + } + + return stack; + } +} diff --git a/common/buildcraft/core/tablet/PacketTabletMessage.java b/common/buildcraft/core/tablet/PacketTabletMessage.java new file mode 100644 index 00000000..b24654f9 --- /dev/null +++ b/common/buildcraft/core/tablet/PacketTabletMessage.java @@ -0,0 +1,58 @@ +package buildcraft.core.tablet; + +import java.io.IOException; +import io.netty.buffer.ByteBuf; +import net.minecraft.nbt.CompressedStreamTools; +import net.minecraft.nbt.NBTSizeTracker; +import net.minecraft.nbt.NBTTagCompound; +import buildcraft.api.core.BCLog; +import buildcraft.core.lib.network.Packet; +import buildcraft.core.network.PacketIds; + +public class PacketTabletMessage extends Packet { + private NBTTagCompound tag; + + public PacketTabletMessage() { + tag = new NBTTagCompound(); + } + + public PacketTabletMessage(NBTTagCompound tag) { + this.tag = tag; + } + + @Override + public int getID() { + return PacketIds.TABLET_MESSAGE; + } + + public NBTTagCompound getTag() { + return tag; + } + + @Override + public void readData(ByteBuf data) { + int length = data.readUnsignedShort(); + byte[] compressed = new byte[length]; + data.readBytes(compressed); + + try { + this.tag = CompressedStreamTools.func_152457_a(compressed, NBTSizeTracker.field_152451_a); + } catch (IOException e) { + e.printStackTrace(); + } + } + + @Override + public void writeData(ByteBuf data) { + try { + byte[] compressed = CompressedStreamTools.compress(tag); + if (compressed.length > 65535) { + BCLog.logger.error("NBT data is too large (" + compressed.length + " > 65535)! Please report!"); + } + data.writeShort(compressed.length); + data.writeBytes(compressed); + } catch (IOException e) { + e.printStackTrace(); + } + } +} diff --git a/common/buildcraft/core/tablet/TabletBase.java b/common/buildcraft/core/tablet/TabletBase.java new file mode 100644 index 00000000..d079e3a7 --- /dev/null +++ b/common/buildcraft/core/tablet/TabletBase.java @@ -0,0 +1,70 @@ +package buildcraft.core.tablet; + +import java.util.LinkedList; +import net.minecraft.nbt.NBTTagCompound; +import cpw.mods.fml.relauncher.Side; +import buildcraft.BuildCraftCore; +import buildcraft.api.core.BCLog; +import buildcraft.api.tablet.ITablet; +import buildcraft.api.tablet.TabletAPI; +import buildcraft.api.tablet.TabletBitmap; +import buildcraft.api.tablet.TabletProgram; +import buildcraft.api.tablet.TabletProgramFactory; + +public abstract class TabletBase implements ITablet { + protected LinkedList programs = new LinkedList(); + + protected TabletBase() { + + } + + public void tick(float time) { + if (programs.size() > 0) { + programs.getLast().tick(time); + } + } + + @Override + public int getScreenWidth() { + return 244; + } + + @Override + public int getScreenHeight() { + return 306; + } + + protected boolean launchProgramInternal(String name) { + TabletProgramFactory factory = TabletAPI.getProgram(name); + if (factory == null) { + BCLog.logger.error("Tried to launch non-existent tablet program on side CLIENT: " + name); + return false; + } + TabletProgram program = factory.create(this); + if (program == null) { + BCLog.logger.error("Factory could not create program on side CLIENT: " + name); + return false; + } + programs.add(program); + return true; + } + + public abstract void receiveMessage(NBTTagCompound compound); + + protected boolean receiveMessageInternal(NBTTagCompound compound) { + if (compound.hasKey("__program")) { + compound.removeTag("__program"); + if (programs.getLast() != null) { + programs.getLast().receiveMessage(compound); + } + return true; + } else { + if (compound.hasKey("programToLaunch")) { + System.out.println("received"); + launchProgramInternal(compound.getString("programToLaunch")); + return true; + } + } + return false; + } +} diff --git a/common/buildcraft/core/tablet/TabletClient.java b/common/buildcraft/core/tablet/TabletClient.java new file mode 100644 index 00000000..28250b23 --- /dev/null +++ b/common/buildcraft/core/tablet/TabletClient.java @@ -0,0 +1,59 @@ +package buildcraft.core.tablet; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.nbt.NBTTagCompound; +import cpw.mods.fml.relauncher.Side; +import buildcraft.BuildCraftCore; +import buildcraft.api.tablet.TabletBitmap; + +public class TabletClient extends TabletBase { + protected final TabletRenderer renderer; + + public TabletClient() { + super(); + this.renderer = new TabletRenderer(new TabletBitmap(this.getScreenWidth(), this.getScreenHeight())); + } + + @Override + public void tick(float time) { + super.tick(time); + } + + public void updateGui(float time, GuiTablet gui, boolean force) { + renderer.tick(time); + + if (renderer.shouldChange() || force) { + gui.copyDisplay(renderer.get()); + } + } + + @Override + public Side getSide() { + return Side.CLIENT; + } + + @Override + public void refreshScreen(TabletBitmap newDisplay) { + renderer.update(newDisplay); + } + + @Override + public void receiveMessage(NBTTagCompound compound) { + if (!receiveMessageInternal(compound)) { + + } + } + + @Override + public void launchProgram(String name) { + // noop + } + + + @Override + public void sendMessage(NBTTagCompound compound) { + compound.setBoolean("__program", true); + BuildCraftCore.instance.sendToServer(new PacketTabletMessage(compound)); + } +} diff --git a/common/buildcraft/core/tablet/TabletProgramMenu.java b/common/buildcraft/core/tablet/TabletProgramMenu.java new file mode 100644 index 00000000..175b46c8 --- /dev/null +++ b/common/buildcraft/core/tablet/TabletProgramMenu.java @@ -0,0 +1,21 @@ +package buildcraft.core.tablet; + +import buildcraft.api.tablet.ITablet; +import buildcraft.api.tablet.TabletProgram; + +public class TabletProgramMenu extends TabletProgram { + private final ITablet tablet; + private boolean init = false; + private float t = 0.0F; + + public TabletProgramMenu(ITablet tablet) { + this.tablet = tablet; + } + + public void tick(float time) { + t+=time; + if (!init && t > 2) { + init = true; + } + } +} diff --git a/common/buildcraft/core/tablet/TabletProgramMenuFactory.java b/common/buildcraft/core/tablet/TabletProgramMenuFactory.java new file mode 100644 index 00000000..efad0a54 --- /dev/null +++ b/common/buildcraft/core/tablet/TabletProgramMenuFactory.java @@ -0,0 +1,24 @@ +package buildcraft.core.tablet; + +import buildcraft.api.tablet.ITablet; +import buildcraft.api.tablet.TabletBitmap; +import buildcraft.api.tablet.TabletProgram; +import buildcraft.api.tablet.TabletProgramFactory; + +public class TabletProgramMenuFactory extends TabletProgramFactory { + @Override + public TabletProgram create(ITablet tablet) { + return new TabletProgramMenu(tablet); + } + + @Override + public String getName() { + return "menu"; + } + + @Override + public TabletBitmap getIcon() { + // TODO + return null; + } +} diff --git a/common/buildcraft/core/tablet/TabletRenderer.java b/common/buildcraft/core/tablet/TabletRenderer.java new file mode 100644 index 00000000..3fe033a1 --- /dev/null +++ b/common/buildcraft/core/tablet/TabletRenderer.java @@ -0,0 +1,74 @@ +package buildcraft.core.tablet; + +import buildcraft.api.tablet.TabletBitmap; +import buildcraft.api.tablet.TabletTicker; + +class TabletRenderer { + private TabletBitmap currDisplay, newDisplay; + private TabletTicker refreshRate = new TabletTicker(0.035F); + private boolean changed = false; + private boolean isTicking = false; + private int tickLocation = 7; + + public TabletRenderer(TabletBitmap display) { + this.currDisplay = display; + } + + public TabletBitmap get() { + return currDisplay; + } + + public boolean shouldChange() { + boolean oldChanged = changed; + changed = false; + return oldChanged; + } + + public void update(TabletBitmap display) { + synchronized (refreshRate) { + newDisplay = display; + isTicking = true; + tickLocation = 7; + refreshRate.reset(); + } + } + + public boolean tick(float tick) { + if (isTicking) { + synchronized (refreshRate) { + refreshRate.add(tick); + changed = false; + for (int times = 0; times < refreshRate.getTicks(); times++) { + for (int j = 0; j < currDisplay.height; j++) { + for (int i = 0; i < currDisplay.width; i++) { + int oldI = currDisplay.get(i, j); + int newI = newDisplay.get(i, j); + if (Math.abs(oldI - newI) == tickLocation) { + if (oldI < newI) { + changed = true; + currDisplay.set(i, j, oldI + 1); + } else if (oldI > newI) { + changed = true; + currDisplay.set(i, j, oldI - 1); + } + } + } + } + + tickLocation--; + + if (!changed || tickLocation == 0) { + isTicking = false; + break; + } + } + + refreshRate.tick(); + } + + return true; + } else { + return false; + } + } +} diff --git a/common/buildcraft/core/tablet/TabletServer.java b/common/buildcraft/core/tablet/TabletServer.java new file mode 100644 index 00000000..003a97ea --- /dev/null +++ b/common/buildcraft/core/tablet/TabletServer.java @@ -0,0 +1,75 @@ +package buildcraft.core.tablet; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import cpw.mods.fml.relauncher.Side; +import buildcraft.BuildCraftCore; +import buildcraft.api.tablet.TabletBitmap; +import buildcraft.api.tablet.TabletProgram; + +public class TabletServer extends TabletBase { + protected final EntityPlayer player; + + public TabletServer(EntityPlayer player) { + super(); + this.player = player; + } + + @Override + public void tick(float time) { + synchronized (programs) { + while (programs.size() > 0 && programs.getLast().hasEnded()) { + closeProgram(); + } + + if (programs.size() == 0) { + launchProgram("menu"); + } + + super.tick(time); + } + } + + @Override + public Side getSide() { + return Side.SERVER; + } + + @Override + public void refreshScreen(TabletBitmap newDisplay) { + // noop + } + + @Override + public void receiveMessage(NBTTagCompound compound) { + if (!receiveMessageInternal(compound)) { + if (compound.hasKey("doRemoveProgram")) { + synchronized (programs) { + programs.removeLast(); + } + } + } + } + + @Override + public void launchProgram(String name) { + if (launchProgramInternal(name)) { + NBTTagCompound compound = new NBTTagCompound(); + compound.setString("programToLaunch", name); + BuildCraftCore.instance.sendToPlayer(player, new PacketTabletMessage(compound)); + } + } + + protected void closeProgram() { + programs.removeLast(); + NBTTagCompound compound = new NBTTagCompound(); + compound.setBoolean("doRemoveProgram", true); + BuildCraftCore.instance.sendToPlayer(player, new PacketTabletMessage(compound)); + } + + @Override + public void sendMessage(NBTTagCompound compound) { + compound.setBoolean("__program", true); + BuildCraftCore.instance.sendToPlayer(player, new PacketTabletMessage(compound)); + } +} diff --git a/common/buildcraft/core/tablet/manager/TabletManagerClient.java b/common/buildcraft/core/tablet/manager/TabletManagerClient.java new file mode 100644 index 00000000..29279271 --- /dev/null +++ b/common/buildcraft/core/tablet/manager/TabletManagerClient.java @@ -0,0 +1,38 @@ +package buildcraft.core.tablet.manager; + +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.PlayerEvent; +import buildcraft.core.tablet.TabletClient; + +public class TabletManagerClient { + public static final TabletManagerClient INSTANCE = new TabletManagerClient(); + + private static TabletClient currentTablet; + private static TabletThread currentTabletThread; + + public TabletThread get() { + if (currentTablet == null) { + currentTablet = new TabletClient(); + currentTabletThread = new TabletThread(currentTablet); + new Thread(currentTabletThread).start(); + } + return currentTabletThread; + } + + public void onServerStopping() { + if (currentTablet != null) { + currentTablet = null; + currentTabletThread.stop(); + currentTabletThread = null; + } + } + + @SubscribeEvent + public void playerLogout(PlayerEvent.PlayerLoggedOutEvent event) { + if (currentTablet != null) { + currentTablet = null; + currentTabletThread.stop(); + currentTabletThread = null; + } + } +} diff --git a/common/buildcraft/core/tablet/manager/TabletManagerServer.java b/common/buildcraft/core/tablet/manager/TabletManagerServer.java new file mode 100644 index 00000000..e2dd7e4a --- /dev/null +++ b/common/buildcraft/core/tablet/manager/TabletManagerServer.java @@ -0,0 +1,47 @@ +package buildcraft.core.tablet.manager; + +import java.util.HashMap; +import net.minecraft.entity.player.EntityPlayer; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.PlayerEvent; +import cpw.mods.fml.common.gameevent.TickEvent; +import buildcraft.core.tablet.TabletServer; + +public class TabletManagerServer { + public static final TabletManagerServer INSTANCE = new TabletManagerServer(); + + private HashMap threads = new HashMap(); + + public TabletServer get(EntityPlayer player) { + if (!threads.containsKey(player)) { + TabletServer tablet = new TabletServer(player); + TabletThread thread = new TabletThread(tablet); + threads.put(player, thread); + new Thread(thread).start(); + } + return (TabletServer) threads.get(player).getTablet(); + } + + public void onServerStopping() { + for (TabletThread thread : threads.values()) { + thread.stop(); + } + threads.clear(); + } + + @SubscribeEvent + public void serverTick(TickEvent.ServerTickEvent event) { + for (TabletThread thread : threads.values()) { + thread.tick(0.05F); + } + } + + @SubscribeEvent + public void playerLogout(PlayerEvent.PlayerLoggedOutEvent event) { + TabletThread thread = threads.get(event.player); + if (thread != null) { + thread.stop(); + threads.remove(event.player); + } + } +} diff --git a/common/buildcraft/core/tablet/manager/TabletThread.java b/common/buildcraft/core/tablet/manager/TabletThread.java new file mode 100644 index 00000000..a2dd50b1 --- /dev/null +++ b/common/buildcraft/core/tablet/manager/TabletThread.java @@ -0,0 +1,52 @@ +package buildcraft.core.tablet.manager; + +import java.util.Date; +import cpw.mods.fml.relauncher.Side; +import buildcraft.core.tablet.TabletBase; + +public class TabletThread implements Runnable { + private final TabletBase tablet; + + private long begunTickDate; + private long lastTickReceivedDate; + private float ticksLeft = 0.0F; + private boolean isRunning = false; + + public TabletThread(TabletBase tablet) { + this.tablet = tablet; + lastTickReceivedDate = begunTickDate = (new Date()).getTime(); + } + + public TabletBase getTablet() { + return tablet; + } + + @Override + public void run() { + isRunning = true; + while (isRunning) { + if (ticksLeft > 0.0F) { + begunTickDate = (new Date()).getTime(); + tablet.tick(ticksLeft); + float timeElapsed = (float) (lastTickReceivedDate - begunTickDate) / 1000.0F; + if (timeElapsed > 0) { + ticksLeft -= timeElapsed; + } + } else { + try { + Thread.sleep(1); + } catch (Exception e) { + } + } + } + } + + public void stop() { + isRunning = false; + } + + public void tick(float time) { + ticksLeft += time; + lastTickReceivedDate = (new Date()).getTime(); + } +} diff --git a/common/buildcraft/core/tablet/utils/TabletBitmapLoader.java b/common/buildcraft/core/tablet/utils/TabletBitmapLoader.java new file mode 100644 index 00000000..cd45fc47 --- /dev/null +++ b/common/buildcraft/core/tablet/utils/TabletBitmapLoader.java @@ -0,0 +1,30 @@ +package buildcraft.core.tablet.utils; + +import java.io.InputStream; +import buildcraft.api.tablet.TabletBitmap; + +public class TabletBitmapLoader { + private TabletBitmapLoader() { + + } + + /** + * This function takes a 16-bit grayscale RAW file (GIMP can output these) + */ + public static TabletBitmap createFromGray(InputStream stream, int width, int height) { + try { + byte[] data = new byte[stream.available()]; + stream.read(data); + stream.close(); + + TabletBitmap bitmap = new TabletBitmap(width, height); + for (int i = 0; i < width * height; i++) { + bitmap.set(i % width, i / width, ~((int) data[i * 2] >>> 5) & 7); + } + return bitmap; + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } +} diff --git a/common/buildcraft/core/tablet/utils/TabletFont.java b/common/buildcraft/core/tablet/utils/TabletFont.java new file mode 100644 index 00000000..fb7dead9 --- /dev/null +++ b/common/buildcraft/core/tablet/utils/TabletFont.java @@ -0,0 +1,83 @@ +package buildcraft.core.tablet.utils; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; + +public final class TabletFont { + private String family; + private boolean isBold; + private boolean isItalic; + private int pointSize, maxW, maxH, ascent, descent; + + public TabletFont(File file) throws Exception { + this(new FileInputStream(file)); + } + + public TabletFont(InputStream stream) throws Exception { + while (stream.available() > 0) { + String section = readString(stream, 4); + int sectionLength = readInt(stream); + if ("FAMI".equals(section)) { + this.family = readString(stream, sectionLength); + } else if ("WEIG".equals(section)) { + this.isBold = readString(stream, sectionLength).equals("bold"); + } else if ("SLAN".equals(section)) { + this.isItalic = readString(stream, sectionLength).equals("italic"); + } else if ("PTSZ".equals(section)) { + this.pointSize = readUnsignedShort(stream); + } else if ("MAXW".equals(section)) { + this.maxW = readUnsignedShort(stream); + } else if ("MAXH".equals(section)) { + this.maxH = readUnsignedShort(stream); + } else if ("ASCE".equals(section)) { + this.ascent = readUnsignedShort(stream); + } else if ("DESC".equals(section)) { + this.descent = readUnsignedShort(stream); + } + // TODO: character index/data + } + } + + private static int readUnsignedShort(InputStream stream) { + byte[] data = new byte[2]; + try { + stream.read(data); + } catch (IOException e) { + e.printStackTrace(); + } + return ((int) data[0] & 0xFF) << 8 | ((int) data[1] & 0xFF); + } + + private static int readShort(InputStream stream) { + int t = readUnsignedShort(stream); + if (t >= 0x8000) { + return 0x7FFF - t; + } else { + return t; + } + } + + private static int readInt(InputStream stream) { + byte[] data = new byte[4]; + try { + stream.read(data); + } catch (IOException e) { + e.printStackTrace(); + } + return ((int) data[0] & 0xFF) << 24 | ((int) data[1] & 0xFF) << 16 + | ((int) data[2] & 0xFF) << 8 | ((int) data[3] & 0xFF); + } + + private static String readString(InputStream stream, int length) { + byte[] data = new byte[length]; + try { + stream.read(data); + return new String(data, "ASCII"); + } catch (IOException e) { + e.printStackTrace(); + return ""; + } + } +} diff --git a/common/buildcraft/energy/TileEngineIron.java b/common/buildcraft/energy/TileEngineIron.java index 73c551a6..d1fca7a8 100644 --- a/common/buildcraft/energy/TileEngineIron.java +++ b/common/buildcraft/energy/TileEngineIron.java @@ -27,7 +27,7 @@ import buildcraft.api.fuels.ICoolant; import buildcraft.api.fuels.IFuel; import buildcraft.api.fuels.ISolidCoolant; import buildcraft.core.GuiIds; -import buildcraft.core.IItemPipe; +import buildcraft.api.transport.IItemPipe; import buildcraft.core.lib.engines.TileEngineWithInventory; import buildcraft.core.lib.fluids.Tank; import buildcraft.core.lib.fluids.TankManager; diff --git a/common/buildcraft/factory/BlockAutoWorkbench.java b/common/buildcraft/factory/BlockAutoWorkbench.java index 952f6292..9a77d68b 100644 --- a/common/buildcraft/factory/BlockAutoWorkbench.java +++ b/common/buildcraft/factory/BlockAutoWorkbench.java @@ -14,7 +14,7 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import buildcraft.BuildCraftFactory; import buildcraft.core.GuiIds; -import buildcraft.core.IItemPipe; +import buildcraft.api.transport.IItemPipe; import buildcraft.core.lib.block.BlockBuildCraft; public class BlockAutoWorkbench extends BlockBuildCraft { diff --git a/common/buildcraft/factory/BlockFrame.java b/common/buildcraft/factory/BlockFrame.java index 6e5a08dd..80530d41 100644 --- a/common/buildcraft/factory/BlockFrame.java +++ b/common/buildcraft/factory/BlockFrame.java @@ -26,7 +26,7 @@ import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; import buildcraft.BuildCraftCore; import buildcraft.core.CoreConstants; -import buildcraft.core.IFramePipeConnection; +import buildcraft.core.internal.IFramePipeConnection; import buildcraft.core.lib.utils.Utils; public class BlockFrame extends Block implements IFramePipeConnection { diff --git a/common/buildcraft/factory/BlockHopper.java b/common/buildcraft/factory/BlockHopper.java index 5004a84c..5a94c1e5 100644 --- a/common/buildcraft/factory/BlockHopper.java +++ b/common/buildcraft/factory/BlockHopper.java @@ -19,7 +19,7 @@ import cpw.mods.fml.relauncher.SideOnly; import buildcraft.BuildCraftCore; import buildcraft.BuildCraftFactory; import buildcraft.core.GuiIds; -import buildcraft.core.IItemPipe; +import buildcraft.api.transport.IItemPipe; import buildcraft.core.lib.block.BlockBuildCraft; public class BlockHopper extends BlockBuildCraft { diff --git a/common/buildcraft/factory/BlockPlainPipe.java b/common/buildcraft/factory/BlockPlainPipe.java index 0dfb6416..f70c02a9 100644 --- a/common/buildcraft/factory/BlockPlainPipe.java +++ b/common/buildcraft/factory/BlockPlainPipe.java @@ -21,7 +21,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import buildcraft.core.CoreConstants; -import buildcraft.core.IFramePipeConnection; +import buildcraft.core.internal.IFramePipeConnection; public class BlockPlainPipe extends Block implements IFramePipeConnection { diff --git a/common/buildcraft/factory/TileQuarry.java b/common/buildcraft/factory/TileQuarry.java index c0c70fa8..d1c3ac15 100644 --- a/common/buildcraft/factory/TileQuarry.java +++ b/common/buildcraft/factory/TileQuarry.java @@ -45,7 +45,7 @@ import buildcraft.core.Box; import buildcraft.core.Box.Kind; import buildcraft.core.CoreConstants; import buildcraft.core.DefaultAreaProvider; -import buildcraft.core.IDropControlInventory; +import buildcraft.core.internal.IDropControlInventory; import buildcraft.core.blueprints.Blueprint; import buildcraft.core.blueprints.BptBuilderBase; import buildcraft.core.blueprints.BptBuilderBlueprint; diff --git a/common/buildcraft/robotics/gui/ContainerZonePlan.java b/common/buildcraft/robotics/gui/ContainerZonePlan.java index 4e0c27ac..5ea3ba90 100755 --- a/common/buildcraft/robotics/gui/ContainerZonePlan.java +++ b/common/buildcraft/robotics/gui/ContainerZonePlan.java @@ -22,13 +22,13 @@ import buildcraft.core.lib.gui.slots.SlotOutput; import buildcraft.core.lib.network.command.CommandWriter; import buildcraft.core.lib.network.command.ICommandReceiver; import buildcraft.core.lib.network.command.PacketCommand; -import buildcraft.core.lib.render.DynamicTexturePaletted; +import buildcraft.core.lib.render.DynamicTextureBC; import buildcraft.core.lib.utils.NetworkUtils; import buildcraft.robotics.TileZonePlan; public class ContainerZonePlan extends BuildCraftContainer implements ICommandReceiver { - public DynamicTexturePaletted mapTexture; + public DynamicTextureBC mapTexture; public ZonePlan currentAreaSelection; public GuiZonePlan gui; diff --git a/common/buildcraft/robotics/gui/GuiZonePlan.java b/common/buildcraft/robotics/gui/GuiZonePlan.java index 7885bb1a..8596feee 100755 --- a/common/buildcraft/robotics/gui/GuiZonePlan.java +++ b/common/buildcraft/robotics/gui/GuiZonePlan.java @@ -30,7 +30,7 @@ import buildcraft.core.lib.gui.tooltips.ToolTip; import buildcraft.core.lib.gui.tooltips.ToolTipLine; import buildcraft.core.lib.network.command.CommandWriter; import buildcraft.core.lib.network.command.PacketCommand; -import buildcraft.core.lib.render.DynamicTexturePaletted; +import buildcraft.core.lib.render.DynamicTextureBC; import buildcraft.core.lib.utils.NetworkUtils; import buildcraft.core.lib.utils.StringUtils; import buildcraft.robotics.TileZonePlan; @@ -44,7 +44,7 @@ public class GuiZonePlan extends GuiAdvancedInterface { private TileZonePlan zonePlan; - private DynamicTexturePaletted newSelection; + private DynamicTextureBC newSelection; private int selX1 = 0; private int selX2 = 0; private int selY1 = 0; @@ -52,7 +52,7 @@ public class GuiZonePlan extends GuiAdvancedInterface { private boolean inSelection = false; - private DynamicTexturePaletted currentSelection; + private DynamicTextureBC currentSelection; private int mapXMin = 0; private int mapYMin = 0; @@ -103,14 +103,9 @@ public class GuiZonePlan extends GuiAdvancedInterface { zonePlan = iZonePlan; - getContainer().mapTexture = new DynamicTexturePaletted(mapWidth, mapHeight); - getContainer().mapTexture.createDynamicTexture(); - - currentSelection = new DynamicTexturePaletted(mapWidth, mapHeight); - currentSelection.createDynamicTexture(); - - newSelection = new DynamicTexturePaletted(1, 1); - newSelection.createDynamicTexture(); + getContainer().mapTexture = new DynamicTextureBC(mapWidth, mapHeight); + currentSelection = new DynamicTextureBC(mapWidth, mapHeight); + newSelection = new DynamicTextureBC(1, 1); getContainer().currentAreaSelection = new ZonePlan(); @@ -180,17 +175,17 @@ public class GuiZonePlan extends GuiAdvancedInterface { mapYMin = (height - getContainer().mapTexture.height) / 2; } - getContainer().mapTexture.drawMap(mapXMin, mapYMin, zLevel); + getContainer().mapTexture.draw(mapXMin, mapYMin, zLevel); GL11.glPushAttrib(GL11.GL_ENABLE_BIT); GL11.glEnable(GL11.GL_BLEND); - currentSelection.drawMap(mapXMin, mapYMin, zLevel); + currentSelection.draw(mapXMin, mapYMin, zLevel); GL11.glPopAttrib(); GL11.glDisable(GL11.GL_BLEND); - newSelection.updateDynamicTexture(); + newSelection.updateTexture(); if (inSelection && selX2 != 0) { GL11.glPushAttrib(GL11.GL_ENABLE_BIT); @@ -345,28 +340,24 @@ public class GuiZonePlan extends GuiAdvancedInterface { mapWidth = 213; mapHeight = 100; - getContainer().mapTexture = new DynamicTexturePaletted(mapWidth, mapHeight); - getContainer().mapTexture.createDynamicTexture(); - - currentSelection = new DynamicTexturePaletted(mapWidth, mapHeight); - currentSelection.createDynamicTexture(); + getContainer().mapTexture = new DynamicTextureBC(mapWidth, mapHeight); + currentSelection = new DynamicTextureBC(mapWidth, mapHeight); uploadMap(); refreshSelectedArea(); + container.inventorySlots = inventorySlots; buttonList = savedButtonList; } else if (carac == 'M') { mapWidth = this.mc.displayWidth; mapHeight = this.mc.displayHeight; - getContainer().mapTexture = new DynamicTexturePaletted(mapWidth, mapHeight); - getContainer().mapTexture.createDynamicTexture(); - - currentSelection = new DynamicTexturePaletted(mapWidth, mapHeight); - currentSelection.createDynamicTexture(); + getContainer().mapTexture = new DynamicTextureBC(mapWidth, mapHeight); + currentSelection = new DynamicTextureBC(mapWidth, mapHeight); uploadMap(); refreshSelectedArea(); + container.inventorySlots = new LinkedList(); buttonList = new LinkedList(); } @@ -405,14 +396,10 @@ public class GuiZonePlan extends GuiAdvancedInterface { g /= zoomLevel * zoomLevel; b /= zoomLevel * zoomLevel; - r /= 255F; - g /= 255F; - b /= 255F; - if (r != 0) { - currentSelection.setColor(i, j, r, g, b, alpha); + currentSelection.setColori(i, j, (int) r, (int) g, (int) b, (int) (alpha * 255.0F)); } else { - currentSelection.setColor(i, j, 0, 0, 0, 0); + currentSelection.setColori(i, j, 0, 0, 0, 0); } } } diff --git a/common/buildcraft/transport/BlockFilteredBuffer.java b/common/buildcraft/transport/BlockFilteredBuffer.java index 277321bf..44504180 100644 --- a/common/buildcraft/transport/BlockFilteredBuffer.java +++ b/common/buildcraft/transport/BlockFilteredBuffer.java @@ -14,7 +14,7 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import buildcraft.BuildCraftTransport; import buildcraft.core.GuiIds; -import buildcraft.core.IItemPipe; +import buildcraft.api.transport.IItemPipe; import buildcraft.core.lib.block.BlockBuildCraft; public class BlockFilteredBuffer extends BlockBuildCraft { diff --git a/common/buildcraft/transport/ItemFacade.java b/common/buildcraft/transport/ItemFacade.java index ca98f03e..af1eadd9 100644 --- a/common/buildcraft/transport/ItemFacade.java +++ b/common/buildcraft/transport/ItemFacade.java @@ -451,7 +451,7 @@ public class ItemFacade extends ItemBuildCraft implements IFacadeItem, IPipePlug facade6Hollow.stackSize = 6; // 3 Structurepipes + this block makes 6 facades - if (Loader.isModLoaded("BuildCraft|Silicon")) { + if (Loader.isModLoaded("BuildCraft|Silicon") && !BuildCraftTransport.facadeForceNonLaserReicpe) { BuildcraftRecipeRegistry.assemblyTable.addRecipe(recipeId, 8000, facade6, new ItemStack( BuildCraftTransport.pipeStructureCobblestone, 3), itemStack); diff --git a/common/buildcraft/transport/ItemPipe.java b/common/buildcraft/transport/ItemPipe.java index 42a11283..60e62f22 100644 --- a/common/buildcraft/transport/ItemPipe.java +++ b/common/buildcraft/transport/ItemPipe.java @@ -25,7 +25,7 @@ import buildcraft.BuildCraftTransport; import buildcraft.api.core.BCLog; import buildcraft.api.core.IIconProvider; import buildcraft.core.BCCreativeTab; -import buildcraft.core.IItemPipe; +import buildcraft.api.transport.IItemPipe; import buildcraft.core.lib.items.ItemBuildCraft; import buildcraft.core.lib.utils.ColorUtils; import buildcraft.core.lib.utils.StringUtils; diff --git a/common/buildcraft/transport/Pipe.java b/common/buildcraft/transport/Pipe.java index 827b9e62..f549a8c8 100644 --- a/common/buildcraft/transport/Pipe.java +++ b/common/buildcraft/transport/Pipe.java @@ -33,7 +33,7 @@ import buildcraft.api.statements.StatementSlot; import buildcraft.api.transport.IPipe; import buildcraft.api.transport.IPipeTile; import buildcraft.api.transport.PipeWire; -import buildcraft.core.IDropControlInventory; +import buildcraft.core.internal.IDropControlInventory; import buildcraft.core.lib.inventory.InvUtils; import buildcraft.core.lib.utils.Utils; import buildcraft.transport.gates.GateFactory; diff --git a/common/buildcraft/transport/TileGenericPipe.java b/common/buildcraft/transport/TileGenericPipe.java index 947b455b..e700dd61 100644 --- a/common/buildcraft/transport/TileGenericPipe.java +++ b/common/buildcraft/transport/TileGenericPipe.java @@ -47,7 +47,7 @@ import buildcraft.api.transport.PipeWire; import buildcraft.api.transport.pluggable.IFacadePluggable; import buildcraft.api.transport.pluggable.PipePluggable; import buildcraft.core.DefaultProps; -import buildcraft.core.IDropControlInventory; +import buildcraft.core.internal.IDropControlInventory; import buildcraft.core.lib.ITileBufferHolder; import buildcraft.core.lib.TileBuffer; import buildcraft.core.lib.network.IGuiReturnHandler; diff --git a/common/buildcraft/transport/network/PacketHandlerTransport.java b/common/buildcraft/transport/network/PacketHandlerTransport.java index 8bec2714..022deacf 100644 --- a/common/buildcraft/transport/network/PacketHandlerTransport.java +++ b/common/buildcraft/transport/network/PacketHandlerTransport.java @@ -17,6 +17,7 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import cpw.mods.fml.common.network.NetworkRegistry; import buildcraft.core.lib.network.Packet; +import buildcraft.core.lib.network.PacketHandler; import buildcraft.core.lib.network.PacketSlotChange; import buildcraft.core.network.PacketIds; import buildcraft.core.proxy.CoreProxy; @@ -27,8 +28,7 @@ import buildcraft.transport.pipes.PipeItemsDiamond; import buildcraft.transport.pipes.PipeItemsEmerald; @Sharable -public class PacketHandlerTransport extends SimpleChannelInboundHandler { - +public class PacketHandlerTransport extends PacketHandler { /** * TODO: A lot of this is based on the player to retrieve the world. * Passing a dimension id would be more appropriate. More generally, it @@ -36,7 +36,8 @@ public class PacketHandlerTransport extends SimpleChannelInboundHandler * RPCs. */ @Override - protected void channelRead0(ChannelHandlerContext ctx, Packet packet) { + protected void channelRead0(ChannelHandlerContext ctx, Packet packet) { + super.channelRead0(ctx, packet); try { INetHandler netHandler = ctx.channel().attr(NetworkRegistry.NET_HANDLER).get(); EntityPlayer player = CoreProxy.proxy.getPlayerFromNetHandler(netHandler);