diff --git a/build.gradle b/build.gradle index 23e6ce2..918b7ce 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,7 @@ buildscript { mavenCentral() maven { name = "forge" - url = "http://files.minecraftforge.net/maven" + url = "https://files.minecraftforge.net/maven" } } dependencies { @@ -14,15 +14,20 @@ buildscript { } apply plugin: 'net.minecraftforge.gradle.forge' -version = "6.0.0.8" +version = "6.0.0.9" group= "com.buildcraft.additionalpipes" archivesBaseName = "additionalpipes" minecraft { - version = "${mc_version}-14.23.0.2544" + version = "${mc_version}-14.23.5.2847" runDir = "minecraft" mappings = "snapshot_20171120" + if (!developmentEnvironmentUserName.isEmpty()){ + clientRunArgs +=['--username', developmentEnvironmentUserName.toString()] + } + + } // http://maven.apache.org/guides/mini/guide-naming-conventions.html repositories { @@ -32,7 +37,7 @@ repositories { { // location of the maven that hosts JEI files name = "Progwml6 maven" - url = "http://dvs1.progwml6.com/files/maven" + url = "https://dvs1.progwml6.com/files/maven" } maven { @@ -44,22 +49,28 @@ repositories { // Adding a "fake" ivy repository to allow downloading buildcraft from its URL // See https://stackoverflow.com/a/34327202/7083698 ivy { - url 'http://www.mod-buildcraft.com/releases/' + url 'https://www.mod-buildcraft.com/releases/' patternLayout { artifact "[organization]/[revision]/[module]-main-[revision]-[classifier].jar" } - metadataSources { artifact() } + metadataSources { artifact() } } - + + maven { + url "https://cursemaven.com" + } + } dependencies { - compile 'BuildCraft:buildcraft:7.99.24.1:dev' + implementation('BuildCraft:buildcraft:8.0.0:dev') + implementation('curse.maven:bccompat-233140:6376390') + // compile against the JEI API but do not include it at runtime deobfProvided "mezz.jei:jei_${mc_version}:${jei_version}:api" // at runtime, use the full JEI jar - runtime "mezz.jei:jei_${mc_version}:${jei_version}" + runtimeOnly "mezz.jei:jei_${mc_version}:${jei_version}" } // 30 96 254 sourceSets { diff --git a/gradle.properties b/gradle.properties index a9a10fe..5b184ea 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,4 @@ org.gradle.jvmargs=-Xmx4096M mc_version=1.12.2 -jei_version=4.8.5.142 \ No newline at end of file +jei_version=4.16.1.301 +developmentEnvironmentUserName = Hydra \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 99340b4..ca78035 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/src/main/java/buildcraft/additionalpipes/APPipeDefintions.java b/src/main/java/buildcraft/additionalpipes/APPipeDefintions.java index 6d5fea4..2d081fc 100644 --- a/src/main/java/buildcraft/additionalpipes/APPipeDefintions.java +++ b/src/main/java/buildcraft/additionalpipes/APPipeDefintions.java @@ -93,7 +93,7 @@ public static void createPipes() additionPipeDef = new PipeDefinitionBuilder().flowItem().idTexPrefix("pipe_items_addition").logic(PipeBehaviorAddition::new, PipeBehaviorAddition::new).define(); additionPipeItem = PipeCreator.createPipeItem(additionPipeDef); - advWoodPipeDef = new PipeDefinitionBuilder().flowItem().idTexPrefix("pipe_items_adv_wood").texSuffixes("_output", "_input").logic(PipeBehaviorAdvWood::new, PipeBehaviorAdvWood::new).define(); + advWoodPipeDef = new PipeDefinitionBuilder().flowItem().idTexPrefix("pipe_items_adv_wood").texSuffixes("_output", "_input").logic(PipeBehaviorAdvWood::new, PipeBehaviorAdvWood::new).enableColouring().define(); advWoodPipeItem = PipeCreator.createPipeItem(advWoodPipeDef); closedPipeDef = new PipeDefinitionBuilder().flowItem().idTexPrefix("pipe_items_closed").texSuffixes("_open", "_closed").logic(PipeBehaviorClosed::new, PipeBehaviorClosed::new).define(); @@ -105,7 +105,7 @@ public static void createPipes() distributionPipeDef = distPipeDefBuilder.define(); distributionPipeItem = PipeCreator.createPipeItem(distributionPipeDef); - gravityFeedPipeDef = new PipeDefinitionBuilder().flowItem().idTexPrefix("pipe_items_gravity_feed").texSuffixes("_up", "_sides").logic(PipeBehaviorGravityFeed::new, PipeBehaviorGravityFeed::new).define(); + gravityFeedPipeDef = new PipeDefinitionBuilder().flowItem().idTexPrefix("pipe_items_gravity_feed").texSuffixes("_up", "_sides").logic(PipeBehaviorGravityFeed::new, PipeBehaviorGravityFeed::new).enableColouring().define(); gravityFeedPipeItem = PipeCreator.createPipeItem(gravityFeedPipeDef); PipeDefinitionBuilder priorityPipeDefBuilder = new PipeDefinitionBuilder().flowItem().idTexPrefix("pipe_items_priority").logic(PipeBehaviorPriorityInsertion::new, PipeBehaviorPriorityInsertion::new); @@ -117,7 +117,7 @@ public static void createPipes() attachSidedSuffixes(jeweledPipeDefBuilder); jeweledPipeDef = jeweledPipeDefBuilder.define(); jeweledPipeItem = PipeCreator.createPipeItem(jeweledPipeDef); - + itemsTeleportPipeDef = new PipeDefinitionBuilder().flowItem().idTexPrefix("pipe_items_teleport").logic(PipeBehaviorTeleportItems::new, PipeBehaviorTeleportItems::new).define(); itemsTeleportPipeItem = PipeCreator.createPipeItem(itemsTeleportPipeDef); @@ -134,10 +134,10 @@ public static void createPipes() //powerTeleportPipeDef = new PipeDefinitionBuilder().flowPower().idTexPrefix("pipe_power_teleport").logic(PipeBehaviorTeleportPower::new, PipeBehaviorTeleportPower::new).define(); //powerTeleportPipeItem = PipeCreator.createPipeItemAndRecipe(1, powerTeleportPipeDef, true, new Object[] {"dustRedstone", itemsTeleportPipeItem}); - itemsSwitchPipeDef = new PipeDefinitionBuilder().flowItem().idTexPrefix("pipe_items_switch").texSuffixes("_closed", "_open").logic(PipeBehaviorSwitch::new, PipeBehaviorSwitch::new).define(); + itemsSwitchPipeDef = new PipeDefinitionBuilder().flowItem().idTexPrefix("pipe_items_switch").texSuffixes("_closed", "_open").logic(PipeBehaviorSwitch::new, PipeBehaviorSwitch::new).enableColouring().define(); itemsSwitchPipeItem = PipeCreator.createPipeItem(itemsSwitchPipeDef); - fluidsSwitchPipeDef = new PipeDefinitionBuilder().flowFluid().idTexPrefix("pipe_fluids_switch").texSuffixes("_closed", "_open").logic(PipeBehaviorSwitch::new, PipeBehaviorSwitch::new).define(); + fluidsSwitchPipeDef = new PipeDefinitionBuilder().flowFluid().idTexPrefix("pipe_fluids_switch").texSuffixes("_closed", "_open").logic(PipeBehaviorSwitch::new, PipeBehaviorSwitch::new).enableColouring().define(); fluidsSwitchPipeItem = PipeCreator.createPipeItem(fluidsSwitchPipeDef); powerSwitchPipeDef = new PipeDefinitionBuilder().flowPower().idTexPrefix("pipe_power_switch").texSuffixes("_closed", "_open").logic(PipeBehaviorSwitch::new, PipeBehaviorSwitch::new).define(); diff --git a/src/main/java/buildcraft/additionalpipes/AdditionalPipes.java b/src/main/java/buildcraft/additionalpipes/AdditionalPipes.java index eaf029f..26f014f 100644 --- a/src/main/java/buildcraft/additionalpipes/AdditionalPipes.java +++ b/src/main/java/buildcraft/additionalpipes/AdditionalPipes.java @@ -48,7 +48,7 @@ public class AdditionalPipes { public static final String MODID = "additionalpipes"; public static final String NAME = "Additional Pipes"; - public static final String VERSION = "6.0.0.8"; + public static final String VERSION = "6.0.0.9"; @Instance(MODID) public static AdditionalPipes instance; diff --git a/src/main/java/buildcraft/additionalpipes/CommandAdditionalPipes.java b/src/main/java/buildcraft/additionalpipes/CommandAdditionalPipes.java index 9677667..36c97e0 100644 --- a/src/main/java/buildcraft/additionalpipes/CommandAdditionalPipes.java +++ b/src/main/java/buildcraft/additionalpipes/CommandAdditionalPipes.java @@ -59,7 +59,7 @@ else if(args[1].equals("power")) sb.append(pipe.getPosition().getX()).append(", "); sb.append(pipe.getPosition().getY()).append(", "); sb.append(pipe.getPosition().getZ()).append("] "); - sb.append(pipe.ownerName); + sb.append(pipe.getOwnerName()); sender.sendMessage(new TextComponentString(sb.toString())); } } diff --git a/src/main/java/buildcraft/additionalpipes/api/ITeleportPipe.java b/src/main/java/buildcraft/additionalpipes/api/ITeleportPipe.java index 36476e3..765f8fb 100644 --- a/src/main/java/buildcraft/additionalpipes/api/ITeleportPipe.java +++ b/src/main/java/buildcraft/additionalpipes/api/ITeleportPipe.java @@ -46,6 +46,8 @@ public interface ITeleportPipe public String getOwnerName(); + public UUID getPipeUUID(); + public TilePipeHolder getContainer(); /** diff --git a/src/main/java/buildcraft/additionalpipes/gui/ContainerAdvancedWoodPipe.java b/src/main/java/buildcraft/additionalpipes/gui/ContainerAdvancedWoodPipe.java index 0ef236c..0fd6ba7 100644 --- a/src/main/java/buildcraft/additionalpipes/gui/ContainerAdvancedWoodPipe.java +++ b/src/main/java/buildcraft/additionalpipes/gui/ContainerAdvancedWoodPipe.java @@ -13,7 +13,6 @@ import buildcraft.transport.tile.TilePipeHolder; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IContainerListener; -import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.SlotItemHandler; @@ -23,7 +22,7 @@ public class ContainerAdvancedWoodPipe extends ContainerBC_Neptune { private boolean exclude; private PipeBehaviorAdvWood pipe; - public ContainerAdvancedWoodPipe(EntityPlayer player, IInventory playerInventory, PipeBehaviorAdvWood pipe) { + public ContainerAdvancedWoodPipe(EntityPlayer player, PipeBehaviorAdvWood pipe) { super(player); this.pipe = pipe; exclude = !pipe.getExclude(); // force a network update @@ -35,13 +34,13 @@ public ContainerAdvancedWoodPipe(EntityPlayer player, IInventory playerInventory for(int l = 0; l < 3; l++) { for(int k1 = 0; k1 < 9; k1++) { - addSlotToContainer(new Slot(playerInventory, k1 + l * 9 + 9, 8 + k1 * 18, 76 + l * 18)); + addSlotToContainer(new Slot(player.inventory, k1 + l * 9 + 9, 8 + k1 * 18, 76 + l * 18)); } } for(int i1 = 0; i1 < 9; i1++) { - addSlotToContainer(new Slot(playerInventory, i1, 8 + i1 * 18, 134)); + addSlotToContainer(new Slot(player.inventory, i1, 8 + i1 * 18, 134)); } } diff --git a/src/main/java/buildcraft/additionalpipes/gui/ContainerTeleportPipe.java b/src/main/java/buildcraft/additionalpipes/gui/ContainerTeleportPipe.java index 96e6ac2..2d0e125 100644 --- a/src/main/java/buildcraft/additionalpipes/gui/ContainerTeleportPipe.java +++ b/src/main/java/buildcraft/additionalpipes/gui/ContainerTeleportPipe.java @@ -13,6 +13,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.inventory.IContainerListener; +import net.minecraft.util.EnumFacing; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.relauncher.Side; @@ -25,6 +26,7 @@ public class ContainerTeleportPipe extends ContainerBC_Neptune { private int freq; private byte state; private boolean isPublic; + private EnumFacing tpSide; //true if the provided pipe is sending items to other pipes //and output locations should be shown on the ledger @@ -40,7 +42,7 @@ public ContainerTeleportPipe(EntityPlayer player, PipeBehaviorTeleport pipe) //set these variables to invalid values so that they will be updated state = -1; - isPublic = !pipe.isPublic; + isPublic = !pipe.isPublic(); freq = -1; isSendingPipe = pipe.canSend(); @@ -56,7 +58,7 @@ public ContainerTeleportPipe(EntityPlayer player, PipeBehaviorTeleport pipe) locations[3 * i + 2] = connectedPipe.getContainer().getPos().getZ(); } - MessageTelePipeData message = new MessageTelePipeData(pipe.getPos(), locations, pipe.ownerUUID, pipe.ownerName); + MessageTelePipeData message = new MessageTelePipeData(pipe.getPos(), locations, pipe.getOwnerUUID(), pipe.getOwnerName()); PacketHandler.INSTANCE.sendTo(message, (EntityPlayerMP) player); //save the pipe's old frequency so it can be removed later @@ -88,37 +90,45 @@ public void detectAndSendChanges() { for(IContainerListener crafter : listeners) { if(freq != pipe.getFrequency()) { crafter.sendWindowProperty(this, 0, pipe.getFrequency()); + freq = pipe.getFrequency(); } - if(state != pipe.state) { - crafter.sendWindowProperty(this, 1, pipe.state); + if(state != pipe.getState()) { + crafter.sendWindowProperty(this, 1, pipe.getState()); + state = pipe.getState(); } if(connectedPipesNew != connectedPipes) { crafter.sendWindowProperty(this, 2, connectedPipesNew); + connectedPipes = connectedPipesNew; } - if(isPublic != pipe.isPublic) { - crafter.sendWindowProperty(this, 3, pipe.isPublic ? 1 : 0); + if(isPublic != pipe.isPublic()) { + crafter.sendWindowProperty(this, 3, pipe.isPublic() ? 1 : 0); + isPublic = pipe.isPublic(); + } + if(tpSide != pipe.getTeleportSide()) { + crafter.sendWindowProperty(this, 4, pipe.getTeleportSide().ordinal()); + tpSide = pipe.getTeleportSide(); + pipe.pipe.markForUpdate(); } } - state = pipe.state; - freq = pipe.getFrequency(); - isPublic = pipe.isPublic; - connectedPipes = connectedPipesNew; } @Override - public void updateProgressBar(int i, int j) { - switch(i) { + public void updateProgressBar(int id, int data) { + switch(id) { case 0: - pipe.setFrequency(j); + pipe.setFrequency(data); break; case 1: - pipe.state = (byte) j; + pipe.setState((byte) data); break; case 2: - connectedPipes = j; + connectedPipes = data; break; case 3: - pipe.isPublic = (j == 1); + pipe.setPublic((data == 1)); + break; + case 4: + pipe.setTeleportSide(EnumFacing.values()[data]); break; } } diff --git a/src/main/java/buildcraft/additionalpipes/gui/GuiAdvancedWoodPipe.java b/src/main/java/buildcraft/additionalpipes/gui/GuiAdvancedWoodPipe.java index c8efd6f..4d3537a 100644 --- a/src/main/java/buildcraft/additionalpipes/gui/GuiAdvancedWoodPipe.java +++ b/src/main/java/buildcraft/additionalpipes/gui/GuiAdvancedWoodPipe.java @@ -8,6 +8,7 @@ package buildcraft.additionalpipes.gui; +import buildcraft.lib.gui.GuiBC8; import org.lwjgl.opengl.GL11; import buildcraft.additionalpipes.network.PacketHandler; @@ -15,7 +16,6 @@ import buildcraft.additionalpipes.pipes.PipeBehaviorAdvWood; import buildcraft.additionalpipes.textures.Textures; import net.minecraft.client.gui.GuiButton; -import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.resources.I18n; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; @@ -23,7 +23,7 @@ import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class GuiAdvancedWoodPipe extends GuiContainer { +public class GuiAdvancedWoodPipe extends GuiBC8 { int inventoryRows = 1; IInventory playerInventory; @@ -32,24 +32,29 @@ public class GuiAdvancedWoodPipe extends GuiContainer { int guiX, guiY; - public GuiAdvancedWoodPipe(EntityPlayer player, IInventory playerInventory, PipeBehaviorAdvWood pipe) + public GuiAdvancedWoodPipe(EntityPlayer player, PipeBehaviorAdvWood pipe) { - super(new ContainerAdvancedWoodPipe(player, playerInventory, pipe)); - this.playerInventory = playerInventory; + super(new ContainerAdvancedWoodPipe(player, pipe)); + this.playerInventory = player.inventory; this.pipe = pipe; // container = theContainer; - xSize = 175; - ySize = 156; + xSize = 176; + ySize = 158; } + @Override + protected boolean shouldAddHelpLedger() { + return false; + } + @Override public void initGui() { super.initGui(); guiX = (width - xSize) / 2; guiY = (height - ySize) / 2; - buttons[0] = new GuiButton(1, guiX + 8, guiY + 40, 140, 20, ""); + buttons[0] = new GuiButton(1, guiLeft + 7, guiTop + 38, 140, 20, ""); buttonList.add(buttons[0]); } @@ -61,8 +66,10 @@ public void drawScreen(int mouseX, int mouseY, float partialTicks) } @Override - protected void drawGuiContainerForegroundLayer(int p1, int p2) + protected void drawForegroundLayer() { + fontRenderer.drawString(I18n.format("gui.advwood_pipe.title"), guiLeft + 8, guiTop + 6, 4210752); + if(pipe.getExclude()) { buttons[0].displayString = I18n.format("gui.advwood_pipe.blacklist"); @@ -71,8 +78,10 @@ protected void drawGuiContainerForegroundLayer(int p1, int p2) { buttons[0].displayString = I18n.format("gui.advwood_pipe.whitelist"); } - - fontRenderer.drawString(I18n.format("gui.advwood_pipe.title"), guiX + 42, guiY + 22, 4210752); + + double invY = mainGui.rootElement.getY() + ySize - 95; + fontRenderer.drawString(I18n.format("gui.inventory"), (int) mainGui.rootElement.getX() + 8, (int) invY, 0x404040); + } @Override @@ -86,13 +95,10 @@ protected void actionPerformed(GuiButton guibutton) { } @Override - protected void drawGuiContainerBackgroundLayer(float f, int i, int j) { - + protected void drawBackgroundLayer(float partialTicks) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); mc.renderEngine.bindTexture(Textures.GUI_ADVANCEDWOOD); - int j1 = (width - xSize) / 2; - int k = (height - ySize) / 2; - drawTexturedModalRect(j1, k, 0, 0, xSize, ySize); + drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); } } diff --git a/src/main/java/buildcraft/additionalpipes/gui/GuiHandler.java b/src/main/java/buildcraft/additionalpipes/gui/GuiHandler.java index 444ade9..28b6a4a 100644 --- a/src/main/java/buildcraft/additionalpipes/gui/GuiHandler.java +++ b/src/main/java/buildcraft/additionalpipes/gui/GuiHandler.java @@ -39,7 +39,7 @@ public Object getServerGuiElement(int ID, EntityPlayer player, World world, int case PIPE_DIST: return new ContainerDistributionPipe((PipeBehaviorDistribution) ((TilePipeHolder) tile).getPipe().getBehaviour()); case PIPE_WOODEN_ADV: - return new ContainerAdvancedWoodPipe(player, player.inventory, (PipeBehaviorAdvWood) ((TilePipeHolder) tile).getPipe().getBehaviour()); + return new ContainerAdvancedWoodPipe(player, (PipeBehaviorAdvWood) ((TilePipeHolder) tile).getPipe().getBehaviour()); case PIPE_CLOSED: return new ContainerPipeClosed(player, (PipeBehaviorClosed) ((TilePipeHolder) tile).getPipe().getBehaviour()); case PIPE_PRIORITY: @@ -67,7 +67,7 @@ public Object getClientGuiElement(int ID, EntityPlayer player, World world, int case PIPE_DIST: return new GuiDistributionPipe((PipeBehaviorDistribution) ((TilePipeHolder) tile).getPipe().getBehaviour()); case PIPE_WOODEN_ADV: - return new GuiAdvancedWoodPipe(player, player.inventory, (PipeBehaviorAdvWood) ((TilePipeHolder) tile).getPipe().getBehaviour()); + return new GuiAdvancedWoodPipe(player, (PipeBehaviorAdvWood) ((TilePipeHolder) tile).getPipe().getBehaviour()); case PIPE_CLOSED: return new GuiPipeClosed(player, (PipeBehaviorClosed) ((TilePipeHolder) tile).getPipe().getBehaviour()); case PIPE_PRIORITY: diff --git a/src/main/java/buildcraft/additionalpipes/gui/GuiTeleportPipe.java b/src/main/java/buildcraft/additionalpipes/gui/GuiTeleportPipe.java index e23122a..2972e02 100644 --- a/src/main/java/buildcraft/additionalpipes/gui/GuiTeleportPipe.java +++ b/src/main/java/buildcraft/additionalpipes/gui/GuiTeleportPipe.java @@ -1,5 +1,10 @@ package buildcraft.additionalpipes.gui; +import buildcraft.additionalpipes.utils.TranslationKeys; +import buildcraft.api.core.render.ISprite; +import buildcraft.lib.misc.SpriteUtil; +import com.mojang.authlib.GameProfile; +import net.minecraft.util.EnumFacing; import org.lwjgl.opengl.GL11; import buildcraft.additionalpipes.network.PacketHandler; @@ -16,6 +21,8 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; +import java.util.Objects; + @SideOnly(Side.CLIENT) public class GuiTeleportPipe extends GuiBC8 { @@ -30,9 +37,9 @@ protected class TeleportPipeLedger extends Ledger_Neptune public TeleportPipeLedger() { super(GuiTeleportPipe.this.mainGui, OVERLAY_COLOR, true); - this.title = "gui.teleport.ledger.title"; + this.title = TranslationKeys.TELEPORT_LEDGER_TITLE; - appendText(() -> ((pipe.state & 0x1) >= 1) ? I18n.format("gui.teleport.ledger.outputs", container.connectedPipes) : I18n.format("gui.teleport.ledger.inputs", container.connectedPipes), headerColour); + appendText(() -> ((pipe.getState() & 0x1) >= 1) ? I18n.format(TranslationKeys.TELEPORT_LEDGER_OUTPUT, container.connectedPipes) : I18n.format(TranslationKeys.TELEPORT_LEDGER_INPUT, container.connectedPipes), headerColour); // print up to the first 3 connected pipes, with 3 coords each for(int coordIndex = 0; coordIndex < 3; coordIndex += 3) @@ -41,9 +48,9 @@ public TeleportPipeLedger() { appendText( () -> { StringBuilder text = new StringBuilder(); - if(pipe.network.length >= capturedIdx + 2) + if(pipe.getNetwork().length >= capturedIdx + 2) { - text.append("(").append(pipe.network[capturedIdx]).append(", ").append(pipe.network[capturedIdx + 1]).append(", ").append(pipe.network[capturedIdx + 2]).append(")"); + text.append("(").append(pipe.getNetwork()[capturedIdx]).append(", ").append(pipe.getNetwork()[capturedIdx + 1]).append(", ").append(pipe.getNetwork()[capturedIdx + 2]).append(")"); } return text.toString(); @@ -63,74 +70,138 @@ protected void drawIcon(double x, double y) } + protected class LedgerPipeOwnership extends Ledger_Neptune { + + final static int OVERLAY_COLOR = 0xFF_E0_F0_FF; + + public LedgerPipeOwnership() { + super(GuiTeleportPipe.this.mainGui, OVERLAY_COLOR, true); + this.title = TranslationKeys.TELEPORT_LEDGER_OWNERSHIP; + + appendText(() -> ((!Objects.equals(pipe.getOwnerName(), ""))? pipe.getOwnerName() : TranslationKeys.TELEPORT_LEDGER_NO_OWNER), 0); + + calculateMaxSize(); + } + + @Override + protected void drawIcon(double x, double y) { + if (pipe.getOwnerUUID() != null){ + GameProfile ownerProfile = new GameProfile(pipe.getOwnerUUID(), pipe.getOwnerName()); + ISprite sprite = SpriteUtil.getFaceSprite(ownerProfile); + GuiIcon.draw(sprite, x, y, x + 16, y + 16); + sprite = SpriteUtil.getFaceSprite(ownerProfile); + if (sprite != null) { + GuiIcon.draw(sprite, x - 0.5, y - 0.5, x + 17, y + 17); + } + } + } + } + + protected enum BtnIndex{ + FreqNeg100, FreqNeg10, FreqNeg1, FreqPos1, FreqPos10, FreqPos100, Mode, IsPublic, TP_Side + } + private final PipeBehaviorTeleport pipe; private final ContainerTeleportPipe container; - private final GuiButton[] buttons = new GuiButton[8]; + private final GuiButton[] buttons = new GuiButton[BtnIndex.values().length]; public GuiTeleportPipe(EntityPlayer player, PipeBehaviorTeleport pipe) { super(new ContainerTeleportPipe(player, pipe)); this.pipe = pipe; container = (ContainerTeleportPipe) inventorySlots; xSize = 228; - ySize = 117; - + ySize = 127; + + if (pipe.getOwnerUUID() != null){ + mainGui.shownElements.add(new LedgerPipeOwnership());} + mainGui.shownElements.add(new TeleportPipeLedger()); } + //Removes the help button top left of the gui, as it does nothing but take up space + @Override + protected boolean shouldAddHelpLedger() { + return false; + } + @Override public void initGui() { super.initGui(); int x = (width - xSize) / 2; int bw = xSize - 24; + int btnHeight = 20; + int ID = 0; final int freqButtonTop = 78; - buttonList.add(buttons[0] = new GuiButton(1, x + 12, guiTop + freqButtonTop, bw / 6, 20, "-100")); - buttonList.add(buttons[1] = new GuiButton(2, x + 12 + bw / 6, guiTop + freqButtonTop, bw / 6, 20, "-10")); - buttonList.add(buttons[2] = new GuiButton(3, x + 12 + bw * 2 / 6, guiTop + freqButtonTop, bw / 6, 20, "-1")); - buttonList.add(buttons[3] = new GuiButton(4, x + 12 + bw * 3 / 6, guiTop + freqButtonTop, bw / 6, 20, "+1")); - buttonList.add(buttons[4] = new GuiButton(5, x + 12 + bw * 4 / 6, guiTop + freqButtonTop, bw / 6, 20, "+10")); - buttonList.add(buttons[5] = new GuiButton(6, x + 12 + bw * 5 / 6, guiTop + freqButtonTop, bw / 6, 20, "+100")); - - buttonList.add(buttons[6] = new GuiButton(7, x + 12, guiTop + 35, bw / 2, 20, "")); - buttonList.add(buttons[7] = new GuiButton(8, x + 12 + bw * 3 / 6, guiTop + 35, bw / 2, 20, "")); + buttonList.add(buttons[BtnIndex.FreqNeg100.ordinal()] = new GuiButton(++ID, x + 12, guiTop + freqButtonTop, bw / 6, btnHeight, "-100")); + buttonList.add(buttons[BtnIndex.FreqNeg10.ordinal()] = new GuiButton(++ID, x + 12 + bw / 6, guiTop + freqButtonTop, bw / 6, btnHeight, "-10")); + buttonList.add(buttons[BtnIndex.FreqNeg1.ordinal()] = new GuiButton(++ID, x + 12 + bw * 2 / 6, guiTop + freqButtonTop, bw / 6, btnHeight, "-1")); + buttonList.add(buttons[BtnIndex.FreqPos1.ordinal()] = new GuiButton(++ID, x + 12 + bw * 3 / 6, guiTop + freqButtonTop, bw / 6, btnHeight, "+1")); + buttonList.add(buttons[BtnIndex.FreqPos10.ordinal()] = new GuiButton(++ID, x + 12 + bw * 4 / 6, guiTop + freqButtonTop, bw / 6, btnHeight, "+10")); + buttonList.add(buttons[BtnIndex.FreqPos100.ordinal()] = new GuiButton(++ID, x + 12 + bw * 5 / 6, guiTop + freqButtonTop, bw / 6, btnHeight, "+100")); + + buttonList.add(buttons[BtnIndex.Mode.ordinal()] = new GuiButton(++ID, x + 12, guiTop + 35, bw / 2, 20, "")); + buttonList.add(buttons[BtnIndex.IsPublic.ordinal()] = new GuiButton(++ID, x + 12 + bw * 3 / 6, guiTop + 35, bw / 2, 20, "")); + buttonList.add(buttons[BtnIndex.TP_Side.ordinal()] = new GuiButton(++ID, x + 12, guiTop + 100, (xSize - 24), btnHeight, "")); } @Override protected void drawForegroundLayer() { fontRenderer.drawString(I18n.format(pipe.getUnlocalizedName()), guiLeft + 70, guiTop + 6, 0x0a0c84, false); - fontRenderer.drawString(I18n.format("gui.teleport.frequency", pipe.getFrequency()), guiLeft + 16, guiTop + 66, 0x404040); - fontRenderer.drawString(I18n.format("gui.teleport.coordPair", pipe.getPos().getX(), pipe.getPos().getY(), pipe.getPos().getZ()), guiLeft + 110, guiTop + 20, 0x404040); + fontRenderer.drawString(I18n.format(TranslationKeys.TELEPORT_FREQ, pipe.getFrequency()), guiLeft + 16, guiTop + 66, 0x404040); + fontRenderer.drawString(I18n.format(TranslationKeys.TELEPORT_COORDS, pipe.getPos().getX(), pipe.getPos().getY(), pipe.getPos().getZ()), guiLeft + 12, guiTop + 20, 0x404040); - fontRenderer.drawString(I18n.format("gui.teleport.ledger.owner", pipe.ownerName), guiLeft + 12, guiTop + 20, 0x404040); + //fontRenderer.drawString(I18n.format(TranslationKeys.TELEPORT_LEDGER_OWNER, pipe.getOwnerName()), guiLeft + 12, guiTop + 20, 0x404040); - switch(pipe.state) { + switch(pipe.getState()) { case 3: - buttons[6].displayString = I18n.format("gui.teleport.send_and_receive"); + buttons[BtnIndex.Mode.ordinal()].displayString = I18n.format(TranslationKeys.TELEPORT_SEND_RECEIVE); break; case 2: - buttons[6].displayString = I18n.format("gui.teleport.receive_only"); + buttons[BtnIndex.Mode.ordinal()].displayString = I18n.format(TranslationKeys.TELEPORT_RECEIVE_ONLY); break; case 1: - buttons[6].displayString = I18n.format("gui.teleport.send_only"); + buttons[BtnIndex.Mode.ordinal()].displayString = I18n.format(TranslationKeys.TELEPORT_SEND_ONLY); break; default: - buttons[6].displayString = I18n.format("gui.teleport.disabled"); + buttons[BtnIndex.Mode.ordinal()].displayString = I18n.format(TranslationKeys.TELEPORT_DISABLED); break; } - if(pipe.isPublic) { - buttons[7].displayString = I18n.format("gui.teleport.public"); + + if(pipe.isPublic()) { + buttons[BtnIndex.IsPublic.ordinal()].displayString = I18n.format(TranslationKeys.TELEPORT_PUBLIC); } else { - buttons[7].displayString = I18n.format("gui.teleport.private"); + buttons[BtnIndex.IsPublic.ordinal()].displayString = I18n.format(TranslationKeys.TELEPORT_PRIVATE); + } + + if (pipe.getTeleportSide() == EnumFacing.DOWN){ + buttons[BtnIndex.TP_Side.ordinal()].displayString = I18n.format(TranslationKeys.SIDE_DOWN);} + else if (pipe.getTeleportSide() == EnumFacing.UP) { + buttons[BtnIndex.TP_Side.ordinal()].displayString = I18n.format(TranslationKeys.SIDE_UP); + } + else if (pipe.getTeleportSide() == EnumFacing.NORTH) { + buttons[BtnIndex.TP_Side.ordinal()].displayString = I18n.format(TranslationKeys.SIDE_NORTH); + } + else if (pipe.getTeleportSide() == EnumFacing.SOUTH) { + buttons[BtnIndex.TP_Side.ordinal()].displayString = I18n.format(TranslationKeys.SIDE_SOUTH); + } + else if (pipe.getTeleportSide() == EnumFacing.WEST) { + buttons[BtnIndex.TP_Side.ordinal()].displayString = I18n.format(TranslationKeys.SIDE_WEST); + } + else if (pipe.getTeleportSide() == EnumFacing.EAST) { + buttons[BtnIndex.TP_Side.ordinal()].displayString = I18n.format(TranslationKeys.SIDE_EAST); } } @Override protected void actionPerformed(GuiButton guibutton) { int freq = pipe.getFrequency(); - byte state = pipe.state; - boolean isPublic = pipe.isPublic; + byte state = pipe.getState(); + boolean isPublic = pipe.isPublic(); + byte tpSide = (byte) pipe.getTeleportSide().ordinal(); + switch(guibutton.id) { case 1: freq -= 100; @@ -156,12 +227,19 @@ protected void actionPerformed(GuiButton guibutton) { case 8: isPublic = !isPublic; break; + case 9: + tpSide += 1; } if(freq < 0) { freq = 0; + } else if (freq >= Integer.MAX_VALUE - 101) { + freq = Integer.MAX_VALUE -101; } - MessageTelePipeUpdate packet = new MessageTelePipeUpdate(pipe.getPos(), freq, isPublic, state); + if (tpSide >= EnumFacing.values().length){ + tpSide = 0;} + + MessageTelePipeUpdate packet = new MessageTelePipeUpdate(pipe.getPos(), freq, isPublic, state, EnumFacing.values()[tpSide]); PacketHandler.INSTANCE.sendToServer(packet); } diff --git a/src/main/java/buildcraft/additionalpipes/network/message/MessageTelePipeData.java b/src/main/java/buildcraft/additionalpipes/network/message/MessageTelePipeData.java index e027e67..176b8bc 100644 --- a/src/main/java/buildcraft/additionalpipes/network/message/MessageTelePipeData.java +++ b/src/main/java/buildcraft/additionalpipes/network/message/MessageTelePipeData.java @@ -68,9 +68,9 @@ public IMessage onMessage(MessageTelePipeData message, MessageContext ctx) TileEntity te = FMLClientHandler.instance().getClient().world.getTileEntity(message.position); PipeBehaviorTeleport pipe = (PipeBehaviorTeleport) ((TilePipeHolder) te).getPipe().getBehaviour(); - pipe.ownerUUID = UUID.fromString(message.ownerUUID); - pipe.ownerName = message.ownerName; - pipe.network = message.locations; + pipe.setOwnerUUID(UUID.fromString(message.ownerUUID)); + pipe.setOwnerName(message.ownerName); + pipe.setNetwork(message.locations); return null; } diff --git a/src/main/java/buildcraft/additionalpipes/network/message/MessageTelePipeUpdate.java b/src/main/java/buildcraft/additionalpipes/network/message/MessageTelePipeUpdate.java index 3189c5e..6dd58be 100644 --- a/src/main/java/buildcraft/additionalpipes/network/message/MessageTelePipeUpdate.java +++ b/src/main/java/buildcraft/additionalpipes/network/message/MessageTelePipeUpdate.java @@ -5,6 +5,7 @@ import io.netty.buffer.ByteBuf; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.TextComponentString; import net.minecraftforge.fml.common.network.simpleimpl.IMessage; @@ -21,18 +22,20 @@ public class MessageTelePipeUpdate implements IMessage, IMessageHandler 5){ + tpSide = EnumFacing.values()[EnumFacing.DOWN.ordinal()]; + } pipe.setFrequency(frequency); - pipe.state = (byte) message._state; - pipe.isPublic = message._isPublic; + pipe.setState(message._state); + pipe.setPublic(message._isPublic); + pipe.setTeleportSide(tpSide); } return null; diff --git a/src/main/java/buildcraft/additionalpipes/pipes/PipeBehaviorDistribution.java b/src/main/java/buildcraft/additionalpipes/pipes/PipeBehaviorDistribution.java index 2cd9390..bc989bd 100644 --- a/src/main/java/buildcraft/additionalpipes/pipes/PipeBehaviorDistribution.java +++ b/src/main/java/buildcraft/additionalpipes/pipes/PipeBehaviorDistribution.java @@ -106,6 +106,13 @@ public void splitStacks(PipeEventItem.Split splitEvent) entry.stack.setCount(entry.stack.getCount() - stackPartThisSide.stack.getCount()); // and leave event.stack with the remainder newDistribution.add(stackPartThisSide); + + + //Fix Stall + if (stackPartThisSide.stack.isEmpty()) { + break; + } + itemsThisSide += stackPartThisSide.stack.getCount(); stackPartThisSide.to.add(distSide); } diff --git a/src/main/java/buildcraft/additionalpipes/pipes/PipeBehaviorSwitch.java b/src/main/java/buildcraft/additionalpipes/pipes/PipeBehaviorSwitch.java index 000a6db..419ea84 100644 --- a/src/main/java/buildcraft/additionalpipes/pipes/PipeBehaviorSwitch.java +++ b/src/main/java/buildcraft/additionalpipes/pipes/PipeBehaviorSwitch.java @@ -1,7 +1,6 @@ package buildcraft.additionalpipes.pipes; import buildcraft.api.transport.pipe.IPipe; -import buildcraft.api.transport.pipe.IPipeHolder.PipeMessageReceiver; import buildcraft.api.transport.pipe.PipeBehaviour; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.PacketBuffer; @@ -49,19 +48,9 @@ public void onTick() if(canConnect != newCanConnect) { canConnect = newCanConnect; - pipe.getHolder().scheduleNetworkUpdate(PipeMessageReceiver.BEHAVIOUR); + pipe.markForUpdate(); } } - - - - /* - @Override - public boolean canConnectRedstone() { - return true; - } - */ - @Override public void writePayload(PacketBuffer buffer, Side side) diff --git a/src/main/java/buildcraft/additionalpipes/pipes/PipeBehaviorTeleport.java b/src/main/java/buildcraft/additionalpipes/pipes/PipeBehaviorTeleport.java index a70407c..9a3848d 100644 --- a/src/main/java/buildcraft/additionalpipes/pipes/PipeBehaviorTeleport.java +++ b/src/main/java/buildcraft/additionalpipes/pipes/PipeBehaviorTeleport.java @@ -1,6 +1,5 @@ package buildcraft.additionalpipes.pipes; -import java.util.Objects; import java.util.Random; import java.util.UUID; @@ -10,6 +9,8 @@ import buildcraft.additionalpipes.gui.GuiHandler; import buildcraft.additionalpipes.utils.Log; import buildcraft.additionalpipes.utils.PlayerUtils; +import buildcraft.additionalpipes.utils.TagStrings; +import buildcraft.additionalpipes.utils.TranslationKeys; import buildcraft.api.core.EnumPipePart; import buildcraft.api.transport.pipe.IPipe; import buildcraft.api.transport.pipe.PipeBehaviour; @@ -19,8 +20,10 @@ import buildcraft.transport.tile.TilePipeHolder; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.text.TextComponentTranslation; @@ -30,26 +33,41 @@ public abstract class PipeBehaviorTeleport extends APPipe implements ITeleportPi protected static final Random rand = new Random(); private int frequency = 0; + public enum States { + NONE, + SEND, + RECEIVE, + SEND_AND_RECEIVE; + + public static final States[] VALUES = new States[3]; + + public static States byIndex(int index) + { + return VALUES[MathHelper.abs(index % VALUES.length)]; + } + } // 0b0 = none, 0b1 = send, 0b10 = receive, 0b11 = both - public byte state = 1; + protected States state = States.SEND; + protected UUID ownerUUID; + protected String ownerName = ""; + + protected int[] network = new int[0]; // coordinates of connected pipes. Used as a sort of cache variable by the teleport pipe GUI. + protected boolean isPublic = false; + protected UUID pipeUUID; + protected EnumFacing teleportSide; - public UUID ownerUUID; - public String ownerName = ""; - - public int[] network = new int[0]; // coordinates of connected pipes. Used as a sort of cache variable by the teleport pipe GUI. - public boolean isPublic = false; - public final TeleportPipeType type; public PipeBehaviorTeleport(IPipe pipe, TeleportPipeType type) { super(pipe); this.type = type; - - if(isServer()) + this.pipeUUID = UUID.randomUUID(); + teleportSide = EnumFacing.UP; +/* if(isServer()) { TeleportManager.instance.add(this, frequency); - } + }*/ } @@ -58,30 +76,38 @@ public PipeBehaviorTeleport(IPipe pipe, NBTTagCompound tagCompound, TeleportPipe super(pipe, tagCompound); this.type = type; - frequency = tagCompound.getInteger("freq"); - state = tagCompound.getByte("state"); - if(tagCompound.hasKey("ownerUUID")) + frequency = tagCompound.getInteger(TagStrings.FREQ); + state = States.values()[tagCompound.getByte(TagStrings.STATE)]; + if(tagCompound.hasKey(TagStrings.OWNER_UUID)) { - ownerUUID = UUID.fromString(tagCompound.getString("ownerUUID")); - ownerName = tagCompound.getString("ownerName"); + ownerUUID = UUID.fromString(tagCompound.getString(TagStrings.OWNER_UUID)); + ownerName = tagCompound.getString(TagStrings.OWNER_NAME); } - isPublic = tagCompound.getBoolean("isPublic"); - - if(isServer()) - { - TeleportManager.instance.add(this, frequency); + isPublic = tagCompound.getBoolean(TagStrings.IS_PUBLIC); + + if (tagCompound.hasKey(TagStrings.PIPE_UUID)){ + this.pipeUUID = UUID.fromString(tagCompound.getString(TagStrings.PIPE_UUID)); } + else{ + pipeUUID = UUID.randomUUID(); + } + + teleportSide = EnumFacing.VALUES[tagCompound.getByte(TagStrings.TELEPORT_SIDE)]; } @Override public byte getState() { - return state; + return (byte) state.ordinal(); } @Override public void setState(byte state) { + this.state = States.values()[state]; + } + + public void setState(States state) { this.state = state; } @@ -107,6 +133,14 @@ public void setOwnerName(String ownerName) this.ownerName = ownerName; } + public int[] getNetwork() { + return network; + } + + public void setNetwork(int[] network) { + this.network = network; + } + @Override public boolean isPublic() { @@ -118,7 +152,23 @@ public void setPublic(boolean isPublic) { this.isPublic = isPublic; } - + + public UUID getPipeUUID() { + return pipeUUID; + } + + public void setPipeUUID(UUID pipeUUID){ + this.pipeUUID = pipeUUID; + } + + public EnumFacing getTeleportSide() { + return teleportSide; + } + + public void setTeleportSide(EnumFacing teleportSide) { + this.teleportSide = teleportSide; + } + @Override public TeleportPipeType getType() { @@ -151,6 +201,7 @@ public void onValidate(PipeEventTileState.Validate event) if(isServer()) { Log.debug("Teleport pipe at " + getPos() + " validated"); + TeleportManager.instance.add(this, frequency); } } @@ -202,7 +253,7 @@ public boolean onPipeActivate(EntityPlayer player, RayTraceResult trace, float h else { //access denied - player.sendMessage(new TextComponentTranslation("message.ap.accessdenied", ownerName)); + player.sendMessage(new TextComponentTranslation(TranslationKeys.ACCESS_DENIED, ownerName)); //if we return false, this method can get called again with a different side, and it will show the message again return true; @@ -231,26 +282,7 @@ public boolean equals(Object obj) if(obj instanceof ITeleportPipe) { ITeleportPipe pipe = (ITeleportPipe)obj; - - if(pipe.getType() == getType()) - { - if(pipe.getState() == getState()) - { - if(pipe.isPublic() == isPublic()) - { - if(Objects.equals(pipe.getOwnerUUID(), getOwnerUUID())) - { - if(Objects.equals(pipe.getPosition(), getPosition())) - { - if(pipe.getFrequency() == getFrequency()) - { - return true; - } - } - } - } - } - } + return pipe.getPipeUUID() == pipeUUID; } return false; @@ -286,24 +318,44 @@ public boolean canConnect(EnumFacing face, PipeBehaviour other) { return false; } + + if (face == EnumFacing.VALUES[teleportSide.ordinal()]){ + return false; + } return super.canConnect(face, other); } - + + @Override + public boolean canConnect(EnumFacing face, TileEntity oTile) { + if (face == EnumFacing.VALUES[teleportSide.ordinal()]){ + return false; + } + + return super.canConnect(face, oTile); + } @Override public NBTTagCompound writeToNbt() { NBTTagCompound nbttagcompound = super.writeToNbt(); - nbttagcompound.setInteger("freq", frequency); - nbttagcompound.setByte("state", state); + nbttagcompound.setInteger(TagStrings.FREQ, frequency); + nbttagcompound.setByte(TagStrings.STATE, (byte) state.ordinal()); if(ownerUUID != null) { - nbttagcompound.setString("ownerUUID", ownerUUID.toString()); - nbttagcompound.setString("ownerName", ownerName); + nbttagcompound.setString(TagStrings.OWNER_UUID, ownerUUID.toString()); + nbttagcompound.setString(TagStrings.OWNER_NAME, ownerName); + } + nbttagcompound.setBoolean(TagStrings.IS_PUBLIC, isPublic); + + if (pipeUUID != null){ + nbttagcompound.setString(TagStrings.PIPE_UUID, pipeUUID.toString()); + } + + if(teleportSide != null) + { + nbttagcompound.setByte(TagStrings.TELEPORT_SIDE, (byte) teleportSide.ordinal()); } - nbttagcompound.setBoolean("isPublic", isPublic); - return nbttagcompound; } @@ -321,12 +373,12 @@ public BlockPos getPosition() { @Override public boolean canReceive() { - return (state & 0x2) > 0; + return (state.ordinal() & States.RECEIVE.ordinal()) > 0; } @Override public boolean canSend() { - return (state & 0x1) > 0; + return (state.ordinal() & States.SEND.ordinal()) > 0; } } diff --git a/src/main/java/buildcraft/additionalpipes/pipes/PipeBehaviorTeleportFluids.java b/src/main/java/buildcraft/additionalpipes/pipes/PipeBehaviorTeleportFluids.java index 9d50ca7..209c27a 100644 --- a/src/main/java/buildcraft/additionalpipes/pipes/PipeBehaviorTeleportFluids.java +++ b/src/main/java/buildcraft/additionalpipes/pipes/PipeBehaviorTeleportFluids.java @@ -60,7 +60,7 @@ public void preMoveCenter(PipeEventFluid.PreMoveToCentre event) for(EnumFacing side : EnumFacing.VALUES) { int fluidFromThisSide = Math.min(event.totalOffered[side.ordinal()], totalMBNeeded); - + event.actuallyOffered[side.ordinal()] = fluidFromThisSide; totalMBNeeded -= fluidFromThisSide; } @@ -74,15 +74,21 @@ public void onMoveCenter(PipeEventFluid.OnMoveToCentre event) if(canSend()) { ArrayList connectedPipes = (ArrayList)TeleportManager.instance.getConnectedPipes(this, false, true); + + + int totalRecieved = 0; + for (EnumFacing side : EnumFacing.VALUES){ + if (side == teleportSide){continue;} + totalRecieved += event.fluidEnteringCentre[side.ordinal()]; + } + + Log.debug("[FluidTeleportPipe] Got " + totalRecieved + " MB of fluid"); - Log.debug("[FluidTeleportPipe] Got " + event.fluid.amount + " MB of fluid"); - - FluidStack remaining = event.fluid.copy(); + FluidStack remaining = new FluidStack(event.fluid.getFluid(), totalRecieved); // loop until we're out of fluid, or until no pipes need it while(remaining.amount > 0 && connectedPipes.size() > 0) { - // divide the fluid into apportionments for each pipe FluidStack maxPerIteration = remaining.copy(); maxPerIteration.amount /= connectedPipes.size(); // it's OK if we have rounding errors, it will get resolved eventually @@ -110,7 +116,7 @@ public void onMoveCenter(PipeEventFluid.OnMoveToCentre event) if(remaining.amount > 0) { - Log.debug("PipeLiquidsTeleport's PreMoveToCentre event handler requested more fluid than can be handled! " + remaining.amount + " MB is left and will be rejected."); + Log.warn("PipeLiquidsTeleport's PreMoveToCentre event handler requested more fluid than can be handled! " + remaining.amount + " MB is left and will be rejected."); } // update event data diff --git a/src/main/java/buildcraft/additionalpipes/pipes/PipeBehaviorTeleportItems.java b/src/main/java/buildcraft/additionalpipes/pipes/PipeBehaviorTeleportItems.java index b6e1257..63ca89b 100644 --- a/src/main/java/buildcraft/additionalpipes/pipes/PipeBehaviorTeleportItems.java +++ b/src/main/java/buildcraft/additionalpipes/pipes/PipeBehaviorTeleportItems.java @@ -14,7 +14,6 @@ import buildcraft.additionalpipes.api.TeleportPipeType; import buildcraft.additionalpipes.utils.Log; import buildcraft.api.transport.pipe.IPipe; -import buildcraft.api.transport.pipe.PipeBehaviour; import buildcraft.api.transport.pipe.PipeEventHandler; import buildcraft.api.transport.pipe.PipeEventItem; import buildcraft.transport.pipe.flow.PipeFlowItems; @@ -27,13 +26,10 @@ public class PipeBehaviorTeleportItems extends PipeBehaviorTeleport final private static double TELEPORTED_ITEM_SPEED = .1; // side of the pipe that teleported items enter and exit from - private EnumFacing teleportSide = null; public PipeBehaviorTeleportItems(IPipe pipe, NBTTagCompound tagCompound) { super(pipe, tagCompound, TeleportPipeType.ITEMS); - - teleportSide = EnumFacing.VALUES[tagCompound.getByte("teleportSide")]; } public PipeBehaviorTeleportItems(IPipe pipe) @@ -41,91 +37,6 @@ public PipeBehaviorTeleportItems(IPipe pipe) super(pipe, TeleportPipeType.ITEMS); } - @Override - public NBTTagCompound writeToNbt() - { - NBTTagCompound nbt = super.writeToNbt(); - - if(getTeleportSide() != null) - { - nbt.setByte("teleportSide", (byte) getTeleportSide().ordinal()); - } - - return nbt; - } - - @Override - public boolean canConnect(EnumFacing face, PipeBehaviour other) - { - // can't connect to all 6 sides since one side has to be the teleport side - int numConnectedSides = 0; - for(EnumFacing direction : EnumFacing.VALUES) - { - if(pipe.isConnected(direction)) - { - ++numConnectedSides; - } - } - - if(numConnectedSides >= 5) - { - return false; - } - - return super.canConnect(face, other); - } - - /** - * Get the side of the pipe that items are teleported into and out of. - * Items that come from this side are not teleported again. - * - * The teleport side will change only if a pipe is connected to teleportSide, or disconnected from the opposite of teleportSide. - * - * If this returns null, then the pipe is connected on no sides. - * @return - */ - public EnumFacing getTeleportSide() - { - // teleportSide can only be calculated on the server - if(isClient()) - { - return null; - } - - // check if we need to recalculate the teleport side - if(teleportSide == null || pipe.isConnected(teleportSide) || !pipe.isConnected(teleportSide.getOpposite())) - { - Log.debug("[ItemTeleportPipe]" + getPosition().toString() + " Recalculating teleport side..."); - teleportSide = null; - - boolean allSidesConnected = true; - - // for recalculation: - // find the first unconnected side that is opposite to a connected side - for(EnumFacing side : EnumFacing.VALUES) - { - //Log.debug("isConnected(" + side + ") = " + pipe.isConnected(side)); - if(!pipe.isConnected(side) && pipe.isConnected(side.getOpposite())) - { - teleportSide = side; - break; - } - - allSidesConnected = allSidesConnected && pipe.isConnected(side); - } - - if(teleportSide == null && allSidesConnected) - { - // should never happen -- just arbitrarily choose down. - teleportSide = EnumFacing.DOWN; - } - - Log.debug("[ItemTeleportPipe]" + getPosition().toString() + " Teleport side set to " + String.valueOf(teleportSide)); - - } - - return teleportSide; - } @SuppressWarnings({ "unchecked", "rawtypes" }) @PipeEventHandler @@ -146,7 +57,7 @@ public void onReachCenter(PipeEventItem.ReachCenter event) ArrayList connectedTeleportPipes = (ArrayList)TeleportManager.instance.getConnectedPipes(this, false, true); // no teleport pipes connected, use default - if(connectedTeleportPipes.size() <= 0 || (state & 0x1) == 0) { + if(connectedTeleportPipes.size() <= 0 || (state.ordinal() & States.SEND.ordinal()) == 0) { return; } diff --git a/src/main/java/buildcraft/additionalpipes/pipes/PipeBehaviorTeleportPower.java b/src/main/java/buildcraft/additionalpipes/pipes/PipeBehaviorTeleportPower.java index 6c700f9..9f2c96d 100644 --- a/src/main/java/buildcraft/additionalpipes/pipes/PipeBehaviorTeleportPower.java +++ b/src/main/java/buildcraft/additionalpipes/pipes/PipeBehaviorTeleportPower.java @@ -101,7 +101,7 @@ public int receivePower(EnumFacing from, long energy) List sendingToList = new LinkedList(); // no connected pipes, leave! - if(connectedPipes.size() <= 0 || (state & 0x1) == 0) + if(connectedPipes.size() <= 0 || (state.ordinal() & States.SEND.ordinal()) == 0) { return 0; } @@ -139,7 +139,6 @@ public int receivePower(EnumFacing from, long energy) if(powerEntry.isPipe) { PipeFlowPower nearbyFlow = (PipeFlowPower)(((TilePipeHolder)powerEntry.tile).getPipe().getFlow()); - // will uncomment when Buildcraft API is added //nearbyFlow.addPower(powerEntry.orientation, dividedPowerToSend); } diff --git a/src/main/java/buildcraft/additionalpipes/pipes/TeleportManager.java b/src/main/java/buildcraft/additionalpipes/pipes/TeleportManager.java index 5e465da..b76f7d8 100644 --- a/src/main/java/buildcraft/additionalpipes/pipes/TeleportManager.java +++ b/src/main/java/buildcraft/additionalpipes/pipes/TeleportManager.java @@ -52,7 +52,6 @@ private Collection getPipesInChannel(int frequency, TeleportPipeT @Override public void add(ITeleportPipe newPipe, int frequency) { - Collection pipesInChannel = pipes.get(newPipe.getType()).get(frequency); // check if this pipe was left in the teleport manager because it didn't unload cleanly for some reason @@ -60,7 +59,7 @@ public void add(ITeleportPipe newPipe, int frequency) for(Iterator pipesIter = pipesInChannel.iterator(); pipesIter.hasNext(); ) { ITeleportPipe pipe = pipesIter.next(); - if(pipe.equals(newPipe)) + if(pipe.getPipeUUID() == newPipe.getPipeUUID()) { pipesIter.remove(); } @@ -84,8 +83,9 @@ public void remove(ITeleportPipe pipeToRemove, int frequency) // Remove all pipes matching the one provided for(Iterator pipesIter = pipesInChannel.iterator(); pipesIter.hasNext(); ) { + ITeleportPipe pipe = pipesIter.next(); - if(pipe.equals(pipeToRemove)) + if(pipe.getPipeUUID() == pipeToRemove.getPipeUUID()) { pipesIter.remove(); } diff --git a/src/main/java/buildcraft/additionalpipes/test/TeleportManagerTest.java b/src/main/java/buildcraft/additionalpipes/test/TeleportManagerTest.java index 67cc4c5..15e52a1 100644 --- a/src/main/java/buildcraft/additionalpipes/test/TeleportManagerTest.java +++ b/src/main/java/buildcraft/additionalpipes/test/TeleportManagerTest.java @@ -3,6 +3,7 @@ import java.util.ArrayList; import java.util.UUID; +import buildcraft.additionalpipes.pipes.PipeBehaviorTeleport.States; import buildcraft.additionalpipes.pipes.PipeBehaviorTeleportItems; import buildcraft.additionalpipes.pipes.TeleportManager; import buildcraft.additionalpipes.utils.Log; @@ -107,17 +108,17 @@ public static boolean testGetConnectedPipesBasic() pipe2.setFrequency(3); pipe3.setFrequency(3); - pipe1.state = 0x3; - pipe2.state = 0x3; - pipe3.state = 0x3; + pipe1.setState(States.SEND_AND_RECEIVE);; + pipe2.setState(States.SEND_AND_RECEIVE);; + pipe3.setState(States.SEND_AND_RECEIVE);; - pipe1.ownerUUID = UUID.randomUUID(); - pipe2.ownerUUID = UUID.randomUUID(); - pipe3.ownerUUID = UUID.randomUUID(); + pipe1.setOwnerUUID(UUID.randomUUID()); + pipe2.setOwnerUUID(UUID.randomUUID()); + pipe3.setOwnerUUID(UUID.randomUUID()); - pipe1.isPublic = true; - pipe2.isPublic = true; - pipe3.isPublic = true; + pipe1.setPublic(true); + pipe2.setPublic(true); + pipe3.setPublic(true); TeleportManager.instance.add(pipe1, 3); TeleportManager.instance.add(pipe2, 3); @@ -144,28 +145,31 @@ public static boolean testDuplicateRemoval() PipeBehaviorTeleportItems pipe2 = new PipeBehaviorTeleportItems(null); PipeBehaviorTeleportItems pipe3 = new PipeBehaviorTeleportItems(null); + pipe1.setFrequency(3); pipe2.setFrequency(3); pipe3.setFrequency(3); - pipe1.state = 0x3; - pipe2.state = 0x3; - pipe3.state = 0x3; - - pipe1.ownerUUID = UUID.randomUUID(); - pipe2.ownerUUID = UUID.randomUUID(); - pipe3.ownerUUID = pipe2.ownerUUID; // Muahahahah! I am a glitched duplicate, bet you can't remove me! + pipe1.setState(States.SEND_AND_RECEIVE); + pipe2.setState(States.SEND_AND_RECEIVE); + pipe3.setState(States.SEND_AND_RECEIVE); - pipe1.isPublic = true; - pipe2.isPublic = true; - pipe3.isPublic = true; + pipe1.setOwnerUUID(UUID.randomUUID()); + pipe2.setOwnerUUID(pipe1.getOwnerUUID()); + pipe3.setOwnerUUID(pipe2.getOwnerUUID()); + + pipe1.setPublic(true); + pipe2.setPublic(true); + pipe3.setPublic(true); + + pipe3.setPipeUUID(pipe2.getPipeUUID()); // Muahahahah! I am a glitched duplicate, bet you can't remove me! TeleportManager.instance.add(pipe1, 3); TeleportManager.instance.add(pipe3, 3); TeleportManager.instance.add(pipe2, 3); ArrayList pipesList = (ArrayList)TeleportManager.instance.getConnectedPipes(pipe1, true, true); - + if(!(pipesList.size() == 1 && (pipesList.contains(pipe2)))) { return false; @@ -196,17 +200,17 @@ public static boolean testGetConnectedPipesSendReceive() pipe2.setFrequency(3); pipe3.setFrequency(3); - pipe1.state = 0x3; - pipe2.state = 0x1; - pipe3.state = 0x2; - - pipe1.ownerUUID = UUID.randomUUID(); - pipe2.ownerUUID = UUID.randomUUID(); - pipe3.ownerUUID = UUID.randomUUID(); + pipe1.setState(States.SEND_AND_RECEIVE); + pipe2.setState(States.SEND); + pipe3.setState(States.RECEIVE); - pipe1.isPublic = true; - pipe2.isPublic = true; - pipe3.isPublic = true; + pipe1.setOwnerUUID(UUID.randomUUID()); + pipe2.setOwnerUUID(UUID.randomUUID()); + pipe3.setOwnerUUID(UUID.randomUUID()); + + pipe1.setPublic(true); + pipe2.setPublic(true); + pipe3.setPublic(true); TeleportManager.instance.add(pipe1, 3); TeleportManager.instance.add(pipe2, 3); @@ -250,23 +254,23 @@ public static boolean testGetConnectedPipesRealUseCase() pipe4.setFrequency(3); pipe5.setFrequency(7); - pipe1.state = 0x1; //send only - pipe2.state = 0x3; //send and receive - pipe3.state = 0x2; //receive only - pipe4.state = 0x1; //send only - pipe5.state = 0x3; //send and receive - - pipe1.isPublic = true; - pipe2.isPublic = true; - pipe3.isPublic = true; - pipe4.isPublic = true; - pipe5.isPublic = true; + pipe1.setState(States.SEND); //send only + pipe2.setState(States.SEND_AND_RECEIVE); //send and receive + pipe3.setState(States.RECEIVE); //receive only + pipe4.setState(States.SEND); //send only + pipe5.setState(States.SEND_AND_RECEIVE); //send and receive + + pipe1.setPublic(true); + pipe2.setPublic(true); + pipe3.setPublic(true); + pipe4.setPublic(true); + pipe5.setPublic(true); - pipe1.ownerUUID = UUID.randomUUID(); - pipe2.ownerUUID = UUID.randomUUID(); - pipe3.ownerUUID = UUID.randomUUID(); - pipe4.ownerUUID = UUID.randomUUID(); - pipe5.ownerUUID = UUID.randomUUID(); + pipe1.setOwnerUUID(UUID.randomUUID()); + pipe2.setOwnerUUID(UUID.randomUUID()); + pipe3.setOwnerUUID(UUID.randomUUID()); + pipe4.setOwnerUUID(UUID.randomUUID()); + pipe5.setOwnerUUID(UUID.randomUUID()); TeleportManager.instance.add(pipe1, 3); TeleportManager.instance.add(pipe2, 3); diff --git a/src/main/java/buildcraft/additionalpipes/textures/Textures.java b/src/main/java/buildcraft/additionalpipes/textures/Textures.java index 1acee98..8acd19b 100644 --- a/src/main/java/buildcraft/additionalpipes/textures/Textures.java +++ b/src/main/java/buildcraft/additionalpipes/textures/Textures.java @@ -13,7 +13,7 @@ public class Textures { public static final String TEXTURE_PATH = "textures"; - public static final ResourceLocation GUI_TELEPORT = new ResourceLocation("additionalpipes", TEXTURE_PATH + "/gui/background_generic.png"); + public static final ResourceLocation GUI_TELEPORT = new ResourceLocation("additionalpipes", TEXTURE_PATH + "/gui/background_generic2.png"); public static final ResourceLocation GUI_ADVANCEDWOOD = new ResourceLocation("additionalpipes", TEXTURE_PATH + "/gui/background_adv_wood.png"); public static final ResourceLocation GUI_DISTRIBUTION = new ResourceLocation("additionalpipes", TEXTURE_PATH + "/gui/background_distribution.png"); public static final ResourceLocation GUI_PRIORITY = new ResourceLocation("additionalpipes", TEXTURE_PATH + "/gui/background_priority.png"); diff --git a/src/main/java/buildcraft/additionalpipes/utils/TagStrings.java b/src/main/java/buildcraft/additionalpipes/utils/TagStrings.java new file mode 100644 index 0000000..b471f13 --- /dev/null +++ b/src/main/java/buildcraft/additionalpipes/utils/TagStrings.java @@ -0,0 +1,11 @@ +package buildcraft.additionalpipes.utils; + +public class TagStrings { + public static final String FREQ = "freq"; + public static final String STATE = "state"; + public static final String OWNER_UUID = "ownerUUID"; + public static final String OWNER_NAME = "ownerName"; + public static final String IS_PUBLIC = "isPublic"; + public static final String PIPE_UUID = "pipeUUID"; + public static final String TELEPORT_SIDE = "teleportSide"; +} diff --git a/src/main/java/buildcraft/additionalpipes/utils/TranslationKeys.java b/src/main/java/buildcraft/additionalpipes/utils/TranslationKeys.java new file mode 100644 index 0000000..f2fdb52 --- /dev/null +++ b/src/main/java/buildcraft/additionalpipes/utils/TranslationKeys.java @@ -0,0 +1,25 @@ +package buildcraft.additionalpipes.utils; + +public class TranslationKeys { + public static final String ACCESS_DENIED = "message.ap.accessdenied"; + public static final String TELEPORT_FREQ = "gui.teleport.frequency"; + public static final String TELEPORT_COORDS = "gui.teleport.coordPair"; + public static final String TELEPORT_LEDGER_OWNER = "gui.teleport.ledger.owner"; + public static final String TELEPORT_LEDGER_NO_OWNER = "gui.teleport.ledger.no_owner"; + public static final String TELEPORT_LEDGER_OWNERSHIP = "gui.teleport.ledger.ownership"; + public static final String TELEPORT_LEDGER_TITLE ="gui.teleport.ledger.title"; + public static final String TELEPORT_LEDGER_OUTPUT = "gui.teleport.ledger.outputs"; + public static final String TELEPORT_LEDGER_INPUT = "gui.teleport.ledger.inputs"; + public static final String TELEPORT_SEND_RECEIVE = "gui.teleport.send_and_receive"; + public static final String TELEPORT_SEND_ONLY = "gui.teleport.send_only"; + public static final String TELEPORT_RECEIVE_ONLY = "gui.teleport.receive_only"; + public static final String TELEPORT_DISABLED = "gui.teleport.disabled"; + public static final String TELEPORT_PUBLIC = "gui.teleport.public"; + public static final String TELEPORT_PRIVATE = "gui.teleport.private"; + public static final String SIDE_DOWN = "gui.side.down"; + public static final String SIDE_UP = "gui.side.up"; + public static final String SIDE_NORTH = "gui.side.north"; + public static final String SIDE_SOUTH = "gui.side.south"; + public static final String SIDE_WEST = "gui.side.west"; + public static final String SIDE_EAST = "gui.side.east"; +} diff --git a/src/main/resources/assets/additionalpipes/lang/en_us.lang b/src/main/resources/assets/additionalpipes/lang/en_us.lang index 387a4f2..168d680 100644 --- a/src/main/resources/assets/additionalpipes/lang/en_us.lang +++ b/src/main/resources/assets/additionalpipes/lang/en_us.lang @@ -39,6 +39,9 @@ tip.pipe.ap.pipe_fluids_water_pump=Outputs a small amount of water if placed ove tip.pipe.ap.pipe_items_addition=Adds items to adjacent inventories only if they already have that item tip.pipe.ap.pipe_items_jeweled=Highly capable and configurable sorting pipe +#Common GUI +gui.inventory=Inventory + # Jeweled Pipe GUI gui.jeweled_pipe.title=Jeweled Pipe #tab names @@ -65,7 +68,9 @@ gui.advwood_pipe.whitelist=These items are required # Teleport Pipe GUI # NOTE: "ledger" refers to the menu that expands on the side of the Teleport Pipe GUI when you click the icon gui.teleport.ledger.title=Connected Pipes +gui.teleport.ledger.no_owner=no-one gui.teleport.ledger.owner=Owner: %s +gui.teleport.ledger.ownership=Owner gui.teleport.ledger.outputs=Outputs: %d gui.teleport.ledger.inputs=Inputs: %s gui.teleport.frequency=Frequency: %d @@ -76,6 +81,12 @@ gui.teleport.receive_only=Receive Only gui.teleport.disabled=Disabled gui.teleport.public=Public gui.teleport.private=Private +gui.side.down=Teleport Side: Bottom +gui.side.up=Teleport Side: Top +gui.side.north=Teleport Side: North +gui.side.south=Teleport Side: South +gui.side.west=Teleport Side: West +gui.side.east=Teleport Side: East # name of "closed pipe is closed" trigger trigger.pipe_closed=Pipe Closed (Storing Items) diff --git a/src/main/resources/assets/additionalpipes/lang/ja_jp.lang b/src/main/resources/assets/additionalpipes/lang/ja_jp.lang index 3426eca..6c657ae 100644 --- a/src/main/resources/assets/additionalpipes/lang/ja_jp.lang +++ b/src/main/resources/assets/additionalpipes/lang/ja_jp.lang @@ -40,6 +40,8 @@ gui.NBT=タグ gui.metadata=メタ gui.acceptUnsorted=未指定を許可 +gui.teleport.ledger.no_owner=だれも + gate.pipeClosed=パイプが閉鎖(内部にアイテムを貯蔵) key.lasers=チャンクの境界を表示 diff --git a/src/main/resources/assets/additionalpipes/textures/gui/background_generic2.png b/src/main/resources/assets/additionalpipes/textures/gui/background_generic2.png new file mode 100644 index 0000000..220ef97 Binary files /dev/null and b/src/main/resources/assets/additionalpipes/textures/gui/background_generic2.png differ