From 3c5f8b3f95648883cdf9814d9d360e304713c44f Mon Sep 17 00:00:00 2001 From: Paul19988 Date: Wed, 22 Nov 2023 15:58:24 +0000 Subject: [PATCH 1/2] general code cleanup of GUIs --- .../java/train/client/gui/GuiBuilder.java | 394 ++--- .../train/client/gui/GuiButtonNextPage.java | 64 +- .../java/train/client/gui/GuiCrafterTier.java | 345 ++-- .../train/client/gui/GuiCraftingCart.java | 49 +- .../train/client/gui/GuiCustomButton.java | 103 +- src/main/java/train/client/gui/GuiDistil.java | 178 +- src/main/java/train/client/gui/GuiForney.java | 396 +++-- .../java/train/client/gui/GuiFreight.java | 256 +-- .../java/train/client/gui/GuiFurnaceCart.java | 52 +- .../train/client/gui/GuiGeneratorDiesel.java | 64 +- .../java/train/client/gui/GuiHandler.java | 25 +- .../java/train/client/gui/GuiJukebox.java | 684 ++++---- .../java/train/client/gui/GuiLantern.java | 253 +-- src/main/java/train/client/gui/GuiLiquid.java | 354 ++-- src/main/java/train/client/gui/GuiLoco2.java | 580 ++++--- .../java/train/client/gui/GuiMTCInfo.java | 56 +- .../client/gui/GuiOpenHearthFurnace.java | 60 +- .../java/train/client/gui/GuiRecipeBook.java | 1453 +++++++++-------- .../train/client/gui/GuiRotativeDigger.java | 83 +- .../train/client/gui/GuiSpeedTransmitter.java | 108 +- .../java/train/client/gui/GuiTCTextField.java | 1258 +++++++------- src/main/java/train/client/gui/GuiTender.java | 302 ++-- .../client/gui/GuiTrainCraftingBlock.java | 36 +- .../java/train/client/gui/GuiTraincraft.java | 429 ++--- src/main/java/train/client/gui/GuiZepp.java | 86 +- src/main/java/train/client/gui/HUDMTC.java | 207 ++- src/main/java/train/client/gui/HUDloco.java | 426 +++-- .../train/client/gui/sideTabs/SideTab.java | 293 ++-- .../client/gui/sideTabs/SideTabInfo.java | 86 +- .../client/gui/sideTabs/SideTabManager.java | 359 ++-- .../client/gui/sideTabs/SideTabRecipes.java | 226 ++- .../client/gui/sideTabs/SideTabSlots.java | 196 ++- 32 files changed, 4796 insertions(+), 4665 deletions(-) diff --git a/src/main/java/train/client/gui/GuiBuilder.java b/src/main/java/train/client/gui/GuiBuilder.java index 35f0974c43..fd19d51cda 100644 --- a/src/main/java/train/client/gui/GuiBuilder.java +++ b/src/main/java/train/client/gui/GuiBuilder.java @@ -22,193 +22,209 @@ public class GuiBuilder extends GuiContainer { - private EntityTracksBuilder builder; - private int requestedHeight; - private EntityPlayer player; - private GuiButton buttonLock; - - public GuiBuilder(EntityPlayer player, InventoryPlayer inventoryplayer, Entity entityminecart) { - super(new InventoryBuilder(inventoryplayer, (EntityTracksBuilder) entityminecart)); - xSize = 255; - ySize = 193; - builder = (EntityTracksBuilder) entityminecart; - requestedHeight = builder.getPlannedHeight(); - this.player = player; - } - - @Override - public void initGui() { - super.initGui(); - buttonList.clear(); - if ((builder).getFollowTracks() == 1) { - buttonList.add(new GuiButton(1, ((width - xSize) / 2) + 3, ((height - ySize) / 2) - 20, 80, 20, StatCollector.translateToLocal("builder.follow.name"))); - } - if ((builder).getFollowTracks() == 0) { - buttonList.add(new GuiButton(1, ((width - xSize) / 2) + 3, ((height - ySize) / 2) - 20, 80, 20, StatCollector.translateToLocal("builder.remove.name"))); - } - buttonList.add(new GuiButton(2, ((width - xSize) / 2) + 85, ((height - ySize) / 2) - 40, 30, 20, StatCollector.translateToLocal("builder.up.name"))); - buttonList.add(new GuiButton(3, ((width - xSize) / 2) + 85, ((height - ySize) / 2) - 20, 30, 20, StatCollector.translateToLocal("builder.down.name"))); - - int var1 = (this.width - xSize) / 2; - int var2 = (this.height - ySize) / 2; - if (!(builder).getTrainLockedFromPacket()) { - this.buttonList.add(this.buttonLock = new GuiButton(4, var1 + 3, var2 - 30, 51, 10, StatCollector.translateToLocal("train.unlocked.name"))); - } - else { - this.buttonList.add(this.buttonLock = new GuiButton(4, var1 + 3, var2 - 30, 43, 10, StatCollector.translateToLocal("train.locked.name"))); - } - } - - @Override - protected void drawGuiContainerForegroundLayer(int i, int j) { - fontRendererObj.drawString("Builder", 4, 8, 0x404040); - fontRendererObj.drawString("Inventory", 113, 100, 0x404040); - fontRendererObj.drawString("Doesn't work", 4, 160, 0x404040); - fontRendererObj.drawString("with new tracks", 4, 170, 0x404040); - fontRendererObj.drawString("yet", 4, 180, 0x404040); - - fontRendererObj.drawString(StatCollector.translateToLocal("builder.currElev.name") + ": " + (int) builder.currentHeight, 120, -25, 0xFFFFFF); - fontRendererObj.drawString(StatCollector.translateToLocal("builder.reqElev.name") + ": " + builder.getPlannedHeight(), 120, -10, 0xFFFFFF); - if (intersectsWith(i, j)) { - drawCreativeTabHoveringText("When a builder is locked,", i, j); - } - } - - @Override - protected void actionPerformed(GuiButton guibutton) { - if (guibutton.id == 1) { - if ((builder).getFollowTracks() == 1) { - sendFollow(0, builder.getEntityId()); - guibutton.displayString = StatCollector.translateToLocal("builder.remove.name"); - } - else { - sendFollow(1, builder.getEntityId()); - guibutton.displayString = StatCollector.translateToLocal("builder.follow.name"); - } - } - if (guibutton.id == 2) { - sendPacket(1, builder.getEntityId()); - } - if (guibutton.id == 3) { - sendPacket(-1, builder.getEntityId()); - } - - if (guibutton.id == 4) { - if (player != null && player.getCommandSenderName().toLowerCase().equals((builder).getTrainOwner().toLowerCase())) { - if ((!(builder).getTrainLockedFromPacket())) { - AxisAlignedBB box = (builder).boundingBox.expand(5, 5, 5); - List lis3 = (builder).worldObj.getEntitiesWithinAABBExcludingEntity(builder, box); - if (lis3 != null && lis3.size() > 0) { - for (Object entity : lis3) { - if (entity instanceof EntityPlayer) { - Traincraft.lockChannel.sendToServer(new PacketSetTrainLockedToClient(true, ((EntityPlayer)entity).getEntityId())); - } - } - } - - (builder).locked = true; - guibutton.displayString = StatCollector.translateToLocal("train.locked.name"); - this.initGui(); - } - else { - AxisAlignedBB box = (builder).boundingBox.expand(5, 5, 5); - List lis3 = (builder).worldObj.getEntitiesWithinAABBExcludingEntity(builder, box); - if (lis3 != null && lis3.size() > 0) { - for (Object entity : lis3) { - if (entity instanceof EntityPlayer) { - Traincraft.lockChannel.sendToServer(new PacketSetTrainLockedToClient(false, ((EntityPlayer)entity).getEntityId())); - } - } - } - (builder).locked = false; - guibutton.displayString = StatCollector.translateToLocal("train.unlocked.name"); - this.initGui(); - } - } - else if (player != null && player instanceof EntityPlayer) { - player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("train.owner.name"))); - } - } - } - - @Override - protected void drawCreativeTabHoveringText(String str, int t, int g) { - String state = ""; - if ((builder).getTrainLockedFromPacket()) - state = "Locked"; - if (!(builder).getTrainLockedFromPacket()) - state = "Unlocked"; - - int textWidth = fontRendererObj.getStringWidth("the GUI, change speed, destroy it."); - int startX = 10; - int startY = -10; - - int i4 = 0xf0100010; - drawGradientRect(startX - 3, startY - 4, startX + textWidth + 3, startY + 8 + 4 + 40, i4, i4); - drawGradientRect(startX - 4, startY - 3, startX + textWidth + 4, startY + 8 + 3 + 40, i4, i4); - int colour1 = 0x505000ff; - int colour2 = (colour1 & 0xfefefe) >> 1 | colour1 & 0xff000000; - drawGradientRect(startX - 3, startY - 3, startX + textWidth + 3, startY + 8 + 3 + 40, colour1, colour2); - drawGradientRect(startX - 2, startY - 2, startX + textWidth + 2, startY + 8 + 2 + 40, i4, i4); - fontRendererObj.drawStringWithShadow(str, startX, startY, -1); - fontRendererObj.drawStringWithShadow("only its owner can open", startX, startY + 10, -1); - fontRendererObj.drawStringWithShadow("the GUI and destroy it.", startX, startY + 20, -1); - fontRendererObj.drawStringWithShadow("Current state: " + state, startX, startY + 30, -1); - fontRendererObj.drawStringWithShadow("Owner: " + (builder).getTrainOwner().trim(), startX, startY + 40, -1); - } - - public boolean intersectsWith(int mouseX, int mouseY) { - int j = (width - xSize) / 2; - int k = (height - ySize) / 2; - return (mouseX >= j + 3 && mouseX <= j + 55 && mouseY >= k - 30 && mouseY <= k - 20); - } - - private void sendPacket(int packet, int packetID) { - AxisAlignedBB box = (builder).boundingBox.expand(5, 5, 5); - List lis3 = (builder).worldObj.getEntitiesWithinAABBExcludingEntity(builder, box); - if (lis3 != null && lis3.size() > 0) { - for (Object entity : lis3) { - if (entity instanceof EntityPlayer) { - Traincraft.builderChannel.sendToServer(new PacketTrackBuilderHeight(packet, packetID)); - } - } - } - } - - private void sendFollow(int packet, int packetID) { - AxisAlignedBB box = (builder).boundingBox.expand(5, 5, 5); - List lis3 = (builder).worldObj.getEntitiesWithinAABBExcludingEntity(builder, box); - if (lis3 != null && lis3.size() > 0) { - for (Object entity : lis3) { - if (entity instanceof EntityPlayer) { - Traincraft.builderChannel.sendToServer(new PacketTrackBuilderFollow(packet, packetID)); - } - } - } - } - - @Override - protected void drawGuiContainerBackgroundLayer(float f, int t, int g) { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - mc.renderEngine.bindTexture(new ResourceLocation(Info.resourceLocation, Info.guiPrefix + "gui_builder2.png")); - int j = ((width - xSize) / 2); - int k = (height - ySize) / 2; - drawTexturedModalRect(j, k, 0, 0, xSize, ySize); - if (builder.getFuel() > 0) { - int l = builder.scaleMaxFuel(12); - drawTexturedModalRect(j + 8, (k + 36 + 12) - l, 0, 250 - l, 14, l + 2); - } - for (int i1 = builder.numBuilderSlots; i1 < 5; i1++) { - drawTexturedModalRect(j + 105 + 18 * i1, k + 6, 14, 166, 18, 18); - } - for (int j1 = builder.numBuilderSlots1; j1 < 5; j1++) { - drawTexturedModalRect(j + 105 + 18 * j1, k + 24, 14, 166, 18, 18);// - } - for (int k1 = builder.numBuilderSlots2; k1 < 5; k1++) { - drawTexturedModalRect(j + 105 + 18 * k1, k + 42, 14, 166, 18, 18); - } - for (int k1 = builder.numBuilderSlots3; k1 < 5; k1++) { - drawTexturedModalRect(j + 105 + 18 * k1, k + 60, 14, 166, 18, 18); - } - } + private final EntityTracksBuilder builder; + private final int requestedHeight; + private final EntityPlayer player; + private GuiButton buttonLock; + + public GuiBuilder(EntityPlayer player, InventoryPlayer inventoryplayer, Entity entityminecart) { + super(new InventoryBuilder(inventoryplayer, (EntityTracksBuilder) entityminecart)); + xSize = 255; + ySize = 193; + builder = (EntityTracksBuilder) entityminecart; + requestedHeight = builder.getPlannedHeight(); + this.player = player; + } + + @Override + public void initGui() { + super.initGui(); + buttonList.clear(); + + if ((builder).getFollowTracks() == 1) { + buttonList.add(new GuiButton(1, ((width - xSize) / 2) + 3, ((height - ySize) / 2) - 20, 80, 20, StatCollector.translateToLocal("builder.follow.name"))); + } + + if ((builder).getFollowTracks() == 0) { + buttonList.add(new GuiButton(1, ((width - xSize) / 2) + 3, ((height - ySize) / 2) - 20, 80, 20, StatCollector.translateToLocal("builder.remove.name"))); + } + + buttonList.add(new GuiButton(2, ((width - xSize) / 2) + 85, ((height - ySize) / 2) - 40, 30, 20, StatCollector.translateToLocal("builder.up.name"))); + buttonList.add(new GuiButton(3, ((width - xSize) / 2) + 85, ((height - ySize) / 2) - 20, 30, 20, StatCollector.translateToLocal("builder.down.name"))); + + int buttonPosX = (this.width - xSize) / 2; + int buttonPosY = (this.height - ySize) / 2; + + if (!(builder).getTrainLockedFromPacket()) { + this.buttonList.add(this.buttonLock = new GuiButton(4, buttonPosX + 3, buttonPosY - 30, 51, 10, StatCollector.translateToLocal("train.unlocked.name"))); + } else { + this.buttonList.add(this.buttonLock = new GuiButton(4, buttonPosX + 3, buttonPosY - 30, 43, 10, StatCollector.translateToLocal("train.locked.name"))); + } + } + + @Override + protected void drawGuiContainerForegroundLayer(int i, int j) { + fontRendererObj.drawString("Builder", 4, 8, 0x404040); + fontRendererObj.drawString("Inventory", 113, 100, 0x404040); + fontRendererObj.drawString("Doesn't work", 4, 160, 0x404040); + fontRendererObj.drawString("with new tracks", 4, 170, 0x404040); + fontRendererObj.drawString("yet", 4, 180, 0x404040); + + fontRendererObj.drawString(StatCollector.translateToLocal("builder.currElev.name") + ": " + (int) builder.currentHeight, 120, -25, 0xFFFFFF); + fontRendererObj.drawString(StatCollector.translateToLocal("builder.reqElev.name") + ": " + builder.getPlannedHeight(), 120, -10, 0xFFFFFF); + + if (intersectsWith(i, j)) { + drawCreativeTabHoveringText("When a builder is locked,", i, j); + } + } + + @Override + protected void actionPerformed(GuiButton guibutton) { + if (guibutton.id == 1) { + if ((builder).getFollowTracks() == 1) { + sendFollow(0, builder.getEntityId()); + guibutton.displayString = StatCollector.translateToLocal("builder.remove.name"); + } else { + sendFollow(1, builder.getEntityId()); + guibutton.displayString = StatCollector.translateToLocal("builder.follow.name"); + } + } + + if (guibutton.id == 2) { + sendPacket(1, builder.getEntityId()); + } + + if (guibutton.id == 3) { + sendPacket(-1, builder.getEntityId()); + } + + if (guibutton.id == 4) { + if (player != null && player.getCommandSenderName().equalsIgnoreCase(builder.getTrainOwner())) { + AxisAlignedBB box = builder.boundingBox.expand(5, 5, 5); + List lis3 = builder.worldObj.getEntitiesWithinAABBExcludingEntity(builder, box); + + if (!builder.getTrainLockedFromPacket()) { + + if (lis3 != null && !lis3.isEmpty()) { + for (Object entity : lis3) { + if (entity instanceof EntityPlayer) { + Traincraft.lockChannel.sendToServer(new PacketSetTrainLockedToClient(true, ((EntityPlayer) entity).getEntityId())); + } + } + } + + builder.locked = true; + guibutton.displayString = StatCollector.translateToLocal("train.locked.name"); + } else { + if (lis3 != null && !lis3.isEmpty()) { + for (Object entity : lis3) { + if (entity instanceof EntityPlayer) { + Traincraft.lockChannel.sendToServer(new PacketSetTrainLockedToClient(false, ((EntityPlayer) entity).getEntityId())); + } + } + } + + builder.locked = false; + guibutton.displayString = StatCollector.translateToLocal("train.unlocked.name"); + } + + this.initGui(); + } else if (player != null) { + player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("train.owner.name"))); + } + } + } + + @Override + protected void drawCreativeTabHoveringText(String str, int t, int g) { + String state = ""; + if ((builder).getTrainLockedFromPacket()) + state = "Locked"; + if (!(builder).getTrainLockedFromPacket()) + state = "Unlocked"; + + int textWidth = fontRendererObj.getStringWidth("the GUI, change speed, destroy it."); + int startX = 10; + int startY = -10; + + int i4 = 0xf0100010; + + int colour1 = 0x505000ff; + int colour2 = (colour1 & 0xfefefe) >> 1 | colour1 & 0xff000000; + + drawGradientRect(startX - 3, startY - 4, startX + textWidth + 3, startY + 8 + 4 + 40, i4, i4); + drawGradientRect(startX - 4, startY - 3, startX + textWidth + 4, startY + 8 + 3 + 40, i4, i4); + + drawGradientRect(startX - 3, startY - 3, startX + textWidth + 3, startY + 8 + 3 + 40, colour1, colour2); + drawGradientRect(startX - 2, startY - 2, startX + textWidth + 2, startY + 8 + 2 + 40, i4, i4); + + fontRendererObj.drawStringWithShadow(str, startX, startY, -1); + fontRendererObj.drawStringWithShadow("only its owner can open", startX, 0, -1); + fontRendererObj.drawStringWithShadow("the GUI and destroy it.", startX, startY + 20, -1); + fontRendererObj.drawStringWithShadow("Current state: " + state, startX, startY + 30, -1); + fontRendererObj.drawStringWithShadow("Owner: " + (builder).getTrainOwner().trim(), startX, startY + 40, -1); + } + + public boolean intersectsWith(int mouseX, int mouseY) { + int j = (width - xSize) / 2; + int k = (height - ySize) / 2; + return (mouseX >= j + 3 && mouseX <= j + 55 && mouseY >= k - 30 && mouseY <= k - 20); + } + + private void sendPacket(int packet, int packetID) { + AxisAlignedBB box = (builder).boundingBox.expand(5, 5, 5); + List lis3 = (builder).worldObj.getEntitiesWithinAABBExcludingEntity(builder, box); + if (lis3 != null && !lis3.isEmpty()) { + for (Object entity : lis3) { + if (entity instanceof EntityPlayer) { + Traincraft.builderChannel.sendToServer(new PacketTrackBuilderHeight(packet, packetID)); + } + } + } + } + + private void sendFollow(int packet, int packetID) { + AxisAlignedBB box = (builder).boundingBox.expand(5, 5, 5); + List lis3 = (builder).worldObj.getEntitiesWithinAABBExcludingEntity(builder, box); + if (lis3 != null && !lis3.isEmpty()) { + for (Object entity : lis3) { + if (entity instanceof EntityPlayer) { + Traincraft.builderChannel.sendToServer(new PacketTrackBuilderFollow(packet, packetID)); + } + } + } + } + + @Override + protected void drawGuiContainerBackgroundLayer(float f, int t, int g) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + + mc.renderEngine.bindTexture(new ResourceLocation(Info.resourceLocation, Info.guiPrefix + "gui_builder2.png")); + + int j = ((width - xSize) / 2); + int k = (height - ySize) / 2; + + drawTexturedModalRect(j, k, 0, 0, xSize, ySize); + + if (builder.getFuel() > 0) { + int l = builder.scaleMaxFuel(12); + drawTexturedModalRect(j + 8, (k + 36 + 12) - l, 0, 250 - l, 14, l + 2); + } + + for (int i1 = builder.numBuilderSlots; i1 < 5; i1++) { + drawTexturedModalRect(j + 105 + 18 * i1, k + 6, 14, 166, 18, 18); + } + + for (int j1 = builder.numBuilderSlots1; j1 < 5; j1++) { + drawTexturedModalRect(j + 105 + 18 * j1, k + 24, 14, 166, 18, 18);// + } + + for (int k1 = builder.numBuilderSlots2; k1 < 5; k1++) { + drawTexturedModalRect(j + 105 + 18 * k1, k + 42, 14, 166, 18, 18); + } + + for (int k1 = builder.numBuilderSlots3; k1 < 5; k1++) { + drawTexturedModalRect(j + 105 + 18 * k1, k + 60, 14, 166, 18, 18); + } + } } \ No newline at end of file diff --git a/src/main/java/train/client/gui/GuiButtonNextPage.java b/src/main/java/train/client/gui/GuiButtonNextPage.java index 393bd45b39..ddb303aeb1 100644 --- a/src/main/java/train/client/gui/GuiButtonNextPage.java +++ b/src/main/java/train/client/gui/GuiButtonNextPage.java @@ -10,40 +10,40 @@ @SideOnly(Side.CLIENT) class GuiButtonNextPage extends GuiButton { - /** - * True for pointing right (next page), false for pointing left (previous page). - */ - private final boolean nextPage; - /** - * if the button has to be drawn drawButton is more than just draw, it makes the button exists or not too - */ - public boolean showButton; + /** + * True for pointing right (next page), false for pointing left (previous page). + */ + private final boolean nextPage; + /** + * if the button has to be drawn drawButton is more than just draw, it makes the button exists or not too + */ + public boolean showButton; - public GuiButtonNextPage(int par1, int par2, int par3, int xSize, int ySize, boolean par4) { - super(par1, par2, par3, 23, 13, ""); - this.nextPage = par4; - } + public GuiButtonNextPage(int par1, int par2, int par3, int xSize, int ySize, boolean par4) { + super(par1, par2, par3, 23, 13, ""); + this.nextPage = par4; + } - /** - * Draws this button to the screen. - */ - @Override - public void drawButton(Minecraft mc, int par2, int par3) { - if (this.visible && showButton) { - boolean var4 = par2 >= this.xPosition && par3 >= this.yPosition && par2 < this.xPosition + this.width && par3 < this.yPosition + this.height; - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - mc.renderEngine.bindTexture(new ResourceLocation(Info.resourceLocation,Info.bookPrefix + "bookleft.png")); - int var5 = 0; - int var6 = 206; + /** + * Draws this button to the screen. + */ + @Override + public void drawButton(Minecraft mc, int par2, int par3) { + if (this.visible && showButton) { + boolean var4 = par2 >= this.xPosition && par3 >= this.yPosition && par2 < this.xPosition + this.width && par3 < this.yPosition + this.height; + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + mc.renderEngine.bindTexture(new ResourceLocation(Info.resourceLocation, Info.bookPrefix + "bookleft.png")); + int var5 = 0; + int var6 = 206; - if (var4) { - var5 += 23; - } + if (var4) { + var5 += 23; + } - if (!this.nextPage) { - var6 += 13; - } - this.drawTexturedModalRect(this.xPosition, this.yPosition, var5, var6, 23, 13); - } - } + if (!this.nextPage) { + var6 += 13; + } + this.drawTexturedModalRect(this.xPosition, this.yPosition, var5, var6, 23, 13); + } + } } diff --git a/src/main/java/train/client/gui/GuiCrafterTier.java b/src/main/java/train/client/gui/GuiCrafterTier.java index 53b8f64cf9..7617be409a 100644 --- a/src/main/java/train/client/gui/GuiCrafterTier.java +++ b/src/main/java/train/client/gui/GuiCrafterTier.java @@ -15,7 +15,6 @@ import train.common.core.interfaces.ITier; import train.common.core.managers.TierRecipe; import train.common.core.managers.TierRecipeManager; -import train.common.library.EnumTrains; import train.common.library.Info; import train.common.library.ItemIDs; import train.common.Traincraft; @@ -26,161 +25,191 @@ public class GuiCrafterTier extends GuiTraincraft { - public static ITier tier1; - private static int[] states = new int[10]; - public static int[] slotStates = new int[8]; - public static int recipeSize = 0; - public static List recipes; - public static List recipeList; - - public static boolean isShow = false; - public static boolean isClear = false; - public static boolean isTabRecipeOpen = false; - - private float yaw; - private float roll; - private boolean rollDown; - public Item currentKnownItem=null; - private int ticksInGui=0; - private Item previousItem; - private AbstractTrains renderEntity; - private int color = 0; - private int currentRenderTabY = 40; - public GuiCrafterTier(InventoryPlayer inv, IInventory tier) { - super(new ContainerTier(inv, tier), tier); - - tier1 = (ITier) tier; - recipeList = TierRecipeManager.getInstance().getTierRecipeList(tier1.Tier()); - recipes = tier1.knownRecipes(); - ySize = 256; - previousItem = ItemIDs.minecartLoco3.item;//just to init the thing - } - - @Override - protected void drawGuiContainerForegroundLayer(int i, int j) { - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_DEPTH_TEST); - - fontRendererObj.drawString(tier1.getGUIName(), 9 + 1, 6, 0x000000); - fontRendererObj.drawString("Output:", 90 + 1, 118, 0x000000); - fontRendererObj.drawString("Storage:", 9 + 1, 118, 0xffffff); - fontRendererObj.drawString("Inventory:", 9 + 1, 164, 0xffffff); - - fontRendererObj.drawString(tier1.getGUIName(), 9, 6, 0xd3a900); - fontRendererObj.drawString("Output:", 90, 118, 0xd3a900); - fontRendererObj.drawString("Storage:", 9, 118, 0x202020); - fontRendererObj.drawString("Inventory:", 9, 164, 0x202020); - - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glEnable(GL11.GL_DEPTH_TEST); - - super.drawGuiContainerForegroundLayer(i, j); - } - - @Override - protected void drawGuiContainerBackgroundLayer(float f, int t, int g) { - //List cs = inventorySlots.inventorySlots; - - int j = (width - xSize) / 2; - int k = (height - ySize) / 2; - - mc.renderEngine.bindTexture(new ResourceLocation(Info.resourceLocation,tier1.getGUITexture())); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - drawTexturedModalRect(j, k, 0, 0, this.xSize, this.ySize); - - borderSlots(recipeList, states); - - if(!isTabRecipeOpen){ - currentRenderTabY=40; - } - /**Render the entity in GUI*/ - if(currentKnownItem!=null && isTabRecipeOpen){ - if(currentRenderTabY<120)currentRenderTabY++; - ticksInGui++; - for(int a=0;a<6;a++){ - for(int b=0;b<5;b++){ - drawTexturedModalRect(j - 120 + a*16, (k + currentRenderTabY + b*16), 240, 48, 16, 16);//black squares - - drawTexturedModalRect(j -120 -1, (k + currentRenderTabY+b*16), 252, 68, 2, 16);//border left - drawTexturedModalRect(j -120 -1 + 6*16, (k + currentRenderTabY+b*16), 254, 68, 2, 16);//border right - drawTexturedModalRect(j -120 + a*16, (k + (currentRenderTabY-1) +5*16), 240, 64, 16, 2);//border bottom - } - } - if(currentRenderTabY==120){ - GL11.glPushMatrix(); - GL11.glColor3f(1, 1, 1); - GL11.glTranslatef(guiLeft-70, this.guiTop+170, 100); - - RenderHelper.enableGUIStandardItemLighting(); - TrainRecord train = Traincraft.instance.traincraftRegistry.findTrainRecordByItem(currentKnownItem); - renderEntity = train.getEntity(mc.theWorld); - if(renderEntity!=null && !Item.itemRegistry.getNameForObject(currentKnownItem).equals(Item.itemRegistry.getNameForObject(previousItem))){ - previousItem = currentKnownItem; - } - if(train.getLiveries().size()!=0){ - if(color < 0)color = 0; - if(ticksInGui % 400 == 0)color++; - if(color>train.getColors().size()-1)color=0; - if(renderEntity!=null)renderEntity.setColor(train.getLiveries().get(color)); - } - GL11.glScalef(-train.getGuiRenderScale(), train.getGuiRenderScale(), train.getGuiRenderScale()); - GL11.glRotatef(180, 0, 0, 1); - GL11.glRotatef(roll, 1, 0, 0); - GL11.glRotatef(yaw, 0, 1, 0); - if(renderEntity!=null)RenderManager.instance.renderEntityWithPosYaw(renderEntity, 0, 0, 0, 0, 0); - RenderHelper.disableStandardItemLighting(); - GL11.glPopMatrix(); - yaw += 0.5F; - if(rollDown){ - roll -= 0.05F; - if(roll < -5){ - rollDown = false; - roll = -5; - } - }else{ - roll += 0.05F; - if(roll > 15){ - rollDown = true; - roll = 15; - } - } - } - } - - if (isShow) { - if (tier1.knownRecipes().size() != 0) { - drawOverlays(recipeSize, recipes); - } - } - - for (int i = 0; i < slotStates.length / 2; i++) { - if (slotStates[i] == 1) { - colorSlot(92 + i * 18, 128); - } - if (slotStates[i + 4] == 1) { - colorSlot(92 + i * 18, 146); - } - } - - if (recipeSize > tier1.knownRecipes().size() - 1) { - recipeSize = 0; - } - else if (recipeSize < 0) { - recipeSize = tier1.knownRecipes().size() - 1; - } - - recipes = tier1.knownRecipes(); - } - - @Override - protected void mouseClicked(int x, int y, int button) { - super.mouseClicked(x, y, button); - } - @Override - protected void initSideTabs(IInventory inventory) { - super.initSideTabs(inventory); - sideTabManager.add(new SideTabInfo(this, true, true, true, Info.tooltipsTierI)); - sideTabManager.add(new SideTabRecipes(this, true, true, true)); - sideTabManager.add(new SideTabSlots(tier1, this, true, true, true, slotStates)); - } + public static ITier tier1; + private static final int[] states = new int[10]; + public static int[] slotStates = new int[8]; + public static int recipeSize = 0; + public static List recipes; + public static List recipeList; + + public static boolean isShow = false; + public static boolean isClear = false; + public static boolean isTabRecipeOpen = false; + + private float yaw; + private float roll; + private boolean rollDown; + public Item currentKnownItem = null; + private int ticksInGui = 0; + private Item previousItem; + private AbstractTrains renderEntity; + private int color = 0; + private int currentRenderTabY = 40; + + public GuiCrafterTier(InventoryPlayer inv, IInventory tier) { + super(new ContainerTier(inv, tier), tier); + + tier1 = (ITier) tier; + recipeList = TierRecipeManager.getInstance().getTierRecipeList(tier1.Tier()); + recipes = tier1.knownRecipes(); + ySize = 256; + // Init the item + previousItem = ItemIDs.minecartLoco3.item; + } + + @Override + protected void drawGuiContainerForegroundLayer(int i, int j) { + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_DEPTH_TEST); + + fontRendererObj.drawString(tier1.getGUIName(), 9 + 1, 6, 0x000000); + fontRendererObj.drawString("Output:", 90 + 1, 118, 0x000000); + fontRendererObj.drawString("Storage:", 9 + 1, 118, 0xffffff); + fontRendererObj.drawString("Inventory:", 9 + 1, 164, 0xffffff); + + fontRendererObj.drawString(tier1.getGUIName(), 9, 6, 0xd3a900); + fontRendererObj.drawString("Output:", 90, 118, 0xd3a900); + fontRendererObj.drawString("Storage:", 9, 118, 0x202020); + fontRendererObj.drawString("Inventory:", 9, 164, 0x202020); + + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_DEPTH_TEST); + + super.drawGuiContainerForegroundLayer(i, j); + } + + @Override + protected void drawGuiContainerBackgroundLayer(float f, int t, int g) { + //List cs = inventorySlots.inventorySlots; + + int j = (width - xSize) / 2; + int k = (height - ySize) / 2; + + mc.renderEngine.bindTexture(new ResourceLocation(Info.resourceLocation, tier1.getGUITexture())); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + drawTexturedModalRect(j, k, 0, 0, this.xSize, this.ySize); + + borderSlots(recipeList, states); + + if (!isTabRecipeOpen) { + currentRenderTabY = 40; + } + + // Render the entity in GUI + if (currentKnownItem != null && isTabRecipeOpen) { + if (currentRenderTabY < 120) { + currentRenderTabY++; + } + ticksInGui++; + for (int a = 0; a < 6; a++) { + for (int b = 0; b < 5; b++) { + // Black Squares + drawTexturedModalRect(j - 120 + a * 16, (k + currentRenderTabY + b * 16), 240, 48, 16, 16); + + // Border Left + drawTexturedModalRect(j - 120 - 1, (k + currentRenderTabY + b * 16), 252, 68, 2, 16); + // Border Right + drawTexturedModalRect(j - 120 - 1 + 6 * 16, (k + currentRenderTabY + b * 16), 254, 68, 2, 16); + // Border Bottom + drawTexturedModalRect(j - 120 + a * 16, (k + (currentRenderTabY - 1) + 5 * 16), 240, 64, 16, 2); + } + } + if (currentRenderTabY == 120) { + GL11.glPushMatrix(); + GL11.glColor3f(1, 1, 1); + GL11.glTranslatef(guiLeft - 70, this.guiTop + 170, 100); + + RenderHelper.enableGUIStandardItemLighting(); + TrainRecord train = Traincraft.instance.traincraftRegistry.findTrainRecordByItem(currentKnownItem); + renderEntity = train.getEntity(mc.theWorld); + + if (renderEntity != null && !Item.itemRegistry.getNameForObject(currentKnownItem).equals(Item.itemRegistry.getNameForObject(previousItem))) { + previousItem = currentKnownItem; + } + + if (!train.getLiveries().isEmpty()) { + if (color < 0) { + color = 0; + } + + if (ticksInGui % 400 == 0) { + color++; + } + + if (color > train.getColors().size() - 1) { + color = 0; + } + + if (renderEntity != null) { + renderEntity.setColor(train.getLiveries().get(color)); + } + } + + GL11.glScalef(-train.getGuiRenderScale(), train.getGuiRenderScale(), train.getGuiRenderScale()); + GL11.glRotatef(180, 0, 0, 1); + GL11.glRotatef(roll, 1, 0, 0); + GL11.glRotatef(yaw, 0, 1, 0); + + if (renderEntity != null) { + RenderManager.instance.renderEntityWithPosYaw(renderEntity, 0, 0, 0, 0, 0); + } + + RenderHelper.disableStandardItemLighting(); + GL11.glPopMatrix(); + yaw += 0.5F; + if (rollDown) { + roll -= 0.05F; + if (roll < -5) { + rollDown = false; + roll = -5; + } + } else { + roll += 0.05F; + if (roll > 15) { + rollDown = true; + roll = 15; + } + } + } + } + + if (isShow && !tier1.knownRecipes().isEmpty()) { + drawOverlays(recipeSize, recipes); + } + + for (int i = 0; i < slotStates.length / 2; i++) { + if (slotStates[i] == 1) { + colorSlot(92 + i * 18, 128); + } + + if (slotStates[i + 4] == 1) { + colorSlot(92 + i * 18, 146); + } + } + + if (recipeSize > tier1.knownRecipes().size() - 1) { + recipeSize = 0; + } else if (recipeSize < 0) { + recipeSize = tier1.knownRecipes().size() - 1; + } + + recipes = tier1.knownRecipes(); + } + + @Override + protected void mouseClicked(int x, int y, int button) { + super.mouseClicked(x, y, button); + } + + @Override + protected void initSideTabs(IInventory inventory) { + super.initSideTabs(inventory); + sideTabManager.add(new SideTabInfo(this, true, true, true, Info.tooltipsTierI)); + sideTabManager.add(new SideTabRecipes(this, true, true, true)); + sideTabManager.add(new SideTabSlots(tier1, this, true, true, true, slotStates)); + } + + public AbstractTrains getRenderEntity() { + return renderEntity; + } } diff --git a/src/main/java/train/client/gui/GuiCraftingCart.java b/src/main/java/train/client/gui/GuiCraftingCart.java index b2192d8738..8b8bc82787 100644 --- a/src/main/java/train/client/gui/GuiCraftingCart.java +++ b/src/main/java/train/client/gui/GuiCraftingCart.java @@ -10,27 +10,30 @@ import train.common.library.Info; public class GuiCraftingCart extends GuiContainer { - public GuiCraftingCart(InventoryPlayer par1InventoryPlayer, World par2World) { - super(new ContainerWorkbenchCart(par1InventoryPlayer, par2World)); - } - - @Override - public void onGuiClosed() { - super.onGuiClosed(); - } - - @Override - protected void drawGuiContainerForegroundLayer(int i, int j) { - this.fontRendererObj.drawString(StatCollector.translateToLocal("container.crafting"), 28, 6, 4210752); - this.fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 8, this.ySize - 96 + 2, 4210752); - } - - @Override - protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - mc.renderEngine.bindTexture(new ResourceLocation(Info.resourceLocation,Info.guiPrefix + "crafting_table.png")); - int var5 = (this.width - this.xSize) / 2; - int var6 = (this.height - this.ySize) / 2; - this.drawTexturedModalRect(var5, var6, 0, 0, this.xSize, this.ySize); - } + public GuiCraftingCart(InventoryPlayer par1InventoryPlayer, World par2World) { + super(new ContainerWorkbenchCart(par1InventoryPlayer, par2World)); + } + + @Override + public void onGuiClosed() { + super.onGuiClosed(); + } + + @Override + protected void drawGuiContainerForegroundLayer(int i, int j) { + this.fontRendererObj.drawString(StatCollector.translateToLocal("container.crafting"), 28, 6, 4210752); + this.fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 8, this.ySize - 96 + 2, 4210752); + } + + @Override + protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + + mc.renderEngine.bindTexture(new ResourceLocation(Info.resourceLocation, Info.guiPrefix + "crafting_table.png")); + + int var5 = (this.width - this.xSize) / 2; + int var6 = (this.height - this.ySize) / 2; + + this.drawTexturedModalRect(var5, var6, 0, 0, this.xSize, this.ySize); + } } diff --git a/src/main/java/train/client/gui/GuiCustomButton.java b/src/main/java/train/client/gui/GuiCustomButton.java index ce54c93130..b094e4164d 100644 --- a/src/main/java/train/client/gui/GuiCustomButton.java +++ b/src/main/java/train/client/gui/GuiCustomButton.java @@ -9,56 +9,55 @@ public class GuiCustomButton extends GuiButton { - private String texture = Info.guiPrefix + "customButton.png"; - private int textureX = 0; - private int textureY = 46; - - public GuiCustomButton(int par1, int par2, int par3, String par4Str, String texture, int textureX, int textureY) { - this(par1, par2, par3, 200, 20, par4Str, texture, textureX, textureY); - } - - public GuiCustomButton(int par1, int par2, int par3, int par4, int par5, String par6Str, String texture, int textureX, int textureY) { - super(par1, par2, par3, par4, par5, par6Str); - this.width = 200; - this.height = 20; - this.enabled = true; - this.visible = true; - this.id = par1; - this.xPosition = par2; - this.yPosition = par3; - this.width = par4; - this.height = par5; - this.displayString = par6Str; - this.texture = texture; - this.textureX = textureX; - this.textureY = textureY; - } - - public void setTexture(String texture, int textureX, int textureY) { - this.texture = texture; - this.textureX = textureX; - this.textureY = textureY; - } - - @Override - public void drawButton(Minecraft mc, int par2, int par3) { - if (this.visible) { - FontRenderer var4 = mc.fontRenderer; - mc.getTextureManager().bindTexture(new ResourceLocation(Info.resourceLocation,this.texture)); - //GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureInt); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - boolean var5 = par2 >= this.xPosition && par3 >= this.yPosition && par2 < this.xPosition + this.width && par3 < this.yPosition + this.height; - this.drawTexturedModalRect(this.xPosition, this.yPosition, textureX, textureY, this.width, this.height); - this.mouseDragged(mc, par2, par3); - int var7 = 14737632; - - if (!this.enabled) { - var7 = -6250336; - } - else if (var5) { - var7 = 16777120; - } - this.drawCenteredString(var4, this.displayString, this.xPosition + this.width / 2, this.yPosition + (this.height - 8) / 2, var7); - } - } + private String texture = Info.guiPrefix + "customButton.png"; + private int textureX = 0; + private int textureY = 46; + + public GuiCustomButton(int par1, int par2, int par3, String par4Str, String texture, int textureX, int textureY) { + this(par1, par2, par3, 200, 20, par4Str, texture, textureX, textureY); + } + + public GuiCustomButton(int par1, int par2, int par3, int par4, int par5, String par6Str, String texture, int textureX, int textureY) { + super(par1, par2, par3, par4, par5, par6Str); + this.width = 200; + this.height = 20; + this.enabled = true; + this.visible = true; + this.id = par1; + this.xPosition = par2; + this.yPosition = par3; + this.width = par4; + this.height = par5; + this.displayString = par6Str; + this.texture = texture; + this.textureX = textureX; + this.textureY = textureY; + } + + public void setTexture(String texture, int textureX, int textureY) { + this.texture = texture; + this.textureX = textureX; + this.textureY = textureY; + } + + @Override + public void drawButton(Minecraft mc, int par2, int par3) { + if (this.visible) { + FontRenderer var4 = mc.fontRenderer; + mc.getTextureManager().bindTexture(new ResourceLocation(Info.resourceLocation, this.texture)); + //GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureInt); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + boolean var5 = par2 >= this.xPosition && par3 >= this.yPosition && par2 < this.xPosition + this.width && par3 < this.yPosition + this.height; + this.drawTexturedModalRect(this.xPosition, this.yPosition, textureX, textureY, this.width, this.height); + this.mouseDragged(mc, par2, par3); + int var7 = 14737632; + + if (!this.enabled) { + var7 = -6250336; + } else if (var5) { + var7 = 16777120; + } + this.drawCenteredString(var4, this.displayString, this.xPosition + this.width / 2, this.yPosition + (this.height - 8) / 2, var7); + } + } } \ No newline at end of file diff --git a/src/main/java/train/client/gui/GuiDistil.java b/src/main/java/train/client/gui/GuiDistil.java index 301d700efb..8c4c6b7ba2 100644 --- a/src/main/java/train/client/gui/GuiDistil.java +++ b/src/main/java/train/client/gui/GuiDistil.java @@ -14,103 +14,101 @@ public class GuiDistil extends GuiContainer { - private TileEntityDistil distilInventory; - private int staticAmount; + private final TileEntityDistil distilInventory; + private int staticAmount; - public GuiDistil(InventoryPlayer invPlayer, TileEntityDistil tileentitydistil) { - super(new ContainerDistil(invPlayer, tileentitydistil)); - distilInventory = tileentitydistil; - staticAmount = distilInventory.amount; - } + public GuiDistil(InventoryPlayer invPlayer, TileEntityDistil tileentitydistil) { + super(new ContainerDistil(invPlayer, tileentitydistil)); + distilInventory = tileentitydistil; + staticAmount = distilInventory.amount; + } - @Override - public void updateScreen(){ - if (distilInventory.amount != staticAmount){ - staticAmount = distilInventory.amount; - super.updateScreen(); - } - } + @Override + public void updateScreen() { + if (distilInventory.amount != staticAmount) { + staticAmount = distilInventory.amount; + super.updateScreen(); + } + } - @Override - protected void drawGuiContainerForegroundLayer(int par1, int par2) { - fontRendererObj.drawString("Distillation tower", 8, 6, 0x404040); - fontRendererObj.drawString("Inventory", 8, (ySize - 96) + 2, 0x404040); - if (distilInventory.slots[0] != null) { - /** - * Stops showing 100% on copper - */ - if (Block.getBlockFromItem(distilInventory.slots[0].getItem()) == BlockIDs.oreTC.block - && (distilInventory.slots[0].getItemDamage() != 1 - && distilInventory.slots[0].getItemDamage() != 2)) { - return; - } - double plasticChance = DistilRecipes.smelting().getPlasticChance(distilInventory.slots[0].getItem()); - if(plasticChance!=0){//stops showing 100% for blocks that aren't part of a recipe - double chanceShown = ((1 / plasticChance) * 100); - fontRendererObj.drawString((int) chanceShown + "%", 79, 70, 0x404040); - } - } - } + @Override + protected void drawGuiContainerForegroundLayer(int par1, int par2) { + fontRendererObj.drawString("Distillation tower", 8, 6, 0x404040); + fontRendererObj.drawString("Inventory", 8, (ySize - 96) + 2, 0x404040); + if (distilInventory.slots[0] != null) { + // Stops showing 100% on copper + if (Block.getBlockFromItem(distilInventory.slots[0].getItem()) == BlockIDs.oreTC.block + && (distilInventory.slots[0].getItemDamage() != 1 + && distilInventory.slots[0].getItemDamage() != 2)) { + return; + } + double plasticChance = DistilRecipes.smelting().getPlasticChance(distilInventory.slots[0].getItem()); + if (plasticChance != 0) {//stops showing 100% for blocks that aren't part of a recipe + double chanceShown = ((1 / plasticChance) * 100); + fontRendererObj.drawString((int) chanceShown + "%", 79, 70, 0x404040); + } + } + } - @Override - public void drawScreen(int t, int g, float par3) { - //drawGuiContainerBackgroundLayer(par3, t, g); - //drawGuiContainerForegroundLayer(t, g); - super.drawScreen(t, g, par3); - if ((LiquidManager.DIESEL != null && distilInventory.getLiquidItemID() == LiquidManager.DIESEL.getID())) { - if (intersectsWith(t, g)) { - drawCreativeTabHoveringText("Diesel", t, g); - } - } - if ((LiquidManager.REFINED_FUEL != null && distilInventory.getLiquidItemID() == LiquidManager.REFINED_FUEL.getID())) { - if (intersectsWith(t, g)) { - drawCreativeTabHoveringText("Fuel", t, g); - } - } - } + @Override + public void drawScreen(int t, int g, float par3) { + //drawGuiContainerBackgroundLayer(par3, t, g); + //drawGuiContainerForegroundLayer(t, g); + super.drawScreen(t, g, par3); + if ((LiquidManager.DIESEL != null && distilInventory.getLiquidItemID() == LiquidManager.DIESEL.getID())) { + if (intersectsWith(t, g)) { + drawCreativeTabHoveringText("Diesel", t, g); + } + } + if ((LiquidManager.REFINED_FUEL != null && distilInventory.getLiquidItemID() == LiquidManager.REFINED_FUEL.getID())) { + if (intersectsWith(t, g)) { + drawCreativeTabHoveringText("Fuel", t, g); + } + } + } - @Override - protected void drawCreativeTabHoveringText(String str, int t, int g) { - int textWidth = fontRendererObj.getStringWidth(distilInventory.amount + "/" + distilInventory.getTankCapacity()); - int startX = t + 14; - int startY = g - 12; + @Override + protected void drawCreativeTabHoveringText(String str, int t, int g) { + int textWidth = fontRendererObj.getStringWidth(distilInventory.amount + "/" + distilInventory.getTankCapacity()); + int startX = t + 14; + int startY = g - 12; - int i4 = 0xf0100010; - drawGradientRect(startX - 3, startY - 4, startX + textWidth + 3, startY + 8 + 4 + 10, i4, i4); - drawGradientRect(startX - 4, startY - 3, startX + textWidth + 4, startY + 8 + 3 + 10, i4, i4); - int colour1 = 0x505000ff; - int colour2 = (colour1 & 0xfefefe) >> 1 | colour1 & 0xff000000; - drawGradientRect(startX - 3, startY - 3, startX + textWidth + 3, startY + 8 + 3 + 10, colour1, colour2); - drawGradientRect(startX - 2, startY - 2, startX + textWidth + 2, startY + 8 + 2 + 10, i4, i4); - fontRendererObj.drawStringWithShadow(str, startX, startY, -1); - fontRendererObj.drawStringWithShadow(distilInventory.amount + "/" + distilInventory.getTankCapacity(), startX, startY + 10, -1); - } + int i4 = 0xf0100010; + drawGradientRect(startX - 3, startY - 4, startX + textWidth + 3, startY + 8 + 4 + 10, i4, i4); + drawGradientRect(startX - 4, startY - 3, startX + textWidth + 4, startY + 8 + 3 + 10, i4, i4); + int colour1 = 0x505000ff; + int colour2 = (colour1 & 0xfefefe) >> 1 | colour1 & 0xff000000; + drawGradientRect(startX - 3, startY - 3, startX + textWidth + 3, startY + 8 + 3 + 10, colour1, colour2); + drawGradientRect(startX - 2, startY - 2, startX + textWidth + 2, startY + 8 + 2 + 10, i4, i4); + fontRendererObj.drawStringWithShadow(str, startX, startY, -1); + fontRendererObj.drawStringWithShadow(distilInventory.amount + "/" + distilInventory.getTankCapacity(), startX, startY + 10, -1); + } - @Override - protected void drawGuiContainerBackgroundLayer(float f, int t, int g) { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - mc.renderEngine.bindTexture(new ResourceLocation(Info.resourceLocation,Info.guiPrefix + "gui_distillation_tower2.png")); - int j = (width - xSize) / 2; - int k = (height - ySize) / 2; - drawTexturedModalRect(j, k, 0, 0, xSize, ySize); - int amount = distilInventory.getLiquid(); - int liqui = Math.abs((amount * 50) / (distilInventory.getTankCapacity())); - drawTexturedModalRect(j + 145, (k + 57) - liqui, 177, 107 - liqui, 18, liqui); - if (LiquidManager.REFINED_FUEL != null && distilInventory.getLiquidItemID() == LiquidManager.REFINED_FUEL.getID()) { - drawRect(j + 145, k + 57, 177, 107, 0); - } + @Override + protected void drawGuiContainerBackgroundLayer(float f, int t, int g) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + mc.renderEngine.bindTexture(new ResourceLocation(Info.resourceLocation, Info.guiPrefix + "gui_distillation_tower2.png")); + int j = (width - xSize) / 2; + int k = (height - ySize) / 2; + drawTexturedModalRect(j, k, 0, 0, xSize, ySize); + int amount = distilInventory.getLiquid(); + int liqui = Math.abs((amount * 50) / (distilInventory.getTankCapacity())); + drawTexturedModalRect(j + 145, (k + 57) - liqui, 177, 107 - liqui, 18, liqui); + if (LiquidManager.REFINED_FUEL != null && distilInventory.getLiquidItemID() == LiquidManager.REFINED_FUEL.getID()) { + drawRect(j + 145, k + 57, 177, 107, 0); + } - if (distilInventory.isBurning()) { - int l = distilInventory.getBurnTimeRemainingScaled(12); - drawTexturedModalRect(j + 56, (k + 36 + 12) - l, 176, 12 - l, 14, l + 2); - } - int i1 = distilInventory.getCookProgressScaled(22);//31 - drawTexturedModalRect(j + 87, k + 36, 184, 15, i1, 41);//41 - } + if (distilInventory.isBurning()) { + int l = distilInventory.getBurnTimeRemainingScaled(12); + drawTexturedModalRect(j + 56, (k + 36 + 12) - l, 176, 12 - l, 14, l + 2); + } + int i1 = distilInventory.getCookProgressScaled(22);//31 + drawTexturedModalRect(j + 87, k + 36, 184, 15, i1, 41);//41 + } - public boolean intersectsWith(int mouseX, int mouseY) { - int j = (width - xSize) / 2; - int k = (height - ySize) / 2; - return (mouseX >= j + 143 && mouseX <= j + 164 && mouseY >= k + 5 && mouseY <= k + 57); - } + public boolean intersectsWith(int mouseX, int mouseY) { + int j = (width - xSize) / 2; + int k = (height - ySize) / 2; + return (mouseX >= j + 143 && mouseX <= j + 164 && mouseY >= k + 5 && mouseY <= k + 57); + } } diff --git a/src/main/java/train/client/gui/GuiForney.java b/src/main/java/train/client/gui/GuiForney.java index bf9a3e84a7..5621f745e8 100644 --- a/src/main/java/train/client/gui/GuiForney.java +++ b/src/main/java/train/client/gui/GuiForney.java @@ -20,204 +20,200 @@ public class GuiForney extends GuiContainer { - private String texture = Info.guiPrefix + "customButton.png"; - private int textureX = 0; - private int textureY = 46; - private int textureSizeX = 40; - private int textureSizeY = 13; - private int buttonPosX = 0; - private int buttonPosY = 0; - - - private GuiButton buttonLock; - - private Locomotive loco; - - public GuiForney(InventoryPlayer inventoryplayer, Entity entityminecart) { - super(new InventoryForney(inventoryplayer, (Locomotive) entityminecart)); - loco = (Locomotive) entityminecart; - } - - @Override - public void initGui() { - super.initGui(); - buttonList.clear(); - if (!loco.parkingBrake) { - if (loco instanceof SteamTrain) { - textureX = 41; - textureY = 13; - textureSizeX = 40; - textureSizeY = 13; - } - else { - textureX = 126; - textureY = 13; - textureSizeX = 43; - textureSizeY = 13; - } - buttonPosX = 33; - buttonPosY = -13; - buttonList.add(new GuiCustomButton(2, ((width - xSize) / 2) + buttonPosX, ((height - ySize) / 2) + buttonPosY, textureSizeX, textureSizeY, "", texture, textureX, textureY));// Brake: Off - } - else if (loco.parkingBrake) { - if (loco instanceof SteamTrain) { - textureX = 0; - textureY = 13; - textureSizeX = 40; - textureSizeY = 13; - } - else { - textureX = 82; - textureY = 13; - textureSizeX = 43; - textureSizeY = 13; - } - buttonPosX = 0; - buttonPosY = -13; - buttonList.add(new GuiCustomButton(2, ((width - xSize) / 2) + buttonPosX, ((height - ySize) / 2) + buttonPosY, textureSizeX, textureSizeY, "", texture, textureX, textureY));// Brake: On - } - int var1 = (this.width - xSize) / 2; - int var2 = (this.height - ySize) / 2; - if (!loco.getTrainLockedFromPacket()) { - this.buttonList.add(this.buttonLock = new GuiButton(3, var1 + 124, var2 - 10, 51, 10, "Unlocked")); - } - else { - this.buttonList.add(this.buttonLock = new GuiButton(3, var1 + 130, var2 - 10, 43, 10, "Locked")); - } - } - - @Override - protected void actionPerformed(GuiButton guibutton) { - if (guibutton.id == 2) { - if ((!loco.getParkingBrakeFromPacket()) && loco.getSpeed() < 10) { - Traincraft.brakeChannel.sendToServer(new PacketParkingBrake(true, loco.getEntityId())); - loco.parkingBrake = true; - guibutton.displayString = "Brake: On"; - this.initGui(); - } - else if (loco.getSpeed() < 10) { - Traincraft.brakeChannel.sendToServer(new PacketParkingBrake(false, loco.getEntityId())); - loco.parkingBrake = false; - guibutton.displayString = "Brake: Off"; - this.initGui(); - } - } - if (guibutton.id == 3) { - //System.out.println("1 "+loco.getTrainOwner()); - //System.out.println("2 "+((EntityPlayer)loco.riddenByEntity).getDisplayName()); - //System.out.println(((EntityPlayer)loco.riddenByEntity).getDisplayName().equals(loco.getTrainOwner().trim())); - - if (loco.riddenByEntity != null && loco.riddenByEntity instanceof EntityPlayer && ((EntityPlayer) loco.riddenByEntity).getDisplayName().equals(loco.getTrainOwner())) { - if ((!loco.getTrainLockedFromPacket())) { - Traincraft.lockChannel.sendToServer(new PacketSetTrainLockedToClient(true, loco.getEntityId())); - loco.locked = true; - guibutton.displayString = "Locked"; - this.initGui(); - } - else { - Traincraft.lockChannel.sendToServer(new PacketSetTrainLockedToClient(false, loco.getEntityId())); - loco.locked = false; - guibutton.displayString = "UnLocked"; - this.initGui(); - } - } - else if (loco.riddenByEntity != null && loco.riddenByEntity instanceof EntityPlayer) { - ((EntityPlayer) loco.riddenByEntity).addChatMessage(new ChatComponentText("You are not the owner")); - } - } - } - - @Override - protected void drawCreativeTabHoveringText(String str, int t, int g) { - - //int liqui = (dieselInventory.getLiquidAmount() * 50) / dieselInventory.getTankCapacity(); - String state = ""; - if (loco.getTrainLockedFromPacket()) { - state = "Locked"; - } else { - state = "Unlocked"; - } - - int textWidth = fontRendererObj.getStringWidth("the GUI, change speed, destroy it."); - int startX = 90; - int startY = 5; - - int i4 = 0xf0100010; - drawGradientRect(startX - 3, startY - 4, startX + textWidth + 3, startY + 8 + 4 + 40, i4, i4); - drawGradientRect(startX - 4, startY - 3, startX + textWidth + 4, startY + 8 + 3 + 40, i4, i4); - int colour1 = 0x505000ff; - int colour2 = (colour1 & 0xfefefe) >> 1 | colour1 & 0xff000000; - drawGradientRect(startX - 3, startY - 3, startX + textWidth + 3, startY + 8 + 3 + 40, colour1, colour2); - drawGradientRect(startX - 2, startY - 2, startX + textWidth + 2, startY + 8 + 2 + 40, i4, i4); - fontRendererObj.drawStringWithShadow(str, startX, startY, -1); - fontRendererObj.drawStringWithShadow("only its owner can open", startX, startY + 10, -1); - fontRendererObj.drawStringWithShadow("the GUI, change speed, destroy it.", startX, startY + 20, -1); - fontRendererObj.drawStringWithShadow("Current state: " + state, startX, startY + 30, -1); - fontRendererObj.drawStringWithShadow("Owner: " + loco.getTrainOwner().trim(), startX, startY + 40, -1); - } - - public boolean intersectsWith(int mouseX, int mouseY) { - //System.out.println(mouseX+" "+mouseY); - int j = (width - xSize) / 2; - int k = (height - ySize) / 2; - return (mouseX >= j + 124 && mouseX <= j + 174 && mouseY >= k - 10 && mouseY <= k); - } - - @Override - protected void drawGuiContainerForegroundLayer(int i, int j) { - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_DEPTH_TEST); - - fontRendererObj.drawString(loco.getCommandSenderName(), 37, 3, 0x000000); - fontRendererObj.drawString(loco.getCommandSenderName(), 39, 1, 0x000000); - fontRendererObj.drawString(loco.getCommandSenderName(), 37, 1, 0x000000); - fontRendererObj.drawString(loco.getCommandSenderName(), 39, 3, 0x000000); - - fontRendererObj.drawString(loco.getCommandSenderName(), 38, 3, 0x000000); - fontRendererObj.drawString(loco.getCommandSenderName(), 38, 1, 0x000000); - fontRendererObj.drawString(loco.getCommandSenderName(), 37, 2, 0x000000); - fontRendererObj.drawString(loco.getCommandSenderName(), 39, 2, 0x000000); - fontRendererObj.drawString(loco.getCommandSenderName(), 38, 2, 0xd3a900); - - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glEnable(GL11.GL_DEPTH_TEST); - if (intersectsWith(i, j)) { - drawCreativeTabHoveringText("When a locomotive is locked,", i, j); - } - } - - @Override - protected void drawGuiContainerBackgroundLayer(float f, int t, int g) { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - mc.renderEngine.bindTexture(new ResourceLocation(Info.resourceLocation, Info.guiPrefix + "gui_forney.png")); - int j = (width - xSize) / 2; - int k = (height - ySize) / 2; - drawTexturedModalRect(j, k, 0, 0, xSize, ySize); - - if (loco.getIsFuelled()) { - int l = loco.getFuelDiv(12); - drawTexturedModalRect(j + 8, (k + 30) - l, 176, 12 - l, 14, l + 2); - } - - if (loco instanceof SteamTrain) { - - int load = (((SteamTrain) loco).getWater()); - int lo = Math.abs(((load * 50) / (((SteamTrain) loco).getCartTankCapacity()))); - - if (((SteamTrain) loco).getLiquidItemID() == LiquidManager.WATER_FILTER.getFluidID()) { - drawTexturedModalRect(j + 143, (k + 68) - lo, 190, 69 - lo, 18, lo + 1); - } - } - fontRendererObj.drawStringWithShadow("Carts pulled: " + loco.getCurrentNumCartsPulled(), 1, 10, 0xFFFFFF); - fontRendererObj.drawStringWithShadow("Mass pulled: " + loco.getCurrentMassPulled(), 1, 20, 0xFFFFFF); - fontRendererObj.drawStringWithShadow("Speed reduction: " + loco.getCurrentSpeedSlowDown() + " km/h", 1, 30, 0xFFFFFF); - fontRendererObj.drawStringWithShadow("Accel reduction: " + loco.getCurrentAccelSlowDown(), 1, 40, 0xFFFFFF); - fontRendererObj.drawStringWithShadow("Brake reduction: " + loco.getCurrentBrakeSlowDown(), 1, 50, 0xFFFFFF); - fontRendererObj.drawStringWithShadow("Fuel consumption: 1 every " + loco.getFuelConsumption() + " ticks", 1, 60, 0xFFFFFF); - fontRendererObj.drawStringWithShadow("Fuel: " + loco.getFuel(), 1, 70, 0xFFFFFF); - fontRendererObj.drawStringWithShadow("Power: " + loco.getPower() + " Mhp", 1, 80, 0xFFFFFF); - fontRendererObj.drawStringWithShadow("State: " + loco.getState(), 1, 90, 0xFFFFFF); - fontRendererObj.drawStringWithShadow("Heat level: " + loco.getOverheatLevel(), 1, 100, 0xFFFFFF); - fontRendererObj.drawStringWithShadow("Maximum Speed: " + (loco.getCustomSpeedGUI()), 1, 110, 0xFFFFFF); - } + private final String texture = Info.guiPrefix + "customButton.png"; + private final Locomotive loco; + private GuiButton buttonLock; + private int textureX = 0; + private int textureY = 46; + private int textureSizeX = 40; + private int textureSizeY = 13; + private int buttonPosX = 0; + private int buttonPosY = 0; + + + public GuiForney(InventoryPlayer inventoryplayer, Entity entityminecart) { + super(new InventoryForney(inventoryplayer, (Locomotive) entityminecart)); + loco = (Locomotive) entityminecart; + } + + @Override + public void initGui() { + super.initGui(); + buttonList.clear(); + if (!loco.parkingBrake) { + // Brake: On + if (loco instanceof SteamTrain) { + textureX = 41; + textureY = 13; + textureSizeX = 40; + textureSizeY = 13; + } else { + textureX = 126; + textureY = 13; + textureSizeX = 43; + textureSizeY = 13; + } + buttonPosX = 33; + } else { + // Brake: Off + if (loco instanceof SteamTrain) { + textureX = 0; + textureY = 13; + textureSizeX = 40; + textureSizeY = 13; + } else { + textureX = 82; + textureY = 13; + textureSizeX = 43; + textureSizeY = 13; + } + buttonPosX = 0; + } + buttonPosY = -13; + + buttonList.add(new GuiCustomButton(2, ((width - xSize) / 2) + buttonPosX, ((height - ySize) / 2) + buttonPosY, textureSizeX, textureSizeY, "", texture, textureX, textureY)); + + int buttonPosX = (this.width - xSize) / 2; + int buttonPosY = (this.height - ySize) / 2; + + if (!loco.getTrainLockedFromPacket()) { + this.buttonList.add(this.buttonLock = new GuiButton(3, buttonPosX + 124, buttonPosY - 10, 51, 10, "Unlocked")); + } else { + this.buttonList.add(this.buttonLock = new GuiButton(3, buttonPosX + 130, buttonPosY - 10, 43, 10, "Locked")); + } + } + + @Override + protected void actionPerformed(GuiButton guibutton) { + if (guibutton.id == 2) { + if ((!loco.getParkingBrakeFromPacket()) && loco.getSpeed() < 10) { + Traincraft.brakeChannel.sendToServer(new PacketParkingBrake(true, loco.getEntityId())); + loco.parkingBrake = true; + guibutton.displayString = "Brake: On"; + this.initGui(); + } else if (loco.getSpeed() < 10) { + Traincraft.brakeChannel.sendToServer(new PacketParkingBrake(false, loco.getEntityId())); + loco.parkingBrake = false; + guibutton.displayString = "Brake: Off"; + this.initGui(); + } + } + + if (guibutton.id == 3) { + //System.out.println("1 "+loco.getTrainOwner()); + //System.out.println("2 "+((EntityPlayer)loco.riddenByEntity).getDisplayName()); + //System.out.println(((EntityPlayer)loco.riddenByEntity).getDisplayName().equals(loco.getTrainOwner().trim())); + + if (loco.riddenByEntity != null && loco.riddenByEntity instanceof EntityPlayer && ((EntityPlayer) loco.riddenByEntity).getDisplayName().equals(loco.getTrainOwner())) { + if (!loco.getTrainLockedFromPacket()) { + Traincraft.lockChannel.sendToServer(new PacketSetTrainLockedToClient(true, loco.getEntityId())); + loco.locked = true; + guibutton.displayString = "Locked"; + this.initGui(); + } else { + Traincraft.lockChannel.sendToServer(new PacketSetTrainLockedToClient(false, loco.getEntityId())); + loco.locked = false; + guibutton.displayString = "Unlocked"; + this.initGui(); + } + } else if (loco.riddenByEntity != null && loco.riddenByEntity instanceof EntityPlayer) { + ((EntityPlayer) loco.riddenByEntity).addChatMessage(new ChatComponentText("You are not the owner")); + } + } + } + + @Override + protected void drawCreativeTabHoveringText(String str, int t, int g) { + + //int liqui = (dieselInventory.getLiquidAmount() * 50) / dieselInventory.getTankCapacity(); + String state = ""; + if (loco.getTrainLockedFromPacket()) { + state = "Locked"; + } else { + state = "Unlocked"; + } + + int textWidth = fontRendererObj.getStringWidth("the GUI, change speed, destroy it."); + int startX = 90; + int startY = 5; + + int i4 = 0xf0100010; + drawGradientRect(startX - 3, startY - 4, startX + textWidth + 3, startY + 8 + 4 + 40, i4, i4); + drawGradientRect(startX - 4, startY - 3, startX + textWidth + 4, startY + 8 + 3 + 40, i4, i4); + int colour1 = 0x505000ff; + int colour2 = (colour1 & 0xfefefe) >> 1 | colour1 & 0xff000000; + drawGradientRect(startX - 3, startY - 3, startX + textWidth + 3, startY + 8 + 3 + 40, colour1, colour2); + drawGradientRect(startX - 2, startY - 2, startX + textWidth + 2, startY + 8 + 2 + 40, i4, i4); + fontRendererObj.drawStringWithShadow(str, startX, startY, -1); + fontRendererObj.drawStringWithShadow("only its owner can open", startX, startY + 10, -1); + fontRendererObj.drawStringWithShadow("the GUI, change speed, destroy it.", startX, startY + 20, -1); + fontRendererObj.drawStringWithShadow("Current state: " + state, startX, startY + 30, -1); + fontRendererObj.drawStringWithShadow("Owner: " + loco.getTrainOwner().trim(), startX, startY + 40, -1); + } + + public boolean intersectsWith(int mouseX, int mouseY) { + //System.out.println(mouseX+" "+mouseY); + int j = (width - xSize) / 2; + int k = (height - ySize) / 2; + return (mouseX >= j + 124 && mouseX <= j + 174 && mouseY >= k - 10 && mouseY <= k); + } + + @Override + protected void drawGuiContainerForegroundLayer(int i, int j) { + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_DEPTH_TEST); + + fontRendererObj.drawString(loco.getCommandSenderName(), 37, 3, 0x000000); + fontRendererObj.drawString(loco.getCommandSenderName(), 39, 1, 0x000000); + fontRendererObj.drawString(loco.getCommandSenderName(), 37, 1, 0x000000); + fontRendererObj.drawString(loco.getCommandSenderName(), 39, 3, 0x000000); + + fontRendererObj.drawString(loco.getCommandSenderName(), 38, 3, 0x000000); + fontRendererObj.drawString(loco.getCommandSenderName(), 38, 1, 0x000000); + fontRendererObj.drawString(loco.getCommandSenderName(), 37, 2, 0x000000); + fontRendererObj.drawString(loco.getCommandSenderName(), 39, 2, 0x000000); + fontRendererObj.drawString(loco.getCommandSenderName(), 38, 2, 0xd3a900); + + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_DEPTH_TEST); + + if (intersectsWith(i, j)) { + drawCreativeTabHoveringText("When a locomotive is locked,", i, j); + } + } + + @Override + protected void drawGuiContainerBackgroundLayer(float f, int t, int g) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + mc.renderEngine.bindTexture(new ResourceLocation(Info.resourceLocation, Info.guiPrefix + "gui_forney.png")); + int j = (width - xSize) / 2; + int k = (height - ySize) / 2; + drawTexturedModalRect(j, k, 0, 0, xSize, ySize); + + if (loco.getIsFuelled()) { + int l = loco.getFuelDiv(12); + drawTexturedModalRect(j + 8, (k + 30) - l, 176, 12 - l, 14, l + 2); + } + + if (loco instanceof SteamTrain) { + int load = (((SteamTrain) loco).getWater()); + int lo = Math.abs(((load * 50) / (((SteamTrain) loco).getCartTankCapacity()))); + + if (((SteamTrain) loco).getLiquidItemID() == LiquidManager.WATER_FILTER.getFluidID()) { + drawTexturedModalRect(j + 143, (k + 68) - lo, 190, 69 - lo, 18, lo + 1); + } + } + + fontRendererObj.drawStringWithShadow("Carts pulled: " + loco.getCurrentNumCartsPulled(), 1, 10, 0xFFFFFF); + fontRendererObj.drawStringWithShadow("Mass pulled: " + loco.getCurrentMassPulled(), 1, 20, 0xFFFFFF); + fontRendererObj.drawStringWithShadow("Speed reduction: " + loco.getCurrentSpeedSlowDown() + " km/h", 1, 30, 0xFFFFFF); + fontRendererObj.drawStringWithShadow("Accel reduction: " + loco.getCurrentAccelSlowDown(), 1, 40, 0xFFFFFF); + fontRendererObj.drawStringWithShadow("Brake reduction: " + loco.getCurrentBrakeSlowDown(), 1, 50, 0xFFFFFF); + fontRendererObj.drawStringWithShadow("Fuel consumption: 1 every " + loco.getFuelConsumption() + " ticks", 1, 60, 0xFFFFFF); + fontRendererObj.drawStringWithShadow("Fuel: " + loco.getFuel(), 1, 70, 0xFFFFFF); + fontRendererObj.drawStringWithShadow("Power: " + loco.getPower() + " Mhp", 1, 80, 0xFFFFFF); + fontRendererObj.drawStringWithShadow("State: " + loco.getState(), 1, 90, 0xFFFFFF); + fontRendererObj.drawStringWithShadow("Heat level: " + loco.getOverheatLevel(), 1, 100, 0xFFFFFF); + fontRendererObj.drawStringWithShadow("Maximum Speed: " + (loco.getCustomSpeedGUI()), 1, 110, 0xFFFFFF); + } } \ No newline at end of file diff --git a/src/main/java/train/client/gui/GuiFreight.java b/src/main/java/train/client/gui/GuiFreight.java index 48e7ddad46..72283086ba 100644 --- a/src/main/java/train/client/gui/GuiFreight.java +++ b/src/main/java/train/client/gui/GuiFreight.java @@ -19,137 +19,141 @@ public class GuiFreight extends GuiContainer { - private Freight freight; - private int inventoryRows; - private EntityPlayer player; - - private float yaw; - private float roll; - private boolean rollDown; - private GuiButton buttonLock; - - public GuiFreight(EntityPlayer player, InventoryPlayer inventoryplayer, Entity entityminecart) { - super(new InventoryFreight(inventoryplayer, (Freight) entityminecart)); - freight = (Freight) entityminecart; - this.player = player; - inventoryRows = 0; - char c = '\336'; - int i = c - 108; - inventoryRows = (freight.getSizeInventory() / 9); - ySize = i + inventoryRows * 18; - } - - @Override - public void initGui() { - super.initGui(); - buttonList.clear(); - int var1 = (this.width - xSize) / 2; - int var2 = (this.height - ySize) / 2; - if (!freight.getTrainLockedFromPacket()) { - this.buttonList.add(this.buttonLock = new GuiButton(3, var1 + 124, var2 - 10, 51, 10, "Unlocked")); - } - else { - this.buttonList.add(this.buttonLock = new GuiButton(3, var1 + 130, var2 - 10, 43, 10, "Locked")); - } - } - - @Override - protected void actionPerformed(GuiButton guibutton) { - if (guibutton.id == 3) { - if (player != null && player.getCommandSenderName().toLowerCase().equals(freight.getTrainOwner().toLowerCase())) { - if ((!freight.getTrainLockedFromPacket())) { - AxisAlignedBB box = freight.boundingBox.expand(5, 5, 5); - List lis3 = freight.worldObj.getEntitiesWithinAABBExcludingEntity(freight, box); - if (lis3 != null && lis3.size() > 0) { - for (Object entity : lis3) { - if (entity instanceof EntityPlayer) { - Traincraft.lockChannel.sendToServer(new PacketSetTrainLockedToClient(true, freight.getEntityId())); - } - } - } - - freight.locked = true; - guibutton.displayString = "Locked"; - this.initGui(); - } - else { - AxisAlignedBB box = freight.boundingBox.expand(5, 5, 5); - List lis3 = freight.worldObj.getEntitiesWithinAABBExcludingEntity(freight, box); - if (lis3 != null && lis3.size() > 0) { - for (Object entity : lis3) { - if (entity instanceof EntityPlayer) { - Traincraft.lockChannel.sendToServer(new PacketSetTrainLockedToClient(false, freight.getEntityId())); - } - } - } - freight.locked = false; - guibutton.displayString = "UnLocked"; - this.initGui(); - } - } - else if (player != null && player instanceof EntityPlayer) { - player.addChatMessage(new ChatComponentText("You are not the owner")); - } - } - } + private final Freight freight; + private int inventoryRows; + private final EntityPlayer player; - @Override - protected void drawCreativeTabHoveringText(String str, int t, int g) { + private float yaw; + private float roll; + private boolean rollDown; + private GuiButton buttonLock; - String state = ""; - if (freight.getTrainLockedFromPacket()) + public GuiFreight(EntityPlayer player, InventoryPlayer inventoryplayer, Entity entityminecart) { + super(new InventoryFreight(inventoryplayer, (Freight) entityminecart)); + + this.player = player; + freight = (Freight) entityminecart; + + inventoryRows = 0; + char c = '\336'; + int i = c - 108; + inventoryRows = (freight.getSizeInventory() / 9); + ySize = i + inventoryRows * 18; + } + + @Override + public void initGui() { + super.initGui(); + buttonList.clear(); + + int buttonPosX = (this.width - xSize) / 2; + int buttonPosY = (this.height - ySize) / 2; + + if (!freight.getTrainLockedFromPacket()) { + this.buttonList.add(this.buttonLock = new GuiButton(3, buttonPosX + 124, buttonPosY - 10, 51, 10, "Unlocked")); + } else { + this.buttonList.add(this.buttonLock = new GuiButton(3, buttonPosX + 130, buttonPosY - 10, 43, 10, "Locked")); + } + } + + @Override + protected void actionPerformed(GuiButton guibutton) { + if (guibutton.id == 3) { + if (player != null && player.getCommandSenderName().equalsIgnoreCase(freight.getTrainOwner())) { + AxisAlignedBB box = freight.boundingBox.expand(5, 5, 5); + List lis3 = freight.worldObj.getEntitiesWithinAABBExcludingEntity(freight, box); + + if (!freight.getTrainLockedFromPacket()) { + if (lis3 != null && !lis3.isEmpty()) { + for (Object entity : lis3) { + if (entity instanceof EntityPlayer) { + Traincraft.lockChannel.sendToServer(new PacketSetTrainLockedToClient(true, freight.getEntityId())); + } + } + } + + freight.locked = true; + guibutton.displayString = "Locked"; + } else { + if (lis3 != null && !lis3.isEmpty()) { + for (Object entity : lis3) { + if (entity instanceof EntityPlayer) { + Traincraft.lockChannel.sendToServer(new PacketSetTrainLockedToClient(false, freight.getEntityId())); + } + } + } + + freight.locked = false; + guibutton.displayString = "Unlocked"; + } + + this.initGui(); + } else if (player != null) { + player.addChatMessage(new ChatComponentText("You are not the owner")); + } + } + } + + @Override + protected void drawCreativeTabHoveringText(String str, int t, int g) { + String state = ""; + if (freight.getTrainLockedFromPacket()) { state = "Locked"; - if (!freight.getTrainLockedFromPacket()) + } + + if (!freight.getTrainLockedFromPacket()) { state = "Unlocked"; + } - int textWidth = fontRendererObj.getStringWidth("the GUI, change speed, destroy it."); - int startX = 90; - int startY = 5; - - int i4 = 0xf0100010; - drawGradientRect(startX - 3, startY - 4, startX + textWidth + 3, startY + 8 + 4 + 40, i4, i4); - drawGradientRect(startX - 4, startY - 3, startX + textWidth + 4, startY + 8 + 3 + 40, i4, i4); + int textWidth = fontRendererObj.getStringWidth("the GUI, change speed, destroy it."); + int startX = 90; + int startY = 5; + int i4 = 0xf0100010; int colour1 = 0x505000ff; int colour2 = (colour1 & 0xfefefe) >> 1 | colour1 & 0xff000000; - drawGradientRect(startX - 3, startY - 3, startX + textWidth + 3, startY + 8 + 3 + 40, colour1, colour2); - drawGradientRect(startX - 2, startY - 2, startX + textWidth + 2, startY + 8 + 2 + 40, i4, i4); - fontRendererObj.drawStringWithShadow(str, startX, startY, -1); - fontRendererObj.drawStringWithShadow("only its owner can open", startX, startY + 10, -1); - fontRendererObj.drawStringWithShadow("the GUI and destroy it.", startX, startY + 20, -1); - fontRendererObj.drawStringWithShadow("Current state: " + state, startX, startY + 30, -1); - fontRendererObj.drawStringWithShadow("Owner: " + freight.getTrainOwner().trim(), startX, startY + 40, -1); - } - - public boolean intersectsWith(int mouseX, int mouseY) { - int j = (width - xSize) / 2; - int k = (height - ySize) / 2; - return (mouseX >= j + 124 && mouseX <= j + 174 && mouseY >= k - 10 && mouseY <= k); - } - - @Override - protected void drawGuiContainerForegroundLayer(int i, int j) { - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_DEPTH_TEST); - - fontRendererObj.drawString(freight.getCommandSenderName(), 10, 6, 0x404040); - fontRendererObj.drawString("Inventory", 8, (ySize - 96) + 2, 0x404040); - - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glEnable(GL11.GL_DEPTH_TEST); - - if (intersectsWith(i, j)) { - drawCreativeTabHoveringText("When a freight is locked,", i, j); - } - } - - @Override - protected void drawGuiContainerBackgroundLayer(float f, int t, int g) { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - mc.renderEngine.bindTexture(new ResourceLocation(Info.resourceLocation, Info.guiPrefix + "container.png")); - int j = (width - xSize) / 2; - int k = (height - ySize) / 2; - - drawTexturedModalRect(j, k, 0, 0, xSize, inventoryRows * 18 + 17); - drawTexturedModalRect(j, k + inventoryRows * 18 + 17, 0, 126, xSize, 96); - } + + drawGradientRect(startX - 3, startY - 4, startX + textWidth + 3, startY + 8 + 4 + 40, i4, i4); + drawGradientRect(startX - 4, startY - 3, startX + textWidth + 4, startY + 8 + 3 + 40, i4, i4); + drawGradientRect(startX - 3, startY - 3, startX + textWidth + 3, startY + 8 + 3 + 40, colour1, colour2); + drawGradientRect(startX - 2, startY - 2, startX + textWidth + 2, startY + 8 + 2 + 40, i4, i4); + + fontRendererObj.drawStringWithShadow(str, startX, startY, -1); + fontRendererObj.drawStringWithShadow("only its owner can open", startX, startY + 10, -1); + fontRendererObj.drawStringWithShadow("the GUI and destroy it.", startX, startY + 20, -1); + fontRendererObj.drawStringWithShadow("Current state: " + state, startX, startY + 30, -1); + fontRendererObj.drawStringWithShadow("Owner: " + freight.getTrainOwner().trim(), startX, startY + 40, -1); + } + + public boolean intersectsWith(int mouseX, int mouseY) { + int j = (width - xSize) / 2; + int k = (height - ySize) / 2; + return (mouseX >= j + 124 && mouseX <= j + 174 && mouseY >= k - 10 && mouseY <= k); + } + + @Override + protected void drawGuiContainerForegroundLayer(int i, int j) { + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_DEPTH_TEST); + + fontRendererObj.drawString(freight.getCommandSenderName(), 10, 6, 0x404040); + fontRendererObj.drawString("Inventory", 8, (ySize - 96) + 2, 0x404040); + + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_DEPTH_TEST); + + if (intersectsWith(i, j)) { + drawCreativeTabHoveringText("When a freight is locked,", i, j); + } + } + + @Override + protected void drawGuiContainerBackgroundLayer(float f, int t, int g) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + mc.renderEngine.bindTexture(new ResourceLocation(Info.resourceLocation, Info.guiPrefix + "container.png")); + int j = (width - xSize) / 2; + int k = (height - ySize) / 2; + + drawTexturedModalRect(j, k, 0, 0, xSize, inventoryRows * 18 + 17); + drawTexturedModalRect(j, k + inventoryRows * 18 + 17, 0, 126, xSize, 96); + } } \ No newline at end of file diff --git a/src/main/java/train/client/gui/GuiFurnaceCart.java b/src/main/java/train/client/gui/GuiFurnaceCart.java index 71a8f593dc..67b42a6355 100644 --- a/src/main/java/train/client/gui/GuiFurnaceCart.java +++ b/src/main/java/train/client/gui/GuiFurnaceCart.java @@ -11,35 +11,35 @@ import train.common.library.Info; public class GuiFurnaceCart extends GuiContainer { - private AbstractWorkCart furnaceInventory; + private final AbstractWorkCart furnaceInventory; - public GuiFurnaceCart(InventoryPlayer par1InventoryPlayer, Entity entityminecart) { - super(new InventoryWorkCart(par1InventoryPlayer, entityminecart)); - this.furnaceInventory = (AbstractWorkCart) entityminecart; - } + public GuiFurnaceCart(InventoryPlayer par1InventoryPlayer, Entity entityminecart) { + super(new InventoryWorkCart(par1InventoryPlayer, entityminecart)); + this.furnaceInventory = (AbstractWorkCart) entityminecart; + } - @Override - protected void drawGuiContainerForegroundLayer(int i, int j) { - this.fontRendererObj.drawString(StatCollector.translateToLocal("container.furnace"), 60, 6, 4210752); - this.fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 8, this.ySize - 96 + 2, 4210752); - } + @Override + protected void drawGuiContainerForegroundLayer(int i, int j) { + this.fontRendererObj.drawString(StatCollector.translateToLocal("container.furnace"), 60, 6, 4210752); + this.fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 8, this.ySize - 96 + 2, 4210752); + } - @Override - protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { - //int var4 = this.mc.renderEngine.getTexture("/gui/furnace.png"); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - mc.renderEngine.bindTexture(new ResourceLocation(Info.resourceLocation,Info.guiPrefix +"furnace.png")); - int var5 = (this.width - this.xSize) / 2; - int var6 = (this.height - this.ySize) / 2; - this.drawTexturedModalRect(var5, var6, 0, 0, this.xSize, this.ySize); - int var7; + @Override + protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { + //int var4 = this.mc.renderEngine.getTexture("/gui/furnace.png"); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + mc.renderEngine.bindTexture(new ResourceLocation(Info.resourceLocation, Info.guiPrefix + "furnace.png")); + int var5 = (this.width - this.xSize) / 2; + int var6 = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(var5, var6, 0, 0, this.xSize, this.ySize); + int var7; - if (this.furnaceInventory.isBurningFurnace()) { - var7 = this.furnaceInventory.getBurnTimeRemainingScaled(12); - this.drawTexturedModalRect(var5 + 56, var6 + 36 + 12 - var7, 176, 12 - var7, 14, var7 + 2); - } + if (this.furnaceInventory.isBurningFurnace()) { + var7 = this.furnaceInventory.getBurnTimeRemainingScaled(12); + this.drawTexturedModalRect(var5 + 56, var6 + 36 + 12 - var7, 176, 12 - var7, 14, var7 + 2); + } - var7 = this.furnaceInventory.getCookProgressScaled(24); - this.drawTexturedModalRect(var5 + 79, var6 + 34, 176, 14, var7 + 1, 16); - } + var7 = this.furnaceInventory.getCookProgressScaled(24); + this.drawTexturedModalRect(var5 + 79, var6 + 34, 176, 14, var7 + 1, 16); + } } diff --git a/src/main/java/train/client/gui/GuiGeneratorDiesel.java b/src/main/java/train/client/gui/GuiGeneratorDiesel.java index be860c5458..aef6c460f3 100644 --- a/src/main/java/train/client/gui/GuiGeneratorDiesel.java +++ b/src/main/java/train/client/gui/GuiGeneratorDiesel.java @@ -8,69 +8,73 @@ import train.common.library.Info; import train.common.tile.TileGeneratorDiesel; -public class GuiGeneratorDiesel extends GuiContainer{ +public class GuiGeneratorDiesel extends GuiContainer { - private TileGeneratorDiesel dieselInventory; + private final TileGeneratorDiesel dieselInventory; - public GuiGeneratorDiesel(InventoryPlayer invPlayer, TileGeneratorDiesel tile){ + public GuiGeneratorDiesel(InventoryPlayer invPlayer, TileGeneratorDiesel tile) { super(new ContainerGeneratorDiesel(invPlayer, tile)); dieselInventory = tile; } @Override - protected void drawGuiContainerForegroundLayer(int par1, int par2){ + protected void drawGuiContainerForegroundLayer(int par1, int par2) { fontRendererObj.drawString("Diesel Generator", 8, 6, 0x404040); - fontRendererObj.drawString("Inventory", 8, (ySize-96)+2, 0x404040); + fontRendererObj.drawString("Inventory", 8, (ySize - 96) + 2, 0x404040); } @Override - public void drawScreen(int t, int g, float par3){ + public void drawScreen(int t, int g, float par3) { super.drawScreen(t, g, par3); //if ((LiquidManager.diesel != null && dieselInventory.getLiquidItemIDClient() == LiquidManager.diesel.itemID)) { - if(intersectsWith(t, g)){ + if (intersectsWith(t, g)) { drawCreativeTabHoveringText("Diesel", t, g); } //} } @Override - protected void drawCreativeTabHoveringText(String str, int t, int g){ - int textWidth = fontRendererObj.getStringWidth(dieselInventory.theTank.getFluidAmount()+"/"+dieselInventory.getTankCapacity()); - int startX = t+14; - int startY = g-12; - + protected void drawCreativeTabHoveringText(String str, int t, int g) { + int textWidth = fontRendererObj.getStringWidth(dieselInventory.theTank.getFluidAmount() + "/" + dieselInventory.getTankCapacity()); + int startX = t + 14; + int startY = g - 12; int i4 = 0xf0100010; - drawGradientRect(startX-3, startY-4, startX+textWidth+3, startY+8+4+10, i4, i4); - drawGradientRect(startX-4, startY-3, startX+textWidth+4, startY+8+3+10, i4, i4); int colour1 = 0x505000ff; int colour2 = (colour1 & 0xfefefe) >> 1 | colour1 & 0xff000000; - drawGradientRect(startX-3, startY-3, startX+textWidth+3, startY+8+3+10, colour1, colour2); - drawGradientRect(startX-2, startY-2, startX+textWidth+2, startY+8+2+10, i4, i4); + + drawGradientRect(startX - 3, startY - 4, startX + textWidth + 3, startY + 8 + 4 + 10, i4, i4); + drawGradientRect(startX - 4, startY - 3, startX + textWidth + 4, startY + 8 + 3 + 10, i4, i4); + drawGradientRect(startX - 3, startY - 3, startX + textWidth + 3, startY + 8 + 3 + 10, colour1, colour2); + drawGradientRect(startX - 2, startY - 2, startX + textWidth + 2, startY + 8 + 2 + 10, i4, i4); + fontRendererObj.drawStringWithShadow(str, startX, startY, -1); - fontRendererObj.drawStringWithShadow(dieselInventory.theTank.getFluidAmount()+"/"+dieselInventory.getTankCapacity(), startX, startY+10, -1); + fontRendererObj.drawStringWithShadow(dieselInventory.theTank.getFluidAmount() + "/" + dieselInventory.getTankCapacity(), startX, startY + 10, -1); } @Override - protected void drawGuiContainerBackgroundLayer(float f, int t, int g){ + protected void drawGuiContainerBackgroundLayer(float f, int t, int g) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - mc.renderEngine.bindTexture(new ResourceLocation(Info.resourceLocation, Info.guiPrefix+"gui_generator_diesel.png")); - int j = (width-xSize)/2; - int k = (height-ySize)/2; - drawTexturedModalRect(j, k, 0, 0, xSize, ySize); + + mc.renderEngine.bindTexture(new ResourceLocation(Info.resourceLocation, Info.guiPrefix + "gui_generator_diesel.png")); + + int j = (width - xSize) / 2; + int k = (height - ySize) / 2; int amount = dieselInventory.theTank.getFluidAmount(); - int liqui = Math.abs((amount*50)/(dieselInventory.getTankCapacity())); + int liqui = Math.abs((amount * 50) / (dieselInventory.getTankCapacity())); + + drawTexturedModalRect(j, k, 0, 0, xSize, ySize); //if ((LiquidManager.diesel != null && dieselInventory.getLiquidItemIDClient() == LiquidManager.diesel.itemID)) { - drawTexturedModalRect(j+145, (k+57)-liqui, 177, 107-liqui, 18, liqui); + drawTexturedModalRect(j + 145, (k + 57) - liqui, 177, 107 - liqui, 18, liqui); //} - if(dieselInventory.currentBurnTime > 0){ + if (dieselInventory.currentBurnTime > 0) { int l = 12; - drawTexturedModalRect(j+56, (k+36+12)-l, 176, 12-l, 14, l+2); + drawTexturedModalRect(j + 56, (k + 36 + 12) - l, 176, 0, 14, l + 2); } } - public boolean intersectsWith(int mouseX, int mouseY){ - int j = (width-xSize)/2; - int k = (height-ySize)/2; - return mouseX >= j+143 && mouseX <= j+164 && mouseY >= k+5 && mouseY <= k+57; + public boolean intersectsWith(int mouseX, int mouseY) { + int j = (width - xSize) / 2; + int k = (height - ySize) / 2; + return mouseX >= j + 143 && mouseX <= j + 164 && mouseY >= k + 5 && mouseY <= k + 57; } } diff --git a/src/main/java/train/client/gui/GuiHandler.java b/src/main/java/train/client/gui/GuiHandler.java index bc61dfa799..1fe4add7c6 100644 --- a/src/main/java/train/client/gui/GuiHandler.java +++ b/src/main/java/train/client/gui/GuiHandler.java @@ -3,7 +3,6 @@ import cpw.mods.fml.common.network.IGuiHandler; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; public class GuiHandler implements IGuiHandler { @@ -14,28 +13,10 @@ public Object getServerGuiElement(int ID, EntityPlayer player, World world, int @Override public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { - TileEntity te = world.getTileEntity(x, y, z); - if (ID == 1) { - if (player.ridingEntity != null) { - return new GuiMTCInfo(player.ridingEntity); - - } else { - return null; - } - - } else if (ID == 2) { - - if (player.ridingEntity != null) { - - return new GuiSpeedTransmitter(te); - - } else { - return null; - } - + if (player.ridingEntity == null && (ID != 1 && ID != 2)) { + return null; } - - return null; + return ID == 1 ? new GuiMTCInfo(player.ridingEntity) : new GuiSpeedTransmitter(world.getTileEntity(x, y, z)); } } diff --git a/src/main/java/train/client/gui/GuiJukebox.java b/src/main/java/train/client/gui/GuiJukebox.java index 37421afa8c..66fa232fe4 100644 --- a/src/main/java/train/client/gui/GuiJukebox.java +++ b/src/main/java/train/client/gui/GuiJukebox.java @@ -31,345 +31,347 @@ public class GuiJukebox extends GuiScreen { - private GuiTCTextField streamTextBox; - private EntityJukeBoxCart jukebox; - private EntityPlayer player; - public boolean exists = true; - private GuiButton buttonLock; - private int gui_width; - private int gui_height; - private int gui_inner_width; - private int gui_inner_height; - private int anim = 0; - private String infoText; - - public GuiJukebox(EntityPlayer player, EntityJukeBoxCart jukebox) { - this.jukebox = jukebox; - this.player = player; - gui_width = 352; - gui_height = 120; - gui_inner_width = gui_width - 40; - gui_inner_height = 20; - infoText = "Paste the link below. (Only .m3u and .pls radio streams)"; - } - - @Override - public void initGui() { - buttonList.clear(); - buttonList.add(new GuiButton(0, this.width / 2 - 45, this.height / 2 + 30, 90, 20, "Play/Pause")); - buttonList.add(new GuiButton(1, this.width / 2 - 45 - 120, this.height / 2 + 30, 90, 20, "Paste")); - buttonList.add(new GuiButton(2, this.width / 2 - 45 + 120, this.height / 2 + 30, 90, 20, "Clear")); - buttonList.add(new GuiButton(4, this.width / 2 - 70, this.height / 2 + 30, 20, 20, "+")); - buttonList.add(new GuiButton(5, this.width / 2 + 50, this.height / 2 + 30, 20, 20, "-")); - streamTextBox = new GuiTCTextField(this.fontRendererObj, this.width / 2 - (gui_width) / 2 + 10, this.height / 2 - gui_height / 2 + 50, gui_width - 16, 16); - streamTextBox.setMaxStringLength(1000); - streamTextBox.setText(this.jukebox.streamURL); - //Localizations - Keyboard.enableRepeatEvents(true); - int var1 = (this.width - gui_width) / 2; - int var2 = (this.height - gui_height) / 2; - if (!((AbstractTrains) jukebox).locked) { - this.buttonList.add(this.buttonLock = new GuiButton(3, var1 + gui_width - 350, var2 - 10, 51, 10, "Unlocked")); - } - else { - this.buttonList.add(this.buttonLock = new GuiButton(3, var1 + gui_width - 350, var2 - 10, 43, 10, "Locked")); - } - } - - @Override - public void onGuiClosed() { - Keyboard.enableRepeatEvents(false); - } - - @Override - public void drawScreen(int par1, int par2, float par3) { - int var5 = (this.width) / 2 - gui_width / 2; - int var6 = (this.height) / 2 - gui_height / 2; - int var7 = (this.width) / 2 + gui_width / 2; - int var8 = (this.height) / 2 + gui_height / 2; - - drawRect(var5 + 2, var6 + 2, var7 + 2, var8 + 2, 0xffc6c6c6); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - mc.renderEngine.bindTexture(new ResourceLocation(Info.resourceLocation, Info.guiPrefix + "gui_jukebox.png")); - - drawSquareCorners(2, 2, var5, var6, var7, var8, 0, 0); - drawSquareCorners(-6, -20, var5, var6 + 26, var7, var8 - gui_height / 2 + 26, 10, 0); - drawSquareSides(gui_width, gui_height, 2, 2, var5, var6, var7, var8, 0, 0); - drawSquareSides(gui_width - 16, 16, 2, 2, var5 + 8, var6 + 22 + 26, var7 - 8, var8 - gui_height / 2 - 32 + 36, 10, 0); - - drawTexturedModalRect(var5 + 6, var6 + 6, 20, 0, 7, 10); - drawTexturedModalRect(var5 + 13, var6 + 6, 0 + anim / 100, 12, (28 * (gui_width / 28)) / 2, 10); - drawTexturedModalRect(var5 + 13 + (28 * (gui_width / 28)) / 2, var6 + 6, 0 + anim / 100, 12, (28 * (gui_width / 28)) / 2, 10); - if (jukebox.isPlaying) { - anim += 10; - if (anim == 2800) { - anim = 0; - } - } - - //fontRenderer.drawString("Date: " + Calendar.getInstance().get(Calendar.MONTH) + " " + Calendar.getInstance().get(Calendar.DATE), var5 - gui_width / 2, var6 - 30, 0xffffffff); - - if((Minecraft.getMinecraft().thePlayer != null) && ((jukebox).player != null) && (!(jukebox).isInvalid)) { - fontRendererObj.drawString("Volume: " + (int) Math.ceil(jukebox.volume * 100), width / 2 - 26, height / 2 + 18, 0xff0e0e0e); - } - else { - fontRendererObj.drawString("Volume: 0", width / 2 - 26, height / 2 + 18, 0xff0e0e0e); - } - - setText(0xff0e0e0e); - super.drawScreen(par1, par2, par3); - streamTextBox.drawTextBox(); - if (intersectsWith(par1, par2)) { - drawCreativeTabHoveringText("When a jukebox is locked,", par1, par2); - } - } - - private void setText(int color) { - fontRendererObj.drawString(infoText, this.width / 2 - gui_width / 2 + 10, this.height / 2 - 30, color); - } - - public void drawSquareCorners(int x, int y, int x0y0, int x1y0, int x0y1, int x1y1, int u, int v) { - mc.renderEngine.bindTexture(new ResourceLocation(Info.resourceLocation, Info.guiPrefix + "gui_jukebox.png")); - drawTexturedModalRect(x0y0 - x, x1y0 - y, u, v, 4, 4); - drawTexturedModalRect(x0y1 + x, x1y0 - y, u + 5, v, 4, 4); - drawTexturedModalRect(x0y0 - x, x1y1 + y, u, v + 5, 4, 4); - drawTexturedModalRect(x0y1 + x, x1y1 + y, u + 5, v + 5, 4, 4); - } - - public void drawSquareSides(int width, int height, int x, int y, int x0y0, int x1y0, int x0y1, int x1y1, int u, int v) { - mc.renderEngine.bindTexture(new ResourceLocation(Info.resourceLocation, Info.guiPrefix + "gui_jukebox.png")); - int sides = width >= height ? width : height; - for (int i = 0; i < sides; i++) { - if (width > height) { - if (i < height) { - drawTexturedModalRect(x0y0 - x, x1y0 + y + i, u, v + 4, 4, 1); - drawTexturedModalRect(x0y1 + x, x1y0 + y + i, u + 5, v + 4, 4, 1); - } - drawTexturedModalRect(x0y0 + x + i, x1y0 - y, u + 4, v, 1, 4); - drawTexturedModalRect(x0y0 + x + i, x1y1 + y, u + 4, v + 5, 1, 4); - } - else { - if (i < width) { - drawTexturedModalRect(x0y0 + x + i, x1y0 - y, u + 4, v, 1, 4); - drawTexturedModalRect(x0y0 + x + i, x1y1 + y, u + 4, v + 5, 1, 4); - } - drawTexturedModalRect(x0y0 - x, x1y0 + y + i, u, v + 4, 4, 1); - drawTexturedModalRect(x0y1 + x, x1y0 + y + i, u + 5, v + 4, 4, 1); - } - } - } - - @Override - public void updateScreen() { - streamTextBox.updateCursorCounter(); - if (jukebox.isInvalid) { - mc.displayGuiScreen((GuiScreen) null); - mc.setIngameFocus(); - } - super.updateScreen(); - } - - public void customStop() { - jukebox.stopStream(); - } - - @Override - protected void keyTyped(char par1, int par2) { - streamTextBox.textboxKeyTyped(par1, par2); - if (par1 == 28) { - actionPerformed((GuiButton) buttonList.get(1)); - } - if (par2 == 1 || par2 == mc.gameSettings.keyBindInventory.getKeyCode()) { - if (!streamTextBox.isFocused()) { - mc.thePlayer.closeScreen(); - } - } - super.keyTyped(par1, par2); - } - - @Override - protected void mouseClicked(int par1, int par2, int par3) { - streamTextBox.mouseClicked(par1, par2, par3); - super.mouseClicked(par1, par2, par3); - } - - @Override - @SideOnly(Side.CLIENT) - protected void actionPerformed(GuiButton button) { - if (button.id == 0) { - if (streamTextBox.getText() != null && streamTextBox.getText().length() > 0) { - if ((!jukebox.isPlaying())) { - if (this.streamTextBox.getText().toLowerCase().contains(".m3u")) { - this.jukebox.streamURL = takeFirstEntryFromM3U(this.streamTextBox.getText()); - } - else if (this.streamTextBox.getText().toLowerCase().contains(".pls")) { - this.jukebox.streamURL = parsePls(this.streamTextBox.getText()); - } - else { - this.jukebox.streamURL = this.streamTextBox.getText(); - } - Traincraft.modChannel.sendToServer(new PacketSetJukeboxStreamingUrl(this.jukebox, this.jukebox.streamURL, true)); - jukebox.startStream(); - } - else { - Traincraft.modChannel.sendToServer(new PacketSetJukeboxStreamingUrl(this.jukebox, this.jukebox.streamURL, false)); - jukebox.stopStream(); - } - } - else if (jukebox.isPlaying){ - Traincraft.modChannel.sendToServer(new PacketSetJukeboxStreamingUrl(this.jukebox, this.jukebox.streamURL, false)); - jukebox.stopStream(); - } - } - - if (button.id == 1) { - Toolkit toolkit = Toolkit.getDefaultToolkit(); - Clipboard clipboard = toolkit.getSystemClipboard(); - try { - String result = (String) clipboard.getData(DataFlavor.stringFlavor); - streamTextBox.setText(result); - } catch (Exception e) {} - } - - if (button.id == 2) { - streamTextBox.setText(""); - streamTextBox.setFocused(true); - } - - if (button.id == 4) { - if((Minecraft.getMinecraft().thePlayer != null) && (jukebox.player != null) && (!jukebox.isInvalid)){ - if(jukebox.volume<1.0f) { - jukebox.volume += 0.1f; - } - } - } - - if (button.id == 5) { - if((Minecraft.getMinecraft().thePlayer != null) && (jukebox.player != null) && (!jukebox.isInvalid)){ - if(jukebox.volume>0.0f) { - jukebox.volume -= 0.1f; - } - } - } - - if (button.id == 3) { - if (player != null && player instanceof EntityPlayer && player.getDisplayName().equals(((AbstractTrains) jukebox).getTrainOwner())) { - if ((!((AbstractTrains) jukebox).locked)) { - AxisAlignedBB box = jukebox.boundingBox.expand(5, 5, 5); - List lis3 = jukebox.worldObj.getEntitiesWithinAABBExcludingEntity(jukebox, box); - if (lis3 != null && lis3.size() > 0) { - for (int j1 = 0; j1 < lis3.size(); j1++) { - Entity entity = (Entity) lis3.get(j1); - if (entity instanceof EntityPlayer) { - Traincraft.lockChannel.sendToServer(new PacketSetTrainLockedToClient(true, this.jukebox.getEntityId())); - } - } - } - ((AbstractTrains) jukebox).locked = true; - button.displayString = "Locked"; - this.initGui(); - } - else { - AxisAlignedBB box = jukebox.boundingBox.expand(5, 5, 5); - List lis3 = jukebox.worldObj.getEntitiesWithinAABBExcludingEntity(jukebox, box); - if (lis3 != null && lis3.size() > 0) { - for (int j1 = 0; j1 < lis3.size(); j1++) { - Entity entity = (Entity) lis3.get(j1); - if (entity instanceof EntityPlayer) { - Traincraft.lockChannel.sendToServer(new PacketSetTrainLockedToClient(true, this.jukebox.getEntityId())); - } - } - } - ((AbstractTrains) jukebox).locked = false; - button.displayString = "UnLocked"; - this.initGui(); - } - } - else if (player != null && player instanceof EntityPlayer) { - player.addChatMessage(new ChatComponentText("You are not the owner")); - } - } - } - - @SideOnly(Side.CLIENT) - public boolean getState() { - return this.jukebox.isPlaying(); - } - - @Override - public boolean doesGuiPauseGame() { - return false; - } - - @Override - protected void drawCreativeTabHoveringText(String str, int t, int g) { - String state = ""; - if (jukebox.locked) - state = "Locked"; - else - state = "Unlocked"; - - int textWidth = fontRendererObj.getStringWidth("When a jukebox is unlocked,")+2; - - int i4 = 0xf0100010; - drawGradientRect(t + 15 - 3, g - 40 - 4, t + textWidth + 3, g + 8 + 4, i4, i4); - drawGradientRect(t + 15 - 4, g - 40 - 3, t + textWidth + 4, g + 8 + 3, i4, i4); - int colour1 = 0x505000ff; - int colour2 = (colour1 & 0xfefefe) >> 1 | colour1 & 0xff000000; - drawGradientRect(t + 15 - 3, g - 40 - 3, t + textWidth + 3, g + 8 + 3, colour1, colour2); - drawGradientRect(t + 15 - 2, g - 40 - 2, t + textWidth + 2, g + 8 + 2, i4, i4); - fontRendererObj.drawStringWithShadow(str, t + 15, g - 40, -1); - fontRendererObj.drawStringWithShadow("only its owner can open", t + 15, g + 10 - 40, -1); - fontRendererObj.drawStringWithShadow("the GUI and destroy it.", t + 15, g + 20 - 40, -1); - fontRendererObj.drawStringWithShadow("Current state: " + state, t + 15, g + 30 - 40, -1); - fontRendererObj.drawStringWithShadow("Owner: " + jukebox.getTrainOwner(), t + 15, g + 40 - 40, -1); - } - - public boolean intersectsWith(int mouseX, int mouseY) { - int j = (width - gui_width) / 2; - int k = (height - gui_height) / 2; - if (mouseX >= j + gui_width - 350 && mouseX <= j + gui_width-300 && mouseY >= k - 10 && mouseY <= k) { - return true; - } - return false; - } - - public String takeFirstEntryFromM3U(String m3uurl) { - String out = ""; - try { - URL m3u = new URL(m3uurl); - URLConnection con = m3u.openConnection(); - BufferedReader i = new BufferedReader(new InputStreamReader(con.getInputStream())); - String mp3; - while ((mp3 = i.readLine()) != null) { - if (!mp3.startsWith("#")) { - break; - } - } - out = mp3; - } catch (IOException e) { - infoText = "Not a valid stream, only .m3u and .pls"; - } - return out; - } - - public String parsePls(String plsurl) { - String out = ""; - try { - URL pls = new URL(plsurl); - URLConnection con = pls.openConnection(); - BufferedReader i = new BufferedReader(new InputStreamReader(con.getInputStream())); - String mp3; - while ((mp3 = i.readLine()) != null) { - String f = mp3.trim(); - if (f.contains("http://")) { - out = f.substring(f.indexOf("http://")); - break; - } - } - } catch (IOException e) { - infoText = "Not a valid stream, only .m3u and .pls"; - } - return out; - } + private GuiTCTextField streamTextBox; + private final EntityJukeBoxCart jukebox; + private final EntityPlayer player; + public boolean exists = true; + private GuiButton buttonLock; + private final int gui_width; + private final int gui_height; + private final int gui_inner_width; + private final int gui_inner_height; + private int anim = 0; + private String infoText; + + public GuiJukebox(EntityPlayer player, EntityJukeBoxCart jukebox) { + this.jukebox = jukebox; + this.player = player; + gui_width = 352; + gui_height = 120; + gui_inner_width = gui_width - 40; + gui_inner_height = 20; + infoText = "Paste the link below. (Only .m3u and .pls radio streams)"; + } + + @Override + public void initGui() { + buttonList.clear(); + + buttonList.add(new GuiButton(0, this.width / 2 - 45, this.height / 2 + 30, 90, 20, "Play/Pause")); + buttonList.add(new GuiButton(1, this.width / 2 - 45 - 120, this.height / 2 + 30, 90, 20, "Paste")); + buttonList.add(new GuiButton(2, this.width / 2 - 45 + 120, this.height / 2 + 30, 90, 20, "Clear")); + buttonList.add(new GuiButton(4, this.width / 2 - 70, this.height / 2 + 30, 20, 20, "+")); + buttonList.add(new GuiButton(5, this.width / 2 + 50, this.height / 2 + 30, 20, 20, "-")); + + streamTextBox = new GuiTCTextField(this.fontRendererObj, this.width / 2 - (gui_width) / 2 + 10, this.height / 2 - gui_height / 2 + 50, gui_width - 16, 16); + streamTextBox.setMaxStringLength(1000); + streamTextBox.setText(this.jukebox.streamURL); + + //Localizations + Keyboard.enableRepeatEvents(true); + int buttonPosX = (this.width - gui_width) / 2; + int buttonPosY = (this.height - gui_height) / 2; + + if (!jukebox.locked) { + this.buttonList.add(this.buttonLock = new GuiButton(3, buttonPosX + gui_width - 350, buttonPosY - 10, 51, 10, "Unlocked")); + } else { + this.buttonList.add(this.buttonLock = new GuiButton(3, buttonPosX + gui_width - 350, buttonPosY - 10, 43, 10, "Locked")); + } + } + + @Override + public void onGuiClosed() { + Keyboard.enableRepeatEvents(false); + } + + @Override + public void drawScreen(int par1, int par2, float par3) { + int var5 = (this.width) / 2 - gui_width / 2; + int var6 = (this.height) / 2 - gui_height / 2; + int var7 = (this.width) / 2 + gui_width / 2; + int var8 = (this.height) / 2 + gui_height / 2; + + drawRect(var5 + 2, var6 + 2, var7 + 2, var8 + 2, 0xffc6c6c6); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + mc.renderEngine.bindTexture(new ResourceLocation(Info.resourceLocation, Info.guiPrefix + "gui_jukebox.png")); + + drawSquareCorners(2, 2, var5, var6, var7, var8, 0, 0); + drawSquareCorners(-6, -20, var5, var6 + 26, var7, var8 - gui_height / 2 + 26, 10, 0); + drawSquareSides(gui_width, gui_height, 2, 2, var5, var6, var7, var8, 0, 0); + drawSquareSides(gui_width - 16, 16, 2, 2, var5 + 8, var6 + 22 + 26, var7 - 8, var8 - gui_height / 2 - 32 + 36, 10, 0); + + drawTexturedModalRect(var5 + 6, var6 + 6, 20, 0, 7, 10); + drawTexturedModalRect(var5 + 13, var6 + 6, anim / 100, 12, (28 * (gui_width / 28)) / 2, 10); + drawTexturedModalRect(var5 + 13 + (28 * (gui_width / 28)) / 2, var6 + 6, anim / 100, 12, (28 * (gui_width / 28)) / 2, 10); + + if (jukebox.isPlaying) { + anim += 10; + if (anim == 2800) { + anim = 0; + } + } + + //fontRenderer.drawString("Date: " + Calendar.getInstance().get(Calendar.MONTH) + " " + Calendar.getInstance().get(Calendar.DATE), var5 - gui_width / 2, var6 - 30, 0xffffffff); + + if (Minecraft.getMinecraft().thePlayer != null && (jukebox.player != null && !jukebox.isInvalid)) { + fontRendererObj.drawString("Volume: " + (int) Math.ceil(jukebox.volume * 100), width / 2 - 26, height / 2 + 18, 0xff0e0e0e); + } else { + fontRendererObj.drawString("Volume: 0", width / 2 - 26, height / 2 + 18, 0xff0e0e0e); + } + + setText(0xff0e0e0e); + super.drawScreen(par1, par2, par3); + streamTextBox.drawTextBox(); + + if (intersectsWith(par1, par2)) { + drawCreativeTabHoveringText("When a jukebox is locked,", par1, par2); + } + } + + private void setText(int color) { + fontRendererObj.drawString(infoText, this.width / 2 - gui_width / 2 + 10, this.height / 2 - 30, color); + } + + public void drawSquareCorners(int x, int y, int x0y0, int x1y0, int x0y1, int x1y1, int u, int v) { + mc.renderEngine.bindTexture(new ResourceLocation(Info.resourceLocation, Info.guiPrefix + "gui_jukebox.png")); + drawTexturedModalRect(x0y0 - x, x1y0 - y, u, v, 4, 4); + drawTexturedModalRect(x0y1 + x, x1y0 - y, u + 5, v, 4, 4); + drawTexturedModalRect(x0y0 - x, x1y1 + y, u, v + 5, 4, 4); + drawTexturedModalRect(x0y1 + x, x1y1 + y, u + 5, v + 5, 4, 4); + } + + public void drawSquareSides(int width, int height, int x, int y, int x0y0, int x1y0, int x0y1, int x1y1, int u, int v) { + mc.renderEngine.bindTexture(new ResourceLocation(Info.resourceLocation, Info.guiPrefix + "gui_jukebox.png")); + int sides = Math.max(width, height); + + for (int i = 0; i < sides; i++) { + if (width > height) { + if (i < height) { + drawTexturedModalRect(x0y0 - x, x1y0 + y + i, u, v + 4, 4, 1); + drawTexturedModalRect(x0y1 + x, x1y0 + y + i, u + 5, v + 4, 4, 1); + } + + drawTexturedModalRect(x0y0 + x + i, x1y0 - y, u + 4, v, 1, 4); + drawTexturedModalRect(x0y0 + x + i, x1y1 + y, u + 4, v + 5, 1, 4); + } else { + if (i < width) { + drawTexturedModalRect(x0y0 + x + i, x1y0 - y, u + 4, v, 1, 4); + drawTexturedModalRect(x0y0 + x + i, x1y1 + y, u + 4, v + 5, 1, 4); + } + + drawTexturedModalRect(x0y0 - x, x1y0 + y + i, u, v + 4, 4, 1); + drawTexturedModalRect(x0y1 + x, x1y0 + y + i, u + 5, v + 4, 4, 1); + } + } + } + + @Override + public void updateScreen() { + streamTextBox.updateCursorCounter(); + if (jukebox.isInvalid) { + mc.displayGuiScreen(null); + mc.setIngameFocus(); + } + + super.updateScreen(); + } + + public void customStop() { + jukebox.stopStream(); + } + + @Override + protected void keyTyped(char par1, int par2) { + streamTextBox.textboxKeyTyped(par1, par2); + if (par1 == 28) { + actionPerformed((GuiButton) buttonList.get(1)); + } + + if (par2 == 1 || par2 == mc.gameSettings.keyBindInventory.getKeyCode()) { + if (!streamTextBox.isFocused()) { + mc.thePlayer.closeScreen(); + } + } + super.keyTyped(par1, par2); + } + + @Override + protected void mouseClicked(int par1, int par2, int par3) { + streamTextBox.mouseClicked(par1, par2, par3); + super.mouseClicked(par1, par2, par3); + } + + @Override + @SideOnly(Side.CLIENT) + protected void actionPerformed(GuiButton button) { + if (button.id == 0) { + if (streamTextBox.getText() != null && !streamTextBox.getText().isEmpty()) { + if (!jukebox.isPlaying()) { + if (this.streamTextBox.getText().toLowerCase().contains(".m3u")) { + this.jukebox.streamURL = takeFirstEntryFromM3U(this.streamTextBox.getText()); + } else if (this.streamTextBox.getText().toLowerCase().contains(".pls")) { + this.jukebox.streamURL = parsePls(this.streamTextBox.getText()); + } else { + this.jukebox.streamURL = this.streamTextBox.getText(); + } + + Traincraft.modChannel.sendToServer(new PacketSetJukeboxStreamingUrl(this.jukebox, this.jukebox.streamURL, true)); + jukebox.startStream(); + } else { + Traincraft.modChannel.sendToServer(new PacketSetJukeboxStreamingUrl(this.jukebox, this.jukebox.streamURL, false)); + jukebox.stopStream(); + } + } else if (jukebox.isPlaying) { + Traincraft.modChannel.sendToServer(new PacketSetJukeboxStreamingUrl(this.jukebox, this.jukebox.streamURL, false)); + jukebox.stopStream(); + } + } + + if (button.id == 1) { + Toolkit toolkit = Toolkit.getDefaultToolkit(); + Clipboard clipboard = toolkit.getSystemClipboard(); + try { + String result = (String) clipboard.getData(DataFlavor.stringFlavor); + streamTextBox.setText(result); + } catch (Exception ignored) { + } + } + + if (button.id == 2) { + streamTextBox.setText(""); + streamTextBox.setFocused(true); + } + + if (button.id == 4) { + if (Minecraft.getMinecraft().thePlayer != null && (jukebox.player != null && !jukebox.isInvalid)) { + if (jukebox.volume < 1.0f) { + jukebox.volume += 0.1f; + } + } + } + + if (button.id == 5) { + if (Minecraft.getMinecraft().thePlayer != null && (jukebox.player != null && !jukebox.isInvalid)) { + if (jukebox.volume > 0.0f) { + jukebox.volume -= 0.1f; + } + } + } + + if (button.id == 3) { + if (player != null && player.getDisplayName().equals(((AbstractTrains) jukebox).getTrainOwner())) { + if ((!jukebox.locked)) { + AxisAlignedBB box = jukebox.boundingBox.expand(5, 5, 5); + List lis3 = jukebox.worldObj.getEntitiesWithinAABBExcludingEntity(jukebox, box); + if (lis3 != null && !lis3.isEmpty()) { + for (Object o : lis3) { + Entity entity = (Entity) o; + if (entity instanceof EntityPlayer) { + Traincraft.lockChannel.sendToServer(new PacketSetTrainLockedToClient(true, this.jukebox.getEntityId())); + } + } + } + + jukebox.locked = true; + button.displayString = "Locked"; + this.initGui(); + } else { + AxisAlignedBB box = jukebox.boundingBox.expand(5, 5, 5); + List lis3 = jukebox.worldObj.getEntitiesWithinAABBExcludingEntity(jukebox, box); + if (lis3 != null && !lis3.isEmpty()) { + for (Object o : lis3) { + Entity entity = (Entity) o; + if (entity instanceof EntityPlayer) { + Traincraft.lockChannel.sendToServer(new PacketSetTrainLockedToClient(true, this.jukebox.getEntityId())); + } + } + } + + jukebox.locked = false; + button.displayString = "UnLocked"; + this.initGui(); + } + } else if (player != null) { + player.addChatMessage(new ChatComponentText("You are not the owner")); + } + } + } + + @SideOnly(Side.CLIENT) + public boolean getState() { + return this.jukebox.isPlaying(); + } + + @Override + public boolean doesGuiPauseGame() { + return false; + } + + @Override + protected void drawCreativeTabHoveringText(String str, int t, int g) { + int textWidth = fontRendererObj.getStringWidth("When a jukebox is unlocked,") + 2; + + int i4 = 0xf0100010; + drawGradientRect(t + 15 - 3, g - 40 - 4, t + textWidth + 3, g + 8 + 4, i4, i4); + drawGradientRect(t + 15 - 4, g - 40 - 3, t + textWidth + 4, g + 8 + 3, i4, i4); + int colour1 = 0x505000ff; + int colour2 = (colour1 & 0xfefefe) >> 1 | colour1 & 0xff000000; + drawGradientRect(t + 15 - 3, g - 40 - 3, t + textWidth + 3, g + 8 + 3, colour1, colour2); + drawGradientRect(t + 15 - 2, g - 40 - 2, t + textWidth + 2, g + 8 + 2, i4, i4); + fontRendererObj.drawStringWithShadow(str, t + 15, g - 40, -1); + fontRendererObj.drawStringWithShadow("only its owner can open", t + 15, g + 10 - 40, -1); + fontRendererObj.drawStringWithShadow("the GUI and destroy it.", t + 15, g + 20 - 40, -1); + fontRendererObj.drawStringWithShadow("Current state: " + (jukebox.locked ? "Locked" : "Unlocked"), t + 15, g + 30 - 40, -1); + fontRendererObj.drawStringWithShadow("Owner: " + jukebox.getTrainOwner(), t + 15, g + 40 - 40, -1); + } + + public boolean intersectsWith(int mouseX, int mouseY) { + int j = (width - gui_width) / 2; + int k = (height - gui_height) / 2; + + return mouseX >= j + gui_width - 350 && mouseX <= j + gui_width - 300 && mouseY >= k - 10 && mouseY <= k; + } + + public String takeFirstEntryFromM3U(String m3uurl) { + String out = ""; + try { + URL m3u = new URL(m3uurl); + URLConnection con = m3u.openConnection(); + BufferedReader i = new BufferedReader(new InputStreamReader(con.getInputStream())); + String mp3; + + while ((mp3 = i.readLine()) != null) { + if (!mp3.startsWith("#")) { + break; + } + } + + out = mp3; + } catch (IOException e) { + infoText = "Not a valid stream, only .m3u and .pls"; + } + return out; + } + + public String parsePls(String plsurl) { + String out = ""; + try { + URL pls = new URL(plsurl); + URLConnection con = pls.openConnection(); + BufferedReader i = new BufferedReader(new InputStreamReader(con.getInputStream())); + String mp3; + + while ((mp3 = i.readLine()) != null) { + String f = mp3.trim(); + if (f.contains("http://")) { + out = f.substring(f.indexOf("http://")); + break; + } + } + + } catch (IOException e) { + infoText = "Not a valid stream, only .m3u and .pls"; + } + return out; + } } \ No newline at end of file diff --git a/src/main/java/train/client/gui/GuiLantern.java b/src/main/java/train/client/gui/GuiLantern.java index 5bf37e2e3a..8f54b4c32d 100644 --- a/src/main/java/train/client/gui/GuiLantern.java +++ b/src/main/java/train/client/gui/GuiLantern.java @@ -14,121 +14,140 @@ @SideOnly(Side.CLIENT) public class GuiLantern extends GuiScreen { - /** The player editing the gui */ - private final EntityPlayer editingPlayer; - - /** Text field containing the color. */ - private GuiTextField colorTextField; - - /** the block being edited. */ - private final TileLantern lanternBlock; - private GuiButton doneBtn; - private GuiButton cancelBtn; - - public GuiLantern(EntityPlayer par1EntityPlayer, TileLantern tile) { - this.editingPlayer = par1EntityPlayer; - lanternBlock = tile; - } - /** - * Adds the buttons (and other controls) to the screen in question. - */ - @Override - public void initGui() { - this.buttonList.clear(); - Keyboard.enableRepeatEvents(true); - this.buttonList.add(this.doneBtn = new GuiButton(0, this.width / 2 - 100, this.height / 4 + 96 + 12, "Done")); - this.buttonList.add(this.cancelBtn = new GuiButton(1, this.width / 2 - 100, this.height / 4 + 120 + 12, "Cancel")); - this.colorTextField = new GuiTextField(this.fontRendererObj, this.width / 2 - 150, 60, 300, 20); - this.colorTextField.setMaxStringLength(32767); - this.colorTextField.setFocused(true); - this.colorTextField.setText(this.lanternBlock.getColor()); - this.doneBtn.enabled = this.colorTextField.getText().trim().length() > 0; - } - - /** - * Fired when a control is clicked. This is the equivalent of ActionListener.actionPerformed(ActionEvent e). - */ - @Override - protected void actionPerformed(GuiButton par1GuiButton) { - if (par1GuiButton.enabled) { - if (par1GuiButton.id == 1) { - this.mc.displayGuiScreen((GuiScreen)null); - } - if (par1GuiButton.id == 0) { - String colorString = this.colorTextField.getText().replaceFirst("^#","");//removes # - if(colorString.length()==6){ - colorString = colorString.substring(0, 6);//remove additionnal characters - if(colorString.length()==6 &&tryParse(colorString)!=null){//if parse is possible (if string can be converted to an int) - int color = tryParse(colorString);//parse the string as a 16 int - Traincraft.modChannel.sendToServer(new PacketLantern(color, lanternBlock.xCoord, - lanternBlock.yCoord, lanternBlock.zCoord)); - Minecraft.getMinecraft().renderGlobal.markBlockForRenderUpdate(lanternBlock.xCoord, lanternBlock.yCoord, lanternBlock.zCoord); //TODO marks block as dirty, but it's only actually re-renders when chunk is loaded, but we need the re-render after it has been changed. - } - } - this.mc.displayGuiScreen((GuiScreen)null); - } - } - } - - /** - * Tries to convert string to a specific int - * if string is not correct format (hex) then return null - * @param text - * @return - */ - public static Integer tryParse(String text) { - try { - return new Integer(Integer.parseInt(text, 16)); - } catch (NumberFormatException e) { - return null; - } - } - - /** - * Fired when a key is typed. This is the equivalent of KeyListener.keyTyped(KeyEvent e). - */ - @Override - protected void keyTyped(char par1, int par2) { - this.colorTextField.textboxKeyTyped(par1, par2); - this.doneBtn.enabled = this.colorTextField.getText().trim().length() > 0; - - if (par2 != 28 && par1 != 13) { - if (par2 == 1) { - this.actionPerformed(this.cancelBtn); - } - } - else { - this.actionPerformed(this.doneBtn); - } - } - - /** - * Called when the mouse is clicked. - */ - @Override - protected void mouseClicked(int par1, int par2, int par3) { - super.mouseClicked(par1, par2, par3); - this.colorTextField.mouseClicked(par1, par2, par3); - } - - /** - * Draws the screen and all the components in it. - */ - @Override - public void drawScreen(int par1, int par2, float par3) { - this.drawDefaultBackground(); - this.colorTextField.drawTextBox(); - super.drawScreen(par1, par2, par3); - } - - @Override - public void onGuiClosed() { - super.onGuiClosed(); - Keyboard.enableRepeatEvents(false); - } - - @Override - public boolean doesGuiPauseGame() { - return false; - } + /** + * The player editing the gui + */ + private final EntityPlayer editingPlayer; + + /** + * Text field containing the color. + */ + private GuiTextField colorTextField; + + /** + * the block being edited. + */ + private final TileLantern lanternBlock; + private GuiButton doneBtn; + private GuiButton cancelBtn; + + public GuiLantern(EntityPlayer par1EntityPlayer, TileLantern tile) { + this.editingPlayer = par1EntityPlayer; + lanternBlock = tile; + } + + /** + * Adds the buttons (and other controls) to the screen in question. + */ + @Override + public void initGui() { + this.buttonList.clear(); + Keyboard.enableRepeatEvents(true); + + this.buttonList.add(this.doneBtn = new GuiButton(0, this.width / 2 - 100, this.height / 4 + 96 + 12, "Done")); + this.buttonList.add(this.cancelBtn = new GuiButton(1, this.width / 2 - 100, this.height / 4 + 120 + 12, "Cancel")); + + this.colorTextField = new GuiTextField(this.fontRendererObj, this.width / 2 - 150, 60, 300, 20); + this.colorTextField.setMaxStringLength(32767); + this.colorTextField.setFocused(true); + this.colorTextField.setText(this.lanternBlock.getColor()); + + this.doneBtn.enabled = !this.colorTextField.getText().trim().isEmpty(); + } + + /** + * Fired when a control is clicked. This is the equivalent of ActionListener.actionPerformed(ActionEvent e). + */ + @Override + protected void actionPerformed(GuiButton par1GuiButton) { + if (par1GuiButton.enabled) { + if (par1GuiButton.id == 1) { + this.mc.displayGuiScreen(null); + } + + if (par1GuiButton.id == 0) { + // Removes hashtag + String colorString = this.colorTextField.getText().replaceFirst("^#", ""); + + if (colorString.length() == 6) { + // Remove additional characters + colorString = colorString.substring(0, 6); + Integer parsedColor = tryParse(colorString); + // If this parse is possible (If String can be converted to an int) + if (parsedColor != null) { + // Parse the Integer as an 16 int + int color = parsedColor; + Traincraft.modChannel.sendToServer(new PacketLantern(color, lanternBlock.xCoord, + lanternBlock.yCoord, lanternBlock.zCoord)); + // TODO: marks block as dirty, but it's only actually re-renders when chunk is loaded, but we need the re-render after it has been changed. + Minecraft.getMinecraft().renderGlobal.markBlockForRenderUpdate(lanternBlock.xCoord, lanternBlock.yCoord, lanternBlock.zCoord); + } + } + + this.mc.displayGuiScreen(null); + } + } + } + + /** + * Tries to convert string to a specific int + * if string is not correct format (hex) then return null + * + * @param text String to parse + * @return Integer if parse is possible, null if not + */ + public static Integer tryParse(String text) { + try { + return Integer.parseInt(text, 16); + } catch (NumberFormatException e) { + return null; + } + } + + /** + * Fired when a key is typed. This is the equivalent of KeyListener.keyTyped(KeyEvent e). + */ + @Override + protected void keyTyped(char par1, int par2) { + this.colorTextField.textboxKeyTyped(par1, par2); + this.doneBtn.enabled = !this.colorTextField.getText().trim().isEmpty(); + + if (par2 != 28 && par1 != 13) { + if (par2 == 1) { + this.actionPerformed(this.cancelBtn); + } + } else { + this.actionPerformed(this.doneBtn); + } + } + + /** + * Called when the mouse is clicked. + */ + @Override + protected void mouseClicked(int par1, int par2, int par3) { + super.mouseClicked(par1, par2, par3); + this.colorTextField.mouseClicked(par1, par2, par3); + } + + /** + * Draws the screen and all the components in it. + */ + @Override + public void drawScreen(int par1, int par2, float par3) { + this.drawDefaultBackground(); + this.colorTextField.drawTextBox(); + super.drawScreen(par1, par2, par3); + } + + @Override + public void onGuiClosed() { + super.onGuiClosed(); + Keyboard.enableRepeatEvents(false); + } + + @Override + public boolean doesGuiPauseGame() { + return false; + } } \ No newline at end of file diff --git a/src/main/java/train/client/gui/GuiLiquid.java b/src/main/java/train/client/gui/GuiLiquid.java index fea70be036..66c8c87f70 100644 --- a/src/main/java/train/client/gui/GuiLiquid.java +++ b/src/main/java/train/client/gui/GuiLiquid.java @@ -24,179 +24,183 @@ public class GuiLiquid extends GuiContainer { - private LiquidTank liquid; - private EntityPlayer player; - - public GuiLiquid(EntityPlayer player, InventoryPlayer inventoryplayer, Entity entityminecart) { - super(new InventoryLiquid(inventoryplayer, (LiquidTank) entityminecart)); - liquid = (LiquidTank) entityminecart; - this.player = player; - } - - @Override - public void drawScreen(int t, int g, float par3) { - drawGuiContainerBackgroundLayer(par3, t, g); - super.drawScreen(t, g, par3); - - if (intersectsWith(t, g)) { - if (liquid.getLiquidName()!= null && !liquid.getLiquidName().equals("")) { - drawCreativeTabHoveringText(StatCollector.translateToLocal(liquid.getLiquidName()) + ": " + liquid.getAmount() + "mb/" + liquid.getCapacity() + "mb", t, g); - } else { - drawCreativeTabHoveringText( "0mb/" + liquid.getCapacity() + "mb", t, g); - } - } - - - } - - @Override - public void initGui() { - super.initGui(); - buttonList.clear(); - int var1 = (this.width-xSize) / 2; - int var2 = (this.height-ySize) / 2; - if (!liquid.getTrainLockedFromPacket()) { - this.buttonList.add(new GuiButton(3, var1 + 124, var2 - 10, 51, 10, "Unlocked")); - }else{ - this.buttonList.add(new GuiButton(3, var1 + 130, var2 - 10, 43, 10, "Locked")); - } - } - @Override - protected void actionPerformed(GuiButton guibutton) { - if (guibutton.id == 3) { - if(player!=null && player.getCommandSenderName().toLowerCase().equals(((AbstractTrains) liquid).getTrainOwner().toLowerCase())){ - if ((!liquid.getTrainLockedFromPacket())){ - AxisAlignedBB box = liquid.boundingBox.expand(5, 5, 5); - List lis3 = liquid.worldObj.getEntitiesWithinAABBExcludingEntity(liquid, box); - if (lis3 != null && lis3.size() > 0) { - for (Object entity : lis3) { - if (entity instanceof EntityPlayer) { - Traincraft.lockChannel - .sendToServer(new PacketSetTrainLockedToClient(true, liquid.getEntityId())); - } - } - } - liquid.locked = true; - guibutton.displayString = "Locked"; - this.initGui(); - }else{ - AxisAlignedBB box = liquid.boundingBox.expand(5, 5, 5); - List lis3 = liquid.worldObj.getEntitiesWithinAABBExcludingEntity(liquid, box); - if (lis3 != null && lis3.size() > 0) { - for (Object entity : lis3) { - if (entity instanceof EntityPlayer) { - Traincraft.lockChannel - .sendToServer(new PacketSetTrainLockedToClient(false, liquid.getEntityId())); - } - } - } - liquid.locked = false; - guibutton.displayString = "UnLocked"; - this.initGui(); - } - }else if(player!=null && player instanceof EntityPlayer){ - player.addChatMessage(new ChatComponentText("You are not the owner")); - } - } - } - - @Override - protected void drawGuiContainerForegroundLayer(int i, int j) { - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_DEPTH_TEST); - - fontRendererObj.drawString(liquid.getCommandSenderName(), 65, 1, 0x000000); - fontRendererObj.drawString(liquid.getCommandSenderName(), 65, 3, 0x000000); - fontRendererObj.drawString(liquid.getCommandSenderName(), 63, 1, 0x000000); - fontRendererObj.drawString(liquid.getCommandSenderName(), 63, 3, 0x000000); - - fontRendererObj.drawString(liquid.getCommandSenderName(), 65, 2, 0x000000); - fontRendererObj.drawString(liquid.getCommandSenderName(), 63, 2, 0x000000); - fontRendererObj.drawString(liquid.getCommandSenderName(), 64, 1, 0x000000); - fontRendererObj.drawString(liquid.getCommandSenderName(), 64, 3, 0x000000); - fontRendererObj.drawString(liquid.getCommandSenderName(), 64, 2, 0xd3a900); - - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glEnable(GL11.GL_DEPTH_TEST); - if (intersectsWithLockButton(i, j)) { - drawCreativeTabHoveringTextLockButton("When a tank cart is locked,", i, j); - } - } - - protected void drawCreativeTabHoveringTextLockButton(String str, int t, int g) { - - //int liqui = (dieselInventory.getLiquidAmount() * 50) / dieselInventory.getTankCapacity(); - String state = ""; - if(liquid.getTrainLockedFromPacket()){ - state="Locked"; - } else { - state = "Unlocked"; - } - - int textWidth = fontRendererObj.getStringWidth("the GUI, change speed, destroy it."); - int startX = 90; - int startY = 5; - - int i4 = 0xf0100010; - drawGradientRect(startX - 3, startY - 4, startX + textWidth + 3, startY + 52, i4, i4); - drawGradientRect(startX - 4, startY - 3, startX + textWidth + 4, startY + 51, i4, i4); - int colour1 = 0x505000ff; - int colour2 = (colour1 & 0xfefefe) >> 1 | colour1 & 0xff000000; - drawGradientRect(startX - 3, startY - 3, startX + textWidth + 3, startY + 51, colour1, colour2); - drawGradientRect(startX - 2, startY - 2, startX + textWidth + 2, startY + 50, i4, i4); - fontRendererObj.drawStringWithShadow(str, startX, startY, -1); - fontRendererObj.drawStringWithShadow("only its owner can open", startX, startY + 10, -1); - fontRendererObj.drawStringWithShadow("the GUI and destroy it.", startX, startY + 20, -1); - fontRendererObj.drawStringWithShadow("Current state: "+state, startX, startY+30, -1); - fontRendererObj.drawStringWithShadow("Owner: "+(liquid).getTrainOwner().trim(), startX, startY+40, -1); - } - public boolean intersectsWithLockButton(int mouseX, int mouseY) { - //System.out.println(mouseX+" "+mouseY); - int j = (width - xSize) / 2; - int k = (height - ySize) / 2; - return (mouseX >= j + 124 && mouseX <= j + 174 && mouseY >= k-10 && mouseY <= k); - } - - @Override - protected void drawGuiContainerBackgroundLayer(float f, int t, int g) { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - mc.renderEngine.bindTexture(new ResourceLocation(Info.resourceLocation,Info.guiPrefix + "gui_liquid.png")); - int j = (width - xSize) / 2; - int k = (height - ySize) / 2; - drawTexturedModalRect(j, k, 0, 0, xSize, ySize); - - - int l = (liquid.getAmount() * 50) / liquid.getCapacity(); - - Fluid theLiquid = FluidRegistry.getFluid(liquid.getLiquidItemID()); - /** Don't render anything if the cart is empty */ - if (theLiquid != null) { - /** Protection against missing rendering icon, to avoid NPE */ - if (theLiquid.getIcon() == null) - return; - /** Get the texture sheet of the liquid */ - //mc.renderEngine.func_110577_a(new ResourceLocation(Info.resourceLocation,Info.guiPrefix + "empty.png")); - mc.renderEngine.bindTexture(FluidRenderHelper.getFluidSheet(theLiquid)); - //func_110628_a(FluidRenderHelper.getFluidSheet(new FluidStack(theLiquid,1))); - /** Drawing 16*16 icons side by side, extending them gives bad results */ - for (int col = 0; col < 66 / 16; col++) { - for (int row = 0; row <= (l) / 16; row++) { - //System.out.println(ItemIDs.bogie.item.getIconFromDamage(0)); - drawTexturedModelRectFromIcon(j + 58 + col * 16, k + 52 + -row * 16,FluidRenderHelper.getFluidTexture(theLiquid,false), 16, 16); - } - } - /** Bind again to render a black overlay. The icon is rendered in 16*16 square and therefore not adapted to a 50 pixels high tank */ - mc.renderEngine.bindTexture(new ResourceLocation(Info.resourceLocation,Info.guiPrefix + "gui_liquid.png")); - /** Drawing black overlay over the liquid */ - drawTexturedModalRect(j + 58, (k + 1), 4, 168, 64, 50 - l + 15); - } - /** Drawing the red scale over the liquid */ - drawTexturedModalRect(j + 58, (k + 67 - 50), 72, 167, 64, 50); - } - - public boolean intersectsWith(int mouseX, int mouseY) { - int j = (width - xSize) / 2; - int k = (height - ySize) / 2; - return (mouseX >= j + 57 && mouseX <= j + 123 && mouseY >= k + 16 && mouseY <= k + 68); - } + private final LiquidTank liquid; + private final EntityPlayer player; + + public GuiLiquid(EntityPlayer player, InventoryPlayer inventoryplayer, Entity entityminecart) { + super(new InventoryLiquid(inventoryplayer, (LiquidTank) entityminecart)); + + this.player = player; + liquid = (LiquidTank) entityminecart; + } + + @Override + public void drawScreen(int t, int g, float par3) { + drawGuiContainerBackgroundLayer(par3, t, g); + super.drawScreen(t, g, par3); + + if (intersectsWith(t, g)) { + if (liquid.getLiquidName() != null && !liquid.getLiquidName().isEmpty()) { + drawCreativeTabHoveringText(StatCollector.translateToLocal(liquid.getLiquidName()) + ": " + liquid.getAmount() + "mb/" + liquid.getCapacity() + "mb", t, g); + } else { + drawCreativeTabHoveringText("0mb/" + liquid.getCapacity() + "mb", t, g); + } + } + + + } + + @Override + public void initGui() { + super.initGui(); + buttonList.clear(); + int var1 = (this.width - xSize) / 2; + int var2 = (this.height - ySize) / 2; + + if (!liquid.getTrainLockedFromPacket()) { + this.buttonList.add(new GuiButton(3, var1 + 124, var2 - 10, 51, 10, "Unlocked")); + } else { + this.buttonList.add(new GuiButton(3, var1 + 130, var2 - 10, 43, 10, "Locked")); + } + } + + @Override + protected void actionPerformed(GuiButton guibutton) { + if (guibutton.id == 3) { + if (player != null && player.getCommandSenderName().equalsIgnoreCase(((AbstractTrains) liquid).getTrainOwner())) { + if (!liquid.getTrainLockedFromPacket()) { + AxisAlignedBB box = liquid.boundingBox.expand(5, 5, 5); + List lis3 = liquid.worldObj.getEntitiesWithinAABBExcludingEntity(liquid, box); + if (lis3 != null && !lis3.isEmpty()) { + for (Object entity : lis3) { + if (entity instanceof EntityPlayer) { + Traincraft.lockChannel + .sendToServer(new PacketSetTrainLockedToClient(true, liquid.getEntityId())); + } + } + } + + liquid.locked = true; + guibutton.displayString = "Locked"; + this.initGui(); + } else { + AxisAlignedBB box = liquid.boundingBox.expand(5, 5, 5); + List lis3 = liquid.worldObj.getEntitiesWithinAABBExcludingEntity(liquid, box); + if (lis3 != null && !lis3.isEmpty()) { + for (Object entity : lis3) { + if (entity instanceof EntityPlayer) { + Traincraft.lockChannel + .sendToServer(new PacketSetTrainLockedToClient(false, liquid.getEntityId())); + } + } + } + + liquid.locked = false; + guibutton.displayString = "UnLocked"; + this.initGui(); + } + } else if (player != null) { + player.addChatMessage(new ChatComponentText("You are not the owner")); + } + } + } + + @Override + protected void drawGuiContainerForegroundLayer(int i, int j) { + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_DEPTH_TEST); + + fontRendererObj.drawString(liquid.getCommandSenderName(), 65, 1, 0x000000); + fontRendererObj.drawString(liquid.getCommandSenderName(), 65, 3, 0x000000); + fontRendererObj.drawString(liquid.getCommandSenderName(), 63, 1, 0x000000); + fontRendererObj.drawString(liquid.getCommandSenderName(), 63, 3, 0x000000); + + fontRendererObj.drawString(liquid.getCommandSenderName(), 65, 2, 0x000000); + fontRendererObj.drawString(liquid.getCommandSenderName(), 63, 2, 0x000000); + fontRendererObj.drawString(liquid.getCommandSenderName(), 64, 1, 0x000000); + fontRendererObj.drawString(liquid.getCommandSenderName(), 64, 3, 0x000000); + fontRendererObj.drawString(liquid.getCommandSenderName(), 64, 2, 0xd3a900); + + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_DEPTH_TEST); + if (intersectsWithLockButton(i, j)) { + drawCreativeTabHoveringTextLockButton("When a tank cart is locked,", i, j); + } + } + + protected void drawCreativeTabHoveringTextLockButton(String str, int t, int g) { + //int liqui = (dieselInventory.getLiquidAmount() * 50) / dieselInventory.getTankCapacity(); + + int textWidth = fontRendererObj.getStringWidth("the GUI, change speed, destroy it."); + int startX = 90; + int startY = 5; + int i4 = 0xf0100010; + int colour1 = 0x505000ff; + int colour2 = (colour1 & 0xfefefe) >> 1 | colour1 & 0xff000000; + + drawGradientRect(startX - 3, startY - 4, startX + textWidth + 3, startY + 52, i4, i4); + drawGradientRect(startX - 4, startY - 3, startX + textWidth + 4, startY + 51, i4, i4); + drawGradientRect(startX - 3, startY - 3, startX + textWidth + 3, startY + 51, colour1, colour2); + drawGradientRect(startX - 2, startY - 2, startX + textWidth + 2, startY + 50, i4, i4); + + fontRendererObj.drawStringWithShadow(str, startX, startY, -1); + fontRendererObj.drawStringWithShadow("only its owner can open", startX, startY + 10, -1); + fontRendererObj.drawStringWithShadow("the GUI and destroy it.", startX, startY + 20, -1); + fontRendererObj.drawStringWithShadow("Current state: " + (liquid.getTrainLockedFromPacket() ? "Locked" : "Unlocked"), startX, startY + 30, -1); + fontRendererObj.drawStringWithShadow("Owner: " + (liquid).getTrainOwner().trim(), startX, startY + 40, -1); + } + + public boolean intersectsWithLockButton(int mouseX, int mouseY) { + //System.out.println(mouseX+" "+mouseY); + int j = (width - xSize) / 2; + int k = (height - ySize) / 2; + return (mouseX >= j + 124 && mouseX <= j + 174 && mouseY >= k - 10 && mouseY <= k); + } + + @Override + protected void drawGuiContainerBackgroundLayer(float f, int t, int g) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + mc.renderEngine.bindTexture(new ResourceLocation(Info.resourceLocation, Info.guiPrefix + "gui_liquid.png")); + int j = (width - xSize) / 2; + int k = (height - ySize) / 2; + drawTexturedModalRect(j, k, 0, 0, xSize, ySize); + + int l = (liquid.getAmount() * 50) / liquid.getCapacity(); + + Fluid theLiquid = FluidRegistry.getFluid(liquid.getLiquidItemID()); + // Don't render anything if the cart is empty. + if (theLiquid != null) { + // Protection against missing rendering icon, to avoid NPE. + if (theLiquid.getIcon() == null) { + return; + } + + //mc.renderEngine.func_110577_a(new ResourceLocation(Info.resourceLocation,Info.guiPrefix + "empty.png")); + // Get the texture sheet of the liquid. + mc.renderEngine.bindTexture(FluidRenderHelper.getFluidSheet(theLiquid)); + //func_110628_a(FluidRenderHelper.getFluidSheet(new FluidStack(theLiquid,1))); + + // Drawing 16*16 icons side by side, extending them gives bad results. + for (int col = 0; col < 66 / 16; col++) { + for (int row = 0; row <= (l) / 16; row++) { + //System.out.println(ItemIDs.bogie.item.getIconFromDamage(0)); + drawTexturedModelRectFromIcon(j + 58 + col * 16, k + 52 + -row * 16, FluidRenderHelper.getFluidTexture(theLiquid, false), 16, 16); + } + } + + // Bind again to render a black overlay. The icon is rendered in a 16*16 square and therefore not adapted to a 50 pixels high tank. + mc.renderEngine.bindTexture(new ResourceLocation(Info.resourceLocation, Info.guiPrefix + "gui_liquid.png")); + + // Drawing black overlay over the liquid. + drawTexturedModalRect(j + 58, (k + 1), 4, 168, 64, 50 - l + 15); + } + // Drawing the red scale over the liquid. + drawTexturedModalRect(j + 58, (k + 67 - 50), 72, 167, 64, 50); + } + + public boolean intersectsWith(int mouseX, int mouseY) { + int j = (width - xSize) / 2; + int k = (height - ySize) / 2; + return (mouseX >= j + 57 && mouseX <= j + 123 && mouseY >= k + 16 && mouseY <= k + 68); + } } diff --git a/src/main/java/train/client/gui/GuiLoco2.java b/src/main/java/train/client/gui/GuiLoco2.java index 8b19876669..d631e16270 100644 --- a/src/main/java/train/client/gui/GuiLoco2.java +++ b/src/main/java/train/client/gui/GuiLoco2.java @@ -20,299 +20,293 @@ import java.util.Collections; public class GuiLoco2 extends GuiContainer { + private final String texture = Info.guiPrefix + "customButton.png"; + private final Locomotive loco; + private GuiButton buttonLock; + private int textureX = 0; + private int textureY = 46; + private int textureSizeX = 40; + private int textureSizeY = 13; + private int buttonPosX = 0; + private int buttonPosY = 0; - private String texture = Info.guiPrefix + "customButton.png"; - private int textureX = 0; - private int textureY = 46; - private int textureSizeX = 40; - private int textureSizeY = 13; - private int buttonPosX = 0; - private int buttonPosY = 0; - private GuiButton buttonLock; - - private Locomotive loco; - - public GuiLoco2(InventoryPlayer inventoryplayer, Entity entityminecart) { - super(new InventoryLoco(inventoryplayer, (Locomotive) entityminecart)); - loco = (Locomotive) entityminecart; - } - - @Override - public void initGui() { - super.initGui(); - buttonList.clear(); - if (!loco.getParkingBrakeFromPacket()) { - if (loco instanceof SteamTrain) { - textureX = 41; - textureY = 13; - textureSizeX = 40; - textureSizeY = 13; - } - else { - textureX = 126; - textureY = 13; - textureSizeX = 43; - textureSizeY = 13; - } - buttonPosX = 43; - buttonPosY = -13; - buttonList.add(new GuiCustomButton(2, ((width - xSize) / 2) + buttonPosX - 12, ((height - ySize) / 2) + buttonPosY, textureSizeX, textureSizeY, "", texture, textureX, textureY));//Brake: Off - } - else { - if (loco instanceof SteamTrain) { - textureX = 0; - textureY = 13; - textureSizeX = 40; - textureSizeY = 13; - } - else { - textureX = 82; - textureY = 13; - textureSizeX = 43; - textureSizeY = 13; - } - buttonPosX = 0; - buttonPosY = -13; - buttonList.add(new GuiCustomButton(2, ((width - xSize) / 2) + buttonPosX, ((height - ySize) / 2) + buttonPosY, textureSizeX, textureSizeY, "", texture, textureX, textureY));//Brake: On - } - int var1 = (this.width - xSize) / 2; - int var2 = (this.height - ySize) / 2; - if (!loco.getTrainLockedFromPacket()) { - this.buttonList.add(this.buttonLock = new GuiButton(3, var1 + 108, var2 - 10, 67, 10, "Unlocked")); - } - else { - this.buttonList.add(this.buttonLock = new GuiButton(3, var1 + 108, var2 - 10, 67, 10, "Locked")); - } - if (!(loco instanceof SteamTrain)) { - if (loco.isLocoTurnedOn()) { - this.buttonList.add(this.buttonLock = new GuiButton(4, var1 + 108, var2 - 22, 67, 12, "Stop Engine")); - } - else { - this.buttonList.add(this.buttonLock = new GuiButton(4, var1 + 108, var2 - 22, 67, 12, "Start Engine")); - } - } - } - - @Override - protected void actionPerformed(GuiButton guibutton) { - if (guibutton.id == 2) { - if ((!loco.parkingBrake) && loco.getSpeed() < 10) { - Traincraft.brakeChannel.sendToServer(new PacketParkingBrake(true, loco.getEntityId())); - loco.parkingBrake=true; - loco.isBraking=true; - guibutton.displayString = "Brake: On"; - this.initGui(); - } - else if (loco.getSpeed() < 10) { - Traincraft.brakeChannel.sendToServer(new PacketParkingBrake(false, loco.getEntityId())); - loco.parkingBrake=false; - loco.isBraking=false; - guibutton.displayString = "Brake: Off"; - this.initGui(); - } - } - if (guibutton.id == 3) { - if (loco.riddenByEntity instanceof EntityPlayer && ((EntityPlayer) loco.riddenByEntity).getDisplayName().equals(loco.getTrainOwner())) { - if ((!loco.getTrainLockedFromPacket())) { - Traincraft.lockChannel.sendToServer(new PacketSetTrainLockedToClient(true, loco.getEntityId())); - loco.locked = true; - guibutton.displayString = "Locked"; - this.initGui(); - } - else { - Traincraft.lockChannel.sendToServer(new PacketSetTrainLockedToClient(false, loco.getEntityId())); - loco.locked = false; - guibutton.displayString = "UnLocked"; - this.initGui(); - } - } - else if (loco.riddenByEntity instanceof EntityPlayer) { - ((EntityPlayer) loco.riddenByEntity).addChatMessage(new ChatComponentText("You are not the owner")); - } - } - if (guibutton.id == 4) { - if (loco.isLocoTurnedOn()) { - if(loco.getSpeed() <= 1){ - Traincraft.ignitionChannel.sendToServer(new PacketSetLocoTurnedOn(false)); - loco.isLocoTurnedOn = false; - guibutton.displayString = "Start Engine"; - /** - * We implemented Auto ParkingBrake since Brutal tried to did it in the Locomotive API when you turn off the damn Train - */ - Traincraft.brakeChannel.sendToServer(new PacketParkingBrake(true, loco.getEntityId())); - loco.parkingBrake = true; - loco.isBraking = true; - this.initGui(); - }else{ - ((EntityPlayer)loco.riddenByEntity).addChatMessage(new ChatComponentText("Stop before turning it Off!")); - } - } - else { - Traincraft.ignitionChannel.sendToServer(new PacketSetLocoTurnedOn(true)); - loco.isLocoTurnedOn = true; - guibutton.displayString = "Stop Engine"; - } - } - } - - @Override - protected void drawCreativeTabHoveringText(String str, int t, int g) { - - //int liqui = (dieselInventory.getLiquidAmount() * 50) / dieselInventory.getTankCapacity(); - String state = ""; - if (loco.getTrainLockedFromPacket()){ - state = "Locked"; - } else { - state = "Unlocked"; - } - - int textWidth = fontRendererObj.getStringWidth("the GUI, change speed, destroy it."); - int startX = 90; - int startY = 5; - - int i4 = 0xf0100010; - drawGradientRect(startX - 3, startY - 4, startX + textWidth + 3, startY + 52, i4, i4); - drawGradientRect(startX - 4, startY - 3, startX + textWidth + 4, startY + 51, i4, i4); - int colour1 = 0x505000ff; - int colour2 = (colour1 & 0xfefefe) >> 1 | colour1 & 0xff000000; - drawGradientRect(startX - 3, startY - 3, startX + textWidth + 3, startY + 51, colour1, colour2); - drawGradientRect(startX - 2, startY - 2, startX + textWidth + 2, startY + 50, i4, i4); - fontRendererObj.drawStringWithShadow(str, startX, startY, -1); - fontRendererObj.drawStringWithShadow("only its owner can open", startX, startY + 10, -1); - fontRendererObj.drawStringWithShadow("the GUI, change speed, destroy it.", startX, startY + 20, -1); - fontRendererObj.drawStringWithShadow("Current state: " + state, startX, startY + 30, -1); - fontRendererObj.drawStringWithShadow("Owner: " + loco.getTrainOwner().trim(), startX, - startY + 40, -1); - } - - public boolean intersectsWith(int mouseX, int mouseY) { - //System.out.println(mouseX+" "+mouseY); - int j = (width - xSize) / 2; - int k = (height - ySize) / 2; - return (mouseX >= j + 124 && mouseX <= j + 174 && mouseY >= k - 10 && mouseY <= k); - } - - @Override - protected void drawGuiContainerForegroundLayer(int i, int j) { - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_DEPTH_TEST); - - fontRendererObj.drawString(loco.getInventoryName(), 39, 7, 0x000000); - fontRendererObj.drawString(loco.getInventoryName(), 41, 5, 0x000000); - fontRendererObj.drawString(loco.getInventoryName(), 39, 5, 0x000000); - fontRendererObj.drawString(loco.getInventoryName(), 41, 7, 0x000000); - - fontRendererObj.drawString(loco.getInventoryName(), 39, 6, 0x000000); - fontRendererObj.drawString(loco.getInventoryName(), 41, 6, 0x000000); - fontRendererObj.drawString(loco.getInventoryName(), 40, 7, 0x000000); - fontRendererObj.drawString(loco.getInventoryName(), 40, 5, 0x000000); - fontRendererObj.drawString(loco.getInventoryName(), 40, 6, 0xd3a900); - - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glEnable(GL11.GL_DEPTH_TEST); - - if (intersectsWith(i, j)) { - drawCreativeTabHoveringText("When a locomotive is locked,", i, j); - } - } - - @Override - public void drawScreen(int mouseX, int mouseY, float par3){ - super.drawScreen(mouseX, mouseY,par3); - if(loco instanceof SteamTrain){ - int j = (width - xSize) / 2; - int k = (height - ySize) / 2; - if (mouseX>j+143 && mouseXk+18 && mouseYj+143 && mouseXk+18 && mouseY> 1 | colour1 & 0xff000000; + + drawGradientRect(startX - 3, startY - 4, startX + textWidth + 3, startY + 52, i4, i4); + drawGradientRect(startX - 4, startY - 3, startX + textWidth + 4, startY + 51, i4, i4); + drawGradientRect(startX - 3, startY - 3, startX + textWidth + 3, startY + 51, colour1, colour2); + drawGradientRect(startX - 2, startY - 2, startX + textWidth + 2, startY + 50, i4, i4); + + fontRendererObj.drawStringWithShadow(str, startX, startY, -1); + fontRendererObj.drawStringWithShadow("only its owner can open", startX, startY + 10, -1); + fontRendererObj.drawStringWithShadow("the GUI, change speed, destroy it.", startX, startY + 20, -1); + fontRendererObj.drawStringWithShadow("Current state: " + (loco.getTrainLockedFromPacket() ? "Locked" : "Unlocked"), startX, startY + 30, -1); + fontRendererObj.drawStringWithShadow("Owner: " + loco.getTrainOwner().trim(), startX, startY + 40, -1); + } + + public boolean intersectsWith(int mouseX, int mouseY) { + //System.out.println(mouseX+" "+mouseY); + int j = (width - xSize) / 2; + int k = (height - ySize) / 2; + return (mouseX >= j + 124 && mouseX <= j + 174 && mouseY >= k - 10 && mouseY <= k); + } + + @Override + protected void drawGuiContainerForegroundLayer(int i, int j) { + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_DEPTH_TEST); + + fontRendererObj.drawString(loco.getInventoryName(), 39, 7, 0x000000); + fontRendererObj.drawString(loco.getInventoryName(), 41, 5, 0x000000); + fontRendererObj.drawString(loco.getInventoryName(), 39, 5, 0x000000); + fontRendererObj.drawString(loco.getInventoryName(), 41, 7, 0x000000); + + fontRendererObj.drawString(loco.getInventoryName(), 39, 6, 0x000000); + fontRendererObj.drawString(loco.getInventoryName(), 41, 6, 0x000000); + fontRendererObj.drawString(loco.getInventoryName(), 40, 7, 0x000000); + fontRendererObj.drawString(loco.getInventoryName(), 40, 5, 0x000000); + fontRendererObj.drawString(loco.getInventoryName(), 40, 6, 0xd3a900); + + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_DEPTH_TEST); + + if (intersectsWith(i, j)) { + drawCreativeTabHoveringText("When a locomotive is locked,", i, j); + } + } + + @Override + public void drawScreen(int mouseX, int mouseY, float par3) { + super.drawScreen(mouseX, mouseY, par3); + + if (loco instanceof SteamTrain) { + int j = (width - xSize) / 2; + int k = (height - ySize) / 2; + + if (mouseX > j + 143 && mouseX < j + 161 && mouseY > k + 18 && mouseY < k + 68) { + drawHoveringText(Collections.singletonList("Water: " + (((SteamTrain) loco).getWater()) + "mb / " + (((SteamTrain) loco).getCartTankCapacity()) + "mb"), + mouseX, mouseY, fontRendererObj); + } + } else if (loco instanceof DieselTrain) { + int j = (width - xSize) / 2; + int k = (height - ySize) / 2; + if (mouseX > j + 143 && mouseX < j + 161 && mouseY > k + 18 && mouseY < k + 68) { + if (((DieselTrain) loco).getDiesel() != 0) { + drawHoveringText(Collections.singletonList(StatCollector.translateToLocal("fluid.tc:" + ((DieselTrain) loco).getLiquidName()) + " " + + ((DieselTrain) loco).getDiesel() + "mb / " + (((DieselTrain) loco).getCartTankCapacity()) + "mb"), + mouseX, mouseY, fontRendererObj); + } else { + drawHoveringText(Collections.singletonList("Fuel: " + + "0mb / " + (((DieselTrain) loco).getCartTankCapacity()) + "mb"), + mouseX, mouseY, fontRendererObj); + } + } + } + } + + @Override + protected void drawGuiContainerBackgroundLayer(float f, int t, int g) { + String i = Info.guiPrefix + "gui_loco.png"; + + if (loco instanceof ElectricTrain) { + i = Info.guiPrefix + "gui_tram.png"; + } + + if (loco instanceof SteamTrain) { + i = Info.guiPrefix + "gui_loco_steam.png"; + } + + if (loco instanceof DieselTrain) { + i = Info.guiPrefix + "gui_loco_diesel.png"; + } + + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + mc.renderEngine.bindTexture(new ResourceLocation(Info.resourceLocation, i)); + int j = (width - xSize) / 2; + int k = (height - ySize) / 2; + drawTexturedModalRect(j, k, 0, 0, xSize, ySize); + + if (loco instanceof SteamTrain) { + int load = (((SteamTrain) loco).getWater()); + int lo = Math.abs(((load * 50) / (((SteamTrain) loco).getCartTankCapacity()))); + + if (((SteamTrain) loco).getLiquidItemID() == LiquidManager.WATER_FILTER.getFluidID()) { + drawTexturedModalRect(j + 143, (k + 68) - lo, 190, 69 - lo, 18, lo + 1); + } + + if (loco.getIsFuelled()) { + int l = loco.getFuelDiv(12); + drawTexturedModalRect(j + 8, (k + 36 + 12) - l, 176, 12 - l, 14, l + 2); + } + } else if (loco instanceof DieselTrain) { + int load = (((DieselTrain) loco).getDiesel()); + int lo2 = Math.abs(((load * 50) / (((DieselTrain) loco).getCartTankCapacity()))); + drawTexturedModalRect(j + 143, (k + 68) - lo2, 192, 120 - lo2, 18, lo2); + + if (loco.getIsFuelled()) { + int l = loco.getFuelDiv(12); + drawTexturedModalRect(j + 10, (k + 36 + 13) - l, 178, 12 - l, 14, l + 2); + } + } else { + for (int i1 = loco.numCargoSlots; i1 < 5; i1++) { + drawTexturedModalRect(j + 79 + 18 * i1, k + 17, 190, 0, 18, 18); + } + + for (int j1 = loco.numCargoSlots1; j1 < 5; j1++) { + drawTexturedModalRect(j + 79 + 18 * j1, k + 35, 190, 0, 18, 18); + } + + for (int k1 = loco.numCargoSlots2; k1 < 5; k1++) { + drawTexturedModalRect(j + 79 + 18 * k1, k + 53, 190, 0, 18, 18); + } + + if (loco.getIsFuelled()) { + int l = loco.getFuelDiv(12); + drawTexturedModalRect(j + 8, (k + 36 + 12) - l, 176, 12 - l, 14, l + 2); + } + } + + fontRendererObj.drawStringWithShadow("Carts pulled: " + loco.getCurrentNumCartsPulled(), 1, 10, 0xFFFFFF); + fontRendererObj.drawStringWithShadow("Mass pulled: " + loco.getCurrentMassPulled(), 1, 20, 0xFFFFFF); + fontRendererObj.drawStringWithShadow("Speed reduction: " + loco.getCurrentSpeedSlowDown() + " km/h", 1, 30, 0xFFFFFF); + fontRendererObj.drawStringWithShadow("Accel reduction: " + loco.getCurrentAccelSlowDown(), 1, 40, 0xFFFFFF); + fontRendererObj.drawStringWithShadow("Brake reduction: " + loco.getCurrentBrakeSlowDown(), 1, 50, 0xFFFFFF); + fontRendererObj.drawStringWithShadow("Fuel consumption: " + ((loco.getFuelConsumption() * 0.2) + "").substring(0, Math.min(((loco.getFuelConsumption() * 0.2) + "").length(), 4)) + " mB/s", 1, + 60, 0xFFFFFF); + fontRendererObj.drawStringWithShadow("Fuel: " + loco.getFuel(), 1, 70, 0xFFFFFF); + fontRendererObj.drawStringWithShadow("Power: " + loco.getPower() + " Mhp", 1, 80, 0xFFFFFF); + fontRendererObj.drawStringWithShadow("State: " + loco.getState(), 1, 90, 0xFFFFFF); + fontRendererObj.drawStringWithShadow("Heat level: " + loco.getOverheatLevel(), 1, 100, 0xFFFFFF); + fontRendererObj.drawStringWithShadow("Maximum Speed: " + (loco.getCustomSpeedGUI()) + " km/h" + " (" + (loco.getCustomSpeedGUI() + loco.getCurrentSpeedSlowDown()) + ")", 1, 110, 0xFFFFFF); + fontRendererObj.drawStringWithShadow("Destination: " + (loco.getDestinationGUI()), 1, 120, 0xFFFFFF); + } } \ No newline at end of file diff --git a/src/main/java/train/client/gui/GuiMTCInfo.java b/src/main/java/train/client/gui/GuiMTCInfo.java index 680bf7c117..8c59893935 100644 --- a/src/main/java/train/client/gui/GuiMTCInfo.java +++ b/src/main/java/train/client/gui/GuiMTCInfo.java @@ -14,42 +14,38 @@ import train.common.mtc.packets.PacketMTCLevelUpdate; public class GuiMTCInfo extends GuiScreen { - Locomotive theLocomotive; - private GuiTCTextField trainLevel; - private GuiTCTextField trainID; - private GuiTCTextField destination; - private GuiButton okayButton; - public GuiMTCInfo(Entity entity) { + Locomotive theLocomotive; + private GuiTCTextField trainLevel; + private GuiTCTextField trainID; + private GuiTCTextField destination; + private GuiButton okayButton; + public GuiMTCInfo(Entity entity) { if (entity instanceof Locomotive) { - theLocomotive = (Locomotive)entity; - } + theLocomotive = (Locomotive) entity; + } } @Override public void initGui() { - - trainLevel = new GuiTCTextField(fontRendererObj, this.width/2 -5, this.height/2 - 1, 15,15); - destination = new GuiTCTextField(fontRendererObj, this.width/2 -5, this.height/2 + 20, 80,15); - trainID = new GuiTCTextField(fontRendererObj, this.width/2 -5, this.height/2 - 20, 80,15); - okayButton = new GuiButton(0,this.width/2 -5, this.height/2 + 40, 60,25, "Okay" ); + trainLevel = new GuiTCTextField(fontRendererObj, this.width / 2 - 5, this.height / 2 - 1, 15, 15); + destination = new GuiTCTextField(fontRendererObj, this.width / 2 - 5, this.height / 2 + 20, 80, 15); + trainID = new GuiTCTextField(fontRendererObj, this.width / 2 - 5, this.height / 2 - 20, 80, 15); + okayButton = new GuiButton(0, this.width / 2 - 5, this.height / 2 + 40, 60, 25, "Okay"); trainLevel.setMaxStringLength(1); trainLevel.setText(theLocomotive.trainLevel); trainID.setMaxStringLength(6); trainID.setText(theLocomotive.trainID); destination.setText(theLocomotive.getDestinationGUI()); - - - } @Override public void drawScreen(int mouseX, int mouseY, float partialTicks) { - drawDefaultBackground(); + drawDefaultBackground(); this.drawCenteredString(this.fontRendererObj, "Minecraft Train Control Setup", this.width / 2, 40, 0xFFFFFFFF); - this.drawString( this.fontRendererObj,"Train Level: ", this.width/2 -70, this.height/2 + 3, 0xFFFFFFFF); - this.drawString( this.fontRendererObj,"Train ID: ", this.width/2 -70, this.height/2 - 17, 0xFFFFFFFF); - this.drawString( this.fontRendererObj,"Destination: ", this.width/2 -70, this.height/2 + 23, 0xFFFFFFFF); + this.drawString(this.fontRendererObj, "Train Level: ", this.width / 2 - 70, this.height / 2 + 3, 0xFFFFFFFF); + this.drawString(this.fontRendererObj, "Train ID: ", this.width / 2 - 70, this.height / 2 - 17, 0xFFFFFFFF); + this.drawString(this.fontRendererObj, "Destination: ", this.width / 2 - 70, this.height / 2 + 23, 0xFFFFFFFF); trainLevel.drawTextBox(); trainID.drawTextBox(); destination.drawTextBox(); @@ -61,40 +57,44 @@ public void drawScreen(int mouseX, int mouseY, float partialTicks) { protected void actionPerformed(GuiButton button) { } + @Override public void updateScreen() { super.updateScreen(); if (trainLevel.isFocused()) { trainLevel.updateCursorCounter(); } + if (trainID.isFocused()) { trainID.updateCursorCounter(); } + if (destination.isFocused()) { destination.updateCursorCounter(); } - } + @Override protected void keyTyped(char par1, int par2) { - - if (trainLevel.isFocused() && par2 == Keyboard.KEY_1 || par2 == Keyboard.KEY_2 || par2 == Keyboard.KEY_3 || par2 == Keyboard.KEY_4 || par2 == Keyboard.KEY_5 || par2 == Keyboard.KEY_6 ||par2 == Keyboard.KEY_7 || par2 == Keyboard.KEY_8 || par2 == Keyboard.KEY_9 || par2 == Keyboard.KEY_0 || par2 == Keyboard.KEY_BACK) { + if (trainLevel.isFocused() && par2 == Keyboard.KEY_1 || par2 == Keyboard.KEY_2 || par2 == Keyboard.KEY_3 || par2 == Keyboard.KEY_4 || par2 == Keyboard.KEY_5 || par2 == Keyboard.KEY_6 || par2 == Keyboard.KEY_7 || par2 == Keyboard.KEY_8 || par2 == Keyboard.KEY_9 || par2 == Keyboard.KEY_0 || par2 == Keyboard.KEY_BACK) { trainLevel.textboxKeyTyped(par1, par2); } - if (trainID.isFocused()) { + + if (trainID.isFocused()) { trainID.textboxKeyTyped(par1, par2); - } + } + if (destination.isFocused()) { destination.textboxKeyTyped(par1, par2); } - if (par2 == 1 || par2 == Keyboard.KEY_ESCAPE) { + if (par2 == 1) { if (!destination.isFocused() || !trainID.isFocused() || !trainLevel.isFocused()) { mc.thePlayer.closeScreen(); theLocomotive.trainLevel = trainLevel.getText(); - if (!trainLevel.getText().equals("")) { + if (!trainLevel.getText().isEmpty()) { Traincraft.mtlChannel.sendToServer(new PacketMTCLevelUpdate(theLocomotive.getEntityId(), Integer.parseInt(trainLevel.getText()))); } @@ -115,10 +115,12 @@ protected void mouseClicked(int par1, int par2, int par3) { destination.mouseClicked(par1, par2, par3); super.mouseClicked(par1, par2, par3); } + @Override public boolean doesGuiPauseGame() { return false; } + public static boolean isInteger(String s) { try { Integer.parseInt(s); diff --git a/src/main/java/train/client/gui/GuiOpenHearthFurnace.java b/src/main/java/train/client/gui/GuiOpenHearthFurnace.java index 89b0c54c33..08a0e8c514 100644 --- a/src/main/java/train/client/gui/GuiOpenHearthFurnace.java +++ b/src/main/java/train/client/gui/GuiOpenHearthFurnace.java @@ -10,33 +10,35 @@ public class GuiOpenHearthFurnace extends GuiContainer { - private TileEntityOpenHearthFurnace furnaceInventory; - private final ResourceLocation gui = new ResourceLocation(Info.resourceLocation, Info.guiPrefix + "gui_open_hearth_furnace.png"); - - public GuiOpenHearthFurnace(InventoryPlayer invPlayer, TileEntityOpenHearthFurnace tileentityfurnace) { - super(new ContainerOpenHearthFurnace(invPlayer, tileentityfurnace)); - furnaceInventory = tileentityfurnace; - } - - @Override - protected void drawGuiContainerForegroundLayer(int par1, int par2) { - fontRendererObj.drawString("Open Hearth Furnace", 8, 6, 0x404040); - fontRendererObj.drawString("Inventory", 8, (ySize - 96) + 2, 0x404040); - } - - @Override - protected void drawGuiContainerBackgroundLayer(float f, int t, int g) { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - mc.renderEngine.bindTexture(gui); - int j = (width - xSize) / 2; - int k = (height - ySize) / 2; - drawTexturedModalRect(j, k, 0, 0, xSize, ySize); - if (furnaceInventory.isBurning()) { - int l = furnaceInventory.getBurnTimeRemainingScaled(12); - drawTexturedModalRect(j + 56, (k + 36 + 12) - l, 176, 12 - l, 14, l + 2); - drawTexturedModalRect(j + 36, (k + 36 + 12) - l, 176, 12 - l, 14, l + 2); - } - int i1 = furnaceInventory.getCookProgressScaled(24); - drawTexturedModalRect(j + 79, k + 34, 176, 14, i1 + 1, 16); - } + private final TileEntityOpenHearthFurnace furnaceInventory; + private final ResourceLocation gui = new ResourceLocation(Info.resourceLocation, Info.guiPrefix + "gui_open_hearth_furnace.png"); + + public GuiOpenHearthFurnace(InventoryPlayer invPlayer, TileEntityOpenHearthFurnace tileentityfurnace) { + super(new ContainerOpenHearthFurnace(invPlayer, tileentityfurnace)); + furnaceInventory = tileentityfurnace; + } + + @Override + protected void drawGuiContainerForegroundLayer(int par1, int par2) { + fontRendererObj.drawString("Open Hearth Furnace", 8, 6, 0x404040); + fontRendererObj.drawString("Inventory", 8, (ySize - 96) + 2, 0x404040); + } + + @Override + protected void drawGuiContainerBackgroundLayer(float f, int t, int g) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + mc.renderEngine.bindTexture(gui); + int j = (width - xSize) / 2; + int k = (height - ySize) / 2; + drawTexturedModalRect(j, k, 0, 0, xSize, ySize); + + if (furnaceInventory.isBurning()) { + int l = furnaceInventory.getBurnTimeRemainingScaled(12); + drawTexturedModalRect(j + 56, (k + 36 + 12) - l, 176, 12 - l, 14, l + 2); + drawTexturedModalRect(j + 36, (k + 36 + 12) - l, 176, 12 - l, 14, l + 2); + } + + int i1 = furnaceInventory.getCookProgressScaled(24); + drawTexturedModalRect(j + 79, k + 34, 176, 14, i1 + 1, 16); + } } diff --git a/src/main/java/train/client/gui/GuiRecipeBook.java b/src/main/java/train/client/gui/GuiRecipeBook.java index 3c9de3c234..38ab4ddb6a 100644 --- a/src/main/java/train/client/gui/GuiRecipeBook.java +++ b/src/main/java/train/client/gui/GuiRecipeBook.java @@ -30,701 +30,760 @@ @SideOnly(Side.CLIENT) public class GuiRecipeBook extends GuiScreen { - /** The player editing the book */ - private final EntityPlayer editingPlayer; - private final ItemStack itemstackBook; - - /** Update ticks since the gui was opened */ - private int bookImageWidth = 206; - private int bookImageHeight = 200; - public static int bookTotalPages = 2; - private int currPage; - private int currRecipe; - public ArrayList leftPage = new ArrayList(); - public ArrayList leftPageImage = new ArrayList(); - public ArrayList leftPageItemStacks = new ArrayList(); - public ArrayList rightPage = new ArrayList(); - public ArrayList rightPageImage = new ArrayList(); - public ArrayList rightPageItemStacks = new ArrayList(); - private List recipeListWB =null; - private List recipeList=null; - - private GuiButtonNextPage buttonRead; - private GuiButtonNextPage buttonNextPage; - private GuiButtonNextPage buttonPreviousPage; - private GuiButtonNextPage buttonBack; - private RenderItem renderItem = new RenderItem(); - - public GuiRecipeBook(EntityPlayer par1EntityPlayer, ItemStack par2ItemStack) { - this.editingPlayer = par1EntityPlayer; - this.itemstackBook = par2ItemStack; - this.currPage = this.itemstackBook.getTagCompound().getInteger("currPage"); - this.currRecipe = this.itemstackBook.getTagCompound().getInteger("currRecipe"); - - addPage("", "", "left", null); - addPage("", "", "right", null); - addPage("Welcome to the Traincraft guide! \nThis book contains everything you need to know about Traincraft.\n\nAuthors:\nSpitfire4466,\nMrbrutal\n\nBukkit port: \nDV8FromTheWorld\n\nThanks to CovertJaguar for his help and a great API.\n", "", "left", new ArrayList() { - { - add(new StackToDraw(new ItemStack(ItemIDs.minecartLocoBR80_DB.item), 20, 16)); - add(new StackToDraw(new ItemStack(BlockIDs.trainWorkbench.block), 170, 16)); - add(new StackToDraw(new ItemStack(ItemIDs.minecartCabooseWork.item), 60, 175)); - add(new StackToDraw(new ItemStack(ItemIDs.minecartTankWagon_DB.item), 80, 175)); - add(new StackToDraw(new ItemStack(ItemIDs.minecartFlatCartRail_DB.item), 100, 175)); - add(new StackToDraw(new ItemStack(ItemIDs.minecartFreightWagon_DB.item), 120, 175)); - add(new StackToDraw(new ItemStack(ItemIDs.minecartPassengerBlue.item), 140, 175)); - add(new StackToDraw(new ItemStack(ItemIDs.minecartV60_DB.item), 160, 175)); - } - }); - addPage("Modelers:\nDAYdiecast,\nhelldiver,\nBlockStormTwo,\nChandlerBingUA.\n\nGitHub 1.7.10 port Team: \nEternal BlueFlame,\nNitroxydeX,\nFirEmerald,\nHagurd\n \nWebsite:\nhttp://traincraft-mod.\nblogspot.com", "", "right", new ArrayList() { - { - add(new StackToDraw(new ItemStack(ItemIDs.minecartLocoSteamAdler.item), 20, 16)); - add(new StackToDraw(new ItemStack(BlockIDs.assemblyTableII.block), 170, 16)); - - add(new StackToDraw(new ItemStack(ItemIDs.minecartLocoForneyRed.item), 20, 175)); - add(new StackToDraw(new ItemStack(ItemIDs.minecartPassengerBlue.item), 40, 175)); - add(new StackToDraw(new ItemStack(ItemIDs.minecartPassengerBlue.item), 60, 175)); - add(new StackToDraw(new ItemStack(ItemIDs.minecartFreightWagon_DB.item), 80, 175)); - add(new StackToDraw(new ItemStack(ItemIDs.minecartWood.item), 100, 175)); - add(new StackToDraw(new ItemStack(ItemIDs.minecartCabooseLogging.item), 120, 175)); - } - }); - addPage("World generation:\n\n By default, petrol and oil sands will be generated in the world. If you don't want them, open Traincraft.cfg and change the line ENABLE_ORE_SPAWN from true to false.\nOnly the new ores will generate, the old ones can be transformed into the new ones in a crafting table.", "", "left", new ArrayList() { - { - add(new StackToDraw(new ItemStack(BlockIDs.oreTC.block, 1, 1), 60, 160)); - add(new StackToDraw(new ItemStack(BlockIDs.oreTC.block, 1, 2), 120, 160)); - } - }); - - addPage("Keys:\nTo interact with the trains (e.g. enter, display the inventory) click above the shadow the train is casting on the ground.\nInside the locomotive press R to open up the GUI: This is where you can put fuel, water, additional cargo, set brakes, etc.\n", - "", "right", new ArrayList() { - { - add(new StackToDraw(new ItemStack(Items.coal), 60, 160)); - add(new StackToDraw(new ItemStack(Items.water_bucket), 120, 160)); - } - }); - - addPage("Use the W and S keys to move the locomotive forwards or backwards, respectively.\nPress H in the locomotive to activate the whistle.\nIn the Work Carts, press R to open up the Crafting Table and F for the Furnace.\n", "", "left", new ArrayList() { - { - add(new StackToDraw(new ItemStack(ItemIDs.minecartLocoBR80_DB.item), 20, 16)); - add(new StackToDraw(new ItemStack(ItemIDs.minecartGP7Red.item), 170, 16)); - add(new StackToDraw(new ItemStack(ItemIDs.minecartLocoCherepanov.item), 40, 145)); - add(new StackToDraw(new ItemStack(ItemIDs.minecartWork.item), 60, 145)); - add(new StackToDraw(new ItemStack(ItemIDs.minecartCabooseWork.item), 80, 145)); - add(new StackToDraw(new ItemStack(ItemIDs.minecartLocoForneyRed.item), 100, 145)); - add(new StackToDraw(new ItemStack(ItemIDs.minecartShunter.item), 120, 145)); - add(new StackToDraw(new ItemStack(ItemIDs.minecartLocoBR01_DB.item), 140, 145)); - } - }); - addPage("Zeppelin:\nRight click on the Zeppelin to enter it. \nInside, press R to open its GUI. \nUse the WASD keys to move the zeppelin around. \nPress once Y to ascend or X to descend, To lock altitude, press C. \n", "", "right", - new ArrayList() { - { - add(new StackToDraw(new ItemStack(ItemIDs.airship.item), 20, 16)); - add(new StackToDraw(new ItemStack(ItemIDs.balloon.item), 170, 16)); - add(new StackToDraw(new ItemStack(ItemIDs.propeller.item), 40, 135)); - add(new StackToDraw(new ItemStack(ItemIDs.steamengine.item), 60, 135)); - add(new StackToDraw(new ItemStack(Items.boat), 120, 135)); - add(new StackToDraw(new ItemStack(Items.stick), 140, 135)); - - } - }); - addPage("Fuel:\nSteam locomotives need coal and water.\nTenders can only hold coal and water. Attach them to a steam locomotive, they will provide fuel and water for the loco.\nDiesel locos need diesel canisters (from distillation tower) or fuel from BC and Forestry.\n", "", "left", new ArrayList() { - { - add(new StackToDraw(new ItemStack(ItemIDs.minecartTender.item), 20, 16)); - add(new StackToDraw(new ItemStack(ItemIDs.minecartLocomogulBlue.item), 170, 16)); - add(new StackToDraw(new ItemStack(Items.coal), 40, 155)); - add(new StackToDraw(new ItemStack(Items.water_bucket), 60, 155)); - add(new StackToDraw(new ItemStack(Blocks.planks), 80, 155)); - add(new StackToDraw(new ItemStack(Items.blaze_rod), 100, 155)); - add(new StackToDraw(new ItemStack(ItemIDs.diesel.item), 120, 155)); - add(new StackToDraw(new ItemStack(ItemIDs.refinedFuel.item), 140, 155)); - } - }); - - addPage("Electric locomotives need redstone or RF-based energy storages, they can also be powered by Electric tracks.\n\nHeat:\nHeat level is indicated by the heat bar in the HUD.\nHeat level will go to a normal state when the train is fueled but don't forget to put water in steam locomotive or it will overheat very fast.\n", - "", "right", new ArrayList() { - { - add(new StackToDraw(new ItemStack(ItemIDs.minecartBR_E69.item), 20, 16)); - add(new StackToDraw(new ItemStack(Items.redstone), 170, 16)); - } - }); - - addPage("Heat level will go down to cold when there's no fuel.\nWait until the locomotive has heated up before trying to move. but be careful overheating can cause explosions...\n\nRouting:\nLocomotives can be routed using Railcraft routing track. Destination will show in the GUI, Sneak+Crowbar to reset. There is no space for tickets. Not 'Color=' compatible.", "", "left", new ArrayList() { - { - add(new StackToDraw(new ItemStack(ItemIDs.firebox.item), 20, 16)); - add(new StackToDraw(new ItemStack(Blocks.tnt), 170, 16)); - } - }); - addPage("Minecraft Horse Power - Mhp:\n\nLocomotives have different pulling abilities represented by their 'power' in Mhp.\nEach cart has a mass in tons which will affect the locomotive depending on its power.\nMass pulled affects the maximum speed, the brake rate and accelerate rate, as well as fuel consumption.\n", "", "right", new ArrayList() { - { - add(new StackToDraw(new ItemStack(ItemIDs.stake.item), 20, 16)); - add(new StackToDraw(new ItemStack(ItemIDs.minecartLocoBR01_DB.item), 40, 165)); - add(new StackToDraw(new ItemStack(ItemIDs.stake.item), 60, 165)); - add(new StackToDraw(new ItemStack(ItemIDs.minecartFreightCart2.item), 80, 165)); - add(new StackToDraw(new ItemStack(ItemIDs.stake.item), 100, 165)); - add(new StackToDraw(new ItemStack(ItemIDs.minecartFreightClosed.item), 120, 165)); - add(new StackToDraw(new ItemStack(ItemIDs.stake.item), 140, 165)); - add(new StackToDraw(new ItemStack(ItemIDs.minecartWatertransp.item), 160, 165)); - } - }); - addPage("Derailment:\n\nDo not go too fast on turns or your locomotives will derail!\n\nIt is recommended to slow down under 90km/h before turning or you will find yourself crashing off tracks.", "", "left", new ArrayList() { - { - add(new StackToDraw(new ItemStack(Items.skull, 1, 1), 20, 16)); - } - }); - - addPage("Pulling:\nRight click both carts with a stake in your hand, it will say 'Attaching mode on', then make them collide and it will say 'Attached'.\nLocomotives have pulling capabilities, don't make too long trains with weak locomotives. Stats of the locomotive will be affected. (they can be seen on the top left corner when you open the locomotive's inventory).\n", "", "right", new ArrayList() { - { - add(new StackToDraw(new ItemStack(ItemIDs.stake.item), 20, 16)); - add(new StackToDraw(new ItemStack(ItemIDs.minecartCaboose.item), 40, 165)); - add(new StackToDraw(new ItemStack(ItemIDs.stake.item), 60, 165)); - add(new StackToDraw(new ItemStack(ItemIDs.minecartBoxCartUS.item), 80, 165)); - add(new StackToDraw(new ItemStack(ItemIDs.stake.item), 100, 165)); - add(new StackToDraw(new ItemStack(ItemIDs.minecartFlatCartLogs_DB.item), 120, 165)); - add(new StackToDraw(new ItemStack(ItemIDs.stake.item), 140, 165)); - add(new StackToDraw(new ItemStack(ItemIDs.minecartCD742.item), 160, 165)); - } - }); - addPage("Chunk Loading:\n\nEach rolling stock can load one chunk around itself.\nTo start chunk loading, right click with chunk loader activator on the rolling stock.\nTo stop chunk loading, right click again.\n", "", "left", new ArrayList() { - { - add(new StackToDraw(new ItemStack(ItemIDs.chunkLoaderActivator.item), 20, 16)); - add(new StackToDraw(new ItemStack(Items.ender_pearl), 170, 16)); - } - }); - addPage("Colors:\n\nSome rolling stock has several textures and can be painted with dyes.\nThe rolling stock that can be painted will show the possible colors in the chat once placed in the world.\nTo paint, simply right click with the correct dye.\n\nLantern color is randomly picked, but you can set the hex color manually with a wrench", "", "right", new ArrayList() { - { - add(new StackToDraw(new ItemStack(Items.dye, 1, 1), 20, 16)); - add(new StackToDraw(new ItemStack(Items.dye, 1, 11), 170, 16)); - } - }); - addPage("Stock car:\n\nThe stock car is the only rolling stock that can be ridden by any animals and mobs.\nTo fill the stock car, either collide the animal with the car or use the animal/mob boarding tracks (Railcraft required).\nTo empty the car, use the disembark track (Railcraft required).\n", "", "left", new ArrayList() { - { - add(new StackToDraw(new ItemStack(ItemIDs.minecartStockCar.item), 20, 16)); - add(new StackToDraw(new ItemStack(Items.skull, 1, 4), 170, 16)); - } - }); - addPage("A word about tracks I:\nCopper tracks will slow trains down.\nSteel tracks allow trains to go faster.\nSpeed controller track allows you to change the locomotive's max speed (hit with crowbar).\nThe energy track can be powered by redstone and will power electric trains, redstone power will be transmitted two tracks away.\n", "", "right", new ArrayList() { - { - add(new StackToDraw(new ItemStack(Blocks.rail), 17, 16)); - add(new StackToDraw(new ItemStack(Blocks.rail), 17, 32)); - add(new StackToDraw(new ItemStack(Blocks.rail), 17, 48)); - add(new StackToDraw(new ItemStack(Blocks.rail), 17, 64)); - add(new StackToDraw(new ItemStack(Blocks.rail), 17, 80)); - add(new StackToDraw(new ItemStack(Blocks.rail), 17, 96)); - add(new StackToDraw(new ItemStack(Blocks.rail), 17, 112)); - add(new StackToDraw(new ItemStack(Blocks.rail), 17, 128)); - add(new StackToDraw(new ItemStack(Blocks.rail), 17, 144)); - add(new StackToDraw(new ItemStack(Blocks.rail), 17, 160)); - add(new StackToDraw(new ItemStack(Blocks.golden_rail), 170, 16)); - } - }); - addPage("A word about tracks II:\nTo check the current charge click the track with a crowbar.\nAn electric track connected to a redstone power source gets 1 energy unit every two ticks.\nLocomotive holding track will only hold TC locomotives. No boost is given, the previous speed is restored once released.\nAll tracks require Railcraft to be installed.","","left",new ArrayList() { - { - add(new StackToDraw(new ItemStack(Blocks.activator_rail), 17, 16)); - add(new StackToDraw(new ItemStack(Blocks.golden_rail), 170, 16)); - } - }); - - addPage("Steel rails parts and copper rails parts are crafted inside RC Rolling Machine, tracks are assembled in vanilla workbench.\nTC boarding/disembarking track are designed to work only on the Stock Car. Animal boarding will take any nearby animal and put it inside a passing Stock Car. Mob boarding will affect any mob.\nDisembark will eject any mob inside the Stock Car.","","right",new ArrayList() { - { - add(new StackToDraw(new ItemStack(Blocks.detector_rail), 17, 16)); - add(new StackToDraw(new ItemStack(Blocks.golden_rail), 170, 16)); - } - }); - addPage("Builder I:\n\nThe tracks builder has a very special inventory, in order to start it you must provide:\nBallast in the slot under it (planks, gravel, stone, ...).\nCoal in the fuel slot, Tracks in the slot under the fuel slot. The slot on the right of the builder will activate tunnel function when provided (not all blocks are accepted).\n", "", "left", new ArrayList() { - { - add(new StackToDraw(new ItemStack(ItemIDs.minecartBuilder.item), 20, 16)); - add(new StackToDraw(new ItemStack(ItemIDs.minecartBuilder.item), 60, 165)); - add(new StackToDraw(new ItemStack(ItemIDs.stake.item), 80, 165)); - add(new StackToDraw(new ItemStack(ItemIDs.minecartFreightClosed.item), 100, 165)); - } - }); - addPage("Builder II:\n\nThe slots on top of the builder are roof slots, the builder will build a roof when provided (not all blocks are accepted). If you attach a freight cart to the builder, it will dump things in it.\n\n", "", "right", new ArrayList() { - { - add(new StackToDraw(new ItemStack(ItemIDs.minecartBuilder.item), 20, 16)); - add(new StackToDraw(new ItemStack(ItemIDs.minecartBuilder.item), 60, 125)); - add(new StackToDraw(new ItemStack(ItemIDs.stake.item), 80, 125)); - add(new StackToDraw(new ItemStack(ItemIDs.minecartFreightClosed.item), 100, 125)); - } - }); - addPage("Limitations:\n\nVERY IMPORTANT:\nLong trains imply limitations: Do not try to make sharp 180 turns, leave 3+ spaces between each 90 turn. Otherwise weird stuff may happen especially with very long trains.\n\nAlways PULL carts! Bounding boxes are buggy and unreliable!", "", "left", new ArrayList() { - { - add(new StackToDraw(new ItemStack(Blocks.detector_rail), 20, 16)); - add(new StackToDraw(new ItemStack(Blocks.rail), 170, 16)); - add(new StackToDraw(new ItemStack(ItemIDs.minecartPower.item), 40, 165)); - add(new StackToDraw(new ItemStack(ItemIDs.minecartFlatCartWoodUS.item), 60, 165)); - add(new StackToDraw(new ItemStack(ItemIDs.minecartBoxCartUS.item), 80, 165)); - add(new StackToDraw(new ItemStack(ItemIDs.minecartPassenger9_2class_DB.item), 100, 165)); - add(new StackToDraw(new ItemStack(ItemIDs.minecartFlatCartLogs_DB.item), 120, 165)); - add(new StackToDraw(new ItemStack(ItemIDs.minecartFreightCart2.item), 140, 165)); - add(new StackToDraw(new ItemStack(ItemIDs.minecartCaboose.item), 160, 165)); - } - }); - addPage("Crafting:\nAll train parts are crafted in the train workbench,\n\nthen trains have to be assembled in the assembly tables.\n\nThere are three assembly tables:\n\nTierI - Iron age\nTierII - Steel age\nTierIII - Advanced age\n", "", "right", new ArrayList() { - { - add(new StackToDraw(new ItemStack(BlockIDs.trainWorkbench.block), 20, 16)); - add(new StackToDraw(new ItemStack(BlockIDs.assemblyTableI.block), 40, 165)); - add(new StackToDraw(new ItemStack(BlockIDs.assemblyTableII.block), 80, 165)); - add(new StackToDraw(new ItemStack(BlockIDs.assemblyTableIII.block), 140, 165)); - } - }); - addPage("Crafting steel:\nSteel is crafted in Open Hearth Furnace, supply iron ingots and graphite in the top slots, fuel in the bottom slot, \nand it will cook slowly into steel.\nYou can also use steel from other mods or use this steel in other mods.\n", "", "left", new ArrayList() { - { - add(new StackToDraw(new ItemStack(BlockIDs.openFurnaceIdle.block), 20, 16)); - add(new StackToDraw(new ItemStack(BlockIDs.openFurnaceActive.block), 80, 155)); - add(new StackToDraw(new ItemStack(ItemIDs.graphite.item), 70, 135)); - add(new StackToDraw(new ItemStack(Items.iron_ingot), 90, 135)); - add(new StackToDraw(new ItemStack(Items.coal), 80, 175)); - add(new StackToDraw(new ItemStack(ItemIDs.steel.item), 120, 155)); - } - }); - - addPage("Making diesel:\nDiesel is made in a distillation tower using petroleum or oil sands found in the world.\nInsert petroleum in the top slot and fuel in the bottom slot, also try reed.\nIt will cook into liquid diesel and give you plastic with a random chance depending on the input.\nTo get diesel into canisters, you must first craft them using plastic. Then put an empty one in the top right slot.", "", "right", new ArrayList() { - { - add(new StackToDraw(new ItemStack(BlockIDs.distilIdle.block), 20, 16)); - add(new StackToDraw(new ItemStack(BlockIDs.distilActive.block), 150, 40)); - add(new StackToDraw(new ItemStack(BlockIDs.oreTC.block, 1, 1), 150, 20)); - add(new StackToDraw(new ItemStack(Items.coal), 150, 60)); - add(new StackToDraw(new ItemStack(ItemIDs.diesel.item), 167, 40)); - add(new StackToDraw(new ItemStack(ItemIDs.rawPlastic.item), 167, 60)); - } - }); - addPage("Special pull I: \nYou can attach two locomotives together.\n\nTo do that: shift+click the locomotive you want to PULL with a stake in your hand. Then fuel it and wait until it heats up.\n\nNow put both locomotives in attaching mode. Then move attach them by moving one locomotive towards the other.", "", "left", new ArrayList() { - { - add(new StackToDraw(new ItemStack(ItemIDs.minecartLocoBR80_DB.item), 20, 16)); - add(new StackToDraw(new ItemStack(ItemIDs.stake.item), 170, 16)); - add(new StackToDraw(new ItemStack(ItemIDs.minecartCabooseWork.item), 40, 165)); - add(new StackToDraw(new ItemStack(ItemIDs.minecartTankWagon_DB.item), 60, 165)); - add(new StackToDraw(new ItemStack(ItemIDs.minecartFlatCartRail_DB.item), 80, 165)); - add(new StackToDraw(new ItemStack(ItemIDs.minecartFreightWagon_DB.item), 100, 165)); - add(new StackToDraw(new ItemStack(ItemIDs.minecartCD742.item), 120, 165)); - add(new StackToDraw(new ItemStack(ItemIDs.minecartCD742.item), 140, 165)); - } - }); - addPage("Special pull II: \nLocomotives have two states: 'Can pull' and 'Can be pulled'.\n'Can pull' means that the locomotive is able to pull any attach cart. But it can't be pulled.\n'Can be pulled' means that the locomotive behaves like a cart and can be pulled by another locomotive (which is in 'can pull' state). Attached locomotives share power.", "", "right", new ArrayList() { - { - add(new StackToDraw(new ItemStack(ItemIDs.minecartLoco3.item), 20, 16)); - add(new StackToDraw(new ItemStack(ItemIDs.stake.item), 170, 16)); - add(new StackToDraw(new ItemStack(ItemIDs.minecartCD742.item), 40, 165)); - add(new StackToDraw(new ItemStack(ItemIDs.minecartFreightWagon_DB.item), 60, 165)); - add(new StackToDraw(new ItemStack(ItemIDs.minecartFreightWagon_DB.item), 80, 165)); - add(new StackToDraw(new ItemStack(ItemIDs.minecartFreightWagon_DB.item), 100, 165)); - add(new StackToDraw(new ItemStack(ItemIDs.minecartFreightWagon_DB.item), 120, 165)); - add(new StackToDraw(new ItemStack(ItemIDs.minecartCD742.item), 140, 165)); - } - }); - addPage("Armors I: \nThere are several armors in the mod.\nThree of them are mostly skins (engineer, ticket man and driver) with same caracteristics as leather armor.\nOn the contrary, the composite suit is an armor with special capabilities and strong resistance and durability.\nSee next page for details.", "", "left", new ArrayList() { - { - add(new StackToDraw(new ItemStack(ItemIDs.hat.item), 20, 16)); - add(new StackToDraw(new ItemStack(ItemIDs.hat_ticketMan_paintable.item), 170, 16)); - add(new StackToDraw(new ItemStack(ItemIDs.hat_driver_paintable.item), 40, 165)); - add(new StackToDraw(new ItemStack(ItemIDs.jacket_driver_paintable.item), 90, 165)); - add(new StackToDraw(new ItemStack(ItemIDs.pants_driver_paintable.item), 140, 165)); - } - }); - addPage("Armors II: \nThe helmet cures poisons, helps you breathe under water, and gives night vision in dark places (not when riding an entity)\nThe chest regen half a heart every 5s.\nThe pants protect you against fire damage.\nThe boots absorb fall damage.\n"+ - "Ticket man, driver and composite armors are paintable (in train workbench)", "", "right", new ArrayList() { - { - add(new StackToDraw(new ItemStack(ItemIDs.helmet_suit_paintable.item), 20, 16)); - add(new StackToDraw(new ItemStack(ItemIDs.reinforcedPlates.item), 170, 16)); - } - }); - addPage("Generators:\nThere are three generators in the mod.\nWater wheel, Wind mill, and Diesel Generator are RF generators. Water wheel has to be placed beside flowing water. Plug kinesis pipes to the sides.\nWind mill will produce various energy amount depending on wind strength.\nFill the Diesel Generator with diesel, power it with redstone, plug some kinesis pipes.\n","","left",new ArrayList() { - { - add(new StackToDraw(new ItemStack(BlockIDs.windMill.block, 1, 4), 20, 16)); - add(new StackToDraw(new ItemStack(BlockIDs.waterWheel.block, 1, 4), 170, 16)); - } - }); - addPage("Villager\n\nTraincraft adds a new villager and a train station to village generation.\n\nThe villager will trade all traincraft items with you upon various prices.\n","","right",new ArrayList() { - { - add(new StackToDraw(new ItemStack(ItemIDs.jacket_driver_paintable.item, 1, 4), 20, 16)); - add(new StackToDraw(new ItemStack(ItemIDs.hat_driver_paintable.item, 1, 4), 170, 16)); - } - }); - addPage("Known bugs:\n- Sharp turns are not supported (close 180 turns)\n- When coming backwards from the Curve of a switch too slow Switchstate can be false\n- Jukebox Volume incorrect after rejoin/restart\n- Don't use 4 TC Slopes in a row!\n- TC Slopes won't work above about y=160 ", - "", "left", new ArrayList() { - { - add(new StackToDraw(new ItemStack(Items.skull, 1, 4), 20, 16)); - add(new StackToDraw(new ItemStack(Items.skull, 1, 4), 170, 16)); - } - }); - - addPage("Advice:\nDue to the bounding box issues, carts have to be attached and PULLED. Don't try to push\n\nRailcraft pull system has been deactivated on Traincraft loco. Use TC's system. \n","","right",new ArrayList() { - { - add(new StackToDraw(new ItemStack(ItemIDs.minecartTankWagon_DB.item), 20, 16)); - add(new StackToDraw(new ItemStack(BlockIDs.oreTC.block), 170, 16)); - add(new StackToDraw(new ItemStack(ItemIDs.minecartCaboose3.item), 40, 155)); - add(new StackToDraw(new ItemStack(ItemIDs.minecartFreightWellcar.item), 60, 155)); - add(new StackToDraw(new ItemStack(ItemIDs.minecartOpenWagon.item), 80, 155)); - add(new StackToDraw(new ItemStack(ItemIDs.minecartStockCar.item), 100, 155)); - add(new StackToDraw(new ItemStack(ItemIDs.minecartOpenWagon.item), 120, 155)); - add(new StackToDraw(new ItemStack(ItemIDs.minecartBR_E69.item), 140, 155)); - } - }); - - addPage("On the following pages you will find all the train workbench recipes and assembly table recipes.\nIt is however strongly suggested to try to discover the recipes by yourself...\n\nWe hope you will enjoy the mod!\n\nSpitfire4466 and MrBrutal", "", "left", new ArrayList() { - { - add(new StackToDraw(new ItemStack(BlockIDs.trainWorkbench.block), 20, 16)); - add(new StackToDraw(new ItemStack(ItemIDs.hat.item), 40, 155)); - add(new StackToDraw(new ItemStack(ItemIDs.jacket.item), 90, 155)); - add(new StackToDraw(new ItemStack(ItemIDs.overalls.item), 140, 155)); - } - }); - addPage("this page was intentionally left blank, as a joke.","","right",null); - if(recipeListWB==null || recipeListWB.size()<1){ - recipeListWB= RecipeBookHandler.workbenchListCleaner(TrainCraftingManager.getInstance().getRecipeList()); - recipeList = RecipeBookHandler.assemblyListCleaner(TierRecipeManager.getInstance().getRecipeList()); - } - if (rightPage != null && recipeList != null && recipeListWB != null) - bookTotalPages = this.rightPage.size() + (recipeList.size() / 2) + (recipeListWB.size() / 2); - } - - public class StackToDraw { - private ItemStack stack; - private int x; - private int y; - - public StackToDraw(ItemStack stack, int x, int y) { - this.stack = stack; - this.x = x; - this.y = y; - } - - public ItemStack getItemStack() { - return stack; - } - - public int getX() { - return x; - } - - public int getY() { - return y; - } - } - - private void addPage(String text, String image, String side, ArrayList stacks) { - if (side.equals("left")) { - leftPage.add(text); - leftPageImage.add(image); - leftPageItemStacks.add(stacks); - } - if (side.equals("right")) { - rightPage.add(text); - rightPageImage.add(image); - rightPageItemStacks.add(stacks); - } - } - - /** - * Adds the buttons (and other controls) to the screen in question. - */ - @Override - public void initGui() { - this.buttonList.clear(); - - int var1 = (this.width) / 2; - int var2 = (this.height) / 2; - this.buttonList.add(this.buttonBack = new GuiButtonNextPage(4, var1 + 150, var2 + 80, 23, 13, true)); - this.buttonList.add(this.buttonRead = new GuiButtonNextPage(3, var1 - 8, var2 + 98, 40, 20, true)); - this.buttonList.add(this.buttonNextPage = new GuiButtonNextPage(1, var1 + 150, var2 + 80, 23, 13, true)); - this.buttonList.add(this.buttonPreviousPage = new GuiButtonNextPage(2, var1 - 180, var2 + 80, 23, 13, false)); - this.updateButtons(); - } - - private void updateButtons() { - this.buttonBack.visible = (this.currPage == bookTotalPages-1); - this.buttonBack.showButton = true; - this.buttonRead.visible = (this.currPage == 0); - this.buttonRead.showButton = false; - this.buttonNextPage.visible = (this.currPage > 0 && this.currPage < bookTotalPages - 1); - this.buttonNextPage.showButton = (this.currPage > 0 && this.currPage < bookTotalPages - 1); - this.buttonPreviousPage.visible = this.currPage > 0; - this.buttonPreviousPage.showButton = this.currPage > 0; - } - - /** - * Fired when a control is clicked. This is the equivalent of ActionListener.actionPerformed(ActionEvent e). - */ - @Override - protected void actionPerformed(GuiButton par1GuiButton) { - if (par1GuiButton.enabled) { - if (par1GuiButton.id == 1) { - if (this.currPage < bookTotalPages - 1) { - ++this.currPage; - this.currRecipe += 2; - } - } - else if (par1GuiButton.id == 2) { - if (this.currPage > 0) { - --this.currPage; - this.currRecipe -= 2; - } - } - else if (par1GuiButton.id == 3) { - if (this.currPage == 0) { - ++this.currPage; - this.currRecipe += 2; - } - } - else if (par1GuiButton.id == 4) { - if (this.currPage == bookTotalPages-1) { - this.currPage = 0; - this.currRecipe = 0; - } - } - this.updateButtons(); - } - } - - /** - * Draws the screen and all the components in it. - */ - @Override - public void drawScreen(int par1, int par2, float par3) { - String pageIndic; - int var9; - int var5 = (this.width) / 2; - int var6 = (this.height) / 2 - bookImageHeight / 2; - - if (this.currPage > 0) { - //GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - mc.renderEngine.bindTexture(new ResourceLocation(Info.resourceLocation,Info.bookPrefix + "bookright.png")); - this.drawTexturedModalRect(var5, var6, 0, 0, this.bookImageWidth, this.bookImageHeight + 20); - //GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - mc.renderEngine.bindTexture(new ResourceLocation(Info.resourceLocation,Info.bookPrefix + "bookleft.png")); - var5 -= this.bookImageWidth; - this.drawTexturedModalRect(var5, var6, 256 - this.bookImageWidth, 0, this.bookImageWidth, this.bookImageHeight); - } - else { - mc.renderEngine.bindTexture(new ResourceLocation(Info.resourceLocation,Info.bookPrefix + "bookcover.png")); - this.drawTexturedModalRect(var5 - 55, var6 - 15, 0, 0, 256, 256); - } - - pageIndic = String.format(StatCollector.translateToLocal("book.pageIndicator"), new Object[] {this.currPage + 1, this.bookTotalPages}); - - var9 = this.fontRendererObj.getStringWidth(pageIndic); - if (this.currPage > 0) { - this.fontRendererObj.drawString(pageIndic, var5 - var9 + this.bookImageWidth - 44, var6 + 7, 0); - } - super.drawScreen(par1, par2, par3); - - if (this.currPage < rightPage.size()) { - this.fontRendererObj.drawSplitString(leftPage.get(this.currPage), var5 + 36, var6 + 16 + 16, 140, 0); - - this.fontRendererObj.drawSplitString(rightPage.get(this.currPage), var5 + 250, var6 + 16 + 16, 140, 0); - - GL11.glEnable(32826); - RenderHelper.enableGUIStandardItemLighting(); - if (this.leftPageItemStacks != null && this.leftPageItemStacks.get(this.currPage) != null && this.leftPageItemStacks.get(this.currPage).get(0) != null) { - for (int t = 0; t < this.leftPageItemStacks.get(this.currPage).size(); t++) { - if (this.leftPageItemStacks.get(this.currPage).get(t) != null) { - renderItem.renderItemIntoGUI(this.fontRendererObj, this.mc.renderEngine, ((StackToDraw) this.leftPageItemStacks.get(this.currPage).get(t)).getItemStack(), var5 + ((StackToDraw) this.leftPageItemStacks.get(this.currPage).get(t)).getX(), var6 + ((StackToDraw) this.leftPageItemStacks.get(this.currPage).get(t)).getY()); - } - } - } - if (this.rightPageItemStacks != null && this.rightPageItemStacks.get(this.currPage) != null && this.rightPageItemStacks.get(this.currPage).get(0) != null) { - for (int t = 0; t < this.rightPageItemStacks.get(this.currPage).size(); t++) { - if (this.rightPageItemStacks.get(this.currPage).get(t) != null) { - renderItem.renderItemIntoGUI(this.fontRendererObj, this.mc.renderEngine, ((StackToDraw) this.rightPageItemStacks.get(this.currPage).get(t)).getItemStack(), var5 + ((StackToDraw) this.rightPageItemStacks.get(this.currPage).get(t)).getX() + 210, var6 + ((StackToDraw) this.rightPageItemStacks.get(this.currPage).get(t)).getY()); - } - } - } - GL11.glDisable(32826); - } - if (this.currPage > rightPage.size() - 1) { - //System.out.println((rightPage.size()*2) -1); - int page = this.currRecipe - (rightPage.size() * 2) + 1; - if (!(page > recipeListWB.size() - 1)) { - drawWorkBenchBackground(recipeListWB, var5, var6, 0, var9, "right"); - drawWorkBenchBackground(recipeListWB, var5, var6, 0, var9, "left"); - RenderHelper.enableGUIStandardItemLighting(); - drawWorkBenchRecipe(recipeListWB, var5, var6, page - 1, var9, "right"); - drawWorkBenchRecipe(recipeListWB, var5, var6, page, var9, "left"); - } - else if ((page - recipeListWB.size()) >= 0 && (page - recipeListWB.size()) < recipeList.size() && recipeList.get(page - recipeListWB.size()) != null) { - drawAssemblyBackground(recipeList, var5 - 125, var6 - 33, page - recipeListWB.size(), var9, "right"); - drawAssemblyBackground(recipeList, var5 - 50, var6 - 33, page - recipeListWB.size() - 1, var9, "left"); - RenderHelper.enableGUIStandardItemLighting(); - drawAssemblyRecipe(recipeList, var5 - 125, var6 - 33, page - recipeListWB.size(), var9, "right"); - drawAssemblyRecipe(recipeList, var5 - 50, var6 - 33, page - recipeListWB.size() - 1, var9, "left"); - } - } - GL11.glDisable(GL11.GL_LIGHTING); - } - - private void drawAssemblyBackground(List recipeList, int var5, int var6, int page, int var9, String side) { - if (page < 0) - return; - int tier = recipeList.get(page).getTier(); - if (tier == 1) - mc.renderEngine.bindTexture(new ResourceLocation(Info.resourceLocation,Info.TEX_TIER_I)); - if (tier == 2) - mc.renderEngine.bindTexture(new ResourceLocation(Info.resourceLocation,Info.TEX_TIER_II)); - if (tier == 3) - mc.renderEngine.bindTexture(new ResourceLocation(Info.resourceLocation,Info.TEX_TIER_III)); - //if (side.equals("right")) - //GL11.glScaled(0.7, 0.7, 0.7); - if (side.equals("left")) - this.drawTexturedModalRect(var5 + 70, var6 + 50, 0, 0, 177, 163); - if (side.equals("right")) - this.drawTexturedModalRect(var5 + 340, var6 + 50, 0, 0, 177, 163); - } - - private void drawWorkBenchBackground(List recipeListWB, int var5, int var6, int page, int var9, String side) { - //int var4 = this.mc.renderEngine.getTexture("/gui/crafting.png"); - //GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - mc.renderEngine.bindTexture(new ResourceLocation(Info.resourceLocation,Info.guiPrefix+"crafting_table.png")); - if (side.equals("left")) - this.drawTexturedModalRect(var5 + 20, var6 + 50, 0, 0, 177, 80); - if (side.equals("right")) - this.drawTexturedModalRect(var5 + 215, var6 + 50, 0, 0, 177, 80); - } - - private void drawWorkBenchRecipe(List recipeList, int var5, int var6, int page, int var9, String side) { - if (recipeList.get(page) == null) - return; - ItemStack[] itemList = new ItemStack[9]; - ItemStack itemOutput = null; - if (recipeList.get(page) instanceof ShapedTrainRecipes) { - itemList = ((ShapedTrainRecipes) recipeList.get(page)).recipeItems; - itemOutput = ((ShapedTrainRecipes) recipeList.get(page)).getRecipeOutput(); - } - if (recipeList.get(page) instanceof ShapelessTrainRecipe) { - List itemListShapeless = ((ShapelessTrainRecipe) recipeList.get(page)).recipeItems; - for (int t = 0; t < itemListShapeless.size(); t++) { - if (itemListShapeless != null && itemListShapeless.get(t) != null) - itemList[t] = itemListShapeless.get(t); - } - itemOutput = ((ShapelessTrainRecipe) recipeList.get(page)).getRecipeOutput(); - } - - //System.out.println(itemOutput); - int offset = 0; - if (side.equals("right")) - offset = 194; - GL11.glEnable(32826); - if (itemList[0] != null) - renderItem.renderItemIntoGUI(this.fontRendererObj, this.mc.renderEngine, itemList[0], var5 + 50 + offset, var6 + 67); - if (itemList[1] != null) - renderItem.renderItemIntoGUI(this.fontRendererObj, this.mc.renderEngine, itemList[1], var5 + 68 + offset, var6 + 67); - if (itemList[2] != null) - renderItem.renderItemIntoGUI(this.fontRendererObj, this.mc.renderEngine, itemList[2], var5 + 86 + offset, var6 + 67); - if (itemList[3] != null) - renderItem.renderItemIntoGUI(this.fontRendererObj, this.mc.renderEngine, itemList[3], var5 + 50 + offset, var6 + 85); - if (itemList[4] != null) - renderItem.renderItemIntoGUI(this.fontRendererObj, this.mc.renderEngine, itemList[4], var5 + 68 + offset, var6 + 85); - if (itemList[5] != null) - renderItem.renderItemIntoGUI(this.fontRendererObj, this.mc.renderEngine, itemList[5], var5 + 86 + offset, var6 + 85); - if (itemList[6] != null) - renderItem.renderItemIntoGUI(this.fontRendererObj, this.mc.renderEngine, itemList[6], var5 + 50 + offset, var6 + 103); - if (itemList[7] != null) - renderItem.renderItemIntoGUI(this.fontRendererObj, this.mc.renderEngine, itemList[7], var5 + 68 + offset, var6 + 103); - if (itemList[8] != null) - renderItem.renderItemIntoGUI(this.fontRendererObj, this.mc.renderEngine, itemList[8], var5 + 86 + offset, var6 + 103); - if (itemOutput != null && itemOutput.getItem() !=null) - renderItem.renderItemIntoGUI(this.fontRendererObj, this.mc.renderEngine, itemOutput, var5 + 145 + offset, var6 + 85); - if (itemOutput != null && itemOutput.getItem() !=null) - this.fontRendererObj.drawString(itemOutput.getItem().getItemStackDisplayName(itemOutput), var5 + 20 + offset, var6 + 40, 0); - if (itemOutput != null) - this.fontRendererObj.drawString("Crafted in: Train Workbench", var5 + 20 + offset, var6 + 130, 0); - if (itemOutput != null) { - for (int z = 0; z < RecipeBookHandler.vanillaWorkTableRecipes.length; z++) { - if (itemOutput.getItem()!= null && RecipeBookHandler.vanillaWorkTableRecipes[z]!=null && RecipeBookHandler.vanillaWorkTableRecipes[z].equals(itemOutput.getItem().getItemStackDisplayName(itemOutput))) { - this.fontRendererObj.drawString("Also crafted in: Crafting Table", var5 + 20 + offset, var6 + 140, 0); - break; - } - } - } - GL11.glDisable(32826); - } - - private void drawAssemblyRecipe(List recipeList, int var5, int var6, int page, int var9, String side) { - if (page < 0) - return; - int tier = recipeList.get(page).getTier(); - - List itemList = recipeList.get(page).getInput(); - int offset = 0; - if (side.equals("right")) - offset = 271; - GL11.glEnable(32826); - if (itemList.get(0) != null) - renderItem.renderItemIntoGUI(this.fontRendererObj, this.mc.renderEngine, itemList.get(0), var5 + 94 + offset, var6 + 76); - if (itemList.get(0) != null) - renderItem.renderItemOverlayIntoGUI(this.fontRendererObj, this.mc.renderEngine, itemList.get(0), var5 + 94 + offset, var6 + 76); - if (itemList.get(1) != null) - renderItem.renderItemIntoGUI(this.fontRendererObj, this.mc.renderEngine, itemList.get(1), var5 + 113 + offset, var6 + 143); - if (itemList.get(1) != null) - renderItem.renderItemOverlayIntoGUI(this.fontRendererObj, this.mc.renderEngine, itemList.get(1), var5 + 113 + offset, var6 + 143); - if (itemList.get(2) != null) - renderItem.renderItemIntoGUI(this.fontRendererObj, this.mc.renderEngine, itemList.get(2), var5 + 148 + offset, var6 + 143); - if (itemList.get(2) != null) - renderItem.renderItemOverlayIntoGUI(this.fontRendererObj, this.mc.renderEngine, itemList.get(2), var5 + 148 + offset, var6 + 143); - if (itemList.get(3) != null) - renderItem.renderItemIntoGUI(this.fontRendererObj, this.mc.renderEngine, itemList.get(3), var5 + 214 + offset, var6 + 143); - if (itemList.get(3) != null) - renderItem.renderItemOverlayIntoGUI(this.fontRendererObj, this.mc.renderEngine, itemList.get(3), var5 + 214 + offset, var6 + 143); - if (itemList.get(4) != null) - renderItem.renderItemIntoGUI(this.fontRendererObj, this.mc.renderEngine, itemList.get(4), var5 + 148 + offset, var6 + 77); - if (itemList.get(4) != null) - renderItem.renderItemOverlayIntoGUI(this.fontRendererObj, this.mc.renderEngine, itemList.get(4), var5 + 148 + offset, var6 + 77); - if (itemList.get(5) != null) - renderItem.renderItemIntoGUI(this.fontRendererObj, this.mc.renderEngine, itemList.get(5), var5 + 184 + offset, var6 + 77); - if (itemList.get(5) != null) - renderItem.renderItemOverlayIntoGUI(this.fontRendererObj, this.mc.renderEngine, itemList.get(5), var5 + 184 + offset, var6 + 77); - if (itemList.get(6) != null) - renderItem.renderItemIntoGUI(this.fontRendererObj, this.mc.renderEngine, itemList.get(6), var5 + 149 + offset, var6 + 110); - if (itemList.get(6) != null) - renderItem.renderItemOverlayIntoGUI(this.fontRendererObj, this.mc.renderEngine, itemList.get(6), var5 + 149 + offset, var6 + 110); - if (itemList.get(7) != null) - renderItem.renderItemIntoGUI(this.fontRendererObj, this.mc.renderEngine, itemList.get(7), var5 + 185 + offset, var6 + 110); - if (itemList.get(7) != null) - renderItem.renderItemOverlayIntoGUI(this.fontRendererObj, this.mc.renderEngine, itemList.get(7), var5 + 185 + offset, var6 + 110); - if (itemList.get(8) != null) - renderItem.renderItemIntoGUI(this.fontRendererObj, this.mc.renderEngine, itemList.get(8), var5 + 94 + offset, var6 + 110); - if (itemList.get(8) != null) - renderItem.renderItemOverlayIntoGUI(this.fontRendererObj, this.mc.renderEngine, itemList.get(8), var5 + 94 + offset, var6 + 110); - if (itemList.get(9) != null) - renderItem.renderItemIntoGUI(this.fontRendererObj, this.mc.renderEngine, itemList.get(9), var5 + 214 + offset, var6 + 77); - if (itemList.get(9) != null) - renderItem.renderItemOverlayIntoGUI(this.fontRendererObj, this.mc.renderEngine, itemList.get(9), var5 + 214 + offset, var6 + 77); - ItemStack output = recipeList.get(page).getOutput(); - if (output != null && side.equals("left")) - renderItem.renderItemIntoGUI(this.fontRendererObj, this.mc.renderEngine, output, var5 + 162, var6 + 177); - if (output != null && side.equals("right")) - renderItem.renderItemIntoGUI(this.fontRendererObj, this.mc.renderEngine, output, var5 + 432, var6 + 177); - String name = ""; - if (output != null && output.getItem() instanceof ItemRollingStock) - name = output.getDisplayName(); - if (side.equals("left")) { - this.fontRendererObj.drawString("Tier: " + tier, var5 - var9 + this.bookImageWidth - 56, var6 + 40, 0); - this.fontRendererObj.drawString(name, var5 - var9 + this.bookImageWidth - 55, var6 + 56, 0xffffff); - } - if (side.equals("right")) { - this.fontRendererObj.drawString(name, var5 - var9 + this.bookImageWidth + 215, var6 + 56, 0xffffff); - this.fontRendererObj.drawString("Tier: " + tier, var5 - var9 + this.bookImageWidth + 338, var6 + 40, 0); - } - GL11.glDisable(32826); - } - - @Override - public void onGuiClosed() { - ItemRecipeBook.page = this.currPage; - ItemRecipeBook.recipe = this.currRecipe; - this.itemstackBook.getTagCompound().setInteger("currPage", this.currPage); - this.itemstackBook.getTagCompound().setInteger("currRecipe", this.currRecipe); - super.onGuiClosed(); - } - - @Override - public boolean doesGuiPauseGame() { - return false; - } - - @Override - protected void keyTyped(char par1, int par2) { - if(par2 == 1 || par2 == this.mc.gameSettings.keyBindInventory.getKeyCode()) { - this.mc.thePlayer.closeScreen(); - } - } + /** + * The player editing the book + */ + private final EntityPlayer editingPlayer; + private final ItemStack itemstackBook; + + /** + * Update ticks since the gui was opened + */ + private final int bookImageWidth = 206; + public static int bookTotalPages = 2; + private int currPage; + private int currRecipe; + public ArrayList leftPage = new ArrayList(); + public ArrayList leftPageImage = new ArrayList(); + public ArrayList leftPageItemStacks = new ArrayList(); + public ArrayList rightPage = new ArrayList(); + public ArrayList rightPageImage = new ArrayList(); + public ArrayList rightPageItemStacks = new ArrayList(); + private List recipeListWB = null; + private List recipeList = null; + + private GuiButtonNextPage buttonRead; + private GuiButtonNextPage buttonNextPage; + private GuiButtonNextPage buttonPreviousPage; + private GuiButtonNextPage buttonBack; + private final RenderItem renderItem = new RenderItem(); + + public GuiRecipeBook(EntityPlayer par1EntityPlayer, ItemStack par2ItemStack) { + this.editingPlayer = par1EntityPlayer; + this.itemstackBook = par2ItemStack; + this.currPage = this.itemstackBook.getTagCompound().getInteger("currPage"); + this.currRecipe = this.itemstackBook.getTagCompound().getInteger("currRecipe"); + + addPage("", "", "left", null); + addPage("", "", "right", null); + addPage("Welcome to the Traincraft guide! \nThis book contains everything you need to know about Traincraft.\n\nAuthors:\nSpitfire4466,\nMrbrutal\n\nBukkit port: \nDV8FromTheWorld\n\nThanks to CovertJaguar for his help and a great API.\n", "", "left", new ArrayList() { + { + add(new StackToDraw(new ItemStack(ItemIDs.minecartLocoBR80_DB.item), 20, 16)); + add(new StackToDraw(new ItemStack(BlockIDs.trainWorkbench.block), 170, 16)); + add(new StackToDraw(new ItemStack(ItemIDs.minecartCabooseWork.item), 60, 175)); + add(new StackToDraw(new ItemStack(ItemIDs.minecartTankWagon_DB.item), 80, 175)); + add(new StackToDraw(new ItemStack(ItemIDs.minecartFlatCartRail_DB.item), 100, 175)); + add(new StackToDraw(new ItemStack(ItemIDs.minecartFreightWagon_DB.item), 120, 175)); + add(new StackToDraw(new ItemStack(ItemIDs.minecartPassengerBlue.item), 140, 175)); + add(new StackToDraw(new ItemStack(ItemIDs.minecartV60_DB.item), 160, 175)); + } + }); + addPage("Modelers:\nDAYdiecast,\nhelldiver,\nBlockStormTwo,\nChandlerBingUA.\n\nGitHub 1.7.10 port Team: \nEternal BlueFlame,\nNitroxydeX,\nFirEmerald,\nHagurd\n \nWebsite:\nhttp://traincraft-mod.\nblogspot.com", "", "right", new ArrayList() { + { + add(new StackToDraw(new ItemStack(ItemIDs.minecartLocoSteamAdler.item), 20, 16)); + add(new StackToDraw(new ItemStack(BlockIDs.assemblyTableII.block), 170, 16)); + + add(new StackToDraw(new ItemStack(ItemIDs.minecartLocoForneyRed.item), 20, 175)); + add(new StackToDraw(new ItemStack(ItemIDs.minecartPassengerBlue.item), 40, 175)); + add(new StackToDraw(new ItemStack(ItemIDs.minecartPassengerBlue.item), 60, 175)); + add(new StackToDraw(new ItemStack(ItemIDs.minecartFreightWagon_DB.item), 80, 175)); + add(new StackToDraw(new ItemStack(ItemIDs.minecartWood.item), 100, 175)); + add(new StackToDraw(new ItemStack(ItemIDs.minecartCabooseLogging.item), 120, 175)); + } + }); + addPage("World generation:\n\n By default, petrol and oil sands will be generated in the world. If you don't want them, open Traincraft.cfg and change the line ENABLE_ORE_SPAWN from true to false.\nOnly the new ores will generate, the old ones can be transformed into the new ones in a crafting table.", "", "left", new ArrayList() { + { + add(new StackToDraw(new ItemStack(BlockIDs.oreTC.block, 1, 1), 60, 160)); + add(new StackToDraw(new ItemStack(BlockIDs.oreTC.block, 1, 2), 120, 160)); + } + }); + + addPage("Keys:\nTo interact with the trains (e.g. enter, display the inventory) click above the shadow the train is casting on the ground.\nInside the locomotive press R to open up the GUI: This is where you can put fuel, water, additional cargo, set brakes, etc.\n", "", "right", new ArrayList() { + { + add(new StackToDraw(new ItemStack(Items.coal), 60, 160)); + add(new StackToDraw(new ItemStack(Items.water_bucket), 120, 160)); + } + }); + + addPage("Use the W and S keys to move the locomotive forwards or backwards, respectively.\nPress H in the locomotive to activate the whistle.\nIn the Work Carts, press R to open up the Crafting Table and F for the Furnace.\n", "", "left", new ArrayList() { + { + add(new StackToDraw(new ItemStack(ItemIDs.minecartLocoBR80_DB.item), 20, 16)); + add(new StackToDraw(new ItemStack(ItemIDs.minecartGP7Red.item), 170, 16)); + add(new StackToDraw(new ItemStack(ItemIDs.minecartLocoCherepanov.item), 40, 145)); + add(new StackToDraw(new ItemStack(ItemIDs.minecartWork.item), 60, 145)); + add(new StackToDraw(new ItemStack(ItemIDs.minecartCabooseWork.item), 80, 145)); + add(new StackToDraw(new ItemStack(ItemIDs.minecartLocoForneyRed.item), 100, 145)); + add(new StackToDraw(new ItemStack(ItemIDs.minecartShunter.item), 120, 145)); + add(new StackToDraw(new ItemStack(ItemIDs.minecartLocoBR01_DB.item), 140, 145)); + } + }); + addPage("Zeppelin:\nRight click on the Zeppelin to enter it. \nInside, press R to open its GUI. \nUse the WASD keys to move the zeppelin around. \nPress once Y to ascend or X to descend, To lock altitude, press C. \n", "", "right", new ArrayList() { + { + add(new StackToDraw(new ItemStack(ItemIDs.airship.item), 20, 16)); + add(new StackToDraw(new ItemStack(ItemIDs.balloon.item), 170, 16)); + add(new StackToDraw(new ItemStack(ItemIDs.propeller.item), 40, 135)); + add(new StackToDraw(new ItemStack(ItemIDs.steamengine.item), 60, 135)); + add(new StackToDraw(new ItemStack(Items.boat), 120, 135)); + add(new StackToDraw(new ItemStack(Items.stick), 140, 135)); + + } + }); + addPage("Fuel:\nSteam locomotives need coal and water.\nTenders can only hold coal and water. Attach them to a steam locomotive, they will provide fuel and water for the loco.\nDiesel locos need diesel canisters (from distillation tower) or fuel from BC and Forestry.\n", "", "left", new ArrayList() { + { + add(new StackToDraw(new ItemStack(ItemIDs.minecartTender.item), 20, 16)); + add(new StackToDraw(new ItemStack(ItemIDs.minecartLocomogulBlue.item), 170, 16)); + add(new StackToDraw(new ItemStack(Items.coal), 40, 155)); + add(new StackToDraw(new ItemStack(Items.water_bucket), 60, 155)); + add(new StackToDraw(new ItemStack(Blocks.planks), 80, 155)); + add(new StackToDraw(new ItemStack(Items.blaze_rod), 100, 155)); + add(new StackToDraw(new ItemStack(ItemIDs.diesel.item), 120, 155)); + add(new StackToDraw(new ItemStack(ItemIDs.refinedFuel.item), 140, 155)); + } + }); + + addPage("Electric locomotives need redstone or RF-based energy storages, they can also be powered by Electric tracks.\n\nHeat:\nHeat level is indicated by the heat bar in the HUD.\nHeat level will go to a normal state when the train is fueled but don't forget to put water in steam locomotive or it will overheat very fast.\n", "", "right", new ArrayList() { + { + add(new StackToDraw(new ItemStack(ItemIDs.minecartBR_E69.item), 20, 16)); + add(new StackToDraw(new ItemStack(Items.redstone), 170, 16)); + } + }); + + addPage("Heat level will go down to cold when there's no fuel.\nWait until the locomotive has heated up before trying to move. but be careful overheating can cause explosions...\n\nRouting:\nLocomotives can be routed using Railcraft routing track. Destination will show in the GUI, Sneak+Crowbar to reset. There is no space for tickets. Not 'Color=' compatible.", "", "left", new ArrayList() { + { + add(new StackToDraw(new ItemStack(ItemIDs.firebox.item), 20, 16)); + add(new StackToDraw(new ItemStack(Blocks.tnt), 170, 16)); + } + }); + addPage("Minecraft Horse Power - Mhp:\n\nLocomotives have different pulling abilities represented by their 'power' in Mhp.\nEach cart has a mass in tons which will affect the locomotive depending on its power.\nMass pulled affects the maximum speed, the brake rate and accelerate rate, as well as fuel consumption.\n", "", "right", new ArrayList() { + { + add(new StackToDraw(new ItemStack(ItemIDs.stake.item), 20, 16)); + add(new StackToDraw(new ItemStack(ItemIDs.minecartLocoBR01_DB.item), 40, 165)); + add(new StackToDraw(new ItemStack(ItemIDs.stake.item), 60, 165)); + add(new StackToDraw(new ItemStack(ItemIDs.minecartFreightCart2.item), 80, 165)); + add(new StackToDraw(new ItemStack(ItemIDs.stake.item), 100, 165)); + add(new StackToDraw(new ItemStack(ItemIDs.minecartFreightClosed.item), 120, 165)); + add(new StackToDraw(new ItemStack(ItemIDs.stake.item), 140, 165)); + add(new StackToDraw(new ItemStack(ItemIDs.minecartWatertransp.item), 160, 165)); + } + }); + addPage("Derailment:\n\nDo not go too fast on turns or your locomotives will derail!\n\nIt is recommended to slow down under 90km/h before turning or you will find yourself crashing off tracks.", "", "left", new ArrayList() { + { + add(new StackToDraw(new ItemStack(Items.skull, 1, 1), 20, 16)); + } + }); + + addPage("Pulling:\nRight click both carts with a stake in your hand, it will say 'Attaching mode on', then make them collide and it will say 'Attached'.\nLocomotives have pulling capabilities, don't make too long trains with weak locomotives. Stats of the locomotive will be affected. (they can be seen on the top left corner when you open the locomotive's inventory).\n", "", "right", new ArrayList() { + { + add(new StackToDraw(new ItemStack(ItemIDs.stake.item), 20, 16)); + add(new StackToDraw(new ItemStack(ItemIDs.minecartCaboose.item), 40, 165)); + add(new StackToDraw(new ItemStack(ItemIDs.stake.item), 60, 165)); + add(new StackToDraw(new ItemStack(ItemIDs.minecartBoxCartUS.item), 80, 165)); + add(new StackToDraw(new ItemStack(ItemIDs.stake.item), 100, 165)); + add(new StackToDraw(new ItemStack(ItemIDs.minecartFlatCartLogs_DB.item), 120, 165)); + add(new StackToDraw(new ItemStack(ItemIDs.stake.item), 140, 165)); + add(new StackToDraw(new ItemStack(ItemIDs.minecartCD742.item), 160, 165)); + } + }); + addPage("Chunk Loading:\n\nEach rolling stock can load one chunk around itself.\nTo start chunk loading, right click with chunk loader activator on the rolling stock.\nTo stop chunk loading, right click again.\n", "", "left", new ArrayList() { + { + add(new StackToDraw(new ItemStack(ItemIDs.chunkLoaderActivator.item), 20, 16)); + add(new StackToDraw(new ItemStack(Items.ender_pearl), 170, 16)); + } + }); + addPage("Colors:\n\nSome rolling stock has several textures and can be painted with dyes.\nThe rolling stock that can be painted will show the possible colors in the chat once placed in the world.\nTo paint, simply right click with the correct dye.\n\nLantern color is randomly picked, but you can set the hex color manually with a wrench", "", "right", new ArrayList() { + { + add(new StackToDraw(new ItemStack(Items.dye, 1, 1), 20, 16)); + add(new StackToDraw(new ItemStack(Items.dye, 1, 11), 170, 16)); + } + }); + addPage("Stock car:\n\nThe stock car is the only rolling stock that can be ridden by any animals and mobs.\nTo fill the stock car, either collide the animal with the car or use the animal/mob boarding tracks (Railcraft required).\nTo empty the car, use the disembark track (Railcraft required).\n", "", "left", new ArrayList() { + { + add(new StackToDraw(new ItemStack(ItemIDs.minecartStockCar.item), 20, 16)); + add(new StackToDraw(new ItemStack(Items.skull, 1, 4), 170, 16)); + } + }); + addPage("A word about tracks I:\nCopper tracks will slow trains down.\nSteel tracks allow trains to go faster.\nSpeed controller track allows you to change the locomotive's max speed (hit with crowbar).\nThe energy track can be powered by redstone and will power electric trains, redstone power will be transmitted two tracks away.\n", "", "right", new ArrayList() { + { + add(new StackToDraw(new ItemStack(Blocks.rail), 17, 16)); + add(new StackToDraw(new ItemStack(Blocks.rail), 17, 32)); + add(new StackToDraw(new ItemStack(Blocks.rail), 17, 48)); + add(new StackToDraw(new ItemStack(Blocks.rail), 17, 64)); + add(new StackToDraw(new ItemStack(Blocks.rail), 17, 80)); + add(new StackToDraw(new ItemStack(Blocks.rail), 17, 96)); + add(new StackToDraw(new ItemStack(Blocks.rail), 17, 112)); + add(new StackToDraw(new ItemStack(Blocks.rail), 17, 128)); + add(new StackToDraw(new ItemStack(Blocks.rail), 17, 144)); + add(new StackToDraw(new ItemStack(Blocks.rail), 17, 160)); + add(new StackToDraw(new ItemStack(Blocks.golden_rail), 170, 16)); + } + }); + addPage("A word about tracks II:\nTo check the current charge click the track with a crowbar.\nAn electric track connected to a redstone power source gets 1 energy unit every two ticks.\nLocomotive holding track will only hold TC locomotives. No boost is given, the previous speed is restored once released.\nAll tracks require Railcraft to be installed.", "", "left", new ArrayList() { + { + add(new StackToDraw(new ItemStack(Blocks.activator_rail), 17, 16)); + add(new StackToDraw(new ItemStack(Blocks.golden_rail), 170, 16)); + } + }); + + addPage("Steel rails parts and copper rails parts are crafted inside RC Rolling Machine, tracks are assembled in vanilla workbench.\nTC boarding/disembarking track are designed to work only on the Stock Car. Animal boarding will take any nearby animal and put it inside a passing Stock Car. Mob boarding will affect any mob.\nDisembark will eject any mob inside the Stock Car.", "", "right", new ArrayList() { + { + add(new StackToDraw(new ItemStack(Blocks.detector_rail), 17, 16)); + add(new StackToDraw(new ItemStack(Blocks.golden_rail), 170, 16)); + } + }); + addPage("Builder I:\n\nThe tracks builder has a very special inventory, in order to start it you must provide:\nBallast in the slot under it (planks, gravel, stone, ...).\nCoal in the fuel slot, Tracks in the slot under the fuel slot. The slot on the right of the builder will activate tunnel function when provided (not all blocks are accepted).\n", "", "left", new ArrayList() { + { + add(new StackToDraw(new ItemStack(ItemIDs.minecartBuilder.item), 20, 16)); + add(new StackToDraw(new ItemStack(ItemIDs.minecartBuilder.item), 60, 165)); + add(new StackToDraw(new ItemStack(ItemIDs.stake.item), 80, 165)); + add(new StackToDraw(new ItemStack(ItemIDs.minecartFreightClosed.item), 100, 165)); + } + }); + addPage("Builder II:\n\nThe slots on top of the builder are roof slots, the builder will build a roof when provided (not all blocks are accepted). If you attach a freight cart to the builder, it will dump things in it.\n\n", "", "right", new ArrayList() { + { + add(new StackToDraw(new ItemStack(ItemIDs.minecartBuilder.item), 20, 16)); + add(new StackToDraw(new ItemStack(ItemIDs.minecartBuilder.item), 60, 125)); + add(new StackToDraw(new ItemStack(ItemIDs.stake.item), 80, 125)); + add(new StackToDraw(new ItemStack(ItemIDs.minecartFreightClosed.item), 100, 125)); + } + }); + addPage("Limitations:\n\nVERY IMPORTANT:\nLong trains imply limitations: Do not try to make sharp 180 turns, leave 3+ spaces between each 90 turn. Otherwise weird stuff may happen especially with very long trains.\n\nAlways PULL carts! Bounding boxes are buggy and unreliable!", "", "left", new ArrayList() { + { + add(new StackToDraw(new ItemStack(Blocks.detector_rail), 20, 16)); + add(new StackToDraw(new ItemStack(Blocks.rail), 170, 16)); + add(new StackToDraw(new ItemStack(ItemIDs.minecartPower.item), 40, 165)); + add(new StackToDraw(new ItemStack(ItemIDs.minecartFlatCartWoodUS.item), 60, 165)); + add(new StackToDraw(new ItemStack(ItemIDs.minecartBoxCartUS.item), 80, 165)); + add(new StackToDraw(new ItemStack(ItemIDs.minecartPassenger9_2class_DB.item), 100, 165)); + add(new StackToDraw(new ItemStack(ItemIDs.minecartFlatCartLogs_DB.item), 120, 165)); + add(new StackToDraw(new ItemStack(ItemIDs.minecartFreightCart2.item), 140, 165)); + add(new StackToDraw(new ItemStack(ItemIDs.minecartCaboose.item), 160, 165)); + } + }); + addPage("Crafting:\nAll train parts are crafted in the train workbench,\n\nthen trains have to be assembled in the assembly tables.\n\nThere are three assembly tables:\n\nTierI - Iron age\nTierII - Steel age\nTierIII - Advanced age\n", "", "right", new ArrayList() { + { + add(new StackToDraw(new ItemStack(BlockIDs.trainWorkbench.block), 20, 16)); + add(new StackToDraw(new ItemStack(BlockIDs.assemblyTableI.block), 40, 165)); + add(new StackToDraw(new ItemStack(BlockIDs.assemblyTableII.block), 80, 165)); + add(new StackToDraw(new ItemStack(BlockIDs.assemblyTableIII.block), 140, 165)); + } + }); + addPage("Crafting steel:\nSteel is crafted in Open Hearth Furnace, supply iron ingots and graphite in the top slots, fuel in the bottom slot, \nand it will cook slowly into steel.\nYou can also use steel from other mods or use this steel in other mods.\n", "", "left", new ArrayList() { + { + add(new StackToDraw(new ItemStack(BlockIDs.openFurnaceIdle.block), 20, 16)); + add(new StackToDraw(new ItemStack(BlockIDs.openFurnaceActive.block), 80, 155)); + add(new StackToDraw(new ItemStack(ItemIDs.graphite.item), 70, 135)); + add(new StackToDraw(new ItemStack(Items.iron_ingot), 90, 135)); + add(new StackToDraw(new ItemStack(Items.coal), 80, 175)); + add(new StackToDraw(new ItemStack(ItemIDs.steel.item), 120, 155)); + } + }); + + addPage("Making diesel:\nDiesel is made in a distillation tower using petroleum or oil sands found in the world.\nInsert petroleum in the top slot and fuel in the bottom slot, also try reed.\nIt will cook into liquid diesel and give you plastic with a random chance depending on the input.\nTo get diesel into canisters, you must first craft them using plastic. Then put an empty one in the top right slot.", "", "right", new ArrayList() { + { + add(new StackToDraw(new ItemStack(BlockIDs.distilIdle.block), 20, 16)); + add(new StackToDraw(new ItemStack(BlockIDs.distilActive.block), 150, 40)); + add(new StackToDraw(new ItemStack(BlockIDs.oreTC.block, 1, 1), 150, 20)); + add(new StackToDraw(new ItemStack(Items.coal), 150, 60)); + add(new StackToDraw(new ItemStack(ItemIDs.diesel.item), 167, 40)); + add(new StackToDraw(new ItemStack(ItemIDs.rawPlastic.item), 167, 60)); + } + }); + addPage("Special pull I: \nYou can attach two locomotives together.\n\nTo do that: shift+click the locomotive you want to PULL with a stake in your hand. Then fuel it and wait until it heats up.\n\nNow put both locomotives in attaching mode. Then move attach them by moving one locomotive towards the other.", "", "left", new ArrayList() { + { + add(new StackToDraw(new ItemStack(ItemIDs.minecartLocoBR80_DB.item), 20, 16)); + add(new StackToDraw(new ItemStack(ItemIDs.stake.item), 170, 16)); + add(new StackToDraw(new ItemStack(ItemIDs.minecartCabooseWork.item), 40, 165)); + add(new StackToDraw(new ItemStack(ItemIDs.minecartTankWagon_DB.item), 60, 165)); + add(new StackToDraw(new ItemStack(ItemIDs.minecartFlatCartRail_DB.item), 80, 165)); + add(new StackToDraw(new ItemStack(ItemIDs.minecartFreightWagon_DB.item), 100, 165)); + add(new StackToDraw(new ItemStack(ItemIDs.minecartCD742.item), 120, 165)); + add(new StackToDraw(new ItemStack(ItemIDs.minecartCD742.item), 140, 165)); + } + }); + addPage("Special pull II: \nLocomotives have two states: 'Can pull' and 'Can be pulled'.\n'Can pull' means that the locomotive is able to pull any attach cart. But it can't be pulled.\n'Can be pulled' means that the locomotive behaves like a cart and can be pulled by another locomotive (which is in 'can pull' state). Attached locomotives share power.", "", "right", new ArrayList() { + { + add(new StackToDraw(new ItemStack(ItemIDs.minecartLoco3.item), 20, 16)); + add(new StackToDraw(new ItemStack(ItemIDs.stake.item), 170, 16)); + add(new StackToDraw(new ItemStack(ItemIDs.minecartCD742.item), 40, 165)); + add(new StackToDraw(new ItemStack(ItemIDs.minecartFreightWagon_DB.item), 60, 165)); + add(new StackToDraw(new ItemStack(ItemIDs.minecartFreightWagon_DB.item), 80, 165)); + add(new StackToDraw(new ItemStack(ItemIDs.minecartFreightWagon_DB.item), 100, 165)); + add(new StackToDraw(new ItemStack(ItemIDs.minecartFreightWagon_DB.item), 120, 165)); + add(new StackToDraw(new ItemStack(ItemIDs.minecartCD742.item), 140, 165)); + } + }); + addPage("Armors I: \nThere are several armors in the mod.\nThree of them are mostly skins (engineer, ticket man and driver) with same caracteristics as leather armor.\nOn the contrary, the composite suit is an armor with special capabilities and strong resistance and durability.\nSee next page for details.", "", "left", new ArrayList() { + { + add(new StackToDraw(new ItemStack(ItemIDs.hat.item), 20, 16)); + add(new StackToDraw(new ItemStack(ItemIDs.hat_ticketMan_paintable.item), 170, 16)); + add(new StackToDraw(new ItemStack(ItemIDs.hat_driver_paintable.item), 40, 165)); + add(new StackToDraw(new ItemStack(ItemIDs.jacket_driver_paintable.item), 90, 165)); + add(new StackToDraw(new ItemStack(ItemIDs.pants_driver_paintable.item), 140, 165)); + } + }); + addPage("Armors II: \nThe helmet cures poisons, helps you breathe under water, and gives night vision in dark places (not when riding an entity)\nThe chest regen half a heart every 5s.\nThe pants protect you against fire damage.\nThe boots absorb fall damage.\n" + "Ticket man, driver and composite armors are paintable (in train workbench)", "", "right", new ArrayList() { + { + add(new StackToDraw(new ItemStack(ItemIDs.helmet_suit_paintable.item), 20, 16)); + add(new StackToDraw(new ItemStack(ItemIDs.reinforcedPlates.item), 170, 16)); + } + }); + addPage("Generators:\nThere are three generators in the mod.\nWater wheel, Wind mill, and Diesel Generator are RF generators. Water wheel has to be placed beside flowing water. Plug kinesis pipes to the sides.\nWind mill will produce various energy amount depending on wind strength.\nFill the Diesel Generator with diesel, power it with redstone, plug some kinesis pipes.\n", "", "left", new ArrayList() { + { + add(new StackToDraw(new ItemStack(BlockIDs.windMill.block, 1, 4), 20, 16)); + add(new StackToDraw(new ItemStack(BlockIDs.waterWheel.block, 1, 4), 170, 16)); + } + }); + addPage("Villager\n\nTraincraft adds a new villager and a train station to village generation.\n\nThe villager will trade all traincraft items with you upon various prices.\n", "", "right", new ArrayList() { + { + add(new StackToDraw(new ItemStack(ItemIDs.jacket_driver_paintable.item, 1, 4), 20, 16)); + add(new StackToDraw(new ItemStack(ItemIDs.hat_driver_paintable.item, 1, 4), 170, 16)); + } + }); + addPage("Known bugs:\n- Sharp turns are not supported (close 180 turns)\n- When coming backwards from the Curve of a switch too slow Switchstate can be false\n- Jukebox Volume incorrect after rejoin/restart\n- Don't use 4 TC Slopes in a row!\n- TC Slopes won't work above about y=160 ", "", "left", new ArrayList() { + { + add(new StackToDraw(new ItemStack(Items.skull, 1, 4), 20, 16)); + add(new StackToDraw(new ItemStack(Items.skull, 1, 4), 170, 16)); + } + }); + + addPage("Advice:\nDue to the bounding box issues, carts have to be attached and PULLED. Don't try to push\n\nRailcraft pull system has been deactivated on Traincraft loco. Use TC's system. \n", "", "right", new ArrayList() { + { + add(new StackToDraw(new ItemStack(ItemIDs.minecartTankWagon_DB.item), 20, 16)); + add(new StackToDraw(new ItemStack(BlockIDs.oreTC.block), 170, 16)); + add(new StackToDraw(new ItemStack(ItemIDs.minecartCaboose3.item), 40, 155)); + add(new StackToDraw(new ItemStack(ItemIDs.minecartFreightWellcar.item), 60, 155)); + add(new StackToDraw(new ItemStack(ItemIDs.minecartOpenWagon.item), 80, 155)); + add(new StackToDraw(new ItemStack(ItemIDs.minecartStockCar.item), 100, 155)); + add(new StackToDraw(new ItemStack(ItemIDs.minecartOpenWagon.item), 120, 155)); + add(new StackToDraw(new ItemStack(ItemIDs.minecartBR_E69.item), 140, 155)); + } + }); + + addPage("On the following pages you will find all the train workbench recipes and assembly table recipes.\nIt is however strongly suggested to try to discover the recipes by yourself...\n\nWe hope you will enjoy the mod!\n\nSpitfire4466 and MrBrutal", "", "left", new ArrayList() { + { + add(new StackToDraw(new ItemStack(BlockIDs.trainWorkbench.block), 20, 16)); + add(new StackToDraw(new ItemStack(ItemIDs.hat.item), 40, 155)); + add(new StackToDraw(new ItemStack(ItemIDs.jacket.item), 90, 155)); + add(new StackToDraw(new ItemStack(ItemIDs.overalls.item), 140, 155)); + } + }); + addPage("this page was intentionally left blank, as a joke.", "", "right", null); + if (recipeListWB == null || recipeListWB.size() < 1) { + recipeListWB = RecipeBookHandler.workbenchListCleaner(TrainCraftingManager.getInstance().getRecipeList()); + recipeList = RecipeBookHandler.assemblyListCleaner(TierRecipeManager.getInstance().getRecipeList()); + } + if (rightPage != null && recipeList != null && recipeListWB != null) + bookTotalPages = this.rightPage.size() + (recipeList.size() / 2) + (recipeListWB.size() / 2); + } + + public static class StackToDraw { + private final ItemStack stack; + private final int x; + private final int y; + + public StackToDraw(ItemStack stack, int x, int y) { + this.stack = stack; + this.x = x; + this.y = y; + } + + public ItemStack getItemStack() { + return stack; + } + + public int getX() { + return x; + } + + public int getY() { + return y; + } + } + + private void addPage(String text, String image, String side, ArrayList stacks) { + if (side.equals("left")) { + leftPage.add(text); + leftPageImage.add(image); + leftPageItemStacks.add(stacks); + } + + if (side.equals("right")) { + rightPage.add(text); + rightPageImage.add(image); + rightPageItemStacks.add(stacks); + } + } + + /** + * Adds the buttons (and other controls) to the screen in question. + */ + @Override + public void initGui() { + this.buttonList.clear(); + + int var1 = (this.width) / 2; + int var2 = (this.height) / 2; + + this.buttonList.add(this.buttonBack = new GuiButtonNextPage(4, var1 + 150, var2 + 80, 23, 13, true)); + this.buttonList.add(this.buttonRead = new GuiButtonNextPage(3, var1 - 8, var2 + 98, 40, 20, true)); + this.buttonList.add(this.buttonNextPage = new GuiButtonNextPage(1, var1 + 150, var2 + 80, 23, 13, true)); + this.buttonList.add(this.buttonPreviousPage = new GuiButtonNextPage(2, var1 - 180, var2 + 80, 23, 13, false)); + + this.updateButtons(); + } + + private void updateButtons() { + this.buttonBack.visible = (this.currPage == bookTotalPages - 1); + this.buttonBack.showButton = true; + this.buttonRead.visible = (this.currPage == 0); + this.buttonRead.showButton = false; + this.buttonNextPage.visible = (this.currPage > 0 && this.currPage < bookTotalPages - 1); + this.buttonNextPage.showButton = (this.currPage > 0 && this.currPage < bookTotalPages - 1); + this.buttonPreviousPage.visible = this.currPage > 0; + this.buttonPreviousPage.showButton = this.currPage > 0; + } + + /** + * Fired when a control is clicked. This is the equivalent of ActionListener.actionPerformed(ActionEvent e). + */ + @Override + protected void actionPerformed(GuiButton par1GuiButton) { + if (!par1GuiButton.enabled) { + return; + } + + if (par1GuiButton.id == 1) { + if (this.currPage < bookTotalPages - 1) { + ++this.currPage; + this.currRecipe += 2; + } + } else if (par1GuiButton.id == 2) { + if (this.currPage > 0) { + --this.currPage; + this.currRecipe -= 2; + } + } else if (par1GuiButton.id == 3) { + if (this.currPage == 0) { + ++this.currPage; + this.currRecipe += 2; + } + } else if (par1GuiButton.id == 4) { + if (this.currPage == bookTotalPages - 1) { + this.currPage = 0; + this.currRecipe = 0; + } + } + this.updateButtons(); + } + + /** + * Draws the screen and all the components in it. + */ + @Override + public void drawScreen(int par1, int par2, float par3) { + String pageIndic; + int var9; + int var5 = (this.width) / 2; + int bookImageHeight = 200; + int var6 = (this.height) / 2 - bookImageHeight / 2; + + if (this.currPage > 0) { + //GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + mc.renderEngine.bindTexture(new ResourceLocation(Info.resourceLocation, Info.bookPrefix + "bookright.png")); + this.drawTexturedModalRect(var5, var6, 0, 0, this.bookImageWidth, bookImageHeight + 20); + //GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + mc.renderEngine.bindTexture(new ResourceLocation(Info.resourceLocation, Info.bookPrefix + "bookleft.png")); + var5 -= this.bookImageWidth; + this.drawTexturedModalRect(var5, var6, 256 - this.bookImageWidth, 0, this.bookImageWidth, bookImageHeight); + } else { + mc.renderEngine.bindTexture(new ResourceLocation(Info.resourceLocation, Info.bookPrefix + "bookcover.png")); + this.drawTexturedModalRect(var5 - 55, var6 - 15, 0, 0, 256, 256); + } + + pageIndic = String.format(StatCollector.translateToLocal("book.pageIndicator"), new Object[]{this.currPage + 1, this.bookTotalPages}); + + var9 = this.fontRendererObj.getStringWidth(pageIndic); + if (this.currPage > 0) { + this.fontRendererObj.drawString(pageIndic, var5 - var9 + this.bookImageWidth - 44, var6 + 7, 0); + } + super.drawScreen(par1, par2, par3); + + if (this.currPage < rightPage.size()) { + this.fontRendererObj.drawSplitString(leftPage.get(this.currPage), var5 + 36, var6 + 16 + 16, 140, 0); + + this.fontRendererObj.drawSplitString(rightPage.get(this.currPage), var5 + 250, var6 + 16 + 16, 140, 0); + + GL11.glEnable(32826); + RenderHelper.enableGUIStandardItemLighting(); + if (this.leftPageItemStacks != null && this.leftPageItemStacks.get(this.currPage) != null && this.leftPageItemStacks.get(this.currPage).get(0) != null) { + for (int t = 0; t < this.leftPageItemStacks.get(this.currPage).size(); t++) { + if (this.leftPageItemStacks.get(this.currPage).get(t) != null) { + renderItem.renderItemIntoGUI(this.fontRendererObj, this.mc.renderEngine, ((StackToDraw) this.leftPageItemStacks.get(this.currPage).get(t)).getItemStack(), var5 + ((StackToDraw) this.leftPageItemStacks.get(this.currPage).get(t)).getX(), var6 + ((StackToDraw) this.leftPageItemStacks.get(this.currPage).get(t)).getY()); + } + } + } + + if (this.rightPageItemStacks != null && this.rightPageItemStacks.get(this.currPage) != null && this.rightPageItemStacks.get(this.currPage).get(0) != null) { + for (int t = 0; t < this.rightPageItemStacks.get(this.currPage).size(); t++) { + if (this.rightPageItemStacks.get(this.currPage).get(t) != null) { + renderItem.renderItemIntoGUI(this.fontRendererObj, this.mc.renderEngine, ((StackToDraw) this.rightPageItemStacks.get(this.currPage).get(t)).getItemStack(), var5 + ((StackToDraw) this.rightPageItemStacks.get(this.currPage).get(t)).getX() + 210, var6 + ((StackToDraw) this.rightPageItemStacks.get(this.currPage).get(t)).getY()); + } + } + } + GL11.glDisable(32826); + } + if (this.currPage > rightPage.size() - 1) { + //System.out.println((rightPage.size()*2) -1); + int page = this.currRecipe - (rightPage.size() * 2) + 1; + if (!(page > recipeListWB.size() - 1)) { + drawWorkBenchBackground(recipeListWB, var5, var6, 0, var9, "right"); + drawWorkBenchBackground(recipeListWB, var5, var6, 0, var9, "left"); + RenderHelper.enableGUIStandardItemLighting(); + drawWorkBenchRecipe(recipeListWB, var5, var6, page - 1, var9, "right"); + drawWorkBenchRecipe(recipeListWB, var5, var6, page, var9, "left"); + } else if ((page - recipeListWB.size()) >= 0 && (page - recipeListWB.size()) < recipeList.size() && recipeList.get(page - recipeListWB.size()) != null) { + drawAssemblyBackground(recipeList, var5 - 125, var6 - 33, page - recipeListWB.size(), var9, "right"); + drawAssemblyBackground(recipeList, var5 - 50, var6 - 33, page - recipeListWB.size() - 1, var9, "left"); + RenderHelper.enableGUIStandardItemLighting(); + drawAssemblyRecipe(recipeList, var5 - 125, var6 - 33, page - recipeListWB.size(), var9, "right"); + drawAssemblyRecipe(recipeList, var5 - 50, var6 - 33, page - recipeListWB.size() - 1, var9, "left"); + } + } + GL11.glDisable(GL11.GL_LIGHTING); + } + + private void drawAssemblyBackground(List recipeList, int var5, int var6, int page, int var9, String side) { + if (page < 0) return; + int tier = recipeList.get(page).getTier(); + if (tier == 1) mc.renderEngine.bindTexture(new ResourceLocation(Info.resourceLocation, Info.TEX_TIER_I)); + if (tier == 2) mc.renderEngine.bindTexture(new ResourceLocation(Info.resourceLocation, Info.TEX_TIER_II)); + if (tier == 3) mc.renderEngine.bindTexture(new ResourceLocation(Info.resourceLocation, Info.TEX_TIER_III)); + //if (side.equals("right")) + //GL11.glScaled(0.7, 0.7, 0.7); + if (side.equals("left")) this.drawTexturedModalRect(var5 + 70, var6 + 50, 0, 0, 177, 163); + if (side.equals("right")) this.drawTexturedModalRect(var5 + 340, var6 + 50, 0, 0, 177, 163); + } + + private void drawWorkBenchBackground(List recipeListWB, int var5, int var6, int page, int var9, String side) { + //int var4 = this.mc.renderEngine.getTexture("/gui/crafting.png"); + //GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + mc.renderEngine.bindTexture(new ResourceLocation(Info.resourceLocation, Info.guiPrefix + "crafting_table.png")); + if (side.equals("left")) this.drawTexturedModalRect(var5 + 20, var6 + 50, 0, 0, 177, 80); + if (side.equals("right")) this.drawTexturedModalRect(var5 + 215, var6 + 50, 0, 0, 177, 80); + } + + private void drawWorkBenchRecipe(List recipeList, int var5, int var6, int page, int var9, String side) { + if (recipeList.get(page) == null) return; + ItemStack[] itemList = new ItemStack[9]; + ItemStack itemOutput = null; + if (recipeList.get(page) instanceof ShapedTrainRecipes) { + itemList = ((ShapedTrainRecipes) recipeList.get(page)).recipeItems; + itemOutput = ((ShapedTrainRecipes) recipeList.get(page)).getRecipeOutput(); + } + + if (recipeList.get(page) instanceof ShapelessTrainRecipe) { + List itemListShapeless = ((ShapelessTrainRecipe) recipeList.get(page)).recipeItems; + for (int t = 0; t < itemListShapeless.size(); t++) { + if (itemListShapeless.get(t) != null) + itemList[t] = itemListShapeless.get(t); + } + itemOutput = ((ShapelessTrainRecipe) recipeList.get(page)).getRecipeOutput(); + } + + //System.out.println(itemOutput); + int offset = 0; + if (side.equals("right")) offset = 194; + GL11.glEnable(32826); + if (itemList[0] != null) { + renderItem.renderItemIntoGUI(this.fontRendererObj, this.mc.renderEngine, itemList[0], var5 + 50 + offset, var6 + 67); + } + + if (itemList[1] != null) { + renderItem.renderItemIntoGUI(this.fontRendererObj, this.mc.renderEngine, itemList[1], var5 + 68 + offset, var6 + 67); + } + + if (itemList[2] != null) { + renderItem.renderItemIntoGUI(this.fontRendererObj, this.mc.renderEngine, itemList[2], var5 + 86 + offset, var6 + 67); + } + + if (itemList[3] != null) { + renderItem.renderItemIntoGUI(this.fontRendererObj, this.mc.renderEngine, itemList[3], var5 + 50 + offset, var6 + 85); + } + + if (itemList[4] != null) { + renderItem.renderItemIntoGUI(this.fontRendererObj, this.mc.renderEngine, itemList[4], var5 + 68 + offset, var6 + 85); + } + + if (itemList[5] != null) { + renderItem.renderItemIntoGUI(this.fontRendererObj, this.mc.renderEngine, itemList[5], var5 + 86 + offset, var6 + 85); + } + + if (itemList[6] != null) { + renderItem.renderItemIntoGUI(this.fontRendererObj, this.mc.renderEngine, itemList[6], var5 + 50 + offset, var6 + 103); + } + if (itemList[7] != null) { + renderItem.renderItemIntoGUI(this.fontRendererObj, this.mc.renderEngine, itemList[7], var5 + 68 + offset, var6 + 103); + } + + if (itemList[8] != null) { + renderItem.renderItemIntoGUI(this.fontRendererObj, this.mc.renderEngine, itemList[8], var5 + 86 + offset, var6 + 103); + } + + if (itemOutput != null && itemOutput.getItem() != null) { + renderItem.renderItemIntoGUI(this.fontRendererObj, this.mc.renderEngine, itemOutput, var5 + 145 + offset, var6 + 85); + this.fontRendererObj.drawString(itemOutput.getItem().getItemStackDisplayName(itemOutput), var5 + 20 + offset, var6 + 40, 0); + } + + if (itemOutput != null) { + this.fontRendererObj.drawString("Crafted in: Train Workbench", var5 + 20 + offset, var6 + 130, 0); + + for (int z = 0; z < RecipeBookHandler.vanillaWorkTableRecipes.length; z++) { + if (itemOutput.getItem() != null && RecipeBookHandler.vanillaWorkTableRecipes[z] != null && RecipeBookHandler.vanillaWorkTableRecipes[z].equals(itemOutput.getItem().getItemStackDisplayName(itemOutput))) { + this.fontRendererObj.drawString("Also crafted in: Crafting Table", var5 + 20 + offset, var6 + 140, 0); + break; + } + } + } + + GL11.glDisable(32826); + } + + private void drawAssemblyRecipe(List recipeList, int var5, int var6, int page, int var9, String side) { + if (page < 0) { + return; + } + int tier = recipeList.get(page).getTier(); + + List itemList = recipeList.get(page).getInput(); + int offset = 0; + if (side.equals("right")) offset = 271; + GL11.glEnable(32826); + + if (itemList.get(0) != null) { + renderItem.renderItemIntoGUI(this.fontRendererObj, this.mc.renderEngine, itemList.get(0), var5 + 94 + offset, var6 + 76); + } + + if (itemList.get(0) != null) { + renderItem.renderItemOverlayIntoGUI(this.fontRendererObj, this.mc.renderEngine, itemList.get(0), var5 + 94 + offset, var6 + 76); + } + + if (itemList.get(1) != null) { + renderItem.renderItemIntoGUI(this.fontRendererObj, this.mc.renderEngine, itemList.get(1), var5 + 113 + offset, var6 + 143); + } + + if (itemList.get(1) != null) { + renderItem.renderItemOverlayIntoGUI(this.fontRendererObj, this.mc.renderEngine, itemList.get(1), var5 + 113 + offset, var6 + 143); + } + if (itemList.get(2) != null) { + renderItem.renderItemIntoGUI(this.fontRendererObj, this.mc.renderEngine, itemList.get(2), var5 + 148 + offset, var6 + 143); + } + + if (itemList.get(2) != null) { + renderItem.renderItemOverlayIntoGUI(this.fontRendererObj, this.mc.renderEngine, itemList.get(2), var5 + 148 + offset, var6 + 143); + } + + if (itemList.get(3) != null) { + renderItem.renderItemIntoGUI(this.fontRendererObj, this.mc.renderEngine, itemList.get(3), var5 + 214 + offset, var6 + 143); + } + + if (itemList.get(3) != null) { + renderItem.renderItemOverlayIntoGUI(this.fontRendererObj, this.mc.renderEngine, itemList.get(3), var5 + 214 + offset, var6 + 143); + } + + if (itemList.get(4) != null) { + renderItem.renderItemIntoGUI(this.fontRendererObj, this.mc.renderEngine, itemList.get(4), var5 + 148 + offset, var6 + 77); + } + + if (itemList.get(4) != null) { + renderItem.renderItemOverlayIntoGUI(this.fontRendererObj, this.mc.renderEngine, itemList.get(4), var5 + 148 + offset, var6 + 77); + } + + if (itemList.get(5) != null) { + renderItem.renderItemIntoGUI(this.fontRendererObj, this.mc.renderEngine, itemList.get(5), var5 + 184 + offset, var6 + 77); + } + + if (itemList.get(5) != null) { + renderItem.renderItemOverlayIntoGUI(this.fontRendererObj, this.mc.renderEngine, itemList.get(5), var5 + 184 + offset, var6 + 77); + } + + if (itemList.get(6) != null) { + renderItem.renderItemIntoGUI(this.fontRendererObj, this.mc.renderEngine, itemList.get(6), var5 + 149 + offset, var6 + 110); + } + + if (itemList.get(6) != null) { + renderItem.renderItemOverlayIntoGUI(this.fontRendererObj, this.mc.renderEngine, itemList.get(6), var5 + 149 + offset, var6 + 110); + } + + if (itemList.get(7) != null) { + renderItem.renderItemIntoGUI(this.fontRendererObj, this.mc.renderEngine, itemList.get(7), var5 + 185 + offset, var6 + 110); + } + + if (itemList.get(7) != null) { + renderItem.renderItemOverlayIntoGUI(this.fontRendererObj, this.mc.renderEngine, itemList.get(7), var5 + 185 + offset, var6 + 110); + } + + if (itemList.get(8) != null) { + renderItem.renderItemIntoGUI(this.fontRendererObj, this.mc.renderEngine, itemList.get(8), var5 + 94 + offset, var6 + 110); + } + + if (itemList.get(8) != null) { + renderItem.renderItemOverlayIntoGUI(this.fontRendererObj, this.mc.renderEngine, itemList.get(8), var5 + 94 + offset, var6 + 110); + } + + if (itemList.get(9) != null) { + renderItem.renderItemIntoGUI(this.fontRendererObj, this.mc.renderEngine, itemList.get(9), var5 + 214 + offset, var6 + 77); + } + + if (itemList.get(9) != null) { + renderItem.renderItemOverlayIntoGUI(this.fontRendererObj, this.mc.renderEngine, itemList.get(9), var5 + 214 + offset, var6 + 77); + } + + ItemStack output = recipeList.get(page).getOutput(); + if (output != null) { + if (side.equals("left")) { + renderItem.renderItemIntoGUI(this.fontRendererObj, this.mc.renderEngine, output, var5 + 162, var6 + 177); + } + + if (side.equals("right")) { + renderItem.renderItemIntoGUI(this.fontRendererObj, this.mc.renderEngine, output, var5 + 432, var6 + 177); + } + } + + String name = ""; + if (output != null && output.getItem() instanceof ItemRollingStock) { + name = output.getDisplayName(); + } + + if (side.equals("left")) { + this.fontRendererObj.drawString("Tier: " + tier, var5 - var9 + this.bookImageWidth - 56, var6 + 40, 0); + this.fontRendererObj.drawString(name, var5 - var9 + this.bookImageWidth - 55, var6 + 56, 0xffffff); + } + + if (side.equals("right")) { + this.fontRendererObj.drawString(name, var5 - var9 + this.bookImageWidth + 215, var6 + 56, 0xffffff); + this.fontRendererObj.drawString("Tier: " + tier, var5 - var9 + this.bookImageWidth + 338, var6 + 40, 0); + } + GL11.glDisable(32826); + } + + @Override + public void onGuiClosed() { + ItemRecipeBook.page = this.currPage; + ItemRecipeBook.recipe = this.currRecipe; + this.itemstackBook.getTagCompound().setInteger("currPage", this.currPage); + this.itemstackBook.getTagCompound().setInteger("currRecipe", this.currRecipe); + super.onGuiClosed(); + } + + @Override + public boolean doesGuiPauseGame() { + return false; + } + + @Override + protected void keyTyped(char par1, int par2) { + if (par2 == 1 || par2 == this.mc.gameSettings.keyBindInventory.getKeyCode()) { + this.mc.thePlayer.closeScreen(); + } + } } \ No newline at end of file diff --git a/src/main/java/train/client/gui/GuiRotativeDigger.java b/src/main/java/train/client/gui/GuiRotativeDigger.java index 5d03aadcb0..583c4c2ff0 100644 --- a/src/main/java/train/client/gui/GuiRotativeDigger.java +++ b/src/main/java/train/client/gui/GuiRotativeDigger.java @@ -11,43 +11,48 @@ public class GuiRotativeDigger extends GuiContainer { - private EntityRotativeDigger digger; - - public GuiRotativeDigger(InventoryPlayer inventoryplayer, Entity entityzepp) { - super(new InventoryRotativeDigger(inventoryplayer, (EntityRotativeDigger) entityzepp)); - digger = (EntityRotativeDigger) entityzepp; - } - - @Override - protected void drawGuiContainerForegroundLayer(int i, int j) { - fontRendererObj.drawString(digger.getInventoryName(), 60, 6, 0x404040); - fontRendererObj.drawString("Inventory", 8, (ySize - 96) + 2, 0x404040); - if (digger.numCargoSlots > 0) { - fontRendererObj.drawString("Cargo:", 36, 22, 0x404040); - } - } - - @Override - protected void drawGuiContainerBackgroundLayer(float f, int t, int g) { - String i = Info.guiPrefix + "gui_zeppelin.png"; - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - mc.renderEngine.bindTexture(new ResourceLocation(Info.resourceLocation,i)); - int j = (width - xSize) / 2; - int k = (height - ySize) / 2; - drawTexturedModalRect(j, k, 0, 0, xSize, ySize); - if (digger.isFuelled()) { - //System.out.println("Fueled."); - int l = digger.c(12); - drawTexturedModalRect(j + 8, (k + 36 + 12) - l, 176, 12 - l, 14, l + 2); - } - for (int i1 = digger.numCargoSlots; i1 < 5; i1++) { - drawTexturedModalRect(j + 79 + 18 * i1, k + 17, 190, 0, 18, 18); - } - for (int j1 = digger.numCargoSlots1; j1 < 5; j1++) { - drawTexturedModalRect(j + 79 + 18 * j1, k + 35, 190, 0, 18, 18); - } - for (int k1 = digger.numCargoSlots2; k1 < 5; k1++) { - drawTexturedModalRect(j + 79 + 18 * k1, k + 53, 190, 0, 18, 18); - } - } + private final EntityRotativeDigger digger; + + public GuiRotativeDigger(InventoryPlayer inventoryplayer, Entity entityzepp) { + super(new InventoryRotativeDigger(inventoryplayer, (EntityRotativeDigger) entityzepp)); + digger = (EntityRotativeDigger) entityzepp; + } + + @Override + protected void drawGuiContainerForegroundLayer(int i, int j) { + fontRendererObj.drawString(digger.getInventoryName(), 60, 6, 0x404040); + fontRendererObj.drawString("Inventory", 8, (ySize - 96) + 2, 0x404040); + if (digger.numCargoSlots > 0) { + fontRendererObj.drawString("Cargo:", 36, 22, 0x404040); + } + } + + @Override + protected void drawGuiContainerBackgroundLayer(float f, int t, int g) { + String i = Info.guiPrefix + "gui_zeppelin.png"; + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + mc.renderEngine.bindTexture(new ResourceLocation(Info.resourceLocation, i)); + int j = (width - xSize) / 2; + int k = (height - ySize) / 2; + + drawTexturedModalRect(j, k, 0, 0, xSize, ySize); + + if (digger.isFuelled()) { + //System.out.println("Fueled."); + int l = digger.c(12); + drawTexturedModalRect(j + 8, (k + 36 + 12) - l, 176, 12 - l, 14, l + 2); + } + + for (int i1 = digger.numCargoSlots; i1 < 5; i1++) { + drawTexturedModalRect(j + 79 + 18 * i1, k + 17, 190, 0, 18, 18); + } + + for (int j1 = digger.numCargoSlots1; j1 < 5; j1++) { + drawTexturedModalRect(j + 79 + 18 * j1, k + 35, 190, 0, 18, 18); + } + + for (int k1 = digger.numCargoSlots2; k1 < 5; k1++) { + drawTexturedModalRect(j + 79 + 18 * k1, k + 53, 190, 0, 18, 18); + } + } } diff --git a/src/main/java/train/client/gui/GuiSpeedTransmitter.java b/src/main/java/train/client/gui/GuiSpeedTransmitter.java index 8795019f32..333d6ed57d 100644 --- a/src/main/java/train/client/gui/GuiSpeedTransmitter.java +++ b/src/main/java/train/client/gui/GuiSpeedTransmitter.java @@ -25,10 +25,11 @@ public class GuiSpeedTransmitter extends GuiScreen { private GuiTCTextField nextSpeedZTextField; private GuiButton okayButton; + public GuiSpeedTransmitter(TileEntity entity) { if (entity instanceof TileInfoTransmitterSpeed) { - transmitterBlock = (TileInfoTransmitterSpeed)entity; + transmitterBlock = (TileInfoTransmitterSpeed) entity; Block transmitterBlocc = entity.getWorldObj().getBlock(transmitterBlock.xCoord, transmitterBlock.yCoord, transmitterBlock.zCoord); System.out.println(entity.getWorldObj().isBlockIndirectlyGettingPowered(transmitterBlock.xCoord, transmitterBlock.yCoord, transmitterBlock.zCoord)); } @@ -39,21 +40,21 @@ public void initGui() { //trainLevel = new GuiTCTextField(fontRendererObj, this.width/2 -5, this.height/2 - 1, 15,10); //okayButton = new GuiButton(0,this.width/2 -5, this.height/2 + 10, 25,25, "Okay" ); //trainLevel.setMaxStringLength(1); - // trainLevel.setText(theLocomotive.trainLevel); - //this.buttonList.add(okayButton); - speedLimitTextField = new GuiTCTextField(fontRendererObj, this.width/2 -30, 69, 27,10); + // trainLevel.setText(theLocomotive.trainLevel); + //this.buttonList.add(okayButton); + speedLimitTextField = new GuiTCTextField(fontRendererObj, this.width / 2 - 30, 69, 27, 10); speedLimitTextField.setMaxStringLength(3); - nextSpeedLimitTextField = new GuiTCTextField(fontRendererObj, this.width/2 -7, 89, 27,10); + nextSpeedLimitTextField = new GuiTCTextField(fontRendererObj, this.width / 2 - 7, 89, 27, 10); nextSpeedLimitTextField.setMaxStringLength(3); - nextSpeedXTextField = new GuiTCTextField(fontRendererObj, this.width/2 +10, 109, 35,10); + nextSpeedXTextField = new GuiTCTextField(fontRendererObj, this.width / 2 + 10, 109, 35, 10); - nextSpeedYTextField = new GuiTCTextField(fontRendererObj, this.width/2 +10, 129, 35,10); + nextSpeedYTextField = new GuiTCTextField(fontRendererObj, this.width / 2 + 10, 129, 35, 10); - nextSpeedZTextField = new GuiTCTextField(fontRendererObj, this.width/2 +10, 149, 35,10); + nextSpeedZTextField = new GuiTCTextField(fontRendererObj, this.width / 2 + 10, 149, 35, 10); - okayButton = new GuiButton(0,this.width/2 -5, this.height/2 + 45, 30,30, "Okay" ); + okayButton = new GuiButton(0, this.width / 2 - 5, this.height / 2 + 45, 30, 30, "Okay"); speedLimitTextField.setText(Integer.toString(transmitterBlock.setSpeed)); nextSpeedLimitTextField.setText(Integer.toString(transmitterBlock.nextSpeedLimit)); nextSpeedXTextField.setText(Double.toString(transmitterBlock.xFromSpeedChange)); @@ -64,74 +65,93 @@ public void initGui() { @Override public void drawScreen(int mouseX, int mouseY, float partialTicks) { - - - - drawDefaultBackground(); this.drawCenteredString(this.fontRendererObj, "Speed Transmitter Setup", this.width / 2, 40, 0xFFFFFFFF); glColor3f(1, 1, 1); - this.drawString( this.fontRendererObj,"Speed Limit: ", this.width/2 -90, 70, 0xFFFFFFFF); + this.drawString(this.fontRendererObj, "Speed Limit: ", this.width / 2 - 90, 70, 0xFFFFFFFF); speedLimitTextField.drawTextBox(); - this.drawString( this.fontRendererObj,"Speed Next Limit: ", this.width/2 -90, 90, 0xFFFFFFFF); + this.drawString(this.fontRendererObj, "Speed Next Limit: ", this.width / 2 - 90, 90, 0xFFFFFFFF); nextSpeedLimitTextField.drawTextBox(); - this.drawString( this.fontRendererObj,"Speed Next Limit X: ", this.width/2 -90, 110, 0xFFFFFFFF); + this.drawString(this.fontRendererObj, "Speed Next Limit X: ", this.width / 2 - 90, 110, 0xFFFFFFFF); nextSpeedXTextField.drawTextBox(); - this.drawString( this.fontRendererObj,"Speed Next Limit Y: ", this.width/2 -90, 130, 0xFFFFFFFF); + this.drawString(this.fontRendererObj, "Speed Next Limit Y: ", this.width / 2 - 90, 130, 0xFFFFFFFF); nextSpeedYTextField.drawTextBox(); - this.drawString( this.fontRendererObj,"Speed Next Limit Z: ", this.width/2 -90, 150, 0xFFFFFFFF); + this.drawString(this.fontRendererObj, "Speed Next Limit Z: ", this.width / 2 - 90, 150, 0xFFFFFFFF); nextSpeedZTextField.drawTextBox(); super.drawScreen(mouseX, mouseY, partialTicks); } - @Override + @Override @SideOnly(Side.CLIENT) protected void actionPerformed(GuiButton button) { if (button.id == 0) { - TileInfoTransmitterSpeed its = (TileInfoTransmitterSpeed)transmitterBlock.getWorldObj().getTileEntity(transmitterBlock.xCoord,transmitterBlock.yCoord,transmitterBlock.zCoord); - its.setSpeed =Integer.parseInt(speedLimitTextField.getText()); + TileInfoTransmitterSpeed its = (TileInfoTransmitterSpeed) transmitterBlock.getWorldObj().getTileEntity(transmitterBlock.xCoord, transmitterBlock.yCoord, transmitterBlock.zCoord); + its.setSpeed = Integer.parseInt(speedLimitTextField.getText()); Traincraft.itsChannel.sendToServer(new PacketSetSpeed(Integer.parseInt(speedLimitTextField.getText()), its.xCoord, its.yCoord, its.zCoord, 0)); - its.nextUpdateSpeed(Integer.parseInt(nextSpeedLimitTextField.getText()), Double.parseDouble(nextSpeedXTextField.getText()), Double.parseDouble(nextSpeedYTextField.getText()), Double.parseDouble(nextSpeedZTextField.getText())); - Traincraft.itnsChannel.sendToAll(new PacketNextSpeed( Integer.parseInt(nextSpeedLimitTextField.getText()), its.xCoord, its.yCoord, its.zCoord, Double.parseDouble(nextSpeedXTextField.getText()), Double.parseDouble(nextSpeedYTextField.getText()), Double.parseDouble(nextSpeedZTextField.getText()), 0)); + its.nextUpdateSpeed(Integer.parseInt(nextSpeedLimitTextField.getText()), Double.parseDouble(nextSpeedXTextField.getText()), Double.parseDouble(nextSpeedYTextField.getText()), Double.parseDouble(nextSpeedZTextField.getText())); + Traincraft.itnsChannel.sendToAll(new PacketNextSpeed(Integer.parseInt(nextSpeedLimitTextField.getText()), its.xCoord, its.yCoord, its.zCoord, Double.parseDouble(nextSpeedXTextField.getText()), Double.parseDouble(nextSpeedYTextField.getText()), Double.parseDouble(nextSpeedZTextField.getText()), 0)); } mc.thePlayer.closeScreen(); } + @Override public void updateScreen() { super.updateScreen(); - if (speedLimitTextField.isFocused()) {speedLimitTextField.updateCursorCounter();} - if (nextSpeedLimitTextField.isFocused()) {nextSpeedLimitTextField.updateCursorCounter();} - if (nextSpeedXTextField.isFocused()) {nextSpeedXTextField.updateCursorCounter();} - if (nextSpeedYTextField.isFocused()) {nextSpeedYTextField.updateCursorCounter();} - if (nextSpeedZTextField.isFocused()) {nextSpeedZTextField.updateCursorCounter();} + if (speedLimitTextField.isFocused()) { + speedLimitTextField.updateCursorCounter(); + } + if (nextSpeedLimitTextField.isFocused()) { + nextSpeedLimitTextField.updateCursorCounter(); + } + + if (nextSpeedXTextField.isFocused()) { + nextSpeedXTextField.updateCursorCounter(); + } + + if (nextSpeedYTextField.isFocused()) { + nextSpeedYTextField.updateCursorCounter(); + } + + if (nextSpeedZTextField.isFocused()) { + nextSpeedZTextField.updateCursorCounter(); + } } + @Override protected void keyTyped(char par1, int par2) { + if (Character.isDigit(par1) || par1 == KeyEvent.VK_BACK_SPACE || par1 == KeyEvent.VK_PERIOD) { + if (speedLimitTextField.isFocused()) { + speedLimitTextField.textboxKeyTyped(par1, par2); + } + + if (nextSpeedLimitTextField.isFocused()) { + nextSpeedLimitTextField.textboxKeyTyped(par1, par2); + } + + if (nextSpeedXTextField.isFocused()) { + nextSpeedXTextField.textboxKeyTyped(par1, par2); + } + + if (nextSpeedYTextField.isFocused()) { + nextSpeedYTextField.textboxKeyTyped(par1, par2); + } - if (Character.isDigit(par1) || par1 == KeyEvent.VK_BACK_SPACE || par1 == KeyEvent.VK_PERIOD) { - if (speedLimitTextField.isFocused()) { speedLimitTextField.textboxKeyTyped(par1, par2); } - if (nextSpeedLimitTextField.isFocused()) { nextSpeedLimitTextField.textboxKeyTyped(par1, par2); } - if (nextSpeedXTextField.isFocused()) { nextSpeedXTextField.textboxKeyTyped(par1, par2); } - if (nextSpeedYTextField.isFocused()) { nextSpeedYTextField.textboxKeyTyped(par1, par2); } - if (nextSpeedZTextField.isFocused()) { nextSpeedZTextField.textboxKeyTyped(par1, par2); } + if (nextSpeedZTextField.isFocused()) { + nextSpeedZTextField.textboxKeyTyped(par1, par2); + } } if (par2 == 1 || par2 == mc.gameSettings.keyBindBack.getKeyCode()) { - if (! speedLimitTextField.isFocused()) { + if (!speedLimitTextField.isFocused()) { mc.thePlayer.closeScreen(); } - } - } - - - @Override protected void mouseClicked(int par1, int par2, int par3) { speedLimitTextField.mouseClicked(par1, par2, par3); @@ -141,19 +161,19 @@ protected void mouseClicked(int par1, int par2, int par3) { nextSpeedZTextField.mouseClicked(par1, par2, par3); super.mouseClicked(par1, par2, par3); } + @Override public boolean doesGuiPauseGame() { return false; } + public static boolean isInteger(String s) { try { Integer.parseInt(s); - } catch(NumberFormatException e) { - return false; - } catch(NullPointerException e) { + } catch (NumberFormatException | NullPointerException e) { return false; } - // only got here if we didn't return false + // We can only get here if we do not return false. return true; } diff --git a/src/main/java/train/client/gui/GuiTCTextField.java b/src/main/java/train/client/gui/GuiTCTextField.java index 9f12f1d221..fa9621f827 100644 --- a/src/main/java/train/client/gui/GuiTCTextField.java +++ b/src/main/java/train/client/gui/GuiTCTextField.java @@ -1,6 +1,6 @@ /******************************************************************************* * Copyright (c) 2013 Mrbrutal. All rights reserved. - * + * * @name Traincraft * @author Mrbrutal ******************************************************************************/ @@ -18,631 +18,633 @@ @SideOnly(Side.CLIENT) public class GuiTCTextField extends Gui { - /** - * Have the font renderer from GuiScreen to render the textbox text into the screen. - */ - private final FontRenderer fontRenderer; - private final int xPos; - private final int yPos; - - /** The width of this text field. */ - private final int width; - private final int height; - - /** Have the current text beign edited on the textbox. */ - private String text = ""; - private int maxStringLength = 32; - private int cursorCounter; - private boolean enableBackgroundDrawing = true; - - /** - * if true the textbox can lose focus by clicking elsewhere on the screen - */ - private boolean canLoseFocus = true; - - /** - * If this value is true along isEnabled, keyTyped will process the keys. - */ - private boolean isFocused; - - /** - * If this value is true along isFocused, keyTyped will process the keys. - */ - private boolean isEnabled = true; - - /** - * The current character index that should be used as start of the rendered text. - */ - private int lineScrollOffset; - private int cursorPosition; - - /** other selection position, maybe the same as the cursor */ - private int selectionEnd; - private int enabledColor = 14737632; - private int disabledColor = 7368816; - - /** True if this textbox is visible */ - private boolean visible = true; - - public GuiTCTextField(FontRenderer par1FontRenderer, int par2, int par3, int par4, int par5) { - this.fontRenderer = par1FontRenderer; - this.xPos = par2; - this.yPos = par3; - this.width = par4; - this.height = par5; - } - - /** - * Increments the cursor counter - */ - public void updateCursorCounter() { - ++this.cursorCounter; - } - - /** - * Sets the text of the textbox. - */ - public void setText(String par1Str) { - if (par1Str.length() > this.maxStringLength) { - this.text = par1Str.substring(0, this.maxStringLength); - } - else { - this.text = par1Str; - } - - this.setCursorPositionEnd(); - } - - /** - * Returns the text beign edited on the textbox. - */ - public String getText() { - return this.text; - } - - /** - * @return returns the text between the cursor and selectionEnd - */ - public String getSelectedtext() { - int i = this.cursorPosition < this.selectionEnd ? this.cursorPosition : this.selectionEnd; - int j = this.cursorPosition < this.selectionEnd ? this.selectionEnd : this.cursorPosition; - return this.text.substring(i, j); - } - - /** - * replaces selected text, or inserts text at the position on the cursor - */ - public void writeText(String par1Str) { - String s1 = ""; - String s2 = ChatAllowedCharacters.filerAllowedCharacters(par1Str); - int i = this.cursorPosition < this.selectionEnd ? this.cursorPosition : this.selectionEnd; - int j = this.cursorPosition < this.selectionEnd ? this.selectionEnd : this.cursorPosition; - int k = this.maxStringLength - this.text.length() - (i - this.selectionEnd); - - if (this.text.length() > 0) { - s1 = s1 + this.text.substring(0, i); - } - - int l; - - if (k < s2.length()) { - s1 = s1 + s2.substring(0, k); - l = k; - } - else { - s1 = s1 + s2; - l = s2.length(); - } - - if (this.text.length() > 0 && j < this.text.length()) { - s1 = s1 + this.text.substring(j); - } - - this.text = s1; - this.moveCursorBy(i - this.selectionEnd + l); - } - - /** - * Deletes the specified number of words starting at the cursor position. Negative numbers will delete words left of the cursor. - */ - public void deleteWords(int par1) { - if (this.text.length() != 0) { - if (this.selectionEnd != this.cursorPosition) { - this.writeText(""); - } - else { - this.deleteFromCursor(this.getNthWordFromCursor(par1) - this.cursorPosition); - } - } - } - - /** - * delete the selected text, otherwsie deletes characters from either side of the cursor. params: delete num - */ - public void deleteFromCursor(int par1) { - if (this.text.length() != 0) { - if (this.selectionEnd != this.cursorPosition) { - this.writeText(""); - } - else { - boolean flag = par1 < 0; - int j = flag ? this.cursorPosition + par1 : this.cursorPosition; - int k = flag ? this.cursorPosition : this.cursorPosition + par1; - String s = ""; - - if (j >= 0) { - s = this.text.substring(0, j); - } - - if (k < this.text.length()) { - s = s + this.text.substring(k); - } - - this.text = s; - - if (flag) { - this.moveCursorBy(par1); - } - } - } - } - - /** - * see @getNthNextWordFromPos() params: N, position - */ - public int getNthWordFromCursor(int par1) { - return this.getNthWordFromPos(par1, this.getCursorPosition()); - } - - /** - * gets the position of the nth word. N may be negative, then it looks backwards. params: N, position - */ - public int getNthWordFromPos(int par1, int par2) { - return this.func_73798_a(par1, this.getCursorPosition(), true); - } - - public int func_73798_a(int par1, int par2, boolean par3) { - int k = par2; - boolean flag1 = par1 < 0; - int l = Math.abs(par1); - - for (int i1 = 0; i1 < l; ++i1) { - if (flag1) { - while (par3 && k > 0 && this.text.charAt(k - 1) == 32) { - --k; - } - - while (k > 0 && this.text.charAt(k - 1) != 32) { - --k; - } - } - else { - int j1 = this.text.length(); - k = this.text.indexOf(32, k); - - if (k == -1) { - k = j1; - } - else { - while (par3 && k < j1 && this.text.charAt(k) == 32) { - ++k; - } - } - } - } - - return k; - } - - /** - * Moves the text cursor by a specified number of characters and clears the selection - */ - public void moveCursorBy(int par1) { - this.setCursorPosition(this.selectionEnd + par1); - } - - /** - * sets the position of the cursor to the provided index - */ - public void setCursorPosition(int par1) { - this.cursorPosition = par1; - int j = this.text.length(); - - if (this.cursorPosition < 0) { - this.cursorPosition = 0; - } - - if (this.cursorPosition > j) { - this.cursorPosition = j; - } - - this.setSelectionPos(this.cursorPosition); - } - - /** - * sets the cursors position to the beginning - */ - public void setCursorPositionZero() { - this.setCursorPosition(0); - } - - /** - * sets the cursors position to after the text - */ - public void setCursorPositionEnd() { - this.setCursorPosition(this.text.length()); - } - - /** - * Call this method from you GuiScreen to process the keys into textbox. - */ - public boolean textboxKeyTyped(char par1, int par2) { - if (this.isEnabled && this.isFocused) { - switch (par1) { - case 1: - this.setCursorPositionEnd(); - this.setSelectionPos(0); - return true; - case 3: - GuiScreen.setClipboardString(this.getSelectedtext()); - return true; - case 22: - this.writeText(GuiScreen.getClipboardString()); - return true; - case 24: - GuiScreen.setClipboardString(this.getSelectedtext()); - this.writeText(""); - return true; - default: - switch (par2) { - case 14: - if (GuiScreen.isCtrlKeyDown()) { - this.deleteWords(-1); - } - else { - this.deleteFromCursor(-1); - } - - return true; - case 199: - if (GuiScreen.isShiftKeyDown()) { - this.setSelectionPos(0); - } - else { - this.setCursorPositionZero(); - } - - return true; - case 203: - if (GuiScreen.isShiftKeyDown()) { - if (GuiScreen.isCtrlKeyDown()) { - this.setSelectionPos(this.getNthWordFromPos(-1, this.getSelectionEnd())); - } - else { - this.setSelectionPos(this.getSelectionEnd() - 1); - } - } - else if (GuiScreen.isCtrlKeyDown()) { - this.setCursorPosition(this.getNthWordFromCursor(-1)); - } - else { - this.moveCursorBy(-1); - } - - return true; - case 205: - if (GuiScreen.isShiftKeyDown()) { - if (GuiScreen.isCtrlKeyDown()) { - this.setSelectionPos(this.getNthWordFromPos(1, this.getSelectionEnd())); - } - else { - this.setSelectionPos(this.getSelectionEnd() + 1); - } - } - else if (GuiScreen.isCtrlKeyDown()) { - this.setCursorPosition(this.getNthWordFromCursor(1)); - } - else { - this.moveCursorBy(1); - } - - return true; - case 207: - if (GuiScreen.isShiftKeyDown()) { - this.setSelectionPos(this.text.length()); - } - else { - this.setCursorPositionEnd(); - } - - return true; - case 211: - if (GuiScreen.isCtrlKeyDown()) { - this.deleteWords(1); - } - else { - this.deleteFromCursor(1); - } - - return true; - default: - if (ChatAllowedCharacters.isAllowedCharacter(par1)) { - this.writeText(Character.toString(par1)); - return true; - } - else { - return false; - } - } - } - } - else { - return false; - } - } - - /** - * Args: x, y, buttonClicked - */ - public void mouseClicked(int par1, int par2, int par3) { - boolean flag = par1 >= this.xPos && par1 < this.xPos + this.width && par2 >= this.yPos && par2 < this.yPos + this.height; - - if (this.canLoseFocus) { - this.setFocused(this.isEnabled && flag); - } - - if (this.isFocused && par3 == 0) { - int l = par1 - this.xPos; - - if (this.enableBackgroundDrawing) { - l -= 4; - } - - String s = this.fontRenderer.trimStringToWidth(this.text.substring(this.lineScrollOffset), this.getWidth()); - this.setCursorPosition(this.fontRenderer.trimStringToWidth(s, l).length() + this.lineScrollOffset); - } - } - - /** - * Draws the textbox - */ - public void drawTextBox() { - if (this.getVisible()) { - if (this.getEnableBackgroundDrawing()) { - //drawRect(this.xPos - 1, this.yPos - 1, this.xPos + this.width + 1, this.yPos + this.height + 1, -6250336); - drawRect(this.xPos, this.yPos, this.xPos + this.width, this.yPos + this.height, 0xff727272); - } - - int i = this.isEnabled ? this.enabledColor : this.disabledColor; - int j = this.cursorPosition - this.lineScrollOffset; - int k = this.selectionEnd - this.lineScrollOffset; - String s = this.fontRenderer.trimStringToWidth(this.text.substring(this.lineScrollOffset), this.getWidth()); - boolean flag = j >= 0 && j <= s.length(); - boolean flag1 = this.isFocused && this.cursorCounter / 6 % 2 == 0 && flag; - int l = this.enableBackgroundDrawing ? this.xPos + 4 : this.xPos; - int i1 = this.enableBackgroundDrawing ? this.yPos + (this.height - 8) / 2 : this.yPos; - int j1 = l; - - if (k > s.length()) { - k = s.length(); - } - - if (s.length() > 0) { - String s1 = flag ? s.substring(0, j) : s; - j1 = this.fontRenderer.drawStringWithShadow(s1, l, i1, i); - } - - boolean flag2 = this.cursorPosition < this.text.length() || this.text.length() >= this.getMaxStringLength(); - int k1 = j1; - - if (!flag) { - k1 = j > 0 ? l + this.width : l; - } - else if (flag2) { - k1 = j1 - 1; - --j1; - } - - if (s.length() > 0 && flag && j < s.length()) { - this.fontRenderer.drawStringWithShadow(s.substring(j), j1, i1, i); - } - - if (flag1) { - if (flag2) { - Gui.drawRect(k1, i1 - 1, k1 + 1, i1 + 1 + this.fontRenderer.FONT_HEIGHT, -3092272); - } - else { - this.fontRenderer.drawStringWithShadow("_", k1, i1, i); - } - } - - if (k != j) { - int l1 = l + this.fontRenderer.getStringWidth(s.substring(0, k)); - this.drawCursorVertical(k1, i1 - 1, l1 - 1, i1 + 1 + this.fontRenderer.FONT_HEIGHT); - } - } - } - - /** - * draws the vertical line cursor in the textbox - */ - private void drawCursorVertical(int par1, int par2, int par3, int par4) { - int i1; - - if (par1 < par3) { - i1 = par1; - par1 = par3; - par3 = i1; - } - - if (par2 < par4) { - i1 = par2; - par2 = par4; - par4 = i1; - } - - Tessellator tessellator = Tessellator.instance; - GL11.glColor4f(0.0F, 0.0F, 255.0F, 255.0F); - GL11.glDisable(GL11.GL_TEXTURE_2D); - GL11.glEnable(GL11.GL_COLOR_LOGIC_OP); - GL11.glLogicOp(GL11.GL_OR_REVERSE); - tessellator.startDrawingQuads(); - tessellator.addVertex((double) par1, (double) par4, 0.0D); - tessellator.addVertex((double) par3, (double) par4, 0.0D); - tessellator.addVertex((double) par3, (double) par2, 0.0D); - tessellator.addVertex((double) par1, (double) par2, 0.0D); - tessellator.draw(); - GL11.glDisable(GL11.GL_COLOR_LOGIC_OP); - GL11.glEnable(GL11.GL_TEXTURE_2D); - } - - public void setMaxStringLength(int par1) { - this.maxStringLength = par1; - - if (this.text.length() > par1) { - this.text = this.text.substring(0, par1); - } - } - - /** - * returns the maximum number of character that can be contained in this textbox - */ - public int getMaxStringLength() { - return this.maxStringLength; - } - - /** - * returns the current position of the cursor - */ - public int getCursorPosition() { - return this.cursorPosition; - } - - /** - * get enable drawing background and outline - */ - public boolean getEnableBackgroundDrawing() { - return this.enableBackgroundDrawing; - } - - /** - * enable drawing background and outline - */ - public void setEnableBackgroundDrawing(boolean par1) { - this.enableBackgroundDrawing = par1; - } - - /** - * Sets the text colour for this textbox (disabled text will not use this colour) - */ - public void setTextColor(int par1) { - this.enabledColor = par1; - } - - public void setDisabledTextColour(int par1) { - this.disabledColor = par1; - } - - /** - * setter for the focused field - */ - public void setFocused(boolean par1) { - if (par1 && !this.isFocused) { - this.cursorCounter = 0; - } - - this.isFocused = par1; - } - - /** - * getter for the focused field - */ - public boolean isFocused() { - return this.isFocused; - } - - public void setEnabled(boolean par1) { - this.isEnabled = par1; - } - - /** - * the side of the selection that is not the cursor, maye be the same as the cursor - */ - public int getSelectionEnd() { - return this.selectionEnd; - } - - /** - * returns the width of the textbox depending on if the the box is enabled - */ - public int getWidth() { - return this.getEnableBackgroundDrawing() ? this.width - 8 : this.width; - } - - /** - * Sets the position of the selection anchor (i.e. position the selection was started at) - */ - public void setSelectionPos(int par1) { - int j = this.text.length(); - - if (par1 > j) { - par1 = j; - } - - if (par1 < 0) { - par1 = 0; - } - - this.selectionEnd = par1; - - if (this.fontRenderer != null) { - if (this.lineScrollOffset > j) { - this.lineScrollOffset = j; - } - - int k = this.getWidth(); - String s = this.fontRenderer.trimStringToWidth(this.text.substring(this.lineScrollOffset), k); - int l = s.length() + this.lineScrollOffset; - - if (par1 == this.lineScrollOffset) { - this.lineScrollOffset -= this.fontRenderer.trimStringToWidth(this.text, k, true).length(); - } - - if (par1 > l) { - this.lineScrollOffset += par1 - l; - } - else if (par1 <= this.lineScrollOffset) { - this.lineScrollOffset -= this.lineScrollOffset - par1; - } - - if (this.lineScrollOffset < 0) { - this.lineScrollOffset = 0; - } - - if (this.lineScrollOffset > j) { - this.lineScrollOffset = j; - } - } - } - - /** - * if true the textbox can lose focus by clicking elsewhere on the screen - */ - public void setCanLoseFocus(boolean par1) { - this.canLoseFocus = par1; - } - - /** - * @return {@code true} if this textbox is visible - */ - public boolean getVisible() { - return this.visible; - } - - /** - * Sets whether or not this textbox is visible - */ - public void setVisible(boolean par1) { - this.visible = par1; - } + /** + * Have the font renderer from GuiScreen to render the textbox text into the screen. + */ + private final FontRenderer fontRenderer; + private final int xPos; + private final int yPos; + + /** + * The width of this text field. + */ + private final int width; + private final int height; + + /** + * Have the current text beign edited on the textbox. + */ + private String text = ""; + private int maxStringLength = 32; + private int cursorCounter; + private boolean enableBackgroundDrawing = true; + + /** + * if true the textbox can lose focus by clicking elsewhere on the screen + */ + private boolean canLoseFocus = true; + + /** + * If this value is true along isEnabled, keyTyped will process the keys. + */ + private boolean isFocused; + + /** + * If this value is true along isFocused, keyTyped will process the keys. + */ + private boolean isEnabled = true; + + /** + * The current character index that should be used as start of the rendered text. + */ + private int lineScrollOffset; + private int cursorPosition; + + /** + * other selection position, maybe the same as the cursor + */ + private int selectionEnd; + private int enabledColor = 14737632; + private int disabledColor = 7368816; + + /** + * True if this textbox is visible + */ + private boolean visible = true; + + public GuiTCTextField(FontRenderer par1FontRenderer, int par2, int par3, int par4, int par5) { + this.fontRenderer = par1FontRenderer; + this.xPos = par2; + this.yPos = par3; + this.width = par4; + this.height = par5; + } + + /** + * Increments the cursor counter + */ + public void updateCursorCounter() { + ++this.cursorCounter; + } + + /** + * Sets the text of the textbox. + */ + public void setText(String par1Str) { + if (par1Str.length() > this.maxStringLength) { + this.text = par1Str.substring(0, this.maxStringLength); + } else { + this.text = par1Str; + } + + this.setCursorPositionEnd(); + } + + /** + * Returns the text beign edited on the textbox. + */ + public String getText() { + return this.text; + } + + /** + * @return returns the text between the cursor and selectionEnd + */ + public String getSelectedtext() { + int i = Math.min(this.cursorPosition, this.selectionEnd); + int j = Math.max(this.cursorPosition, this.selectionEnd); + return this.text.substring(i, j); + } + + /** + * replaces selected text, or inserts text at the position on the cursor + */ + public void writeText(String par1Str) { + String s1 = ""; + String s2 = ChatAllowedCharacters.filerAllowedCharacters(par1Str); + int i = Math.min(this.cursorPosition, this.selectionEnd); + int j = Math.max(this.cursorPosition, this.selectionEnd); + int k = this.maxStringLength - this.text.length() - (i - this.selectionEnd); + + if (!this.text.isEmpty()) { + s1 = s1 + this.text.substring(0, i); + } + + int l; + + if (k < s2.length()) { + s1 = s1 + s2.substring(0, k); + l = k; + } else { + s1 = s1 + s2; + l = s2.length(); + } + + if (!this.text.isEmpty() && j < this.text.length()) { + s1 = s1 + this.text.substring(j); + } + + this.text = s1; + this.moveCursorBy(i - this.selectionEnd + l); + } + + /** + * Deletes the specified number of words starting at the cursor position. Negative numbers will delete words left of the cursor. + */ + public void deleteWords(int par1) { + if (!this.text.isEmpty()) { + if (this.selectionEnd != this.cursorPosition) { + this.writeText(""); + } else { + this.deleteFromCursor(this.getNthWordFromCursor(par1) - this.cursorPosition); + } + } + } + + /** + * delete the selected text, otherwsie deletes characters from either side of the cursor. params: delete num + */ + public void deleteFromCursor(int par1) { + if (!this.text.isEmpty()) { + if (this.selectionEnd != this.cursorPosition) { + this.writeText(""); + } else { + boolean flag = par1 < 0; + int j = flag ? this.cursorPosition + par1 : this.cursorPosition; + int k = flag ? this.cursorPosition : this.cursorPosition + par1; + String s = ""; + + if (j >= 0) { + s = this.text.substring(0, j); + } + + if (k < this.text.length()) { + s = s + this.text.substring(k); + } + + this.text = s; + + if (flag) { + this.moveCursorBy(par1); + } + } + } + } + + /** + * see @getNthNextWordFromPos() params: N, position + */ + public int getNthWordFromCursor(int par1) { + return this.getNthWordFromPos(par1, this.getCursorPosition()); + } + + /** + * gets the position of the nth word. N may be negative, then it looks backwards. params: N, position + */ + public int getNthWordFromPos(int par1, int par2) { + return this.func_73798_a(par1, this.getCursorPosition(), true); + } + + public int func_73798_a(int par1, int par2, boolean par3) { + int k = par2; + boolean flag1 = par1 < 0; + int l = Math.abs(par1); + + for (int i1 = 0; i1 < l; ++i1) { + if (flag1) { + while (par3 && k > 0 && this.text.charAt(k - 1) == 32) { + --k; + } + + while (k > 0 && this.text.charAt(k - 1) != 32) { + --k; + } + } else { + int j1 = this.text.length(); + k = this.text.indexOf(32, k); + + if (k == -1) { + k = j1; + } else { + while (par3 && k < j1 && this.text.charAt(k) == 32) { + ++k; + } + } + } + } + + return k; + } + + /** + * Moves the text cursor by a specified number of characters and clears the selection + */ + public void moveCursorBy(int par1) { + this.setCursorPosition(this.selectionEnd + par1); + } + + /** + * sets the position of the cursor to the provided index + */ + public void setCursorPosition(int par1) { + this.cursorPosition = par1; + int j = this.text.length(); + + if (this.cursorPosition < 0) { + this.cursorPosition = 0; + } + + if (this.cursorPosition > j) { + this.cursorPosition = j; + } + + this.setSelectionPos(this.cursorPosition); + } + + /** + * sets the cursors position to the beginning + */ + public void setCursorPositionZero() { + this.setCursorPosition(0); + } + + /** + * sets the cursors position to after the text + */ + public void setCursorPositionEnd() { + this.setCursorPosition(this.text.length()); + } + + /** + * Call this method from you GuiScreen to process the keys into textbox. + */ + public boolean textboxKeyTyped(char par1, int par2) { + if (this.isEnabled && this.isFocused) { + switch (par1) { + case 1: + this.setCursorPositionEnd(); + this.setSelectionPos(0); + return true; + case 3: + GuiScreen.setClipboardString(this.getSelectedtext()); + return true; + case 22: + this.writeText(GuiScreen.getClipboardString()); + return true; + case 24: + GuiScreen.setClipboardString(this.getSelectedtext()); + this.writeText(""); + return true; + default: + switch (par2) { + case 14: + if (GuiScreen.isCtrlKeyDown()) { + this.deleteWords(-1); + } else { + this.deleteFromCursor(-1); + } + + return true; + case 199: + if (GuiScreen.isShiftKeyDown()) { + this.setSelectionPos(0); + } else { + this.setCursorPositionZero(); + } + + return true; + case 203: + if (GuiScreen.isShiftKeyDown()) { + if (GuiScreen.isCtrlKeyDown()) { + this.setSelectionPos(this.getNthWordFromPos(-1, this.getSelectionEnd())); + } else { + this.setSelectionPos(this.getSelectionEnd() - 1); + } + } else if (GuiScreen.isCtrlKeyDown()) { + this.setCursorPosition(this.getNthWordFromCursor(-1)); + } else { + this.moveCursorBy(-1); + } + + return true; + case 205: + if (GuiScreen.isShiftKeyDown()) { + if (GuiScreen.isCtrlKeyDown()) { + this.setSelectionPos(this.getNthWordFromPos(1, this.getSelectionEnd())); + } else { + this.setSelectionPos(this.getSelectionEnd() + 1); + } + } else if (GuiScreen.isCtrlKeyDown()) { + this.setCursorPosition(this.getNthWordFromCursor(1)); + } else { + this.moveCursorBy(1); + } + + return true; + case 207: + if (GuiScreen.isShiftKeyDown()) { + this.setSelectionPos(this.text.length()); + } else { + this.setCursorPositionEnd(); + } + + return true; + case 211: + if (GuiScreen.isCtrlKeyDown()) { + this.deleteWords(1); + } else { + this.deleteFromCursor(1); + } + + return true; + default: + if (ChatAllowedCharacters.isAllowedCharacter(par1)) { + this.writeText(Character.toString(par1)); + return true; + } else { + return false; + } + } + } + } else { + return false; + } + } + + /** + * Args: x, y, buttonClicked + */ + public void mouseClicked(int par1, int par2, int par3) { + boolean flag = par1 >= this.xPos && par1 < this.xPos + this.width && par2 >= this.yPos && par2 < this.yPos + this.height; + + if (this.canLoseFocus) { + this.setFocused(this.isEnabled && flag); + } + + if (this.isFocused && par3 == 0) { + int l = par1 - this.xPos; + + if (this.enableBackgroundDrawing) { + l -= 4; + } + + String s = this.fontRenderer.trimStringToWidth(this.text.substring(this.lineScrollOffset), this.getWidth()); + this.setCursorPosition(this.fontRenderer.trimStringToWidth(s, l).length() + this.lineScrollOffset); + } + } + + /** + * Draws the textbox + */ + public void drawTextBox() { + if (this.getVisible()) { + if (this.getEnableBackgroundDrawing()) { + //drawRect(this.xPos - 1, this.yPos - 1, this.xPos + this.width + 1, this.yPos + this.height + 1, -6250336); + drawRect(this.xPos, this.yPos, this.xPos + this.width, this.yPos + this.height, 0xff727272); + } + + int i = this.isEnabled ? this.enabledColor : this.disabledColor; + int j = this.cursorPosition - this.lineScrollOffset; + int k = this.selectionEnd - this.lineScrollOffset; + String s = this.fontRenderer.trimStringToWidth(this.text.substring(this.lineScrollOffset), this.getWidth()); + boolean flag = j >= 0 && j <= s.length(); + boolean flag1 = this.isFocused && this.cursorCounter / 6 % 2 == 0 && flag; + int l = this.enableBackgroundDrawing ? this.xPos + 4 : this.xPos; + int i1 = this.enableBackgroundDrawing ? this.yPos + (this.height - 8) / 2 : this.yPos; + int j1 = l; + + if (k > s.length()) { + k = s.length(); + } + + if (!s.isEmpty()) { + String s1 = flag ? s.substring(0, j) : s; + j1 = this.fontRenderer.drawStringWithShadow(s1, l, i1, i); + } + + boolean flag2 = this.cursorPosition < this.text.length() || this.text.length() >= this.getMaxStringLength(); + int k1 = j1; + + if (!flag) { + k1 = j > 0 ? l + this.width : l; + } else if (flag2) { + k1 = j1 - 1; + --j1; + } + + if (!s.isEmpty() && flag && j < s.length()) { + this.fontRenderer.drawStringWithShadow(s.substring(j), j1, i1, i); + } + + if (flag1) { + if (flag2) { + Gui.drawRect(k1, i1 - 1, k1 + 1, i1 + 1 + this.fontRenderer.FONT_HEIGHT, -3092272); + } else { + this.fontRenderer.drawStringWithShadow("_", k1, i1, i); + } + } + + if (k != j) { + int l1 = l + this.fontRenderer.getStringWidth(s.substring(0, k)); + this.drawCursorVertical(k1, i1 - 1, l1 - 1, i1 + 1 + this.fontRenderer.FONT_HEIGHT); + } + } + } + + /** + * Draws the vertical line cursor in the textbox. + */ + private void drawCursorVertical(int par1, int par2, int par3, int par4) { + int i1; + + if (par1 < par3) { + i1 = par1; + par1 = par3; + par3 = i1; + } + + if (par2 < par4) { + i1 = par2; + par2 = par4; + par4 = i1; + } + + Tessellator tessellator = Tessellator.instance; + GL11.glColor4f(0.0F, 0.0F, 255.0F, 255.0F); + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glEnable(GL11.GL_COLOR_LOGIC_OP); + GL11.glLogicOp(GL11.GL_OR_REVERSE); + tessellator.startDrawingQuads(); + tessellator.addVertex((double) par1, (double) par4, 0.0D); + tessellator.addVertex((double) par3, (double) par4, 0.0D); + tessellator.addVertex((double) par3, (double) par2, 0.0D); + tessellator.addVertex((double) par1, (double) par2, 0.0D); + tessellator.draw(); + GL11.glDisable(GL11.GL_COLOR_LOGIC_OP); + GL11.glEnable(GL11.GL_TEXTURE_2D); + } + + public void setMaxStringLength(int par1) { + this.maxStringLength = par1; + + if (this.text.length() > par1) { + this.text = this.text.substring(0, par1); + } + } + + /** + * Returns the maximum number of character that can be contained in this textbox. + * @return int max string length + */ + public int getMaxStringLength() { + return this.maxStringLength; + } + + /** + * Returns the current position of the cursor. + * @return int cursor position + */ + public int getCursorPosition() { + return this.cursorPosition; + } + + /** + * Get enable drawing background and outline. + * @return boolean enable background drawing + */ + public boolean getEnableBackgroundDrawing() { + return this.enableBackgroundDrawing; + } + + /** + * Enable drawing background and outline. + * @param enableBackgroundDrawing boolean enable background drawing + */ + public void setEnableBackgroundDrawing(boolean enableBackgroundDrawing) { + this.enableBackgroundDrawing = enableBackgroundDrawing; + } + + /** + * Sets the text colour for this textbox (disabled text will not use this colour). + * @param enabledColor int text colour. + */ + public void setTextColor(int enabledColor) { + this.enabledColor = enabledColor; + } + + /** + * Sets the text colour for when this textbox is disabled. + * @param disabledColor int text colour. + */ + public void setDisabledTextColour(int disabledColor) { + this.disabledColor = disabledColor; + } + + /** + * Setter for the focused field. + * @param isFocused boolean focused + */ + public void setFocused(boolean isFocused) { + if (isFocused && !this.isFocused) { + this.cursorCounter = 0; + } + + this.isFocused = isFocused; + } + + /** + * Getter for the focused field. + * @return boolean isFocused + */ + public boolean isFocused() { + return this.isFocused; + } + + public void setEnabled(boolean par1) { + this.isEnabled = par1; + } + + /** + * The side of the selection that is not the cursor, may be the same as the cursor. + * @return int selection end + */ + public int getSelectionEnd() { + return this.selectionEnd; + } + + /** + * returns the width of the textbox depending on if the box is enabled. + * @return int width + */ + public int getWidth() { + return this.getEnableBackgroundDrawing() ? this.width - 8 : this.width; + } + + /** + * Sets the position of the selection anchor (i.e. position the selection was started at). + * @param selectionEnd int selection anchor + */ + public void setSelectionPos(int selectionEnd) { + int j = this.text.length(); + + if (selectionEnd > j) { + selectionEnd = j; + } + + if (selectionEnd < 0) { + selectionEnd = 0; + } + + this.selectionEnd = selectionEnd; + + if (this.fontRenderer != null) { + if (this.lineScrollOffset > j) { + this.lineScrollOffset = j; + } + + int k = this.getWidth(); + String s = this.fontRenderer.trimStringToWidth(this.text.substring(this.lineScrollOffset), k); + int l = s.length() + this.lineScrollOffset; + + if (selectionEnd == this.lineScrollOffset) { + this.lineScrollOffset -= this.fontRenderer.trimStringToWidth(this.text, k, true).length(); + } + + if (selectionEnd > l) { + this.lineScrollOffset += selectionEnd - l; + } else if (selectionEnd <= this.lineScrollOffset) { + this.lineScrollOffset -= this.lineScrollOffset - selectionEnd; + } + + if (this.lineScrollOffset < 0) { + this.lineScrollOffset = 0; + } + + if (this.lineScrollOffset > j) { + this.lineScrollOffset = j; + } + } + } + + /** + * When set to true the textbox can lose focus by clicking elsewhere on the screen. + */ + public void setCanLoseFocus(boolean canLoseFocus) { + this.canLoseFocus = canLoseFocus; + } + + /** + * @return {@code true} if this textbox is visible + */ + public boolean getVisible() { + return this.visible; + } + + /** + * Sets whether or not this textbox is visible. + * @param visible boolean visible + */ + public void setVisible(boolean visible) { + this.visible = visible; + } } diff --git a/src/main/java/train/client/gui/GuiTender.java b/src/main/java/train/client/gui/GuiTender.java index 99dd0638e8..a941484fc9 100644 --- a/src/main/java/train/client/gui/GuiTender.java +++ b/src/main/java/train/client/gui/GuiTender.java @@ -21,151 +21,159 @@ public class GuiTender extends GuiContainer { - private Tender tender; - private EntityPlayer player; - private GuiButton buttonLock; - - public GuiTender(EntityPlayer player, InventoryPlayer inventoryplayer, Entity entityminecart) { - super(new InventoryTender(inventoryplayer, (Tender) entityminecart)); - tender = (Tender) entityminecart; - this.player = player; - } - - @Override - public void initGui() { - super.initGui(); - buttonList.clear(); - int var1 = (this.width-xSize) / 2; - int var2 = (this.height-ySize) / 2; - if (!tender.getTrainLockedFromPacket()) { - this.buttonList.add(this.buttonLock = new GuiButton(3, var1 + 124, var2 - 10, 51, 10, "Unlocked")); - }else{ - this.buttonList.add(this.buttonLock = new GuiButton(3, var1 + 130, var2 - 10, 43, 10, "Locked")); - } - } - @Override - protected void actionPerformed(GuiButton guibutton) { - if (guibutton.id == 3) { - if(player!=null && player.getCommandSenderName().toLowerCase().equals(tender.getTrainOwner().toLowerCase())){ - if ((!tender.getTrainLockedFromPacket())) { - AxisAlignedBB box = tender.boundingBox.expand(5, 5, 5); - List lis3 = tender.worldObj.getEntitiesWithinAABBExcludingEntity(tender, box); - if (lis3 != null && lis3.size() > 0) { - for (Object entity : lis3) { - if (entity instanceof EntityPlayer) { - Traincraft.lockChannel - .sendToServer(new PacketSetTrainLockedToClient(true, tender.getEntityId())); - } - } - } - tender.locked = true; - guibutton.displayString = "Locked"; - this.initGui(); - }else{ - AxisAlignedBB box = tender.boundingBox.expand(5, 5, 5); - List lis3 = tender.worldObj.getEntitiesWithinAABBExcludingEntity(tender, box); - if (lis3 != null && lis3.size() > 0) { - for (Object entity : lis3) { - if (entity instanceof EntityPlayer) { - Traincraft.lockChannel - .sendToServer(new PacketSetTrainLockedToClient(false, tender.getEntityId())); - } - } - } - tender.locked = false; - guibutton.displayString = "UnLocked"; - this.initGui(); - } - }else if(player!=null && player instanceof EntityPlayer){ - player.addChatMessage(new ChatComponentText("You are not the owner")); - } - } - } - - @Override - protected void drawGuiContainerForegroundLayer(int i, int j) { - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_DEPTH_TEST); - - fontRendererObj.drawString(tender.getCommandSenderName(), 34, 1, 0x000000); - fontRendererObj.drawString(tender.getCommandSenderName(), 36, 3, 0x000000); - fontRendererObj.drawString(tender.getCommandSenderName(), 34, 3, 0x000000); - fontRendererObj.drawString(tender.getCommandSenderName(), 36, 1, 0x000000); - - fontRendererObj.drawString(tender.getCommandSenderName(), 34, 2, 0x000000); - fontRendererObj.drawString(tender.getCommandSenderName(), 36, 2, 0x000000); - fontRendererObj.drawString(tender.getCommandSenderName(), 35, 3, 0x000000); - fontRendererObj.drawString(tender.getCommandSenderName(), 35, 1, 0x000000); - fontRendererObj.drawString(tender.getCommandSenderName(), 35, 2, 0xd3a900); - - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glEnable(GL11.GL_DEPTH_TEST); - - if (intersectsWith(i, j)) { - drawCreativeTabHoveringText("When a tender is locked,", i, j); - } - } - - @Override - protected void drawCreativeTabHoveringText(String str, int t, int g) { - - //int liqui = (dieselInventory.getLiquidAmount() * 50) / dieselInventory.getTankCapacity(); - String state = ""; - if (tender.getTrainLockedFromPacket()) state = "Locked"; - if (!tender.getTrainLockedFromPacket()) state = "Unlocked"; - - int textWidth = fontRendererObj.getStringWidth("the GUI, change speed, destroy it."); - int startX = 90; - int startY = 5; - - int i4 = 0xf0100010; - drawGradientRect(startX - 3, startY - 4, startX + textWidth + 3, startY + 8 + 4 + 40, i4, i4); - drawGradientRect(startX - 4, startY - 3, startX + textWidth + 4, startY + 8 + 3 + 40, i4, i4); - int colour1 = 0x505000ff; - int colour2 = (colour1 & 0xfefefe) >> 1 | colour1 & 0xff000000; - drawGradientRect(startX - 3, startY - 3, startX + textWidth + 3, startY + 8 + 3 + 40, colour1, colour2); - drawGradientRect(startX - 2, startY - 2, startX + textWidth + 2, startY + 8 + 2 + 40, i4, i4); - fontRendererObj.drawStringWithShadow(str, startX, startY, -1); - fontRendererObj.drawStringWithShadow("only its owner can open", startX, startY + 10, -1); - fontRendererObj.drawStringWithShadow("the GUI and destroy it.", startX, startY + 20, -1); - fontRendererObj.drawStringWithShadow("Current state: "+state, startX, startY+30, -1); - fontRendererObj.drawStringWithShadow("Owner: "+tender.getTrainOwner().trim(), startX, startY+40, -1); - } - public boolean intersectsWith(int mouseX, int mouseY) { - //System.out.println(mouseX+" "+mouseY); - int j = (width - xSize) / 2; - int k = (height - ySize) / 2; - return (mouseX >= j + 124 && mouseX <= j + 174 && mouseY >= k-10 && mouseY <= k); - } - - @Override - public void drawScreen(int mouseX, int mouseY, float par3){ - super.drawScreen(mouseX, mouseY,par3); - int j = (width - xSize) / 2; - int k = (height - ySize) / 2; - if (mouseX>j+143 && mouseXk+18 && mouseY> 1 | colour1 & 0xff000000; + + drawGradientRect(startX - 3, startY - 4, startX + textWidth + 3, startY + 8 + 4 + 40, i4, i4); + drawGradientRect(startX - 4, startY - 3, startX + textWidth + 4, startY + 8 + 3 + 40, i4, i4); + drawGradientRect(startX - 3, startY - 3, startX + textWidth + 3, startY + 8 + 3 + 40, colour1, colour2); + drawGradientRect(startX - 2, startY - 2, startX + textWidth + 2, startY + 8 + 2 + 40, i4, i4); + + fontRendererObj.drawStringWithShadow(str, startX, startY, -1); + fontRendererObj.drawStringWithShadow("only its owner can open", startX, startY + 10, -1); + fontRendererObj.drawStringWithShadow("the GUI and destroy it.", startX, startY + 20, -1); + fontRendererObj.drawStringWithShadow("Current state: " + (tender.getTrainLockedFromPacket() ? "Locked" : "Unlocked"), startX, startY + 30, -1); + fontRendererObj.drawStringWithShadow("Owner: " + tender.getTrainOwner().trim(), startX, startY + 40, -1); + } + + public boolean intersectsWith(int mouseX, int mouseY) { + //System.out.println(mouseX+" "+mouseY); + int j = (width - xSize) / 2; + int k = (height - ySize) / 2; + return (mouseX >= j + 124 && mouseX <= j + 174 && mouseY >= k - 10 && mouseY <= k); + } + + @Override + public void drawScreen(int mouseX, int mouseY, float par3) { + super.drawScreen(mouseX, mouseY, par3); + int j = (width - xSize) / 2; + int k = (height - ySize) / 2; + + if (mouseX > j + 143 && mouseX < j + 161 && mouseY > k + 18 && mouseY < k + 68) { + drawHoveringText(Collections.singletonList("Water: " + (tender.getWater()) + "mb / " + (tender.getCartTankCapacity()) + "mb"), + mouseX, mouseY, fontRendererObj); + } + } + + @Override + protected void drawGuiContainerBackgroundLayer(float f, int t, int g) { + String i = Info.guiPrefix + "gui_tender.png"; + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + mc.renderEngine.bindTexture(new ResourceLocation(Info.resourceLocation, i)); + + int j = (width - xSize) / 2; + int k = (height - ySize) / 2; + + drawTexturedModalRect(j, k, 0, 0, xSize, ySize); + + if (tender == null) { + return; + } + + int load = (tender.getWater()); + int lo = Math.abs(((load * 50) / (tender.getCartTankCapacity()))); + + if (tender.getLiquidItemID() == LiquidManager.WATER_FILTER.getFluidID()) { + drawTexturedModalRect(j + 143, (k + 69) - lo, 190, 69 - lo, 18, lo); + } + } } diff --git a/src/main/java/train/client/gui/GuiTrainCraftingBlock.java b/src/main/java/train/client/gui/GuiTrainCraftingBlock.java index 59dccaa42a..6a193185ff 100644 --- a/src/main/java/train/client/gui/GuiTrainCraftingBlock.java +++ b/src/main/java/train/client/gui/GuiTrainCraftingBlock.java @@ -11,23 +11,25 @@ import train.common.library.Info; public class GuiTrainCraftingBlock extends GuiContainer { - public GuiTrainCraftingBlock(InventoryPlayer invPlayer, World world, IInventory inv) { - super(new ContainerTrainWorkbench(invPlayer, world, inv)); - } + public GuiTrainCraftingBlock(InventoryPlayer invPlayer, World world, IInventory inv) { + super(new ContainerTrainWorkbench(invPlayer, world, inv)); + } - @Override - protected void drawGuiContainerForegroundLayer(int par1, int par2) { - this.fontRendererObj.drawString("Train Workbench", 8, 6, 4210752); - this.fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 8, this.ySize - 96 + 2, 4210752); - } + @Override + protected void drawGuiContainerForegroundLayer(int par1, int par2) { + this.fontRendererObj.drawString("Train Workbench", 8, 6, 4210752); + this.fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 8, this.ySize - 96 + 2, 4210752); + } - @Override - protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { - String var4 = Info.guiPrefix+"crafting_table.png"; - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - mc.renderEngine.bindTexture(new ResourceLocation(Info.resourceLocation,var4)); - int var5 = (this.width - this.xSize) / 2; - int var6 = (this.height - this.ySize) / 2; - this.drawTexturedModalRect(var5, var6, 0, 0, this.xSize, this.ySize); - } + @Override + protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { + String guiTexture = Info.guiPrefix + "crafting_table.png"; + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + + mc.renderEngine.bindTexture(new ResourceLocation(Info.resourceLocation, guiTexture)); + + int rectPosX = (this.width - this.xSize) / 2; + int rectPosY = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(rectPosX, rectPosY, 0, 0, this.xSize, this.ySize); + } } diff --git a/src/main/java/train/client/gui/GuiTraincraft.java b/src/main/java/train/client/gui/GuiTraincraft.java index d339f4da4c..45d1269baf 100644 --- a/src/main/java/train/client/gui/GuiTraincraft.java +++ b/src/main/java/train/client/gui/GuiTraincraft.java @@ -1,6 +1,6 @@ /******************************************************************************* * Copyright (c) 2012 SirSengir. All rights reserved. - * + * * @name TrainCraft * @author SirSengir ******************************************************************************/ @@ -26,214 +26,223 @@ public abstract class GuiTraincraft extends GuiContainer { - protected SideTabManager sideTabManager = new SideTabManager(this); - - protected TileEntity tile; - protected ITier tier; - - //public int xSize = 176; - //public int ySize = 256; - - public GuiTraincraft(ContainerTraincraft container, IInventory inventory) { - super(container); - - tier = (ITier) inventory; - if (inventory instanceof TileEntity) - tile = (TileEntity) inventory; - - initSideTabs(inventory); - } - - protected void initSideTabs(IInventory inventory) {} - - @Override - protected void drawGuiContainerForegroundLayer(int par1, int par2) { - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_DEPTH_TEST); - sideTabManager.drawSideTabs(par1, par2); - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glEnable(GL11.GL_DEPTH_TEST); - } - - protected int getCenteredOffset(String string) { - return getCenteredOffset(string, xSize); - } - - protected int getCenteredOffset(String string, int xWidth) { - return (xWidth - fontRendererObj.getStringWidth(string)) / 2; - } - - @Override - protected void mouseClicked(int par1, int par2, int mouseButton) { - super.mouseClicked(par1, par2, mouseButton); - // / Handle ledger clicks - sideTabManager.handleMouseClicked(par1, par2, mouseButton); - } - - @Override - public void drawGradientRect(int par1, int par2, int par3, int par4, int par5, int par6) { - super.drawGradientRect(par1, par2, par3, par4, par5, par6); - } - - protected boolean isMouseOverSlot(Slot par1Slot, int par2, int par3) { - return this.func_74188_c(par1Slot.xDisplayPosition, par1Slot.yDisplayPosition, 16, 16, par2, par3); - } - - private int isMouseOverSlot2(Slot slot, int par2, int par3) { - boolean over = func_74188_c(slot.xDisplayPosition, slot.yDisplayPosition, 16, 16, par2, par3); - if (over) { - return slot.slotNumber; - } - else { - return 0; - } - } - - protected boolean func_74188_c(int par1, int par2, int par3, int par4, int par5, int par6) { - int var7 = this.guiLeft; - int var8 = this.guiTop; - par5 -= var7; - par6 -= var8; - return par5 >= par1 - 1 && par5 < par1 + par3 + 1 && par6 >= par2 - 1 && par6 < par2 + par4 + 1; - } - - protected void colorSlot(int x, int y) { - int j = (width - xSize) / 2; - int k = (height - ySize) / 2; - - String var4 = tier.getGUITexture(); - mc.renderEngine.bindTexture(new ResourceLocation(Info.resourceLocation,var4)); - - GL11.glEnable(GL11.GL_BLEND); - GL11.glColor4f(1.0F, 1.F, 1.0F, 0.3F); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - drawTexturedModalRect(j + x, k + y, 240, 0, 16, 16); - GL11.glDisable(GL11.GL_BLEND); - } - - protected void borderSlots(List recipeList, int[] states) { - List cs = inventorySlots.inventorySlots; - for (int l = 0; l < cs.size(); l++) { - Slot slot = (Slot) cs.get(l); - if (slot.slotNumber < 10) { - if (slot.getHasStack()) { - ItemStack stack = slot.getStack(); - for (TierRecipe recipe : recipeList) { - if (recipe!= null) { - List items = recipe.getInput(); - ItemStack stack2 = items.get(l); - if (stack2 != null) { - if (TierRecipe.areItemsIdentical(stack, stack2)) { - states[l] = 1; - break; - } - else { - states[l] = 2; - } - } - } - } - } - else { - states[l] = 0; - } + protected SideTabManager sideTabManager = new SideTabManager(this); + + protected TileEntity tile; + protected ITier tier; + + //public int xSize = 176; + //public int ySize = 256; + + public GuiTraincraft(ContainerTraincraft container, IInventory inventory) { + super(container); + + tier = (ITier) inventory; + + if (inventory instanceof TileEntity) { + tile = (TileEntity) inventory; + } + + initSideTabs(inventory); + } + + protected void initSideTabs(IInventory inventory) { + } + + @Override + protected void drawGuiContainerForegroundLayer(int par1, int par2) { + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_DEPTH_TEST); + sideTabManager.drawSideTabs(par1, par2); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_DEPTH_TEST); + } + + protected int getCenteredOffset(String string) { + return getCenteredOffset(string, xSize); + } + + protected int getCenteredOffset(String string, int xWidth) { + return (xWidth - fontRendererObj.getStringWidth(string)) / 2; + } + + @Override + protected void mouseClicked(int par1, int par2, int mouseButton) { + super.mouseClicked(par1, par2, mouseButton); + + // Handle ledger clicks + sideTabManager.handleMouseClicked(par1, par2, mouseButton); + } + + @Override + public void drawGradientRect(int par1, int par2, int par3, int par4, int par5, int par6) { + super.drawGradientRect(par1, par2, par3, par4, par5, par6); + } + + protected boolean isMouseOverSlot(Slot par1Slot, int par2, int par3) { + return this.func_74188_c(par1Slot.xDisplayPosition, par1Slot.yDisplayPosition, 16, 16, par2, par3); + } + + private int isMouseOverSlot2(Slot slot, int par2, int par3) { + boolean over = func_74188_c(slot.xDisplayPosition, slot.yDisplayPosition, 16, 16, par2, par3); + + if (over) { + return slot.slotNumber; + } else { + return 0; + } + } + + protected boolean func_74188_c(int par1, int par2, int par3, int par4, int par5, int par6) { + int var7 = this.guiLeft; + int var8 = this.guiTop; + par5 -= var7; + par6 -= var8; + return par5 >= par1 - 1 && par5 < par1 + par3 + 1 && par6 >= par2 - 1 && par6 < par2 + par4 + 1; + } + + protected void colorSlot(int x, int y) { + int j = (width - xSize) / 2; + int k = (height - ySize) / 2; + + String guiTexture = tier.getGUITexture(); + mc.renderEngine.bindTexture(new ResourceLocation(Info.resourceLocation, guiTexture)); + + GL11.glEnable(GL11.GL_BLEND); + GL11.glColor4f(1.0F, 1.F, 1.0F, 0.3F); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + drawTexturedModalRect(j + x, k + y, 240, 0, 16, 16); + GL11.glDisable(GL11.GL_BLEND); + } + + protected void borderSlots(List recipeList, int[] states) { + List cs = inventorySlots.inventorySlots; + for (int l = 0; l < cs.size(); l++) { + Slot slot = (Slot) cs.get(l); + if (slot.slotNumber >= 10) { + return; } - } - - int j = (width - xSize) / 2; - int k = (height - ySize) / 2; - - for (int l = 0; l < cs.size(); l++) { - Slot slot = (Slot) cs.get(l); - if (/* slot instanceof Slot && */slot.slotNumber < 10) { - String var4 = tier.getGUITexture(); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.9F); - mc.renderEngine.bindTexture(new ResourceLocation(Info.resourceLocation,var4)); - int x = slot.xDisplayPosition; - int y = slot.yDisplayPosition; - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - if (states[l] == 1) { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.4F); - drawTexturedModalRect(j + x - 7, k + y - 7, 209, 1, 30, 30); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - drawTexturedModalRect(j + x - 7, k + y - 7, 209, 60, 30, 30); - } - else if (states[l] == 2) { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.4F); - drawTexturedModalRect(j + x - 7, k + y - 7, 178, 1, 30, 30); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - drawTexturedModalRect(j + x - 7, k + y - 7, 178, 60, 30, 30); - } - GL11.glDisable(GL11.GL_BLEND); - } - } - } - - public void drawRecipes(int recipeSize, List recipes, int x, int y) { - Item item = null; - - if (recipeSize == -1) { - item = recipes.get(0); - } - else if (recipeSize == recipes.size()) { - item = recipes.get(recipes.size() - 1); - } - else { - item = recipes.get(recipeSize); - } - - if (item != null) { - itemRender.renderItemIntoGUI(this.fontRendererObj, this.mc.renderEngine, new ItemStack(item), x, y); - } - else { - String var4 = Info.guiPrefix + "Icons.png"; - mc.renderEngine.bindTexture(new ResourceLocation(Info.resourceLocation,var4)); - drawTexturedModalRect(x, y, 0, 16, 16, 16); - } - } - - public void drawOverlays(int recipeSize, List recipes) { - - - List itemStacks = null; - if (recipeSize == -1) { - itemStacks = TierRecipeManager.getInstance().getTierRecipe(tier.Tier(), new ItemStack(recipes.get(recipes.size() - 1))).getInput(); - } - else if (recipeSize == recipes.size()) { - itemStacks = TierRecipeManager.getInstance().getTierRecipe(tier.Tier(), new ItemStack(recipes.get(0))).getInput(); - } - else { - itemStacks = TierRecipeManager.getInstance().getTierRecipe(tier.Tier(), new ItemStack(recipes.get(recipeSize))).getInput(); - } - drawOverlays2(itemStacks.get(0), 25, 27); - drawOverlays2(itemStacks.get(1), 43, 93); - drawOverlays2(itemStacks.get(2), 79, 93); - drawOverlays2(itemStacks.get(3), 145, 93); - drawOverlays2(itemStacks.get(4), 79, 27); - drawOverlays2(itemStacks.get(5), 115, 27); - drawOverlays2(itemStacks.get(6), 79, 61); - drawOverlays2(itemStacks.get(7), 115, 61); - drawOverlays2(itemStacks.get(8), 25, 61); - drawOverlays2(itemStacks.get(9), 145, 27); - } - - public void drawOverlays2(ItemStack item, int x, int y) { - int j = (width - xSize) / 2; - int k = (height - ySize) / 2; - - if (item != null) { - String var4 = tier.getGUITexture(); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.3F); - mc.renderEngine.bindTexture(new ResourceLocation(Info.resourceLocation,var4)); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_DEPTH_TEST); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_SRC_ALPHA); - this.itemRender.renderItemIntoGUI(this.mc.fontRenderer, this.mc.renderEngine, item, j + x, k + y); - GL11.glDisable(GL11.GL_BLEND); - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glEnable(GL11.GL_DEPTH_TEST); - } - } + + if (!slot.getHasStack()) { + states[l] = 0; + return; + } + + ItemStack stack = slot.getStack(); + for (TierRecipe recipe : recipeList) { + if (recipe == null) { + return; + } + List items = recipe.getInput(); + ItemStack stack2 = items.get(l); + if (stack2 == null) { + return; + } + + states[l] = TierRecipe.areItemsIdentical(stack, stack2) ? 1 : 2; + } + } + + int j = (width - xSize) / 2; + int k = (height - ySize) / 2; + + for (int l = 0; l < cs.size(); l++) { + Slot slot = (Slot) cs.get(l); + if (slot.slotNumber >= 10) { + return; + } + + String guiTexture = tier.getGUITexture(); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.9F); + + mc.renderEngine.bindTexture(new ResourceLocation(Info.resourceLocation, guiTexture)); + + int x = slot.xDisplayPosition; + int y = slot.yDisplayPosition; + + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + + if (states[l] == 1) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.4F); + drawTexturedModalRect(j + x - 7, k + y - 7, 209, 1, 30, 30); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + drawTexturedModalRect(j + x - 7, k + y - 7, 209, 60, 30, 30); + } else if (states[l] == 2) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.4F); + drawTexturedModalRect(j + x - 7, k + y - 7, 178, 1, 30, 30); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + drawTexturedModalRect(j + x - 7, k + y - 7, 178, 60, 30, 30); + } + GL11.glDisable(GL11.GL_BLEND); + } + } + + public void drawRecipes(int recipeSize, List recipes, int x, int y) { + Item item; + + if (recipeSize == -1) { + item = recipes.get(0); + } else if (recipeSize == recipes.size()) { + item = recipes.get(recipes.size() - 1); + } else { + item = recipes.get(recipeSize); + } + + if (item != null) { + itemRender.renderItemIntoGUI(this.fontRendererObj, this.mc.renderEngine, new ItemStack(item), x, y); + } else { + String var4 = Info.guiPrefix + "Icons.png"; + mc.renderEngine.bindTexture(new ResourceLocation(Info.resourceLocation, var4)); + drawTexturedModalRect(x, y, 0, 16, 16, 16); + } + } + + public void drawOverlays(int recipeSize, List recipes) { + List itemStacks; + + if (recipeSize == -1) { + itemStacks = TierRecipeManager.getInstance().getTierRecipe(tier.Tier(), new ItemStack(recipes.get(recipes.size() - 1))).getInput(); + } else if (recipeSize == recipes.size()) { + itemStacks = TierRecipeManager.getInstance().getTierRecipe(tier.Tier(), new ItemStack(recipes.get(0))).getInput(); + } else { + itemStacks = TierRecipeManager.getInstance().getTierRecipe(tier.Tier(), new ItemStack(recipes.get(recipeSize))).getInput(); + } + + drawOverlays2(itemStacks.get(0), 25, 27); + drawOverlays2(itemStacks.get(1), 43, 93); + drawOverlays2(itemStacks.get(2), 79, 93); + drawOverlays2(itemStacks.get(3), 145, 93); + drawOverlays2(itemStacks.get(4), 79, 27); + drawOverlays2(itemStacks.get(5), 115, 27); + drawOverlays2(itemStacks.get(6), 79, 61); + drawOverlays2(itemStacks.get(7), 115, 61); + drawOverlays2(itemStacks.get(8), 25, 61); + drawOverlays2(itemStacks.get(9), 145, 27); + } + + public void drawOverlays2(ItemStack item, int x, int y) { + int j = (width - xSize) / 2; + int k = (height - ySize) / 2; + + if (item == null) { + return; + } + + String guiTexture = tier.getGUITexture(); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.3F); + + mc.renderEngine.bindTexture(new ResourceLocation(Info.resourceLocation, guiTexture)); + + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_DEPTH_TEST); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_SRC_ALPHA); + + itemRender.renderItemIntoGUI(this.mc.fontRenderer, this.mc.renderEngine, item, j + x, k + y); + + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_DEPTH_TEST); + } } \ No newline at end of file diff --git a/src/main/java/train/client/gui/GuiZepp.java b/src/main/java/train/client/gui/GuiZepp.java index 1fbd77a1bb..e14b794cff 100644 --- a/src/main/java/train/client/gui/GuiZepp.java +++ b/src/main/java/train/client/gui/GuiZepp.java @@ -11,44 +11,50 @@ public class GuiZepp extends GuiContainer { - private AbstractZeppelin zepp; - - public GuiZepp(InventoryPlayer inventoryplayer, Entity entityzepp) { - super(new InventoryZepp(inventoryplayer, (AbstractZeppelin) entityzepp)); - zepp = (AbstractZeppelin) entityzepp; - } - - @Override - protected void drawGuiContainerForegroundLayer(int i, int j) { - fontRendererObj.drawString(zepp.getCommandSenderName(), 60, 6, 0x404040); - fontRendererObj.drawString("Inventory", 8, (ySize - 96) + 2, 0x404040); - if (zepp.numCargoSlots > 0) { - fontRendererObj.drawString("Cargo:", 36, 22, 0x404040); - } - } - - @Override - protected void drawGuiContainerBackgroundLayer(float f, int t, int g) { - String i = Info.guiPrefix + "gui_zeppelin.png"; - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - mc.renderEngine.bindTexture(new ResourceLocation(Info.resourceLocation,i)); - int j = (width - xSize) / 2; - int k = (height - ySize) / 2; - drawTexturedModalRect(j, k, 0, 0, xSize, ySize); - if (zepp.isFuelled()) { - int l = zepp.c(12); - drawTexturedModalRect(j + 8, (k + 36 + 12) - l, 176, 12 - l, 14, l + 2); - } - for (int i1 = zepp.numCargoSlots; i1 < 5; i1++) { - drawTexturedModalRect(j + 79 + 18 * i1, k + 17, 190, 0, 18, 18); - } - - for (int j1 = zepp.numCargoSlots1; j1 < 5; j1++) { - drawTexturedModalRect(j + 79 + 18 * j1, k + 35, 190, 0, 18, 18); - } - - for (int k1 = zepp.numCargoSlots2; k1 < 5; k1++) { - drawTexturedModalRect(j + 79 + 18 * k1, k + 53, 190, 0, 18, 18); - } - } + private final AbstractZeppelin zepp; + + public GuiZepp(InventoryPlayer inventoryplayer, Entity entityzepp) { + super(new InventoryZepp(inventoryplayer, (AbstractZeppelin) entityzepp)); + zepp = (AbstractZeppelin) entityzepp; + } + + @Override + protected void drawGuiContainerForegroundLayer(int i, int j) { + fontRendererObj.drawString(zepp.getCommandSenderName(), 60, 6, 0x404040); + fontRendererObj.drawString("Inventory", 8, (ySize - 96) + 2, 0x404040); + + if (zepp.numCargoSlots > 0) { + fontRendererObj.drawString("Cargo:", 36, 22, 0x404040); + } + } + + @Override + protected void drawGuiContainerBackgroundLayer(float f, int t, int g) { + String guiTexture = Info.guiPrefix + "gui_zeppelin.png"; + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + + mc.renderEngine.bindTexture(new ResourceLocation(Info.resourceLocation, guiTexture)); + + int j = (width - xSize) / 2; + int k = (height - ySize) / 2; + + drawTexturedModalRect(j, k, 0, 0, xSize, ySize); + + if (zepp.isFuelled()) { + int l = zepp.c(12); + drawTexturedModalRect(j + 8, (k + 36 + 12) - l, 176, 12 - l, 14, l + 2); + } + + for (int i1 = zepp.numCargoSlots; i1 < 5; i1++) { + drawTexturedModalRect(j + 79 + 18 * i1, k + 17, 190, 0, 18, 18); + } + + for (int j1 = zepp.numCargoSlots1; j1 < 5; j1++) { + drawTexturedModalRect(j + 79 + 18 * j1, k + 35, 190, 0, 18, 18); + } + + for (int k1 = zepp.numCargoSlots2; k1 < 5; k1++) { + drawTexturedModalRect(j + 79 + 18 * k1, k + 53, 190, 0, 18, 18); + } + } } diff --git a/src/main/java/train/client/gui/HUDMTC.java b/src/main/java/train/client/gui/HUDMTC.java index ae9fe52a5a..205e7972ff 100644 --- a/src/main/java/train/client/gui/HUDMTC.java +++ b/src/main/java/train/client/gui/HUDMTC.java @@ -13,118 +13,97 @@ public class HUDMTC extends GuiScreen { - private Minecraft game; - private int windowWidth, windowHeight; - public boolean mtcIconOnOff = true; -//test15 - @SubscribeEvent - public void onGameRender(RenderGameOverlayEvent.Text event){ - if (game != null && game.thePlayer != null && game.thePlayer.ridingEntity != null && game.thePlayer.ridingEntity instanceof Locomotive && Minecraft.isGuiEnabled() && game.currentScreen == null) { - renderSkillHUD(event, (Locomotive) game.thePlayer.ridingEntity); - } else { - this.game = this.mc = Minecraft.getMinecraft(); - this.fontRendererObj = this.game.fontRenderer; - } - } - - public void renderSkillHUD(RenderGameOverlayEvent event, Locomotive rcCar) { - windowWidth = event.resolution.getScaledWidth(); - windowHeight = event.resolution.getScaledHeight() - 100; - - if (rcCar.mtcStatus == 1 || rcCar.mtcStatus == 2) { - /** - * Steam Train have water - */ - String mtcStatus = ""; - if (rcCar.mtcStatus == 0) { - mtcStatus = "Inactive"; - } - - if (rcCar.mtcStatus == 1) { - mtcStatus = "Active"; - } - if (rcCar.mtcStatus == 2) { - mtcStatus = "Ending Soon"; - } - if (rcCar.mtcStatus == 3) { - - mtcStatus = "Ended"; - } - int width = this.game.fontRenderer.getStringWidth("Speed Limit: " + rcCar.speedLimit + " km/h"); - - int width2 = this.game.fontRenderer.getStringWidth(""); - int height = this.game.fontRenderer.FONT_HEIGHT; - int padding = 2; - int margin = 4; - int xPos = 0 + margin; - int yPos = 0 + margin; - Gui.drawRect(xPos, yPos, xPos + width + padding * 2 + 70, yPos + height + padding + padding + 35, 0xAA000000); - if (rcCar.atoStatus == 1) { - this.drawString(this.game.fontRenderer, "Speed Limit: " + rcCar.speedLimit + " km/h" + ", ATO on", xPos + 4, yPos, 14737632); - } else { - this.drawString(this.game.fontRenderer, "Speed Limit: " + rcCar.speedLimit + " km/h", xPos + 4, yPos, 14737632); - } - this.drawString(this.game.fontRenderer, "Next Speed Limit: " + rcCar.nextSpeedLimit + " km/h", xPos + 4, yPos + 10, 14737632); - rcCar.distanceFromStopPoint = rcCar.getDistance(rcCar.xFromStopPoint, rcCar.yFromStopPoint, rcCar.zFromStopPoint); - rcCar.distanceFromSpeedChange = rcCar.getDistance(rcCar.xSpeedLimitChange, rcCar.ySpeedLimitChange,rcCar.zSpeedLimitChange); - rcCar.distanceFromStationStop = rcCar.getDistance(rcCar.xStationStop, rcCar.yStationStop,rcCar.zStationStop); - if (rcCar.xFromStopPoint != 0 && rcCar.yFromStopPoint != 0 && rcCar.zFromStopPoint != 0) { - this.drawString(this.game.fontRenderer, "Stop in " + Math.round(rcCar.distanceFromStopPoint) + " blocks.", xPos + 4, yPos + 19, 14737632); - } - if (rcCar.xFromStopPoint == 0 && rcCar.yFromStopPoint == 0 && rcCar.zFromStopPoint == 0 && rcCar.xStationStop != 0 && rcCar.yStationStop != 0 && rcCar.xStationStop != 0 ) { - this.drawString(this.game.fontRenderer, "Station stop in " +Math.round(rcCar.distanceFromStationStop) + " blocks.", xPos + 4, yPos + 19, 14737632); - } - if (rcCar.xSpeedLimitChange != 0 && rcCar.ySpeedLimitChange != 0 && rcCar.zSpeedLimitChange != 0) { - this.drawString(this.game.fontRenderer, "Next speed limit in " + Math.round(rcCar.distanceFromSpeedChange) + " blocks.", xPos + 4, yPos + 28, 14737632); - } - - if (rcCar.speedLimit < rcCar.getSpeed() && !rcCar.overspeedOveridePressed) { - drawTexturedRect(new ResourceLocation(Info.resourceLocation, Info.guiPrefix + "mtcspeeding.png"), 30, 45, 0, 0, 64, 64, 64, 64, 0.25); - } else if (rcCar.overspeedOveridePressed) { - drawTexturedRect(new ResourceLocation(Info.resourceLocation, Info.guiPrefix + "mtcspeedingoverride.png"), 30, 45, 0, 0, 64, 64, 64, 64, 0.25); - } - - //hey - - } - - if (rcCar.ticksExisted % 21 == 0 && rcCar.mtcStatus == 2) { - if (mtcIconOnOff) { - mtcIconOnOff = false; - } else { - mtcIconOnOff = true; - } - } else if (rcCar.mtcStatus == 1) { - mtcIconOnOff = true; - } - - if (rcCar.mtcOverridePressed) { - drawTexturedRect(new ResourceLocation(Info.resourceLocation, Info.guiPrefix + "mtcdisable.png"), 12, 45, 0, 0, 64, 64, 64, 64, 0.25); - } else if (rcCar.mtcStatus == 1 || rcCar.mtcStatus == 2) { - if (mtcIconOnOff) { - if (rcCar.mtcType == 1 || rcCar.mtcType == 0) { - drawTexturedRect(new ResourceLocation(Info.resourceLocation, Info.guiPrefix + "mtcicon.png"), 12, 45, 0, 0, 64, 64, 64, 64, 0.25); - } else { - drawTexturedRect(new ResourceLocation(Info.resourceLocation, Info.guiPrefix + "mtcicon2.png"), 12, 45, 0, 0, 64, 64, 64, 64, 0.25); - } - - } - } - - } - - public static void drawTexturedRect(ResourceLocation texture, double x, double y, int u, int v, int width, int height, int imageWidth, int imageHeight, double scale) { - Minecraft.getMinecraft().renderEngine.bindTexture(texture); - double minU = (double)u / (double)imageWidth; - double maxU = (double)(u + width) / (double)imageWidth; - double minV = (double)v / (double)imageHeight; - double maxV = (double)(v + height) / (double)imageHeight; - Tessellator tessellator = Tessellator.instance; - tessellator.startDrawingQuads(); - tessellator.addVertexWithUV(x + scale*(double)width, y + scale*(double)height, 0, maxU, maxV); - tessellator.addVertexWithUV(x + scale*(double)width, y, 0, maxU, minV); - tessellator.addVertexWithUV(x, y, 0, minU, minV); - tessellator.addVertexWithUV(x, y + scale*(double)height, 0, minU, maxV); - tessellator.draw(); - } + private Minecraft game; + private int windowWidth, windowHeight; + public boolean mtcIconOnOff = true; + + //test15 + @SubscribeEvent + public void onGameRender(RenderGameOverlayEvent.Text event) { + if (game != null + && game.thePlayer != null + && game.thePlayer.ridingEntity != null + && game.thePlayer.ridingEntity instanceof Locomotive && Minecraft.isGuiEnabled() + && game.currentScreen == null) { + renderSkillHUD(event, (Locomotive) game.thePlayer.ridingEntity); + } else { + this.game = this.mc = Minecraft.getMinecraft(); + this.fontRendererObj = this.game.fontRenderer; + } + } + + public void renderSkillHUD(RenderGameOverlayEvent event, Locomotive rcCar) { + windowWidth = event.resolution.getScaledWidth(); + windowHeight = event.resolution.getScaledHeight() - 100; + + if (rcCar.mtcStatus == 1 || rcCar.mtcStatus == 2) { + // Steam Trains have water. + int width = this.game.fontRenderer.getStringWidth("Speed Limit: " + rcCar.speedLimit + " km/h"); + + int height = this.game.fontRenderer.FONT_HEIGHT; + int padding = 2; + int margin = 4; + + Gui.drawRect(margin, margin, margin + width + padding * 2 + 70, margin + height + padding + padding + 35, 0xAA000000); + + this.drawString(this.game.fontRenderer, "Speed Limit: " + rcCar.speedLimit + " km/h" + (rcCar.atoStatus == 1 ? ", ATO on" : ""), margin + 4, margin, 14737632); + this.drawString(this.game.fontRenderer, "Next Speed Limit: " + rcCar.nextSpeedLimit + " km/h", margin + 4, margin + 10, 14737632); + + rcCar.distanceFromStopPoint = rcCar.getDistance(rcCar.xFromStopPoint, rcCar.yFromStopPoint, rcCar.zFromStopPoint); + rcCar.distanceFromSpeedChange = rcCar.getDistance(rcCar.xSpeedLimitChange, rcCar.ySpeedLimitChange, rcCar.zSpeedLimitChange); + rcCar.distanceFromStationStop = rcCar.getDistance(rcCar.xStationStop, rcCar.yStationStop, rcCar.zStationStop); + + if (rcCar.xFromStopPoint != 0 && rcCar.yFromStopPoint != 0 && rcCar.zFromStopPoint != 0) { + this.drawString(this.game.fontRenderer, "Stop in " + Math.round(rcCar.distanceFromStopPoint) + " blocks.", margin + 4, margin + 19, 14737632); + } + + if (rcCar.xFromStopPoint == 0 && rcCar.yFromStopPoint == 0 && rcCar.zFromStopPoint == 0 && rcCar.xStationStop != 0 && rcCar.yStationStop != 0) { + this.drawString(this.game.fontRenderer, "Station stop in " + Math.round(rcCar.distanceFromStationStop) + " blocks.", margin + 4, margin + 19, 14737632); + } + + if (rcCar.xSpeedLimitChange != 0 && rcCar.ySpeedLimitChange != 0 && rcCar.zSpeedLimitChange != 0) { + this.drawString(this.game.fontRenderer, "Next speed limit in " + Math.round(rcCar.distanceFromSpeedChange) + " blocks.", margin + 4, margin + 28, 14737632); + } + + if (rcCar.speedLimit < rcCar.getSpeed() && !rcCar.overspeedOveridePressed) { + drawTexturedRect(new ResourceLocation(Info.resourceLocation, Info.guiPrefix + "mtcspeeding.png"), 30, 45, 0, 0, 64, 64, 64, 64, 0.25); + } else if (rcCar.overspeedOveridePressed) { + drawTexturedRect(new ResourceLocation(Info.resourceLocation, Info.guiPrefix + "mtcspeedingoverride.png"), 30, 45, 0, 0, 64, 64, 64, 64, 0.25); + } + } + + if (rcCar.ticksExisted % 21 == 0 && rcCar.mtcStatus == 2) { + mtcIconOnOff = !mtcIconOnOff; + } else if (rcCar.mtcStatus == 1) { + mtcIconOnOff = true; + } + + if (rcCar.mtcOverridePressed) { + drawTexturedRect(new ResourceLocation(Info.resourceLocation, Info.guiPrefix + "mtcdisable.png"), 12, 45, 0, 0, 64, 64, 64, 64, 0.25); + } else if (rcCar.mtcStatus == 1 || rcCar.mtcStatus == 2) { + if (mtcIconOnOff) { + if (rcCar.mtcType == 1 || rcCar.mtcType == 0) { + drawTexturedRect(new ResourceLocation(Info.resourceLocation, Info.guiPrefix + "mtcicon.png"), 12, 45, 0, 0, 64, 64, 64, 64, 0.25); + } else { + drawTexturedRect(new ResourceLocation(Info.resourceLocation, Info.guiPrefix + "mtcicon2.png"), 12, 45, 0, 0, 64, 64, 64, 64, 0.25); + } + } + } + } + + public static void drawTexturedRect(ResourceLocation texture, double x, double y, int u, int v, int width, int height, int imageWidth, int imageHeight, double scale) { + Minecraft.getMinecraft().renderEngine.bindTexture(texture); + double minU = (double) u / (double) imageWidth; + double maxU = (double) (u + width) / (double) imageWidth; + double minV = (double) v / (double) imageHeight; + double maxV = (double) (v + height) / (double) imageHeight; + + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + tessellator.addVertexWithUV(x + scale * (double) width, y + scale * (double) height, 0, maxU, maxV); + tessellator.addVertexWithUV(x + scale * (double) width, y, 0, maxU, minV); + tessellator.addVertexWithUV(x, y, 0, minU, minV); + tessellator.addVertexWithUV(x, y + scale * (double) height, 0, minU, maxV); + tessellator.draw(); + } } diff --git a/src/main/java/train/client/gui/HUDloco.java b/src/main/java/train/client/gui/HUDloco.java index 3f82a4d27b..40385545c9 100644 --- a/src/main/java/train/client/gui/HUDloco.java +++ b/src/main/java/train/client/gui/HUDloco.java @@ -12,219 +12,217 @@ import train.common.library.Info; public class HUDloco extends GuiScreen { - - private Minecraft game; - private int windowWidth, windowHeight; - - @SubscribeEvent - public void onGameRender(RenderGameOverlayEvent.Text event){ - if (game != null && game.thePlayer != null && game.thePlayer.ridingEntity != null && game.thePlayer.ridingEntity instanceof Locomotive && Minecraft.isGuiEnabled() && game.currentScreen == null) { - renderSkillHUD(event, (Locomotive) game.thePlayer.ridingEntity); - } else { - this.game = this.mc = Minecraft.getMinecraft(); - this.fontRendererObj = this.game.fontRenderer; - } - } - - public void renderSkillHUD(RenderGameOverlayEvent event, Locomotive rcCar) { - windowWidth = event.resolution.getScaledWidth(); - windowHeight = event.resolution.getScaledHeight() - 100; - GL11.glColor4f(255, 255, 255, 255); - renderBG(rcCar); - /** - * Steam Train have water - */ - if (rcCar instanceof SteamTrain) { - renderWaterBar(rcCar); - } - - /** - * Some loco may not overheat in the future - */ - if (rcCar.canOverheat()) { - renderOverheating(rcCar); - } - renderSpeedometer(rcCar); - renderFuelBar(rcCar); - renderText(rcCar); - } - - private void renderBG(Locomotive rcCar) { - GL11.glEnable(3042); - GL11.glEnable(32826); - this.zLevel = -90.0F; - if (rcCar instanceof SteamTrain) { - game.renderEngine.bindTexture(new ResourceLocation(Info.resourceLocation,Info.guiPrefix + "loco_hud_steam.png")); - } - else { - game.renderEngine.bindTexture(new ResourceLocation(Info.resourceLocation,Info.guiPrefix + "locohud.png")); - } - drawTexturedModalRect(10, windowHeight, 0, 150, 137, 90); - GL11.glDisable(32826); - GL11.glDisable(3042); - } - - private void renderText(Locomotive loco) { - double speed = loco.getSpeed(); - - int h; - if (loco instanceof SteamTrain) { - h = 15; - } - else { - h = 13; - } - GL11.glEnable(3042 /* GL_BLEND */); - GL11.glEnable(32826); - fontRendererObj.drawStringWithShadow("Speed:", 106, windowHeight + 7 + (h), 0xFFFFFF); - fontRendererObj.drawStringWithShadow(" " + (int) Math.abs(((float) (speed))), 106, - windowHeight + 18 + (h), 0xFFFFFF); - fontRendererObj.drawStringWithShadow(" Km/h", 106, windowHeight + 29 + (h), 0xFFFFFF); - - if (loco.canOverheat()) { - fontRendererObj.drawStringWithShadow("State: " + loco.getState(), 50, windowHeight + 80, 0xFFFFFF); - } - GL11.glDisable(32826); - GL11.glDisable(3042 /* GL_BLEND */); - } - - private void renderFuelBar(Locomotive loco) { - GL11.glEnable(3042 /* GL_BLEND */); - GL11.glEnable(32826); - int l; - /** - * So that the content of the tank is renderer and not the fuel currently burned - */ - if (loco instanceof DieselTrain) { - l = ((((DieselTrain) loco).getDiesel())); - - l = Math.abs(((l * 70) / (((DieselTrain) loco).getCartTankCapacity()))); - } - else { - l = loco.getFuelDiv(70);//scaled on 70 pixels - } - if (l > 70) { - l = 70;// to fit the 70 pixels bar - } - if (l < 0) { - l = 0; - } - - /** - * Steam Train have different HUD - */ - if (loco instanceof SteamTrain) { - game.renderEngine.bindTexture(new ResourceLocation(Info.resourceLocation,Info.guiPrefix + "loco_hud_steam.png")); - } - else { - game.renderEngine.bindTexture(new ResourceLocation(Info.resourceLocation,Info.guiPrefix + "locohud.png")); - } - /** - * Things are slightly different in Steam HUD - * because it's a black bar that is rendered that hides the color bar the black bar is rendered from top to bottom - */ - if (!(loco instanceof SteamTrain)) { - drawTexturedModalRect(28, windowHeight + 11, 148, 150 + l, 7, 70 - l);// l max = 70 - } - else { - drawTexturedModalRect(34, windowHeight + 17, 154, 170 + l, 9, 70 - l);// l max = 70 - } - // fontRendererObj.drawStringWithShadow("Fuel:", 4, (windowHeight/2)+1, 0xFFFFFF); - GL11.glDisable(32826); - GL11.glDisable(3042 /* GL_BLEND */); - } - - private void renderWaterBar(Locomotive loco) { - int l = ((SteamTrain) loco).getWater(); - int l_Scaled = Math.abs((l * 49) / ((SteamTrain) loco).getCartTankCapacity()); - if (l_Scaled > 49) { - l_Scaled = 49;// to fit the 49 pixels bar - } - if (l_Scaled < 0) { - l_Scaled = 0; - } - /** - * because it's a black bar that is rendered that hides the color bar the black bar is rendered from top to bottom - */ - GL11.glEnable(3042 /* GL_BLEND */); - GL11.glEnable(32826); - drawTexturedModalRect(70, windowHeight + 17, 190, 169 + l_Scaled, 6, 49 - l_Scaled);// l max = 49 - GL11.glDisable(32826); - GL11.glDisable(3042 /* GL_BLEND */); - /* this is for the red overlay if you don't put water into steam trains */ - if (l <= 1 && loco.getIsFuelled()) { - this.drawGradientRect(0, 0, windowWidth, windowHeight + 100, 1615855616, -1602211792); - } - } - - private void renderSpeedometer(Locomotive loco) { - double speed = loco.getSpeed(); - GL11.glEnable(3042); - GL11.glEnable(32826); - - /** - * SteamTrain have different HUD - */ - if (loco instanceof SteamTrain) { - game.renderEngine.bindTexture(new ResourceLocation(Info.resourceLocation,Info.guiPrefix + "loco_hud_steam.png")); - } - else { - game.renderEngine.bindTexture(new ResourceLocation(Info.resourceLocation,Info.guiPrefix + "locohud.png")); - } - /** - * Scale the speed so that it doesn't go higher than 49 pixels - */ - double speedScaled = Math.abs((speed * 49) / 280); - if (speedScaled > 49) { - speedScaled = 49; - } - /** - * Things are slightly different in Steam HUD - */ - if (!(loco instanceof SteamTrain)) { - drawTexturedModalRect(75, windowHeight + 37 - ((int) speedScaled) + (20), 163, 150, 30, 5); - } - else { - drawTexturedModalRect(84, windowHeight + 37 - ((int) speedScaled) + (20), 177, 149, 16, 8); - } - GL11.glDisable(32826); - GL11.glDisable(3042); - } - - private void renderOverheating(Locomotive loco) { - int overheatLevel = loco.getOverheatLevel(); - if (overheatLevel > loco.getOverheatTime() + 30) { - overheatLevel = loco.getOverheatTime() + 30; - } - // fontRendererObj.drawStringWithShadow("Heat:", 33, (windowHeight/2)+1, 0xFFFFFF); - GL11.glEnable(3042 /* GL_BLEND */); - GL11.glEnable(32826); - - /** - * Steam Train have different HUD - */ - if (loco instanceof SteamTrain) { - game.renderEngine.bindTexture(new ResourceLocation(Info.resourceLocation,Info.guiPrefix + "loco_hud_steam.png")); - } - else { - game.renderEngine.bindTexture(new ResourceLocation(Info.resourceLocation,Info.guiPrefix + "locohud.png")); - } - - int overheatScaled = Math.abs((overheatLevel * 49) / (loco.getOverheatTime() + 30)); - if (overheatScaled > 49) { - overheatScaled = 49; - } - /** - * Things are slightly different in Steam HUD render overheat arrow black bar for steam train - */ - if (!(loco instanceof SteamTrain)) { - drawTexturedModalRect(58, windowHeight + 37 - ( overheatScaled) + (20), 169, 158, 23, 5); - } - else { - drawTexturedModalRect(56, windowHeight + 17, 176, (169 + overheatScaled), 5, 49 - overheatScaled); - } - GL11.glDisable(32826); - GL11.glDisable(3042 /* GL_BLEND */); - } + private Minecraft game; + private int windowWidth, windowHeight; + + @SubscribeEvent + public void onGameRender(RenderGameOverlayEvent.Text event) { + if (game != null + && game.thePlayer != null + && game.thePlayer.ridingEntity != null + && game.thePlayer.ridingEntity instanceof Locomotive + && Minecraft.isGuiEnabled() + && game.currentScreen == null) { + renderSkillHUD(event, (Locomotive) game.thePlayer.ridingEntity); + } else { + this.game = this.mc = Minecraft.getMinecraft(); + this.fontRendererObj = this.game.fontRenderer; + } + } + + public void renderSkillHUD(RenderGameOverlayEvent event, Locomotive rcCar) { + windowWidth = event.resolution.getScaledWidth(); + windowHeight = event.resolution.getScaledHeight() - 100; + GL11.glColor4f(255, 255, 255, 255); + renderBG(rcCar); + + // Render Water Bar because the steam train has water. + if (rcCar instanceof SteamTrain) { + renderWaterBar(rcCar); + } + + // Some locos may not overheat in the future. + if (rcCar.canOverheat()) { + renderOverheating(rcCar); + } + + renderSpeedometer(rcCar); + renderFuelBar(rcCar); + renderText(rcCar); + } + + private void renderBG(Locomotive rcCar) { + GL11.glEnable(3042); + GL11.glEnable(32826); + this.zLevel = -90.0F; + + if (rcCar instanceof SteamTrain) { + game.renderEngine.bindTexture(new ResourceLocation(Info.resourceLocation, Info.guiPrefix + "loco_hud_steam.png")); + } else { + game.renderEngine.bindTexture(new ResourceLocation(Info.resourceLocation, Info.guiPrefix + "locohud.png")); + } + + drawTexturedModalRect(10, windowHeight, 0, 150, 137, 90); + GL11.glDisable(32826); + GL11.glDisable(3042); + } + + private void renderText(Locomotive loco) { + double speed = loco.getSpeed(); + int h; + + if (loco instanceof SteamTrain) { + h = 15; + } else { + h = 13; + } + + GL11.glEnable(3042 /* GL_BLEND */); + GL11.glEnable(32826); + + fontRendererObj.drawStringWithShadow("Speed:", 106, windowHeight + 7 + (h), 0xFFFFFF); + fontRendererObj.drawStringWithShadow(" " + (int) Math.abs(((float) (speed))), 106, + windowHeight + 18 + (h), 0xFFFFFF); + fontRendererObj.drawStringWithShadow(" Km/h", 106, windowHeight + 29 + (h), 0xFFFFFF); + + if (loco.canOverheat()) { + fontRendererObj.drawStringWithShadow("State: " + loco.getState(), 50, windowHeight + 80, 0xFFFFFF); + } + + GL11.glDisable(32826); + GL11.glDisable(3042 /* GL_BLEND */); + } + + private void renderFuelBar(Locomotive loco) { + GL11.glEnable(3042 /* GL_BLEND */); + GL11.glEnable(32826); + int l; + + // So that the content of the tank is rendered and not the fuel current burned. + if (loco instanceof DieselTrain) { + l = ((((DieselTrain) loco).getDiesel())); + + l = Math.abs(((l * 70) / (((DieselTrain) loco).getCartTankCapacity()))); + } else { + // Scaled on 70 pixels. + l = loco.getFuelDiv(70); + } + + // To fit the 70 pixels bar. + if (l > 70) { + l = 70; + } + + if (l < 0) { + l = 0; + } + + // Steam trains have a different HUD. + if (loco instanceof SteamTrain) { + game.renderEngine.bindTexture(new ResourceLocation(Info.resourceLocation, Info.guiPrefix + "loco_hud_steam.png")); + } else { + game.renderEngine.bindTexture(new ResourceLocation(Info.resourceLocation, Info.guiPrefix + "locohud.png")); + } + + // Things are slightly different in the Steam HUD. + // Because it's a black bar that is rendered that hides the color bar the black bar is rendered from top to bottom. + if (!(loco instanceof SteamTrain)) { + drawTexturedModalRect(28, windowHeight + 11, 148, 150 + l, 7, 70 - l);// l max = 70 + } else { + drawTexturedModalRect(34, windowHeight + 17, 154, 170 + l, 9, 70 - l);// l max = 70 + } + + // fontRendererObj.drawStringWithShadow("Fuel:", 4, (windowHeight/2)+1, 0xFFFFFF); + GL11.glDisable(32826); + GL11.glDisable(3042 /* GL_BLEND */); + } + + private void renderWaterBar(Locomotive loco) { + int l = ((SteamTrain) loco).getWater(); + int l_Scaled = Math.abs((l * 49) / ((SteamTrain) loco).getCartTankCapacity()); + + // Scaled to fit the 49 pixel bar. + if (l_Scaled > 49) { + l_Scaled = 49; + } + + if (l_Scaled < 0) { + l_Scaled = 0; + } + + // Because it's a black bar that is rendered that hides the color bar hte black bar is rendered from top to bottom. + GL11.glEnable(3042 /* GL_BLEND */); + GL11.glEnable(32826); + drawTexturedModalRect(70, windowHeight + 17, 190, 169 + l_Scaled, 6, 49 - l_Scaled);// l max = 49 + GL11.glDisable(32826); + GL11.glDisable(3042 /* GL_BLEND */); + + // This is for the red overlay if you don't put water into steam trains. + if (l <= 1 && loco.getIsFuelled()) { + this.drawGradientRect(0, 0, windowWidth, windowHeight + 100, 1615855616, -1602211792); + } + } + + private void renderSpeedometer(Locomotive loco) { + double speed = loco.getSpeed(); + GL11.glEnable(3042); + GL11.glEnable(32826); + + // SteamTrain has a different HUD. + if (loco instanceof SteamTrain) { + game.renderEngine.bindTexture(new ResourceLocation(Info.resourceLocation, Info.guiPrefix + "loco_hud_steam.png")); + } else { + game.renderEngine.bindTexture(new ResourceLocation(Info.resourceLocation, Info.guiPrefix + "locohud.png")); + } + + // Scale the speed so that it doesn't go higher than 49 pixels. + double speedScaled = Math.abs((speed * 49) / 280); + if (speedScaled > 49) { + speedScaled = 49; + } + + // Things are slightly different in Steam HUD. + if (!(loco instanceof SteamTrain)) { + drawTexturedModalRect(75, windowHeight + 37 - ((int) speedScaled) + (20), 163, 150, 30, 5); + } else { + drawTexturedModalRect(84, windowHeight + 37 - ((int) speedScaled) + (20), 177, 149, 16, 8); + } + + GL11.glDisable(32826); + GL11.glDisable(3042); + } + + private void renderOverheating(Locomotive loco) { + int overheatLevel = loco.getOverheatLevel(); + if (overheatLevel > loco.getOverheatTime() + 30) { + overheatLevel = loco.getOverheatTime() + 30; + } + + // fontRendererObj.drawStringWithShadow("Heat:", 33, (windowHeight/2)+1, 0xFFFFFF); + GL11.glEnable(3042 /* GL_BLEND */); + GL11.glEnable(32826); + + // Steam trains have a different HUD. + if (loco instanceof SteamTrain) { + game.renderEngine.bindTexture(new ResourceLocation(Info.resourceLocation, Info.guiPrefix + "loco_hud_steam.png")); + } else { + game.renderEngine.bindTexture(new ResourceLocation(Info.resourceLocation, Info.guiPrefix + "locohud.png")); + } + + int overheatScaled = Math.abs((overheatLevel * 49) / (loco.getOverheatTime() + 30)); + if (overheatScaled > 49) { + overheatScaled = 49; + } + + // Things are slightly different in Steam HUD, render overheat arrow black bar for steam train. + if (!(loco instanceof SteamTrain)) { + drawTexturedModalRect(58, windowHeight + 37 - (overheatScaled) + (20), 169, 158, 23, 5); + } else { + drawTexturedModalRect(56, windowHeight + 17, 176, (169 + overheatScaled), 5, 49 - overheatScaled); + } + + GL11.glDisable(32826); + GL11.glDisable(3042 /* GL_BLEND */); + } } diff --git a/src/main/java/train/client/gui/sideTabs/SideTab.java b/src/main/java/train/client/gui/sideTabs/SideTab.java index a22c2ce1c1..0761da24c6 100644 --- a/src/main/java/train/client/gui/sideTabs/SideTab.java +++ b/src/main/java/train/client/gui/sideTabs/SideTab.java @@ -1,6 +1,6 @@ /******************************************************************************* * Copyright (c) 2012 Mrbrutal. All rights reserved. - * + * * @name TrainCraft * @author Mrbrutal ******************************************************************************/ @@ -20,171 +20,166 @@ @SideOnly(Side.CLIENT) public abstract class SideTab { + private boolean open; + private final boolean openX; + private final boolean openY; - private boolean open; - private boolean openX; - private boolean openY; + //true==left, false==right + protected boolean side; - //true==left, false==right - protected boolean side; + protected int overlayColor = 0xffffff; - protected int overlayColor = 0xffffff; + public int currentShiftX = 0; + public int currentShiftY = 0; - public int currentShiftX = 0; - public int currentShiftY = 0; + protected int maxWidth = 124; + protected int minWidth = 24; + protected int currentWidth = minWidth; - protected int maxWidth = 124; - protected int minWidth = 24; - protected int currentWidth = minWidth; + protected int maxHeight = 24; + protected int minHeight = 24; + protected int currentHeight = minHeight; - protected int maxHeight = 24; - protected int minHeight = 24; - protected int currentHeight = minHeight; + public GuiCrafterTier gui; + protected static FontRenderer fontRenderer = FMLClientHandler.instance().getClient().fontRenderer; + protected static SoundHandler soundManager = FMLClientHandler.instance().getClient().getSoundHandler(); - public GuiCrafterTier gui; - protected static FontRenderer fontRenderer = FMLClientHandler.instance().getClient().fontRenderer; - protected static SoundHandler soundManager = FMLClientHandler.instance().getClient().getSoundHandler(); + public SideTab(GuiCrafterTier gui, boolean side, boolean x, boolean y) { + this.gui = gui; + this.openX = x; + this.openY = y; + this.side = side; + } - public SideTab(GuiCrafterTier gui, boolean side, boolean x, boolean y) { - this.gui = gui; - this.openX = x; - this.openY = y; - this.side = side; - } + public void update() { + int offset = 2; - public void update() { - int offset = 2; - - if ((openX && openY) || (!openX && !openY)) { - // Width - if (open && currentWidth < maxWidth) + if ((openX && openY) || (!openX && !openY)) { + // Width + if (open && currentWidth < maxWidth) { currentWidth += offset; - else if (!open && currentWidth > minWidth) + } else if (!open && currentWidth > minWidth) { currentWidth -= offset; + } - // Height - if (open && currentHeight < maxHeight) + // Height + if (open && currentHeight < maxHeight) { currentHeight += offset; - else if (!open && currentHeight > minHeight) + } else if (!open && currentHeight > minHeight) { currentHeight -= offset; - } - else if (openX && !openY) { - // Width - if (open && currentWidth < maxWidth) + } + } else if (openX) { + // Width + if (open && currentWidth < maxWidth) { currentWidth += offset; - else if (!open && currentWidth > minWidth) + } else if (!open && currentWidth > minWidth) { currentWidth -= offset; - } - else { - // Height - if (open && currentHeight < maxHeight) + } + } else { + // Height + if (open && currentHeight < maxHeight) { currentHeight += offset; - else if (!open && currentHeight > minHeight) + } else if (!open && currentHeight > minHeight) { currentHeight -= offset; - } - } - - public int getHeight() { - return currentHeight; - } - - public abstract void draw(int x, int y); - - public abstract String getTooltip(); - - public boolean handleMouseClicked(int x, int y, int mouseButton) { - return false; - } - - public boolean intersectsWith(int mouseX, int mouseY, int shiftX, int shiftY) { - if (side) { - if (mouseX <= shiftX && mouseX >= shiftX - currentWidth && mouseY >= shiftY && mouseY <= shiftY + getHeight()) { - return true; - } - } - else { - if (mouseX >= shiftX && mouseX <= shiftX + currentWidth && mouseY >= shiftY && mouseY <= shiftY + getHeight()) { - return true; } - } - return false; - } - - public void setFullyOpen() { - open = true; - currentWidth = maxWidth; - currentHeight = maxHeight; - } - - public void toggleOpen() { - if (open) { - open = false; - SessionHelper.setOpenedLedger(null); - } - else { - open = true; - SessionHelper.setOpenedLedger(this.getClass()); - } - } - - public boolean isVisible() { - return true; - } - - public boolean isOpen() { - return this.open; - } - - public boolean isFullyOpened() { - return currentWidth >= maxWidth; - } - - public void drawBackground(int x, int y) { - String texture; - float colorR = (overlayColor >> 16 & 255) / 255.0F; - float colorG = (overlayColor >> 8 & 255) / 255.0F; - float colorB = (overlayColor & 255) / 255.0F; - - if (side) { - texture = Info.guiPrefix + "sideTab_left.png"; - - GL11.glColor4f(colorR, colorG, colorB, 1.0F); - - tmt.Tessellator.bindTexture(new ResourceLocation(Info.resourceLocation,texture)); - gui.drawTexturedModalRect(x + 24 - currentWidth, y + 2, 0, 256 - currentHeight + 2, 4, currentHeight - 2); - gui.drawTexturedModalRect(x + 28 - currentWidth, y, 256 - currentWidth + 4, 0, currentWidth - 4, 4); - // Add in top left corner again - gui.drawTexturedModalRect(x + 24 - currentWidth, y, 0, 0, 4, 4); - gui.drawTexturedModalRect(x + 28 - currentWidth, y + 4, 256 - currentWidth + 4, 256 - currentHeight + 4, currentWidth - 4, currentHeight - 4); - GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0F); - } - else { - texture = Info.guiPrefix + "sideTab_right.png"; - - GL11.glColor4f(colorR, colorG, colorB, 1.0F); - tmt.Tessellator.bindTexture(new ResourceLocation(Info.resourceLocation,texture)); - gui.drawTexturedModalRect(x, y, 0, 256 - currentHeight, 4, currentHeight); - gui.drawTexturedModalRect(x + 4, y, 256 - currentWidth + 4, 0, currentWidth - 4, 4); - // Add in top left corner again - gui.drawTexturedModalRect(x, y, 0, 0, 4, 4); - gui.drawTexturedModalRect(x + 4, y + 4, 256 - currentWidth + 4, 256 - currentHeight + 4, currentWidth - 4, currentHeight - 4); - GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0F); - } - } - - public void drawIcon(String texture, int iconIndex, int x, int y) { - tmt.Tessellator.bindTexture(new ResourceLocation(Info.resourceLocation,texture)); - if (side) { - GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0F); - int textureRow = iconIndex >> 4; - int textureColumn = iconIndex - 16 * textureRow; - gui.drawTexturedModalRect(x + 24 - currentWidth, y, 16 * textureColumn, 16 * textureRow, 16, 16); - } - else { - GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0F); - int textureRow = iconIndex >> 4; - int textureColumn = iconIndex - 16 * textureRow; - gui.drawTexturedModalRect(x, y, 16 * textureColumn, 16 * textureRow, 16, 16); - } - } + } + } + + public int getHeight() { + return currentHeight; + } + + public abstract void draw(int x, int y); + + public abstract String getTooltip(); + + public boolean handleMouseClicked(int x, int y, int mouseButton) { + return false; + } + + public boolean intersectsWith(int mouseX, int mouseY, int shiftX, int shiftY) { + if (side) { + return mouseX <= shiftX && mouseX >= shiftX - currentWidth && mouseY >= shiftY && mouseY <= shiftY + getHeight(); + } else { + return mouseX >= shiftX && mouseX <= shiftX + currentWidth && mouseY >= shiftY && mouseY <= shiftY + getHeight(); + } + } + + public void setFullyOpen() { + open = true; + currentWidth = maxWidth; + currentHeight = maxHeight; + } + + public void toggleOpen() { + if (open) { + open = false; + SessionHelper.setOpenedLedger(null); + } else { + open = true; + SessionHelper.setOpenedLedger(this.getClass()); + } + } + + public boolean isVisible() { + return true; + } + + public boolean isOpen() { + return this.open; + } + + public boolean isFullyOpened() { + return currentWidth >= maxWidth; + } + + public void drawBackground(int x, int y) { + String texture; + float colorR = (overlayColor >> 16 & 255) / 255.0F; + float colorG = (overlayColor >> 8 & 255) / 255.0F; + float colorB = (overlayColor & 255) / 255.0F; + + if (side) { + texture = Info.guiPrefix + "sideTab_left.png"; + + GL11.glColor4f(colorR, colorG, colorB, 1.0F); + + tmt.Tessellator.bindTexture(new ResourceLocation(Info.resourceLocation, texture)); + gui.drawTexturedModalRect(x + 24 - currentWidth, y + 2, 0, 256 - currentHeight + 2, 4, currentHeight - 2); + gui.drawTexturedModalRect(x + 28 - currentWidth, y, 256 - currentWidth + 4, 0, currentWidth - 4, 4); + + // Add in top left corner again + gui.drawTexturedModalRect(x + 24 - currentWidth, y, 0, 0, 4, 4); + gui.drawTexturedModalRect(x + 28 - currentWidth, y + 4, 256 - currentWidth + 4, 256 - currentHeight + 4, currentWidth - 4, currentHeight - 4); + GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0F); + } else { + texture = Info.guiPrefix + "sideTab_right.png"; + + GL11.glColor4f(colorR, colorG, colorB, 1.0F); + tmt.Tessellator.bindTexture(new ResourceLocation(Info.resourceLocation, texture)); + gui.drawTexturedModalRect(x, y, 0, 256 - currentHeight, 4, currentHeight); + gui.drawTexturedModalRect(x + 4, y, 256 - currentWidth + 4, 0, currentWidth - 4, 4); + + // Add in top left corner again + gui.drawTexturedModalRect(x, y, 0, 0, 4, 4); + gui.drawTexturedModalRect(x + 4, y + 4, 256 - currentWidth + 4, 256 - currentHeight + 4, currentWidth - 4, currentHeight - 4); + GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0F); + } + } + + public void drawIcon(String texture, int iconIndex, int x, int y) { + tmt.Tessellator.bindTexture(new ResourceLocation(Info.resourceLocation, texture)); + + if (side) { + GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0F); + int textureRow = iconIndex >> 4; + int textureColumn = iconIndex - 16 * textureRow; + gui.drawTexturedModalRect(x + 24 - currentWidth, y, 16 * textureColumn, 16 * textureRow, 16, 16); + } else { + GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0F); + int textureRow = iconIndex >> 4; + int textureColumn = iconIndex - 16 * textureRow; + gui.drawTexturedModalRect(x, y, 16 * textureColumn, 16 * textureRow, 16, 16); + } + } } diff --git a/src/main/java/train/client/gui/sideTabs/SideTabInfo.java b/src/main/java/train/client/gui/sideTabs/SideTabInfo.java index 56439eafe9..0f055db6ae 100644 --- a/src/main/java/train/client/gui/sideTabs/SideTabInfo.java +++ b/src/main/java/train/client/gui/sideTabs/SideTabInfo.java @@ -1,6 +1,6 @@ /******************************************************************************* * Copyright (c) 2012 Mrbrutal. All rights reserved. - * + * * @name TrainCraft * @author Mrbrutal ******************************************************************************/ @@ -16,57 +16,57 @@ @SideOnly(Side.CLIENT) public class SideTabInfo extends SideTab { + private final static int headerColour = 0x192c4f; + private final static int underColor = 0xa0a0a0; + private final String[] names; - private int headerColour = 0x192c4f; - private int underColor = 0xa0a0a0; - private String[] names; + public SideTabInfo(GuiCrafterTier gui, boolean side, boolean x, boolean y, String[] names) { + super(gui, side, x, y); + maxHeight = 106; + overlayColor = 0xd3a900; + this.names = names; + } - public SideTabInfo(GuiCrafterTier gui, boolean side, boolean x, boolean y, String[] names) { - super(gui, side, x, y); - maxHeight = 106; - overlayColor = 0xd3a900; - this.names = names; - } + @Override + public void draw(int x, int y) { + // Draw background + drawBackground(x, y); - @Override - public void draw(int x, int y) { - // Draw background - drawBackground(x, y); + // Draw icon + drawIcon((Info.guiPrefix + "Icons.png"), 0, x + 4, y + 4); - // Draw icon - drawIcon((Info.guiPrefix + "Icons.png"), 0, x + 4, y + 4); - - if (!isFullyOpened()) + if (!isFullyOpened()) { return; + } - fontRenderer.drawString("Slot information", x - 69, y + 8, underColor); - fontRenderer.drawString("Slot information", x - 70, y + 8, headerColour); + fontRenderer.drawString("Slot information", x - 69, y + 8, underColor); + fontRenderer.drawString("Slot information", x - 70, y + 8, headerColour); - drawRect(x - 83, y + 20, -90, 107, 0xff524100); - drawRect(x - 82, y + 19, -91, 108, 0xff524100); + drawRect(x - 83, y + 20, -90, 107, 0xff524100); + drawRect(x - 82, y + 19, -91, 108, 0xff524100); - drawRect(x - 63, y + 20, -10, 107, 0xff524100); - drawRect(x - 62, y + 19, -11, 108, 0xff524100); + drawRect(x - 63, y + 20, -10, 107, 0xff524100); + drawRect(x - 62, y + 19, -11, 108, 0xff524100); - for (int i = 0; i < 10; i++) { - fontRenderer.drawString(names[i], x - 59, y + 20 + i * 8, underColor); - fontRenderer.drawString("" + (i + 1), x - 80, y + 20 + i * 8, underColor); - } + for (int i = 0; i < 10; i++) { + fontRenderer.drawString(names[i], x - 59, y + 20 + i * 8, underColor); + fontRenderer.drawString("" + (i + 1), x - 80, y + 20 + i * 8, underColor); + } - fontRenderer.drawString("1", x + 49, y + 19, 0xffffff); - fontRenderer.drawString("2", x + 103, y + 19, 0xffffff); - fontRenderer.drawString("3", x + 139, y + 19, 0xffffff); - fontRenderer.drawString("4", x + 169, y + 19, 0xffffff); - fontRenderer.drawString("5", x + 49, y + 53, 0xffffff); - fontRenderer.drawString("6", x + 103, y + 53, 0xffffff); - fontRenderer.drawString("7", x + 139, y + 53, 0xffffff); - fontRenderer.drawString("8", x + 67, y + 85, 0xffffff); - fontRenderer.drawString("9", x + 103, y + 85, 0xffffff); - fontRenderer.drawString("10", x + 169, y + 85, 0xffffff); - } + fontRenderer.drawString("1", x + 49, y + 19, 0xffffff); + fontRenderer.drawString("2", x + 103, y + 19, 0xffffff); + fontRenderer.drawString("3", x + 139, y + 19, 0xffffff); + fontRenderer.drawString("4", x + 169, y + 19, 0xffffff); + fontRenderer.drawString("5", x + 49, y + 53, 0xffffff); + fontRenderer.drawString("6", x + 103, y + 53, 0xffffff); + fontRenderer.drawString("7", x + 139, y + 53, 0xffffff); + fontRenderer.drawString("8", x + 67, y + 85, 0xffffff); + fontRenderer.drawString("9", x + 103, y + 85, 0xffffff); + fontRenderer.drawString("10", x + 169, y + 85, 0xffffff); + } - @Override - public String getTooltip() { - return "Info"; - } + @Override + public String getTooltip() { + return "Info"; + } } diff --git a/src/main/java/train/client/gui/sideTabs/SideTabManager.java b/src/main/java/train/client/gui/sideTabs/SideTabManager.java index bd6d1796be..a6689b2a30 100644 --- a/src/main/java/train/client/gui/sideTabs/SideTabManager.java +++ b/src/main/java/train/client/gui/sideTabs/SideTabManager.java @@ -1,6 +1,6 @@ /******************************************************************************* * Copyright (c) 2012 Mrbrutal. All rights reserved. - * + * * @name TrainCraft * @author Mrbrutal ******************************************************************************/ @@ -16,180 +16,193 @@ import train.client.gui.GuiTraincraft; import java.util.ArrayList; +import java.util.List; @SideOnly(Side.CLIENT) public class SideTabManager { - private GuiTraincraft gui; - protected ArrayList sideTabLeft = new ArrayList(); - protected ArrayList sideTabRight = new ArrayList(); - - protected static FontRenderer fontRenderer = FMLClientHandler.instance().getClient().fontRenderer; - - public SideTabManager(GuiTraincraft gui) { - this.gui = gui; - } - - public void add(SideTab tab) { - if (tab.side) { - this.sideTabLeft.add(tab); - if (SessionHelper.getOpenedLedger() != null && tab.getClass().equals(SessionHelper.getOpenedLedger())) { - tab.setFullyOpen(); - } - } - else { - this.sideTabRight.add(tab); - if (SessionHelper.getOpenedLedger() != null && tab.getClass().equals(SessionHelper.getOpenedLedger())) { - tab.setFullyOpen(); - } - } - } - - /** - * Inserts a tab into the next-to-last position. - * - * @param tab - */ - public void insert(SideTab tab) { - if (tab.side) { - this.sideTabLeft.add(sideTabLeft.size() - 1, tab); - } - else { - this.sideTabRight.add(sideTabRight.size() - 1, tab); - } - } - - public SideTab getAtPosition(int mX, int mY) { - int xShift = ((gui.width - 176) / 2); - int yShift = ((gui.height - 256) / 2) + 8; - - for (SideTab tab : sideTabLeft) { - if (!tab.isVisible()) - continue; - - tab.currentShiftX = xShift; - tab.currentShiftY = yShift; - if (tab.intersectsWith(mX, mY, xShift, yShift)) - return tab; - - yShift += tab.getHeight(); - } - - xShift = ((gui.width - 176) / 2) + 176; - yShift = ((gui.height - 256) / 2) + 8; - - for (SideTab tab : sideTabRight) { - if (!tab.isVisible()) - continue; - - tab.currentShiftX = xShift; - tab.currentShiftY = yShift; - if (tab.intersectsWith(mX, mY, xShift, yShift)) - return tab; - - yShift += tab.getHeight(); - } - return null; - } - - public void drawSideTabs(int mouseX, int mouseY) { - int xPos = 8; - for (SideTab tab : sideTabLeft) { - tab.update(); - if (!tab.isVisible()) - continue; - - tab.draw(-24, xPos); - xPos += tab.getHeight(); - } - - xPos = 8; - for (SideTab tab : sideTabRight) { - tab.update(); - if (!tab.isVisible()) - continue; - - tab.draw(176, xPos); - xPos += tab.getHeight(); - } - SideTab tab = getAtPosition(mouseX, mouseY); - if (tab != null) { - if (tab.side) { - String tooltip = tab.getTooltip(); - int textWidth = fontRenderer.getStringWidth(tooltip); - int startX = mouseX - ((gui.width - 176) / 2) - textWidth - 14; - int startY = mouseY - ((gui.height - 256) / 2) - 12; - - int i4 = 0xf0100010; - int h = 8; - gui.drawGradientRect(startX - 3, startY - 4, startX + textWidth + 3, startY + 8 + 4, i4, i4); - gui.drawGradientRect(startX - 4, startY - 3, startX + textWidth + 4, startY + 8 + 3, i4, i4); - int colour1 = 0x505000ff; - int colour2 = (colour1 & 0xfefefe) >> 1 | colour1 & 0xff000000; - gui.drawGradientRect(startX - 3, startY - 3, startX + textWidth + 3, startY + 8 + 3, colour1, colour2); - gui.drawGradientRect(startX - 2, startY - 2, startX + textWidth + 2, startY + 8 + 2, i4, i4); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_DEPTH_TEST); - fontRenderer.drawStringWithShadow(tooltip, startX, startY, -1); - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glEnable(GL11.GL_DEPTH_TEST); - } - else { - int startX = mouseX - ((gui.width - 176) / 2) + 12; - int startY = mouseY - ((gui.height - 256) / 2) - 12; - - String tooltip = tab.getTooltip(); - int textWidth = fontRenderer.getStringWidth(tooltip); - gui.drawGradientRect(startX - 3, startY - 3, startX + textWidth + 3, startY + 8 + 3, 0xc0000000, 0xc0000000); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_DEPTH_TEST); - fontRenderer.drawStringWithShadow(tooltip, startX, startY, -1); - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glEnable(GL11.GL_DEPTH_TEST); - } - } - } - - public void handleMouseClicked(int x, int y, int mouseButton) { - if (mouseButton == 0) { - SideTab tab = this.getAtPosition(x, y); - if (tab != null) { - if (tab.side) { - if (!tab.handleMouseClicked(x, y, mouseButton)) { - for (SideTab other : sideTabLeft) - if (other != tab && other.isOpen()) - other.toggleOpen(); - tab.toggleOpen(); - } - } - else { - if (!tab.handleMouseClicked(x, y, mouseButton)) { - for (SideTab other : sideTabRight) - if (other != tab && other.isOpen()) - other.toggleOpen(); - tab.toggleOpen(); - } - } - } - } - } - - public void handleMouseOver(SideTab tab) { - if (tab.side) { - for (SideTab other : sideTabLeft) { - if (other != tab && other.isOpen()) { - other.toggleOpen(); - } - tab.toggleOpen(); - } - } - else { - for (SideTab other : sideTabRight) { - if (other != tab && other.isOpen()) { - other.toggleOpen(); - } - tab.toggleOpen(); - } - } - } + private final GuiTraincraft gui; + protected List sideTabLeft = new ArrayList<>(); + protected List sideTabRight = new ArrayList<>(); + + protected static FontRenderer fontRenderer = FMLClientHandler.instance().getClient().fontRenderer; + + public SideTabManager(GuiTraincraft gui) { + this.gui = gui; + } + + public void add(SideTab tab) { + if (tab.side) { + this.sideTabLeft.add(tab); + } else { + this.sideTabRight.add(tab); + } + + if (SessionHelper.getOpenedLedger() != null && tab.getClass().equals(SessionHelper.getOpenedLedger())) { + tab.setFullyOpen(); + } + } + + /** + * Inserts a tab into the next-to-last position. + * + * @param tab The tab to insert. + */ + public void insert(SideTab tab) { + if (tab.side) { + this.sideTabLeft.add(sideTabLeft.size() - 1, tab); + } else { + this.sideTabRight.add(sideTabRight.size() - 1, tab); + } + } + + public SideTab getAtPosition(int mX, int mY) { + int xShift = ((gui.width - 176) / 2); + int yShift = ((gui.height - 256) / 2) + 8; + + for (SideTab tab : sideTabLeft) { + if (!tab.isVisible()) { + continue; + } + + tab.currentShiftX = xShift; + tab.currentShiftY = yShift; + if (tab.intersectsWith(mX, mY, xShift, yShift)) { + return tab; + } + + yShift += tab.getHeight(); + } + + xShift = ((gui.width - 176) / 2) + 176; + yShift = ((gui.height - 256) / 2) + 8; + + for (SideTab tab : sideTabRight) { + if (!tab.isVisible()) + continue; + + tab.currentShiftX = xShift; + tab.currentShiftY = yShift; + if (tab.intersectsWith(mX, mY, xShift, yShift)) + return tab; + + yShift += tab.getHeight(); + } + return null; + } + + public void drawSideTabs(int mouseX, int mouseY) { + int yPos = 8; + for (SideTab tab : sideTabLeft) { + tab.update(); + if (!tab.isVisible()) + continue; + + tab.draw(-24, yPos); + yPos += tab.getHeight(); + } + + yPos = 8; + for (SideTab tab : sideTabRight) { + tab.update(); + if (!tab.isVisible()) + continue; + + tab.draw(176, yPos); + yPos += tab.getHeight(); + } + SideTab tab = getAtPosition(mouseX, mouseY); + if (tab == null) { + return; + } + + if (tab.side) { + String tooltip = tab.getTooltip(); + int textWidth = fontRenderer.getStringWidth(tooltip); + int startX = mouseX - ((gui.width - 176) / 2) - textWidth - 14; + int startY = mouseY - ((gui.height - 256) / 2) - 12; + int i4 = 0xf0100010; + int h = 8; + int colour1 = 0x505000ff; + int colour2 = (colour1 & 0xfefefe) >> 1 | colour1 & 0xff000000; + + gui.drawGradientRect(startX - 3, startY - 4, startX + textWidth + 3, startY + 8 + 4, i4, i4); + gui.drawGradientRect(startX - 4, startY - 3, startX + textWidth + 4, startY + 8 + 3, i4, i4); + gui.drawGradientRect(startX - 3, startY - 3, startX + textWidth + 3, startY + 8 + 3, colour1, colour2); + gui.drawGradientRect(startX - 2, startY - 2, startX + textWidth + 2, startY + 8 + 2, i4, i4); + + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_DEPTH_TEST); + + fontRenderer.drawStringWithShadow(tooltip, startX, startY, -1); + + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_DEPTH_TEST); + } else { + int startX = mouseX - ((gui.width - 176) / 2) + 12; + int startY = mouseY - ((gui.height - 256) / 2) - 12; + + String tooltip = tab.getTooltip(); + int textWidth = fontRenderer.getStringWidth(tooltip); + + gui.drawGradientRect(startX - 3, startY - 3, startX + textWidth + 3, startY + 8 + 3, 0xc0000000, 0xc0000000); + + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_DEPTH_TEST); + + fontRenderer.drawStringWithShadow(tooltip, startX, startY, -1); + + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_DEPTH_TEST); + } + } + + public void handleMouseClicked(int x, int y, int mouseButton) { + if (mouseButton != 0) { + return; + } + + SideTab tab = this.getAtPosition(x, y); + if (tab == null) { + return; + } + + if (tab.side) { + if (!tab.handleMouseClicked(x, y, mouseButton)) { + for (SideTab other : sideTabLeft) { + if (other != tab && other.isOpen()) { + other.toggleOpen(); + } + } + tab.toggleOpen(); + } + } else { + if (!tab.handleMouseClicked(x, y, mouseButton)) { + for (SideTab other : sideTabRight) { + if (other != tab && other.isOpen()) { + other.toggleOpen(); + } + } + tab.toggleOpen(); + } + } + } + + public void handleMouseOver(SideTab tab) { + if (tab.side) { + for (SideTab other : sideTabLeft) { + if (other != tab && other.isOpen()) { + other.toggleOpen(); + } + tab.toggleOpen(); + } + } else { + for (SideTab other : sideTabRight) { + if (other != tab && other.isOpen()) { + other.toggleOpen(); + } + tab.toggleOpen(); + } + } + } } diff --git a/src/main/java/train/client/gui/sideTabs/SideTabRecipes.java b/src/main/java/train/client/gui/sideTabs/SideTabRecipes.java index 957742c7b0..6768315173 100644 --- a/src/main/java/train/client/gui/sideTabs/SideTabRecipes.java +++ b/src/main/java/train/client/gui/sideTabs/SideTabRecipes.java @@ -1,6 +1,6 @@ /******************************************************************************* * Copyright (c) 2012 Mrbrutal. All rights reserved. - * + * * @name TrainCraft * @author Mrbrutal ******************************************************************************/ @@ -22,121 +22,111 @@ @SideOnly(Side.CLIENT) public class SideTabRecipes extends SideTab { - - protected int headerColour = 0xbd9700; - protected GuiCrafterTier gui; - - public SideTabRecipes(GuiCrafterTier gui, boolean side, boolean x, boolean y) { - super(gui, side, x, y); - this.gui = gui; - maxHeight = 94; - overlayColor = 0x757f90; - } - - @Override - public void draw(int x, int y) { - // Draw background - drawBackground(x, y); - - // Draw icon - drawIcon(Info.guiPrefix + "Icons.png", 1, x + 4, y + 4); - - if (!isFullyOpened()){ - isTabRecipeOpen=false; - return; - } - isTabRecipeOpen=true; - - fontRenderer.drawString("Known recipes:", x - 69, y + 8, 0x000000); - fontRenderer.drawString("Known recipes:", x - 70, y + 8, headerColour); - - //293240 - tmt.Tessellator.bindTexture(new ResourceLocation(Info.resourceLocation,Info.guiPrefix + "Icons.png")); - - drawRect(x - 59, y + 30, -40, 85, 0xff293240); - drawRect(x - 58, y + 29, -41, 86, 0xff293240); - - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - gui.drawTexturedModalRect(x - 76, y + 34, 0, 64, 16, 16); - gui.drawTexturedModalRect(x - 16, y + 34, 16, 64, 16, 16); - - gui.drawTexturedModalRect(x - 76, y + 58, 32, 64, 32, 16); - gui.drawTexturedModalRect(x - 32, y + 58, 64, 64, 32, 16); - - if (recipes.size() == 0) { - fontRenderer.drawString("No recipes found", x - 93, y + 78, headerColour); - tmt.Tessellator.bindTexture(new ResourceLocation(Info.resourceLocation,Info.guiPrefix + "Icons.png")); - gui.drawTexturedModalRect(x - 46, y + 33, 0, 16, 16, 16); - gui.currentKnownItem=null; - } - else { - Item item = null; - if (recipeSize == -1) { - item = recipes.get(0); - } - else if (recipeSize == recipes.size() && recipeSize != 0) { - item = recipes.get(recipes.size() - 1); - } - else if (recipeSize > recipes.size()) { - item = recipes.get(recipeSize - 1); - } - else { - item = recipes.get(recipeSize); - } - - if (item != null) { - fontRenderer.drawString(StatCollector.translateToLocal(item.getUnlocalizedName()), x - 93, y + 78, headerColour); - gui.currentKnownItem = item; - } - else { - fontRenderer.drawString("Item name not found", x - 93, y + 78, headerColour); - } - - if (this.isFullyOpened()) { - gui.drawRecipes(recipeSize, recipes, x - 46, y + 33); - } - } - } - - @Override - public boolean handleMouseClicked(int x, int y, int mouseButton) { - x -= this.currentShiftX; - y -= this.currentShiftY; - - if (!isFullyOpened()) { - return false; - } - else { - if ((x > -98 && x < -88) && (y < 49 && y > 33)) { - soundManager.playSound(PositionedSoundRecord.func_147673_a(new ResourceLocation("random.click"))); - recipeSize--; - return true; - } - else if ((x > -36 && x < -10) && (y < 49 && y > 33)) { - soundManager.playSound(PositionedSoundRecord.func_147673_a(new ResourceLocation("random.click"))); - recipeSize++; - return true; - } - else if ((x > -98 && x < -71) && (y < 71 && y > 61)) { - soundManager.playSound(PositionedSoundRecord.func_147673_a(new ResourceLocation("random.click"))); - isShow = true; - isClear = false; - return true; - } - else if ((x > -54 && x < -26) && (y < 71 && y > 61)) { - soundManager.playSound(PositionedSoundRecord.func_147673_a(new ResourceLocation("random.click"))); - isClear = true; - isShow = false; - return true; - } - else { - return false; - } - } - } - - @Override - public String getTooltip() { - return "Recipes (" + tier1.knownRecipes().size() + ")"; - } + protected int headerColour = 0xbd9700; + protected GuiCrafterTier gui; + + public SideTabRecipes(GuiCrafterTier gui, boolean side, boolean x, boolean y) { + super(gui, side, x, y); + this.gui = gui; + maxHeight = 94; + overlayColor = 0x757f90; + } + + @Override + public void draw(int x, int y) { + // Draw background + drawBackground(x, y); + + // Draw icon + drawIcon(Info.guiPrefix + "Icons.png", 1, x + 4, y + 4); + + if (!isFullyOpened()) { + isTabRecipeOpen = false; + return; + } + + isTabRecipeOpen = true; + + fontRenderer.drawString("Known recipes:", x - 69, y + 8, 0x000000); + fontRenderer.drawString("Known recipes:", x - 70, y + 8, headerColour); + + //293240 + tmt.Tessellator.bindTexture(new ResourceLocation(Info.resourceLocation, Info.guiPrefix + "Icons.png")); + + drawRect(x - 59, y + 30, -40, 85, 0xff293240); + drawRect(x - 58, y + 29, -41, 86, 0xff293240); + + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + gui.drawTexturedModalRect(x - 76, y + 34, 0, 64, 16, 16); + gui.drawTexturedModalRect(x - 16, y + 34, 16, 64, 16, 16); + + gui.drawTexturedModalRect(x - 76, y + 58, 32, 64, 32, 16); + gui.drawTexturedModalRect(x - 32, y + 58, 64, 64, 32, 16); + + if (recipes.isEmpty()) { + fontRenderer.drawString("No recipes found", x - 93, y + 78, headerColour); + tmt.Tessellator.bindTexture(new ResourceLocation(Info.resourceLocation, Info.guiPrefix + "Icons.png")); + gui.drawTexturedModalRect(x - 46, y + 33, 0, 16, 16, 16); + gui.currentKnownItem = null; + } else { + Item item; + if (recipeSize == -1) { + item = recipes.get(0); + } else if (recipeSize == recipes.size()) { + item = recipes.get(recipes.size() - 1); + } else if (recipeSize > recipes.size()) { + item = recipes.get(recipeSize - 1); + } else { + item = recipes.get(recipeSize); + } + + if (item != null) { + fontRenderer.drawString(StatCollector.translateToLocal(item.getUnlocalizedName()), x - 93, y + 78, headerColour); + gui.currentKnownItem = item; + } else { + fontRenderer.drawString("Item name not found", x - 93, y + 78, headerColour); + } + + if (this.isFullyOpened()) { + gui.drawRecipes(recipeSize, recipes, x - 46, y + 33); + } + } + } + + @Override + public boolean handleMouseClicked(int x, int y, int mouseButton) { + x -= this.currentShiftX; + y -= this.currentShiftY; + + if (!isFullyOpened()) { + return false; + } else { + if ((x > -98 && x < -88) && (y < 49 && y > 33)) { + soundManager.playSound(PositionedSoundRecord.func_147673_a(new ResourceLocation("random.click"))); + recipeSize--; + return true; + } else if ((x > -36 && x < -10) && (y < 49 && y > 33)) { + soundManager.playSound(PositionedSoundRecord.func_147673_a(new ResourceLocation("random.click"))); + recipeSize++; + return true; + } else if ((x > -98 && x < -71) && (y < 71 && y > 61)) { + soundManager.playSound(PositionedSoundRecord.func_147673_a(new ResourceLocation("random.click"))); + isShow = true; + isClear = false; + return true; + } else if ((x > -54 && x < -26) && (y < 71 && y > 61)) { + soundManager.playSound(PositionedSoundRecord.func_147673_a(new ResourceLocation("random.click"))); + isClear = true; + isShow = false; + return true; + } else { + return false; + } + } + } + + @Override + public String getTooltip() { + return "Recipes (" + tier1.knownRecipes().size() + ")"; + } } diff --git a/src/main/java/train/client/gui/sideTabs/SideTabSlots.java b/src/main/java/train/client/gui/sideTabs/SideTabSlots.java index 744476e1e4..2af2c98b8f 100644 --- a/src/main/java/train/client/gui/sideTabs/SideTabSlots.java +++ b/src/main/java/train/client/gui/sideTabs/SideTabSlots.java @@ -1,6 +1,6 @@ /******************************************************************************* * Copyright (c) 2012 Mrbrutal. All rights reserved. - * + * * @name TrainCraft * @author Mrbrutal ******************************************************************************/ @@ -21,59 +21,60 @@ @SideOnly(Side.CLIENT) public class SideTabSlots extends SideTab { - protected ITier tile; - protected int headerColour = 0xbd9700; - protected int[] array; + protected ITier tile; + protected int headerColour = 0xbd9700; + protected int[] array; - public SideTabSlots(ITier tile, GuiCrafterTier gui, boolean side, boolean x, boolean y, int[] array) { - super(gui, side, x, y); - maxHeight = 94; - overlayColor = 0x192c4f; - this.array = array; - this.tile = tile; - } - - @Override - public void draw(int x, int y) { - // Draw background - drawBackground(x, y); + public SideTabSlots(ITier tile, GuiCrafterTier gui, boolean side, boolean x, boolean y, int[] array) { + super(gui, side, x, y); - // Draw icon - drawIcon(Info.guiPrefix + "Icons.png", 2, x + 4, y + 4); - - if (!isFullyOpened()) - return; - - fontRenderer.drawString("Output slot", x - 69, y + 8, 0x000000); - fontRenderer.drawString("Output slot", x - 70, y + 8, headerColour); + this.tile = tile; + this.array = array; - tmt.Tessellator.bindTexture(new ResourceLocation(Info.resourceLocation,Info.guiPrefix + "Icons.png")); + this.maxHeight = 94; + this.overlayColor = 0x192c4f; + } - drawRect(x - 91, y + 30, -4, 135, 0xff02142d); - drawRect(x - 90, y + 29, -5, 136, 0xff02142d); + @Override + public void draw(int x, int y) { + // Draw background + drawBackground(x, y); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + // Draw icon + drawIcon(Info.guiPrefix + "Icons.png", 2, x + 4, y + 4); - for (int i = 0; i < 4; i++) { - if (array[i] == 0) { - gui.drawTexturedModalRect(x - 86 + i * 28, y + 34, i * 16, 32, 16, 16); - } - else { - gui.drawTexturedModalRect(x - 86 + i * 28, y + 34, i * 16, 48, 16, 16); - } - } - for (int i = 0; i < 4; i++) { - if (array[i + 4] == 0) { - gui.drawTexturedModalRect(x - 86 + i * 28, y + 58, 64 + i * 16, 32, 16, 16); - } - else { - gui.drawTexturedModalRect(x - 86 + i * 28, y + 58, 64 + i * 16, 48, 16, 16); - } + if (!isFullyOpened()) { + return; } - } - @Override - public boolean handleMouseClicked(int x, int y, int mouseButton) { + fontRenderer.drawString("Output slot", x - 69, y + 8, 0x000000); + fontRenderer.drawString("Output slot", x - 70, y + 8, headerColour); + + tmt.Tessellator.bindTexture(new ResourceLocation(Info.resourceLocation, Info.guiPrefix + "Icons.png")); + + drawRect(x - 91, y + 30, -4, 135, 0xff02142d); + drawRect(x - 90, y + 29, -5, 136, 0xff02142d); + + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + + for (int i = 0; i < 4; i++) { + if (array[i] == 0) { + gui.drawTexturedModalRect(x - 86 + i * 28, y + 34, i * 16, 32, 16, 16); + } else { + gui.drawTexturedModalRect(x - 86 + i * 28, y + 34, i * 16, 48, 16, 16); + } + } + for (int i = 0; i < 4; i++) { + if (array[i + 4] == 0) { + gui.drawTexturedModalRect(x - 86 + i * 28, y + 58, 64 + i * 16, 32, 16, 16); + } else { + gui.drawTexturedModalRect(x - 86 + i * 28, y + 58, 64 + i * 16, 48, 16, 16); + } + } + } + + @Override + public boolean handleMouseClicked(int x, int y, int mouseButton) { x -= this.currentShiftX; y -= this.currentShiftY; @@ -82,63 +83,54 @@ public boolean handleMouseClicked(int x, int y, int mouseButton) { if (!isFullyOpened()) { return false; } - else { - if ((x > -110 && x < -94) && (y < 49 && y > 33)) { - soundManager.playSound(PositionedSoundRecord.func_147673_a(new ResourceLocation("random.click"))); - current = array[0]; - array[0] = current == 0 ? 1 : 0; - return true; - } - else if ((x > -82 && x < -66) && (y < 49 && y > 33)) { - soundManager.playSound(PositionedSoundRecord.func_147673_a(new ResourceLocation("random.click"))); - current = array[1]; - array[1] = current == 0 ? 1 : 0; - return true; - } - else if ((x > -54 && x < -38) && (y < 49 && y > 33)) { - soundManager.playSound(PositionedSoundRecord.func_147673_a(new ResourceLocation("random.click"))); - current = array[2]; - array[2] = current == 0 ? 1 : 0; - return true; - } - else if ((x > -26 && x < -10) && (y < 49 && y > 33)) { - soundManager.playSound(PositionedSoundRecord.func_147673_a(new ResourceLocation("random.click"))); - current = array[3]; - array[3] = current == 0 ? 1 : 0; - return true; - } - else if ((x > -110 && x < -94) && (y < 72 && y > 58)) { - soundManager.playSound(PositionedSoundRecord.func_147673_a(new ResourceLocation("random.click"))); - current = array[4]; - array[4] = current == 0 ? 1 : 0; - return true; - } - else if ((x > -82 && x < -66) && (y < 72 && y > 58)) { - soundManager.playSound(PositionedSoundRecord.func_147673_a(new ResourceLocation("random.click"))); - current = array[5]; - array[5] = current == 0 ? 1 : 0; - return true; - } - else if ((x > -54 && x < -38) && (y < 72 && y > 58)) { - soundManager.playSound(PositionedSoundRecord.func_147673_a(new ResourceLocation("random.click"))); - current = array[6]; - array[6] = current == 0 ? 1 : 0; - return true; - } - else if ((x > -26 && x < -10) && (y < 72 && y > 58)) { - soundManager.playSound(PositionedSoundRecord.func_147673_a(new ResourceLocation("random.click"))); - current = array[7]; - array[7] = current == 0 ? 1 : 0; - return true; - } - else { - return false; - } + + if ((x > -110 && x < -94) && (y < 49 && y > 33)) { + soundManager.playSound(PositionedSoundRecord.func_147673_a(new ResourceLocation("random.click"))); + current = array[0]; + array[0] = current == 0 ? 1 : 0; + return true; + } else if ((x > -82 && x < -66) && (y < 49 && y > 33)) { + soundManager.playSound(PositionedSoundRecord.func_147673_a(new ResourceLocation("random.click"))); + current = array[1]; + array[1] = current == 0 ? 1 : 0; + return true; + } else if ((x > -54 && x < -38) && (y < 49 && y > 33)) { + soundManager.playSound(PositionedSoundRecord.func_147673_a(new ResourceLocation("random.click"))); + current = array[2]; + array[2] = current == 0 ? 1 : 0; + return true; + } else if ((x > -26 && x < -10) && (y < 49 && y > 33)) { + soundManager.playSound(PositionedSoundRecord.func_147673_a(new ResourceLocation("random.click"))); + current = array[3]; + array[3] = current == 0 ? 1 : 0; + return true; + } else if ((x > -110 && x < -94) && (y < 72 && y > 58)) { + soundManager.playSound(PositionedSoundRecord.func_147673_a(new ResourceLocation("random.click"))); + current = array[4]; + array[4] = current == 0 ? 1 : 0; + return true; + } else if ((x > -82 && x < -66) && (y < 72 && y > 58)) { + soundManager.playSound(PositionedSoundRecord.func_147673_a(new ResourceLocation("random.click"))); + current = array[5]; + array[5] = current == 0 ? 1 : 0; + return true; + } else if ((x > -54 && x < -38) && (y < 72 && y > 58)) { + soundManager.playSound(PositionedSoundRecord.func_147673_a(new ResourceLocation("random.click"))); + current = array[6]; + array[6] = current == 0 ? 1 : 0; + return true; + } else if ((x > -26 && x < -10) && (y < 72 && y > 58)) { + soundManager.playSound(PositionedSoundRecord.func_147673_a(new ResourceLocation("random.click"))); + current = array[7]; + array[7] = current == 0 ? 1 : 0; + return true; + } else { + return false; } } - @Override - public String getTooltip() { - return "Slots"; - } + @Override + public String getTooltip() { + return "Slots"; + } } From 8dbc350f75cd1fe8d84a061ee5404098c5012a64 Mon Sep 17 00:00:00 2001 From: Paul19988 Date: Wed, 22 Nov 2023 21:56:35 +0000 Subject: [PATCH 2/2] clean core --- .../train/client/TechneModelRenderer.java | 73 +- .../client/core/AlphaExpiredException.java | 25 +- .../java/train/client/core/ClientProxy.java | 496 +- .../core/handlers/ClientTickHandler.java | 93 +- .../core/handlers/CustomRenderHandler.java | 497 +- .../core/handlers/RecipeBookHandler.java | 112 +- .../handlers/SoundUpdaterRollingStock.java | 154 +- .../client/core/handlers/TCKeyHandler.java | 277 +- .../client/core/helpers/CapesHelper.java | 168 +- .../core/helpers/FluidRenderHelper.java | 37 +- .../train/client/core/helpers/JLayerHook.java | 27 +- .../client/core/helpers/SessionHelper.java | 16 +- src/main/java/train/common/Traincraft.java | 369 +- .../java/train/common/items/ItemTCRail.java | 12945 ++++++++-------- .../java/train/common/items/TCRailTypes.java | 17 + 15 files changed, 7544 insertions(+), 7762 deletions(-) create mode 100644 src/main/java/train/common/items/TCRailTypes.java diff --git a/src/main/java/train/client/TechneModelRenderer.java b/src/main/java/train/client/TechneModelRenderer.java index cae6fb5d32..590b1b7cad 100644 --- a/src/main/java/train/client/TechneModelRenderer.java +++ b/src/main/java/train/client/TechneModelRenderer.java @@ -11,32 +11,43 @@ * A middleman class to convert Techne models to something tmt can actually render properly. */ public class TechneModelRenderer extends ModelRendererTurbo { - private static final int staticTextureSize =512; - /**define the part with no texture offset, but using a static texture size of 512x512 and a defined name.*/ + private static final int staticTextureSize = 512; + + /** + * Define the part with no texture offset, but using a static texture size of 512x512 and a defined name. + */ public TechneModelRenderer(ModelBase modelBase, String name) { super(modelBase, name); - this.setTextureOffset(staticTextureSize,staticTextureSize); + this.setTextureOffset(staticTextureSize, staticTextureSize); } - /**define the part with a texture offset, but using a static name and texture size of 512x512*/ + + /** + * Define the part with a texture offset, but using a static name and texture size of 512x512. + */ public TechneModelRenderer(ModelBase modelBase, int textureOffsetX, int textureOffsetY) { this(modelBase, "void"); - this.setTextureOffset(textureOffsetX,textureOffsetY); + this.setTextureOffset(textureOffsetX, textureOffsetY); } - /**define the part with all data.*/ + + /** + * Define the part with all data. + */ public TechneModelRenderer(ModelBase modelBase, int textureOffsetX, int textureOffsetY, String name) { this(modelBase, name); - this.setTextureOffset(textureOffsetX,textureOffsetY); + this.setTextureOffset(textureOffsetX, textureOffsetY); } - private TexturedPolygon faces[]; + @Override public ModelRendererTurbo addBox(float f, float f1, float f2, int i, int j, int k, float f3) { - faces = new TexturedPolygon[6]; - float f4 = f + i +f3; - float f5 = f1 + j +f3; - float f6 = f2 + k +f3; + TexturedPolygon[] faces = new TexturedPolygon[6]; + float f4 = f + i + f3; + float f5 = f1 + j + f3; + float f6 = f2 + k + f3; + f -= f3; f1 -= f3; f2 -= f3; + TexturedVertex PositionTransformVertex = new TexturedVertex(f, f1, f2, 0.0F, 0.0F); TexturedVertex PositionTransformVertex1 = new TexturedVertex(f4, f1, f2, 0.0F, 8F); TexturedVertex PositionTransformVertex2 = new TexturedVertex(f4, f5, f2, 8F, 8F); @@ -45,12 +56,13 @@ public ModelRendererTurbo addBox(float f, float f1, float f2, int i, int j, int TexturedVertex PositionTransformVertex5 = new TexturedVertex(f4, f1, f6, 0.0F, 8F); TexturedVertex PositionTransformVertex6 = new TexturedVertex(f4, f5, f6, 8F, 8F); TexturedVertex PositionTransformVertex7 = new TexturedVertex(f, f5, f6, 8F, 0.0F); - faces[0] = generateFaces(new TexturedVertex[] { PositionTransformVertex5, PositionTransformVertex1, PositionTransformVertex2, PositionTransformVertex6 }, textureOffsetX + k + i, textureOffsetY + k, textureOffsetX + k + i + k, textureOffsetY + k + j, textureWidth, textureHeight); - faces[1] = generateFaces(new TexturedVertex[] { PositionTransformVertex, PositionTransformVertex4, PositionTransformVertex7, PositionTransformVertex3 }, textureOffsetX, textureOffsetY + k, textureOffsetX + k, textureOffsetY + k + j, textureWidth, textureHeight); - faces[2] = generateFaces(new TexturedVertex[] { PositionTransformVertex5, PositionTransformVertex4, PositionTransformVertex, PositionTransformVertex1 }, textureOffsetX + k, textureOffsetY, textureOffsetX + k + i, textureOffsetY + k, textureWidth, textureHeight); - faces[3] = generateFaces(new TexturedVertex[] { PositionTransformVertex2, PositionTransformVertex3, PositionTransformVertex7, PositionTransformVertex6 }, textureOffsetX + k + i, textureOffsetY, textureOffsetX + k + i + i, textureOffsetY + k, textureWidth, textureHeight); - faces[4] = generateFaces(new TexturedVertex[] { PositionTransformVertex1, PositionTransformVertex, PositionTransformVertex3, PositionTransformVertex2 }, textureOffsetX + k, textureOffsetY + k, textureOffsetX + k + i, textureOffsetY + k + j, textureWidth, textureHeight); - faces[5] = generateFaces(new TexturedVertex[] { PositionTransformVertex4, PositionTransformVertex5, PositionTransformVertex6, PositionTransformVertex7 }, textureOffsetX + k + i + k, textureOffsetY + k, textureOffsetX + k + i + k + i, textureOffsetY + k + j, textureWidth, textureHeight); + + faces[0] = generateFaces(new TexturedVertex[]{PositionTransformVertex5, PositionTransformVertex1, PositionTransformVertex2, PositionTransformVertex6}, textureOffsetX + k + i, textureOffsetY + k, textureOffsetX + k + i + k, textureOffsetY + k + j, textureWidth, textureHeight); + faces[1] = generateFaces(new TexturedVertex[]{PositionTransformVertex, PositionTransformVertex4, PositionTransformVertex7, PositionTransformVertex3}, textureOffsetX, textureOffsetY + k, textureOffsetX + k, textureOffsetY + k + j, textureWidth, textureHeight); + faces[2] = generateFaces(new TexturedVertex[]{PositionTransformVertex5, PositionTransformVertex4, PositionTransformVertex, PositionTransformVertex1}, textureOffsetX + k, textureOffsetY, textureOffsetX + k + i, textureOffsetY + k, textureWidth, textureHeight); + faces[3] = generateFaces(new TexturedVertex[]{PositionTransformVertex2, PositionTransformVertex3, PositionTransformVertex7, PositionTransformVertex6}, textureOffsetX + k + i, textureOffsetY, textureOffsetX + k + i + i, textureOffsetY + k, textureWidth, textureHeight); + faces[4] = generateFaces(new TexturedVertex[]{PositionTransformVertex1, PositionTransformVertex, PositionTransformVertex3, PositionTransformVertex2}, textureOffsetX + k, textureOffsetY + k, textureOffsetX + k + i, textureOffsetY + k + j, textureWidth, textureHeight); + faces[5] = generateFaces(new TexturedVertex[]{PositionTransformVertex4, PositionTransformVertex5, PositionTransformVertex6, PositionTransformVertex7}, textureOffsetX + k + i + k, textureOffsetY + k, textureOffsetX + k + i + k + i, textureOffsetY + k + j, textureWidth, textureHeight); textureGroup.get("0").poly.clear(); textureGroup.get("0").addPoly(faces[0]); @@ -61,26 +73,27 @@ public ModelRendererTurbo addBox(float f, float f1, float f2, int i, int j, int textureGroup.get("0").addPoly(faces[5]); return this; } - - private static TexturedPolygon generateFaces(TexturedVertex aPositionTransformVertex[], int i, int j, int k, int l, float textureWidth, float textureHeight) { + + private static TexturedPolygon generateFaces(TexturedVertex[] aPositionTransformVertex, int i, int j, int k, int l, float textureWidth, float textureHeight) { aPositionTransformVertex[0] = new TexturedVertex(aPositionTransformVertex[0].vector3F, (float) k / textureWidth - 0.0015625F, (float) j / textureHeight + 0.003125F); - aPositionTransformVertex[1] = new TexturedVertex(aPositionTransformVertex[1].vector3F,(float) i / textureWidth + 0.0015625F, (float) j / textureHeight + 0.003125F); - aPositionTransformVertex[2] = new TexturedVertex(aPositionTransformVertex[2].vector3F,(float) i / textureWidth + 0.0015625F, (float) l / textureHeight - 0.003125F); - aPositionTransformVertex[3] = new TexturedVertex(aPositionTransformVertex[3].vector3F,(float) k / textureWidth - 0.0015625F, (float) l / textureHeight - 0.003125F); + aPositionTransformVertex[1] = new TexturedVertex(aPositionTransformVertex[1].vector3F, (float) i / textureWidth + 0.0015625F, (float) j / textureHeight + 0.003125F); + aPositionTransformVertex[2] = new TexturedVertex(aPositionTransformVertex[2].vector3F, (float) i / textureWidth + 0.0015625F, (float) l / textureHeight - 0.003125F); + aPositionTransformVertex[3] = new TexturedVertex(aPositionTransformVertex[3].vector3F, (float) k / textureWidth - 0.0015625F, (float) l / textureHeight - 0.003125F); return new TexturedPolygon(aPositionTransformVertex); } /** - *

set Rotation point

- * this set's the rotation point with the offsets defined in - * @see #addBox(float, float, float, float, float, float) + *

Set Rotation point

+ * This set's the rotation point with the offsets defined. + * + * @see #addBox(float, float, float, int, int, int, float) */ @Override public ModelRendererTurbo setRotationPoint(float pointX, float pointY, float pointZ) { - this.rotationPointX = pointX; - this.rotationPointY = pointY-15; - this.rotationPointZ = pointZ; - return this; + this.rotationPointX = pointX; + this.rotationPointY = pointY - 15; + this.rotationPointZ = pointZ; + return this; } } diff --git a/src/main/java/train/client/core/AlphaExpiredException.java b/src/main/java/train/client/core/AlphaExpiredException.java index 9f4bcffef1..7b90c6699a 100644 --- a/src/main/java/train/client/core/AlphaExpiredException.java +++ b/src/main/java/train/client/core/AlphaExpiredException.java @@ -4,21 +4,20 @@ import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiErrorScreen; -public class AlphaExpiredException extends CustomModLoadingErrorDisplayException { +public class AlphaExpiredException extends CustomModLoadingErrorDisplayException { - private static final long serialVersionUID = 4917296650073454368L; + private static final long serialVersionUID = 4917296650073454368L; - @Override - public void initGui(GuiErrorScreen errorScreen, FontRenderer fontRenderer) { - } + @Override + public void initGui(GuiErrorScreen errorScreen, FontRenderer fontRenderer) { + } - @Override - public void drawScreen(GuiErrorScreen errorScreen, FontRenderer fontRenderer, int mouseRelX, int mouseRelY, - float tickTime) { - errorScreen.drawCenteredString(fontRenderer, "You're trying to use a Traincraft alpha-version past its expiry date.", errorScreen.width/2, 95, 0xEEEEEE); - errorScreen.drawCenteredString(fontRenderer, "Download a release-build at", errorScreen.width/2, 105, 0xEEEEEE); - errorScreen.drawCenteredString(fontRenderer, "https://minecraft.curseforge.com/projects/traincraft.", errorScreen.width/2, 125, 0xEEEEEE); - - } + @Override + public void drawScreen(GuiErrorScreen errorScreen, FontRenderer fontRenderer, int mouseRelX, int mouseRelY, + float tickTime) { + errorScreen.drawCenteredString(fontRenderer, "You're trying to use a Traincraft alpha-version past its expiry date.", errorScreen.width / 2, 95, 0xEEEEEE); + errorScreen.drawCenteredString(fontRenderer, "Download a release-build at", errorScreen.width / 2, 105, 0xEEEEEE); + errorScreen.drawCenteredString(fontRenderer, "https://minecraft.curseforge.com/projects/traincraft.", errorScreen.width / 2, 125, 0xEEEEEE); + } } diff --git a/src/main/java/train/client/core/ClientProxy.java b/src/main/java/train/client/core/ClientProxy.java index 5143ba1506..5c8bfecbef 100644 --- a/src/main/java/train/client/core/ClientProxy.java +++ b/src/main/java/train/client/core/ClientProxy.java @@ -55,130 +55,140 @@ public class ClientProxy extends CommonProxy { - public static boolean isHoliday() { - Calendar cal = Calendar.getInstance(); - return(cal.get(Calendar.MONTH) == Calendar.DECEMBER || (cal.get(Calendar.MONTH) == Calendar.JANUARY) && cal.get(Calendar.DATE) < 7); - } - public static boolean isPumpkin() { - Calendar cal = Calendar.getInstance(); - return(cal.get(Calendar.MONTH) == Calendar.OCTOBER || cal.get(Calendar.MONTH) == Calendar.NOVEMBER && cal.get(Calendar.DATE) < 15); - } - - @Override - public void throwAlphaException() { - throw new AlphaExpiredException(); - } - - @Override - public void registerEvents(FMLPreInitializationEvent event) { - super.registerEvents(event); - ClientTickHandler tickHandler = new ClientTickHandler(); - if (ConfigHandler.ENABLE_TRACK_HOLOGRAM){ - CustomRenderHandler renderHandler = new CustomRenderHandler(); - registerEvent(renderHandler); - } + /** + * Checks if the month is December or January + * + * @return true if it is December or January + */ + public static boolean isHoliday() { + Calendar cal = Calendar.getInstance(); + return (cal.get(Calendar.MONTH) == Calendar.DECEMBER || (cal.get(Calendar.MONTH) == Calendar.JANUARY) && cal.get(Calendar.DATE) < 7); + } + + /** + * Checks if the month is October or November (and is less than 15 days for november). + * + * @return true if it is October or November (and is less than 15 days for november). + */ + public static boolean isPumpkin() { + Calendar cal = Calendar.getInstance(); + return (cal.get(Calendar.MONTH) == Calendar.OCTOBER || cal.get(Calendar.MONTH) == Calendar.NOVEMBER && cal.get(Calendar.DATE) < 15); + } + + @Override + public void throwAlphaException() { + throw new AlphaExpiredException(); + } + + @Override + public void registerEvents(FMLPreInitializationEvent event) { + super.registerEvents(event); + ClientTickHandler tickHandler = new ClientTickHandler(); + if (ConfigHandler.ENABLE_TRACK_HOLOGRAM) { + CustomRenderHandler renderHandler = new CustomRenderHandler(); + registerEvent(renderHandler); + } + + HUDloco huDloco = new HUDloco(); + if (Loader.isModLoaded("ComputerCraft")) { + HUDMTC hudMTC = new HUDMTC(); + registerEvent(hudMTC); + } + + registerEvent(tickHandler); + + registerEvent(huDloco); + } - HUDloco huDloco = new HUDloco(); - if (Loader.isModLoaded("ComputerCraft")){ - HUDMTC hudMTC = new HUDMTC(); - registerEvent(hudMTC); - } + @Override + public void registerRenderInformation() { + FMLCommonHandler.instance().bus().register(new ClientTickHandler()); - registerEvent(tickHandler); + RenderingRegistry.registerEntityRenderingHandler(EntityRollingStock.class, new RenderRollingStock()); + RenderingRegistry.registerEntityRenderingHandler(EntityZeppelinTwoBalloons.class, new RenderZeppelins()); + RenderingRegistry.registerEntityRenderingHandler(EntityZeppelinOneBalloon.class, new RenderZeppelins()); + RenderingRegistry.registerEntityRenderingHandler(EntityRotativeDigger.class, new RenderRotativeDigger()); + RenderingRegistry.registerEntityRenderingHandler(EntityRotativeWheel.class, new RenderRotativeWheel()); - registerEvent(huDloco); - } + // Register Renderer for Bogies + RenderingRegistry.registerEntityRenderingHandler(EntityBogie.class, new RenderBogie()); - @Override - public void registerRenderInformation() { - FMLCommonHandler.instance().bus().register(new ClientTickHandler()); - RenderingRegistry.registerEntityRenderingHandler(EntityRollingStock.class, new RenderRollingStock()); - RenderingRegistry.registerEntityRenderingHandler(EntityZeppelinTwoBalloons.class, new RenderZeppelins()); - RenderingRegistry.registerEntityRenderingHandler(EntityZeppelinOneBalloon.class, new RenderZeppelins()); - RenderingRegistry.registerEntityRenderingHandler(EntityRotativeDigger.class, new RenderRotativeDigger()); - RenderingRegistry.registerEntityRenderingHandler(EntityRotativeWheel.class, new RenderRotativeWheel()); - //bogies - RenderingRegistry.registerEntityRenderingHandler(EntityBogie.class, new RenderBogie()); + ClientRegistry.bindTileEntitySpecialRenderer(TileStopper.class, new RenderStopper()); + MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(BlockIDs.stopper.block), new ItemRenderStopper()); + ClientRegistry.bindTileEntitySpecialRenderer(TileEmbeddedStopper.class, new RenderEmbeddedStopper()); + MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(BlockIDs.embeddedStopper.block), new ItemRenderEmbeddedStopper()); - ClientRegistry.bindTileEntitySpecialRenderer(TileStopper.class, new RenderStopper()); - MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(BlockIDs.stopper.block), new ItemRenderStopper()); + ClientRegistry.bindTileEntitySpecialRenderer(TileAmericanStopper.class, new RenderAmericanStopper()); + MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(BlockIDs.americanstopper.block), new ItemRenderAmericanStopper()); - ClientRegistry.bindTileEntitySpecialRenderer(TileEmbeddedStopper.class, new RenderEmbeddedStopper()); - MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(BlockIDs.embeddedStopper.block), new ItemRenderEmbeddedStopper()); + //ClientRegistry.bindTileEntitySpecialRenderer(TileBook.class, new RenderTCBook()); + //MinecraftForgeClient.registerItemRenderer(BlockIDs.book.blockID, new ItemRenderBook()); - ClientRegistry.bindTileEntitySpecialRenderer(TileAmericanStopper.class, new RenderAmericanStopper()); - MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(BlockIDs.americanstopper.block), new ItemRenderAmericanStopper()); - - //ClientRegistry.bindTileEntitySpecialRenderer(TileBook.class, new RenderTCBook()); - //MinecraftForgeClient.registerItemRenderer(BlockIDs.book.blockID, new ItemRenderBook()); + ClientRegistry.bindTileEntitySpecialRenderer(TileSignal.class, new RenderSignal()); + MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(BlockIDs.signal.block), new ItemRenderSignal()); - ClientRegistry.bindTileEntitySpecialRenderer(TileSignal.class, new RenderSignal()); - MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(BlockIDs.signal.block), new ItemRenderSignal()); - - ClientRegistry.bindTileEntitySpecialRenderer(TileLantern.class, new RenderLantern()); - MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(BlockIDs.lantern.block), new ItemRenderLantern()); + ClientRegistry.bindTileEntitySpecialRenderer(TileLantern.class, new RenderLantern()); + MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(BlockIDs.lantern.block), new ItemRenderLantern()); - ClientRegistry.bindTileEntitySpecialRenderer(TileSwitchStand.class, new RenderSwitchStand()); - MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(BlockIDs.switchStand.block), new ItemRenderSwitchStand()); + ClientRegistry.bindTileEntitySpecialRenderer(TileSwitchStand.class, new RenderSwitchStand()); + MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(BlockIDs.switchStand.block), new ItemRenderSwitchStand()); - ClientRegistry.bindTileEntitySpecialRenderer(TileMFPBWigWag.class, new RenderMFPBWigWag()); - MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(BlockIDs.MFPBWigWag.block), new ItemRenderMFPBWigWag()); - - ClientRegistry.bindTileEntitySpecialRenderer(TileWaterWheel.class, new RenderWaterWheel()); - MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(BlockIDs.waterWheel.block), new ItemRenderWaterWheel()); - - ClientRegistry.bindTileEntitySpecialRenderer(TileWindMill.class, new RenderWindMill()); - MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(BlockIDs.windMill.block), new ItemRenderWindMill()); + ClientRegistry.bindTileEntitySpecialRenderer(TileMFPBWigWag.class, new RenderMFPBWigWag()); + MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(BlockIDs.MFPBWigWag.block), new ItemRenderMFPBWigWag()); - ClientRegistry.bindTileEntitySpecialRenderer(TileGeneratorDiesel.class, new RenderGeneratorDiesel()); - MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(BlockIDs.generatorDiesel.block), new ItemRenderGeneratorDiesel()); - - ClientRegistry.bindTileEntitySpecialRenderer(TileTCRail.class, new RenderTCRail()); - - ClientRegistry.bindTileEntitySpecialRenderer(TileBridgePillar.class, new RenderBridgePillar()); - MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(BlockIDs.bridgePillar.block), new ItemRenderBridgePillar()); + ClientRegistry.bindTileEntitySpecialRenderer(TileWaterWheel.class, new RenderWaterWheel()); + MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(BlockIDs.waterWheel.block), new ItemRenderWaterWheel()); - ClientRegistry.bindTileEntitySpecialRenderer(TileMetroMadridPole.class, new RenderMetroMadridPole()); - MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(BlockIDs.metroMadridPole.block), new ItemRenderModelMetroMadridPole()); + ClientRegistry.bindTileEntitySpecialRenderer(TileWindMill.class, new RenderWindMill()); + MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(BlockIDs.windMill.block), new ItemRenderWindMill()); - ClientRegistry.bindTileEntitySpecialRenderer(TileowoYardSwitchStand.class, new RenderowoYardSwtichStand()); - MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(BlockIDs.owoYardSwitchStand.block), new ItemRenderowoYardSwitchStand()); + ClientRegistry.bindTileEntitySpecialRenderer(TileGeneratorDiesel.class, new RenderGeneratorDiesel()); + MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(BlockIDs.generatorDiesel.block), new ItemRenderGeneratorDiesel()); - ClientRegistry.bindTileEntitySpecialRenderer(TileMILWSwitchStand.class, new RenderMILWSwitchStand()); - MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(BlockIDs.MILWSwitchStand.block), new ItemRenderMILWSwitchStand()); + ClientRegistry.bindTileEntitySpecialRenderer(TileTCRail.class, new RenderTCRail()); - ClientRegistry.bindTileEntitySpecialRenderer(TilecircleSwitchStand.class, new RendercircleSwitchStand()); - MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(BlockIDs.circleSwitchStand.block), new ItemRendercircleSwitchStand()); + ClientRegistry.bindTileEntitySpecialRenderer(TileBridgePillar.class, new RenderBridgePillar()); + MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(BlockIDs.bridgePillar.block), new ItemRenderBridgePillar()); - ClientRegistry.bindTileEntitySpecialRenderer(TileowoSwitchStand.class, new RenderowoSwitchStand()); - MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(BlockIDs.owoSwitchStand.block), new ItemRenderowoSwitchStand()); + ClientRegistry.bindTileEntitySpecialRenderer(TileMetroMadridPole.class, new RenderMetroMadridPole()); + MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(BlockIDs.metroMadridPole.block), new ItemRenderModelMetroMadridPole()); - ClientRegistry.bindTileEntitySpecialRenderer(TileautoSwitchStand.class, new RenderautoSwitchStand()); - MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(BlockIDs.autoSwtichStand.block), new ItemRenderautoSwitchStand()); + ClientRegistry.bindTileEntitySpecialRenderer(TileowoYardSwitchStand.class, new RenderowoYardSwtichStand()); + MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(BlockIDs.owoYardSwitchStand.block), new ItemRenderowoYardSwitchStand()); - ClientRegistry.bindTileEntitySpecialRenderer(TileoverheadWire.class, new RenderoverheadWire()); - MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(BlockIDs.overheadWire.block), new ItemRenderoverheadWire()); + ClientRegistry.bindTileEntitySpecialRenderer(TileMILWSwitchStand.class, new RenderMILWSwitchStand()); + MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(BlockIDs.MILWSwitchStand.block), new ItemRenderMILWSwitchStand()); - ClientRegistry.bindTileEntitySpecialRenderer(TileoverheadWireDouble.class, new RenderoverheadWireDouble()); - MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(BlockIDs.overheadWireDouble.block), new ItemRenderoverheadWireDouble()); + ClientRegistry.bindTileEntitySpecialRenderer(TilecircleSwitchStand.class, new RendercircleSwitchStand()); + MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(BlockIDs.circleSwitchStand.block), new ItemRendercircleSwitchStand()); - ClientRegistry.bindTileEntitySpecialRenderer(TilesignalSpanish.class, new RendersignalSpanish()); - MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(BlockIDs.signalSpanish.block), new ItemRendersignalSpanish()); + ClientRegistry.bindTileEntitySpecialRenderer(TileowoSwitchStand.class, new RenderowoSwitchStand()); + MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(BlockIDs.owoSwitchStand.block), new ItemRenderowoSwitchStand()); - //ClientRegistry.bindTileEntitySpecialRenderer(TiletrackConcrete.class, new RendertrackEmbeddedSmallStraight()); - //MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(BlockIDs.trackConcrete.block), new ItemRendertrackEmbeddedSmallStraight()); + ClientRegistry.bindTileEntitySpecialRenderer(TileautoSwitchStand.class, new RenderautoSwitchStand()); + MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(BlockIDs.autoSwtichStand.block), new ItemRenderautoSwitchStand()); + ClientRegistry.bindTileEntitySpecialRenderer(TileoverheadWire.class, new RenderoverheadWire()); + MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(BlockIDs.overheadWire.block), new ItemRenderoverheadWire()); - ClientRegistry.bindTileEntitySpecialRenderer(TilekSignal.class, new RenderkSignal()); - MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(BlockIDs.kSignal.block), new ItemRenderkSignal()); + ClientRegistry.bindTileEntitySpecialRenderer(TileoverheadWireDouble.class, new RenderoverheadWireDouble()); + MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(BlockIDs.overheadWireDouble.block), new ItemRenderoverheadWireDouble()); - ClientRegistry.bindTileEntitySpecialRenderer(TileSpeedSign.class, new RenderSpeedSign()); - MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(BlockIDs.speedSign.block), new ItemRenderSpeedSign()); + ClientRegistry.bindTileEntitySpecialRenderer(TilesignalSpanish.class, new RendersignalSpanish()); + MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(BlockIDs.signalSpanish.block), new ItemRendersignalSpanish()); + //ClientRegistry.bindTileEntitySpecialRenderer(TiletrackConcrete.class, new RendertrackEmbeddedSmallStraight()); + //MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(BlockIDs.trackConcrete.block), new ItemRendertrackEmbeddedSmallStraight()); + ClientRegistry.bindTileEntitySpecialRenderer(TilekSignal.class, new RenderkSignal()); + MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(BlockIDs.kSignal.block), new ItemRenderkSignal()); + + ClientRegistry.bindTileEntitySpecialRenderer(TileSpeedSign.class, new RenderSpeedSign()); + MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(BlockIDs.speedSign.block), new ItemRenderSpeedSign()); + /* ClientRegistry.bindTileEntitySpecialRenderer(TileFortyFootContainer.class, new FortyFootContainerRender()); MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(BlockIDs.FortyFootContainer.block), new ItemRenderFortyFootContainer()); @@ -187,158 +197,154 @@ public void registerRenderInformation() { /* ClientRegistry.bindTileEntitySpecialRenderer(TileFortyFootContainer.class, new FortyFootContainerRender()); MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(BlockIDs.FortyFootContainer.block), new ItemRenderFortyFootContainer());*/ + } + + @Override + public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { + TileEntity te = world.getTileEntity(x, y, z); + Entity entity = player.ridingEntity; + EntityPlayer riddenByEntity = player.ridingEntity != null ? (EntityPlayer) entity.riddenByEntity : null; + + Entity entity1 = null; + if (y == -1) { + for (Object ent : world.loadedEntityList) { + if (((Entity) ent).getEntityId() == x) { + entity1 = (Entity) ent; + } + } + } - - } - - @Override - public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { - TileEntity te = world.getTileEntity(x, y, z); - EntityPlayer riddenByEntity = null; - Entity entity = player.ridingEntity; - if (player.ridingEntity != null) { - riddenByEntity = (EntityPlayer) entity.riddenByEntity; - } - - Entity entity1 = null; - if (y == -1) { - for (Object ent : world.loadedEntityList) { - if (((Entity) ent).getEntityId() == x) - entity1 = (Entity) ent; - } - } - switch (ID) { - case (GuiIDs.CRAFTER_TIER_I): - return te != null && te instanceof TileCrafterTierI ? new GuiCrafterTier(player.inventory, (TileCrafterTierI) te) : null; - case (GuiIDs.CRAFTER_TIER_II): - return te != null && te instanceof TileCrafterTierII ? new GuiCrafterTier(player.inventory, (TileCrafterTierII) te) : null; - case (GuiIDs.CRAFTER_TIER_III): - return te != null && te instanceof TileCrafterTierIII ? new GuiCrafterTier(player.inventory, (TileCrafterTierIII) te) : null; - case (GuiIDs.DISTIL): - return te != null && te instanceof TileEntityDistil ? new GuiDistil(player.inventory, (TileEntityDistil) te) : null; - case (GuiIDs.GENERATOR_DIESEL): - return te != null && te instanceof TileGeneratorDiesel ? new GuiGeneratorDiesel(player.inventory, (TileGeneratorDiesel) te) : null; - case (GuiIDs.OPEN_HEARTH_FURNACE): - return te != null && te instanceof TileEntityOpenHearthFurnace ? new GuiOpenHearthFurnace(player.inventory, (TileEntityOpenHearthFurnace) te) : null; - case GuiIDs.TRAIN_WORKBENCH: - return te != null && te instanceof TileTrainWbench ? new GuiTrainCraftingBlock(player.inventory, player.worldObj, (TileTrainWbench) te) : null; - case (GuiIDs.LOCO): - return riddenByEntity != null ? new GuiLoco2(riddenByEntity.inventory, entity) : null; - case (GuiIDs.FORNEY): - return riddenByEntity != null ? new GuiForney(riddenByEntity.inventory, entity) : null; - case (GuiIDs.CRAFTING_CART): - return riddenByEntity != null ? new GuiCraftingCart(riddenByEntity.inventory, world) : null; - case (GuiIDs.FURNACE_CART): - return riddenByEntity != null ? new GuiFurnaceCart(riddenByEntity.inventory, entity) : null; - case (GuiIDs.ZEPPELIN): - return riddenByEntity != null ? new GuiZepp(riddenByEntity.inventory, entity) : null; - case (GuiIDs.DIGGER): - return riddenByEntity != null ? new GuiBuilder(player, riddenByEntity.inventory, entity) : null; - case (GuiIDs.MTC_INFO): - return riddenByEntity != null && Loader.isModLoaded("ComputerCraft") ? new GuiMTCInfo(player) : null; - - //Stationary entities while player is not riding. - case (GuiIDs.FREIGHT): - return entity1 != null ? new GuiFreight(player,player.inventory, entity1) : null; - case (GuiIDs.TENDER): - return entity1 != null ? new GuiTender(player,player.inventory, entity1) : null; - case (GuiIDs.BUILDER): - return entity1 != null ? new GuiBuilder(player,player.inventory, entity1) : null; - case (GuiIDs.LIQUID): - return entity1 != null ? new GuiLiquid(player,player.inventory, entity1) : null; - case (GuiIDs.RECIPE_BOOK): - return new GuiRecipeBook(player, player.getCurrentEquippedItem()); + switch (ID) { + case (GuiIDs.CRAFTER_TIER_I): + return te instanceof TileCrafterTierI ? new GuiCrafterTier(player.inventory, (TileCrafterTierI) te) : null; + case (GuiIDs.CRAFTER_TIER_II): + return te instanceof TileCrafterTierII ? new GuiCrafterTier(player.inventory, (TileCrafterTierII) te) : null; + case (GuiIDs.CRAFTER_TIER_III): + return te instanceof TileCrafterTierIII ? new GuiCrafterTier(player.inventory, (TileCrafterTierIII) te) : null; + case (GuiIDs.DISTIL): + return te instanceof TileEntityDistil ? new GuiDistil(player.inventory, (TileEntityDistil) te) : null; + case (GuiIDs.GENERATOR_DIESEL): + return te instanceof TileGeneratorDiesel ? new GuiGeneratorDiesel(player.inventory, (TileGeneratorDiesel) te) : null; + case (GuiIDs.OPEN_HEARTH_FURNACE): + return te instanceof TileEntityOpenHearthFurnace ? new GuiOpenHearthFurnace(player.inventory, (TileEntityOpenHearthFurnace) te) : null; + case GuiIDs.TRAIN_WORKBENCH: + return te instanceof TileTrainWbench ? new GuiTrainCraftingBlock(player.inventory, player.worldObj, (TileTrainWbench) te) : null; + case (GuiIDs.LOCO): + return riddenByEntity != null ? new GuiLoco2(riddenByEntity.inventory, entity) : null; + case (GuiIDs.FORNEY): + return riddenByEntity != null ? new GuiForney(riddenByEntity.inventory, entity) : null; + case (GuiIDs.CRAFTING_CART): + return riddenByEntity != null ? new GuiCraftingCart(riddenByEntity.inventory, world) : null; + case (GuiIDs.FURNACE_CART): + return riddenByEntity != null ? new GuiFurnaceCart(riddenByEntity.inventory, entity) : null; + case (GuiIDs.ZEPPELIN): + return riddenByEntity != null ? new GuiZepp(riddenByEntity.inventory, entity) : null; + case (GuiIDs.DIGGER): + return riddenByEntity != null ? new GuiBuilder(player, riddenByEntity.inventory, entity) : null; + case (GuiIDs.MTC_INFO): + return riddenByEntity != null && Loader.isModLoaded("ComputerCraft") ? new GuiMTCInfo(player) : null; + + // Stationary entities while player is not riding. + case (GuiIDs.FREIGHT): + return entity1 != null ? new GuiFreight(player, player.inventory, entity1) : null; + case (GuiIDs.TENDER): + return entity1 != null ? new GuiTender(player, player.inventory, entity1) : null; + case (GuiIDs.BUILDER): + return entity1 != null ? new GuiBuilder(player, player.inventory, entity1) : null; + case (GuiIDs.LIQUID): + return entity1 != null ? new GuiLiquid(player, player.inventory, entity1) : null; + case (GuiIDs.RECIPE_BOOK): + return new GuiRecipeBook(player, player.getCurrentEquippedItem()); /*case (GuiIDs.RECIPE_BOOK2): return te != null && te instanceof TileBook ? new GuiRecipeBook2(player, player.getCurrentEquippedItem()) : new GuiRecipeBook2(player, player.getCurrentEquippedItem());*/ - case (GuiIDs.LANTERN): - return new GuiLantern(player, (TileLantern)te); - case (GuiIDs.JUKEBOX): - return entity1 != null ? new GuiJukebox(player,(EntityJukeBoxCart)entity1) : null; - case (GuiIDs.FORTY_FOOT_CONTAINER): - return new GuiFortyFootContainer((TileFortyFootContainer)te, player); - - default: - return null; - } - } - - @Override - public int addArmor(String armor) { - return RenderingRegistry.addNewArmourRendererPrefix(armor); - } - - @Override - public GuiScreen getCurrentScreen() { - return Minecraft.getMinecraft().currentScreen; - } - @Override - public void registerVillagerSkin(int villagerId, String textureName) { - VillagerRegistry.instance().registerVillagerSkin(villagerId, new ResourceLocation(Info.resourceLocation,Info.villagerPrefix + textureName)); - } - - @Override - public void registerSounds() { - MinecraftForge.EVENT_BUS.register(new Traincraft_EventSounds()); - } - - @Override - public void registerBookHandler() { - RecipeBookHandler recipeBookHandler = new RecipeBookHandler(); - } - - @Override - public Minecraft getMinecraft() { - return Minecraft.getMinecraft(); - } - - @Override - public EntityPlayer getPlayer() { - return getMinecraft().thePlayer; - } - - @Optional.Method(modid = "NotEnoughItems") - @Override - public void doNEICheck(ItemStack stack) { - if (Minecraft.getMinecraft().thePlayer != null) { - if(Loader.isModLoaded("Not Enough Items")) { - try { - Class neiApi = Class.forName("codechicken.nei.api.API"); - Method hideItem = neiApi.getDeclaredMethod("hideItem", stack.getClass()); - hideItem.invoke(null, stack); - } catch (ClassNotFoundException e) { - Traincraft.tcLog.log(Level.WARN, "Chicken core didn't have required class: Wrong version of the library or something is horribly wrong", e); - } catch (NoSuchMethodException e) { - Traincraft.tcLog.log(Level.WARN, "Chicken core didn't have required method: Wrong version of the library or something is horribly wrong", e); - } catch (SecurityException e) { - Traincraft.tcLog.log(Level.FATAL, "Something is horribly wrong", e); - } catch (IllegalAccessException e) { - Traincraft.tcLog.log(Level.FATAL, "Something is horribly wrong", e); - } catch (IllegalArgumentException e) { - Traincraft.tcLog.log(Level.WARN, "Chicken core had the method but it's signature was wrong: Wrong version of the library or something is horribly wrong", e); - } catch (InvocationTargetException e) { - Traincraft.tcLog.log(Level.WARN, "The method we called from Chicken core threw an exception", e); - } - } + case (GuiIDs.LANTERN): + return new GuiLantern(player, (TileLantern) te); + case (GuiIDs.JUKEBOX): + return entity1 != null ? new GuiJukebox(player, (EntityJukeBoxCart) entity1) : null; + case (GuiIDs.FORTY_FOOT_CONTAINER): + return new GuiFortyFootContainer((TileFortyFootContainer) te, player); + + default: + return null; + } + } + + @Override + public int addArmor(String armor) { + return RenderingRegistry.addNewArmourRendererPrefix(armor); + } + + @Override + public GuiScreen getCurrentScreen() { + return Minecraft.getMinecraft().currentScreen; + } + + @Override + public void registerVillagerSkin(int villagerId, String textureName) { + VillagerRegistry.instance().registerVillagerSkin(villagerId, new ResourceLocation(Info.resourceLocation, Info.villagerPrefix + textureName)); + } + + @Override + public void registerSounds() { + MinecraftForge.EVENT_BUS.register(new Traincraft_EventSounds()); + } + + @Override + public void registerBookHandler() { + RecipeBookHandler recipeBookHandler = new RecipeBookHandler(); + } + + @Override + public Minecraft getMinecraft() { + return Minecraft.getMinecraft(); + } + + @Override + public EntityPlayer getPlayer() { + return getMinecraft().thePlayer; + } + + @Optional.Method(modid = "NotEnoughItems") + @Override + public void doNEICheck(ItemStack stack) { + if (Minecraft.getMinecraft().thePlayer != null) { + if (Loader.isModLoaded("Not Enough Items")) { + try { + Class neiApi = Class.forName("codechicken.nei.api.API"); + Method hideItem = neiApi.getDeclaredMethod("hideItem", stack.getClass()); + hideItem.invoke(null, stack); + } catch (ClassNotFoundException e) { + Traincraft.tcLog.log(Level.WARN, "Chicken core didn't have required class: Wrong version of the library or something is horribly wrong", e); + } catch (NoSuchMethodException e) { + Traincraft.tcLog.log(Level.WARN, "Chicken core didn't have required method: Wrong version of the library or something is horribly wrong", e); + } catch (SecurityException | IllegalAccessException e) { + Traincraft.tcLog.log(Level.FATAL, "Something is horribly wrong", e); + } catch (IllegalArgumentException e) { + Traincraft.tcLog.log(Level.WARN, "Chicken core had the method but it's signature was wrong: Wrong version of the library or something is horribly wrong", e); + } catch (InvocationTargetException e) { + Traincraft.tcLog.log(Level.WARN, "The method we called from Chicken core threw an exception", e); + } + } } - } - - @Override - public float getJukeboxVolume() { - return Minecraft.getMinecraft().gameSettings.getSoundLevel(SoundCategory.RECORDS) * Minecraft.getMinecraft().gameSettings.getSoundLevel(SoundCategory.MASTER); - } - - @Override - public void openadmingui(String data){ - Minecraft.getMinecraft().displayGuiScreen(new GUIAdminBook(data)); - } - - @Override - public void registerKeyBindingHandler() { - FMLCommonHandler.instance().bus().register(new TCKeyHandler()); - } - - @Override - public void setHook() { - JavaLayerUtils.setHook(new JLayerHook(Minecraft.getMinecraft())); - } + } + + @Override + public float getJukeboxVolume() { + return Minecraft.getMinecraft().gameSettings.getSoundLevel(SoundCategory.RECORDS) * Minecraft.getMinecraft().gameSettings.getSoundLevel(SoundCategory.MASTER); + } + + @Override + public void openadmingui(String data) { + Minecraft.getMinecraft().displayGuiScreen(new GUIAdminBook(data)); + } + + @Override + public void registerKeyBindingHandler() { + FMLCommonHandler.instance().bus().register(new TCKeyHandler()); + } + + @Override + public void setHook() { + JavaLayerUtils.setHook(new JLayerHook(Minecraft.getMinecraft())); + } } \ No newline at end of file diff --git a/src/main/java/train/client/core/handlers/ClientTickHandler.java b/src/main/java/train/client/core/handlers/ClientTickHandler.java index 9c11393be0..c010ec724d 100644 --- a/src/main/java/train/client/core/handlers/ClientTickHandler.java +++ b/src/main/java/train/client/core/handlers/ClientTickHandler.java @@ -1,7 +1,6 @@ package train.client.core.handlers; import com.mojang.authlib.minecraft.MinecraftProfileTexture; -import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.TickEvent; import cpw.mods.fml.relauncher.Side; @@ -11,57 +10,57 @@ import net.minecraft.item.ItemStack; import train.client.core.helpers.CapesHelper; import train.common.Traincraft; +import train.common.core.CommonProxy; import train.common.core.util.MP3Player; import train.common.library.Info; +import java.util.Objects; + public class ClientTickHandler { - private static final Minecraft mc = Minecraft.getMinecraft(); - private static boolean isHidden = false; + private static final Minecraft mc = Minecraft.getMinecraft(); + private static boolean isHidden = false; + + @SubscribeEvent + public void tick(TickEvent event) { + if (event.side != Side.CLIENT) { + return; + } + + if (Objects.requireNonNull(event.phase) == TickEvent.Phase.START) { + tickStart(event); + } + } + + private void tickStart(TickEvent event) { + if (mc.theWorld == null) { // fixes streaming after exiting a world + for (MP3Player player : CommonProxy.playerList) if (player != null) player.stop(); + CommonProxy.playerList.clear(); + } + if (mc.theWorld != null && mc.theWorld.playerEntities != null) { + for (Object p : mc.theWorld.playerEntities) { + AbstractClientPlayer player = (AbstractClientPlayer) p; + CapesHelper user = CapesHelper.users.get(player.getDisplayName()); - @SubscribeEvent - public void tick(TickEvent event) { - if(event.side != Side.CLIENT) { - return; - } - switch(event.phase) { - case START: - tickStart(event); - break; - case END: - break; - default: - break; - } - } + if (user == null) { + user = new CapesHelper(player.getDisplayName()); + CapesHelper.users.put(player.getDisplayName(), user); + user.setDaemon(true); + user.setName("Cape for " + player.getDisplayName()); + user.start(); + } else if (CapesHelper.isLoaded && user.MCCape) { + // NOTE: func_152121_a = switchTexture + player.func_152121_a(MinecraftProfileTexture.Type.CAPE, user.getCurrentRL()); + } + } + } - private void tickStart(TickEvent event) { - if (mc.theWorld == null) { // fixes streaming after exiting a world - for (MP3Player player : Traincraft.proxy.playerList) if (player != null) player.stop(); - Traincraft.proxy.playerList.clear(); - } - if(mc.theWorld != null && mc.theWorld.playerEntities != null) { - for (Object p: mc.theWorld.playerEntities) { - AbstractClientPlayer player = (AbstractClientPlayer) p; - CapesHelper user = CapesHelper.users.get(player.getDisplayName()); - if(user == null) { - user = new CapesHelper(player.getDisplayName()); - CapesHelper.users.put(player.getDisplayName(), user); - user.setDaemon(true); - user.setName("Cape for " + player.getDisplayName()); - user.start(); - }else if(CapesHelper.isLoaded && user.MCCape) { - // NOTE: func_152121_a = switchTexture - player.func_152121_a(MinecraftProfileTexture.Type.CAPE, user.getCurrentRL()); - } - } - } - if(!isHidden && Loader.isModLoaded("NotEnoughItems")) { - if(mc.theWorld != null && mc.theWorld.playerEntities != null) { - Traincraft.proxy.doNEICheck(new ItemStack(Block.getBlockFromName(Info.modID + ":tcRail"))); - Traincraft.proxy.doNEICheck(new ItemStack(Block.getBlockFromName(Info.modID + ":tcRailGag"))); - isHidden = true; - } - } - } + if (!isHidden && Traincraft.hasNotEnoughItems()) { + if (mc.theWorld != null && mc.theWorld.playerEntities != null) { + Traincraft.proxy.doNEICheck(new ItemStack(Block.getBlockFromName(Info.modID + ":tcRail"))); + Traincraft.proxy.doNEICheck(new ItemStack(Block.getBlockFromName(Info.modID + ":tcRailGag"))); + isHidden = true; + } + } + } } \ No newline at end of file diff --git a/src/main/java/train/client/core/handlers/CustomRenderHandler.java b/src/main/java/train/client/core/handlers/CustomRenderHandler.java index 2e8327a332..3279943f80 100644 --- a/src/main/java/train/client/core/handlers/CustomRenderHandler.java +++ b/src/main/java/train/client/core/handlers/CustomRenderHandler.java @@ -15,25 +15,25 @@ import org.lwjgl.util.vector.Vector2f; import train.client.render.RenderTCRail; import train.common.items.ItemTCRail; +import train.common.items.TCRailTypes; public class CustomRenderHandler { - String ballastMaterial; int blockColour; @SubscribeEvent - public void onRenderWorldLast(RenderWorldLastEvent event ) - { + public void onRenderWorldLast(RenderWorldLastEvent event) { EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer; - if ( player != null && player.getHeldItem() != null && ( player.getHeldItem().getItem() instanceof ItemTCRail) ) - { - renderTCRailPreview(player, player.getHeldItem() ); + if (player != null && player.getHeldItem() != null && (player.getHeldItem().getItem() instanceof ItemTCRail)) { + renderTCRailPreview(player, player.getHeldItem()); } } private void renderTCRailPreview(EntityClientPlayerMP player, ItemStack stack) { World world = Minecraft.getMinecraft().theWorld; - if(world==null || Minecraft.getMinecraft().objectMouseOver==null){return;} + if (world == null || Minecraft.getMinecraft().objectMouseOver == null) { + return; + } int x = Minecraft.getMinecraft().objectMouseOver.blockX; int y = Minecraft.getMinecraft().objectMouseOver.blockY; int z = Minecraft.getMinecraft().objectMouseOver.blockZ; @@ -42,8 +42,6 @@ private void renderTCRailPreview(EntityClientPlayerMP player, ItemStack stack) { return; } - - ItemTCRail item = (ItemTCRail) player.getHeldItem().getItem(); // Check if item can be placed and select color @@ -61,419 +59,262 @@ private void renderTCRailPreview(EntityClientPlayerMP player, ItemStack stack) { double px = TileEntityRendererDispatcher.staticPlayerX; double py = TileEntityRendererDispatcher.staticPlayerY; double pz = TileEntityRendererDispatcher.staticPlayerZ; - int facing; - - if (item.getTrackType().getType().equals("DIAGONAL")) { - facing = (MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F ) & 3) + 4; - } - else { - facing = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3; - } + int facing = item.getTrackType().getType() == TCRailTypes.DIAGONAL + ? (MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F) & 3) + 4 + : MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3; Vector2f dir = ItemTCRail.getDirectionVector(facing); - - String variant; - if (item.getTrackType().getLabel().contains("EMBEDDED")) { - variant = "embedded"; - } - else { - variant = "normal"; - } + String variant = item.getTrackType().getLabel().contains("EMBEDDED") ? "embedded" : "normal"; // Render GL11.glPushMatrix(); GL11.glTranslated(x - px, y + 1 - py, z - pz); - GL11.glClear( GL11.GL_DEPTH_BUFFER_BIT ); - GL11.glEnable( GL11.GL_BLEND ); + GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT); + GL11.glEnable(GL11.GL_BLEND); // Straights - if (item.getTrackType() == ItemTCRail.TrackTypes.SMALL_STRAIGHT - || item.getTrackType() == ItemTCRail.TrackTypes.MEDIUM_STRAIGHT - || item.getTrackType() == ItemTCRail.TrackTypes.LONG_STRAIGHT - || item.getTrackType() == ItemTCRail.TrackTypes.VERY_LONG_STRAIGHT - || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_SMALL_STRAIGHT - || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_MEDIUM_STRAIGHT - || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_LONG_STRAIGHT - || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_VERY_LONG_STRAIGHT) { + if (item.getTrackType().getType() == TCRailTypes.STRAIGHT) { int length = 1; - if (item.getTrackType() == ItemTCRail.TrackTypes.MEDIUM_STRAIGHT || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_MEDIUM_STRAIGHT) + if (item.getTrackType() == ItemTCRail.TrackTypes.MEDIUM_STRAIGHT || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_MEDIUM_STRAIGHT) length = 3; - if (item.getTrackType() == ItemTCRail.TrackTypes.LONG_STRAIGHT || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_LONG_STRAIGHT) + if (item.getTrackType() == ItemTCRail.TrackTypes.LONG_STRAIGHT || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_LONG_STRAIGHT) length = 6; - else if (item.getTrackType() == ItemTCRail.TrackTypes.VERY_LONG_STRAIGHT || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_VERY_LONG_STRAIGHT) + else if (item.getTrackType() == ItemTCRail.TrackTypes.VERY_LONG_STRAIGHT || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_VERY_LONG_STRAIGHT) length = 12; for (int i = 0; i < length; i++) { float dx = dir.getX() * i; float dz = dir.getY() * i; if (item.getTrackType().getLabel().contains("EMBEDDED")) - RenderTCRail.modelSmallStraight.render("embedded", facing, dx, 0, dz, r, g, b, a); - else RenderTCRail.modelSmallStraight.render("normal", facing, dx, 0, dz, r, g, b, a); + RenderTCRail.modelSmallStraight.render("embedded", facing, dx, 0, dz, r, g, b, a); + else RenderTCRail.modelSmallStraight.render("normal", facing, dx, 0, dz, r, g, b, a); } } - if (item.getTrackType() == ItemTCRail.TrackTypes.SMALL_DIAGONAL_STRAIGHT - || item.getTrackType() == ItemTCRail.TrackTypes.MEDIUM_DIAGONAL_STRAIGHT - || item.getTrackType() == ItemTCRail.TrackTypes.LONG_DIAGONAL_STRAIGHT - || item.getTrackType() == ItemTCRail.TrackTypes.VERY_LONG_DIAGONAL_STRAIGHT - || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_SMALL_DIAGONAL_STRAIGHT - || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_MEDIUM_DIAGONAL_STRAIGHT - || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_LONG_DIAGONAL_STRAIGHT - || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_VERY_LONG_DIAGONAL_STRAIGHT) { - int length = 1; - if (item.getTrackType() == ItemTCRail.TrackTypes.MEDIUM_DIAGONAL_STRAIGHT || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_MEDIUM_DIAGONAL_STRAIGHT) - length = 3; - if (item.getTrackType() == ItemTCRail.TrackTypes.LONG_DIAGONAL_STRAIGHT || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_LONG_DIAGONAL_STRAIGHT) - length = 6; - else if (item.getTrackType() == ItemTCRail.TrackTypes.VERY_LONG_DIAGONAL_STRAIGHT || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_VERY_LONG_DIAGONAL_STRAIGHT) - length = 12; + String labelType = item.getTrackType().getLabel().contains("EMBEDDED") ? "embedded" : "normal"; + + if (item.getTrackType().getType() == TCRailTypes.DIAGONAL) { + int length = getLength(item); float dx = 0; float dz = 0; for (int i = 0; i < length; i++) { if (facing == 6) { - dx = 1 * i; + dx = i; dz = -1 * i; } + if (facing == 4) { dx = -1 * i; - dz = 1 * i; + dz = i; } + if (facing == 7) { - dx = 1 * i; - dz = 1 * i; + dx = i; + dz = i; } + if (facing == 5) { dx = -1 * i; dz = -1 * i; } - if (item.getTrackType().getLabel().contains("EMBEDDED")) - RenderTCRail.modelSmallDiagonalStraight.render("embedded", facing, dx, 0, dz, r, g, b, a); - else RenderTCRail.modelSmallDiagonalStraight.render("normal", facing, dx, 0, dz, r, g, b, a); - } - } - - - + RenderTCRail.modelSmallDiagonalStraight.render(item.getTrackType().getLabel().contains("EMBEDDED") ? "embedded" : "normal", facing, dx, 0, dz, r, g, b, a); + } - // Crossing - else if (item.getTrackType() == ItemTCRail.TrackTypes.SMALL_ROAD_CROSSING) { + // Crossings + } else if (item.getTrackType() == ItemTCRail.TrackTypes.SMALL_ROAD_CROSSING) { RenderTCRail.modelSmallStraight.render("crossing", facing, 0, 0, 0, r, g, b, a); - } - else if (item.getTrackType() == ItemTCRail.TrackTypes.SMALL_ROAD_CROSSING_1) { + } else if (item.getTrackType() == ItemTCRail.TrackTypes.SMALL_ROAD_CROSSING_1) { RenderTCRail.modelSmallStraight.render("crossing1", facing, 0, 0, 0, r, g, b, a); - } - else if (item.getTrackType() == ItemTCRail.TrackTypes.SMALL_ROAD_CROSSING_2) { + } else if (item.getTrackType() == ItemTCRail.TrackTypes.SMALL_ROAD_CROSSING_2) { RenderTCRail.modelSmallStraight.render("crossing2", facing, 0, 0, 0, r, g, b, a); - } - else if (item.getTrackType() == ItemTCRail.TrackTypes.DOUBLE_DIAMOND_CROSSING || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_DOUBLE_DIAMOND_CROSSING) { - String type = "normal"; - if (item.getTrackType().getLabel().contains("EMBEDDED")) - type = "embedded"; + } else if (item.getTrackType() == ItemTCRail.TrackTypes.DOUBLE_DIAMOND_CROSSING || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_DOUBLE_DIAMOND_CROSSING) { float dx = dir.getX(); float dz = dir.getY(); - RenderTCRail.modelTwoWaysCrossing.render(type + "_diamond", dx, 0, dz, facing, r, g, b, a); - } - else if (item.getTrackType() == ItemTCRail.TrackTypes.DIAGONAL_TWO_WAYS_CROSSING || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_DIAGONAL_TWO_WAYS_CROSSING){ - String type = "normal"; - if (item.getTrackType().getLabel().contains("EMBEDDED")) - type = "embedded"; - RenderTCRail.modelTwoWaysCrossing.render(type + "_diagonal_crossing", 0, 0, 0, facing, r, g, b, a); - } - else if (item.getTrackType() == ItemTCRail.TrackTypes.FOUR_WAYS_CROSSING || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_FOUR_WAYS_CROSSING){ - String type = "normal"; - if (item.getTrackType().getLabel().contains("EMBEDDED")) - type = "embedded"; - RenderTCRail.modelTwoWaysCrossing.render(type + "_universal_crossing", 0, 0, 0, facing, r, g, b, a); - } - else if (item.getTrackType() == ItemTCRail.TrackTypes.DIAMOND_CROSSING || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_DIAMOND_CROSSING){ - float yaw = MathHelper.wrapAngleTo180_float(player.rotationYaw); - boolean isLeftTurn = item.getTrackOrientation( facing, yaw ).equals("left"); - String type = "normal"; - if (item.getTrackType().getLabel().contains("EMBEDDED")) - type = "embedded"; + + RenderTCRail.modelTwoWaysCrossing.render(labelType + "_diamond", dx, 0, dz, facing, r, g, b, a); + } else if (item.getTrackType() == ItemTCRail.TrackTypes.DIAGONAL_TWO_WAYS_CROSSING || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_DIAGONAL_TWO_WAYS_CROSSING) { + RenderTCRail.modelTwoWaysCrossing.render(labelType + "_diagonal_crossing", 0, 0, 0, facing, r, g, b, a); + } else if (item.getTrackType() == ItemTCRail.TrackTypes.FOUR_WAYS_CROSSING || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_FOUR_WAYS_CROSSING) { + RenderTCRail.modelTwoWaysCrossing.render(labelType + "_universal_crossing", 0, 0, 0, facing, r, g, b, a); + } else if (item.getTrackType() == ItemTCRail.TrackTypes.DIAMOND_CROSSING || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_DIAMOND_CROSSING) { float dx = dir.getX(); float dz = dir.getY(); - if (isLeftTurn){ - RenderTCRail.modelLeftDiamondCrossing.render(type , dx, 0, dz, facing, r, g, b, a); - } - else { - RenderTCRail.modelRightDiamondCrossing.render(type , dx, 0, dz, facing, r, g, b, a); - } - } - - - - else if (item.getTrackType() == ItemTCRail.TrackTypes.TWO_WAYS_CROSSING || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_TWO_WAYS_CROSSING) { - String type = "normal"; - if (item.getTrackType().getLabel().contains("EMBEDDED")) - type = "embedded"; + if (item.getTrackOrientation(facing, MathHelper.wrapAngleTo180_float(player.rotationYaw)).equals("left")) { + RenderTCRail.modelLeftDiamondCrossing.render(labelType, dx, 0, dz, facing, r, g, b, a); + } else { + RenderTCRail.modelRightDiamondCrossing.render(labelType, dx, 0, dz, facing, r, g, b, a); + } + } else if (item.getTrackType() == ItemTCRail.TrackTypes.TWO_WAYS_CROSSING || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_TWO_WAYS_CROSSING) { float dx = dir.getX(); float dz = dir.getY(); - RenderTCRail.modelTwoWaysCrossing.render( type + "_crossing", dx, 0, dz, facing, r, g, b, a ); - RenderTCRail.modelSmallStraight.render(type, 0, dx, 0, dz +1, r, g, b, a); - RenderTCRail.modelSmallStraight.render(type, 1, dx + 1, 0, dz, r, g, b, a); - RenderTCRail.modelSmallStraight.render(type, 2, dx, 0, dz - 1, r, g, b, a); - RenderTCRail.modelSmallStraight.render(type, 3, dx - 1, 0, dz, r, g, b, a); - } + RenderTCRail.modelTwoWaysCrossing.render(labelType + "_crossing", dx, 0, dz, facing, r, g, b, a); + RenderTCRail.modelSmallStraight.render(labelType, 0, dx, 0, dz + 1, r, g, b, a); + RenderTCRail.modelSmallStraight.render(labelType, 1, dx + 1, 0, dz, r, g, b, a); + RenderTCRail.modelSmallStraight.render(labelType, 2, dx, 0, dz - 1, r, g, b, a); + RenderTCRail.modelSmallStraight.render(labelType, 3, dx - 1, 0, dz, r, g, b, a); - // Slopes - else if (item.getTrackType() == ItemTCRail.TrackTypes.SLOPE_BALLAST) { + // Slopes + } else if (item.getTrackType() == ItemTCRail.TrackTypes.SLOPE_BALLAST) { blockInfo(); - RenderTCRail.modelSlope.render("ballast", facing, 0, 0, 0, r, g, b, a, ballastMaterial, blockColour ); - } - else if (item.getTrackType() == ItemTCRail.TrackTypes.SLOPE_GRAVEL) { + RenderTCRail.modelSlope.render("ballast", facing, 0, 0, 0, r, g, b, a, ballastMaterial, blockColour); + } else if (item.getTrackType() == ItemTCRail.TrackTypes.SLOPE_GRAVEL) { blockInfo(); RenderTCRail.modelSlope.render("gravel", facing, 0, 0, 0, r, g, b, a, ballastMaterial, blockColour); - } - else if (item.getTrackType() == ItemTCRail.TrackTypes.SLOPE_WOOD) { + } else if (item.getTrackType() == ItemTCRail.TrackTypes.SLOPE_WOOD) { blockInfo(); RenderTCRail.modelSlope.render("wood", facing, 0, 0, 0, r, g, b, a, ballastMaterial, blockColour); - } - else if (item.getTrackType() == ItemTCRail.TrackTypes.SLOPE_SNOW_GRAVEL) { + } else if (item.getTrackType() == ItemTCRail.TrackTypes.SLOPE_SNOW_GRAVEL) { blockInfo(); RenderTCRail.modelSlope.render("snow", facing, 0, 0, 0, r, g, b, a, ballastMaterial, blockColour); - } - else if (item.getTrackType() == ItemTCRail.TrackTypes.SLOPE_DYNAMIC) { + } else if (item.getTrackType() == ItemTCRail.TrackTypes.SLOPE_DYNAMIC) { blockInfo(); RenderTCRail.modelSlope.render("dynamic", facing, 0, 0, 0, r, g, b, a, ballastMaterial, blockColour); - } - else if (item.getTrackType() == ItemTCRail.TrackTypes.LARGE_SLOPE_BALLAST) { + } else if (item.getTrackType() == ItemTCRail.TrackTypes.LARGE_SLOPE_BALLAST) { blockInfo(); RenderTCRail.modelLargeSlope.render("ballast", facing, 0, 0, 0, r, g, b, a, ballastMaterial, blockColour); - } - else if (item.getTrackType() == ItemTCRail.TrackTypes.LARGE_SLOPE_GRAVEL) { + } else if (item.getTrackType() == ItemTCRail.TrackTypes.LARGE_SLOPE_GRAVEL) { blockInfo(); RenderTCRail.modelLargeSlope.render("gravel", facing, 0, 0, 0, r, g, b, a, ballastMaterial, blockColour); - } - else if (item.getTrackType() == ItemTCRail.TrackTypes.LARGE_SLOPE_WOOD) { + } else if (item.getTrackType() == ItemTCRail.TrackTypes.LARGE_SLOPE_WOOD) { blockInfo(); RenderTCRail.modelLargeSlope.render("wood", facing, 0, 0, 0, r, g, b, a, ballastMaterial, blockColour); - } - else if (item.getTrackType() == ItemTCRail.TrackTypes.LARGE_SLOPE_SNOW_GRAVEL) { + } else if (item.getTrackType() == ItemTCRail.TrackTypes.LARGE_SLOPE_SNOW_GRAVEL) { blockInfo(); RenderTCRail.modelLargeSlope.render("snow", facing, 0, 0, 0, r, g, b, a, ballastMaterial, blockColour); - } - else if (item.getTrackType() == ItemTCRail.TrackTypes.LARGE_SLOPE_DYNAMIC) { + } else if (item.getTrackType() == ItemTCRail.TrackTypes.LARGE_SLOPE_DYNAMIC) { blockInfo(); RenderTCRail.modelLargeSlope.render("dynamic", facing, 0, 0, 0, r, g, b, a, ballastMaterial, blockColour); - } - else if (item.getTrackType() == ItemTCRail.TrackTypes.VERY_LARGE_SLOPE_BALLAST) { + } else if (item.getTrackType() == ItemTCRail.TrackTypes.VERY_LARGE_SLOPE_BALLAST) { blockInfo(); RenderTCRail.modelVeryLargeSlope.render("ballast", facing, 0, 0, 0, r, g, b, a, ballastMaterial, blockColour); - } - else if (item.getTrackType() == ItemTCRail.TrackTypes.VERY_LARGE_SLOPE_GRAVEL) { + } else if (item.getTrackType() == ItemTCRail.TrackTypes.VERY_LARGE_SLOPE_GRAVEL) { blockInfo(); RenderTCRail.modelVeryLargeSlope.render("gravel", facing, 0, 0, 0, r, g, b, a, ballastMaterial, blockColour); - } - else if (item.getTrackType() == ItemTCRail.TrackTypes.VERY_LARGE_SLOPE_WOOD) { + } else if (item.getTrackType() == ItemTCRail.TrackTypes.VERY_LARGE_SLOPE_WOOD) { blockInfo(); RenderTCRail.modelVeryLargeSlope.render("wood", facing, 0, 0, 0, r, g, b, a, ballastMaterial, blockColour); - } - else if (item.getTrackType() == ItemTCRail.TrackTypes.VERY_LARGE_SLOPE_SNOW_GRAVEL) { + } else if (item.getTrackType() == ItemTCRail.TrackTypes.VERY_LARGE_SLOPE_SNOW_GRAVEL) { blockInfo(); RenderTCRail.modelVeryLargeSlope.render("snow", facing, 0, 0, 0, r, g, b, a, ballastMaterial, blockColour); - } - else if (item.getTrackType() == ItemTCRail.TrackTypes.VERY_LARGE_SLOPE_DYNAMIC) { + } else if (item.getTrackType() == ItemTCRail.TrackTypes.VERY_LARGE_SLOPE_DYNAMIC) { blockInfo(); RenderTCRail.modelVeryLargeSlope.render("dynamic", facing, 0, 0, 0, r, g, b, a, ballastMaterial, blockColour); - } - else if (item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_SLOPE_DYNAMIC) { + } else if (item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_SLOPE_DYNAMIC) { blockInfo(); RenderTCRail.modelSlope.render("embedded_dynamic", facing, 0, 0, 0, r, g, b, a, ballastMaterial, blockColour); - } - else if (item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_LARGE_SLOPE_DYNAMIC) { + } else if (item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_LARGE_SLOPE_DYNAMIC) { blockInfo(); RenderTCRail.modelLargeSlope.render("embedded_dynamic", facing, 0, 0, 0, r, g, b, a, ballastMaterial, blockColour); - } - else if (item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_VERY_LARGE_SLOPE_DYNAMIC) { + } else if (item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_VERY_LARGE_SLOPE_DYNAMIC) { blockInfo(); RenderTCRail.modelVeryLargeSlope.render("embedded_dynamic", facing, 0, 0, 0, r, g, b, a, ballastMaterial, blockColour); - } - else if (item.getTrackType() == ItemTCRail.TrackTypes.LARGE_CURVED_SLOPE_DYNAMIC || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_LARGE_CURVED_SLOPE_DYNAMIC - || item.getTrackType() == ItemTCRail.TrackTypes.VERY_LARGE_CURVED_SLOPE_DYNAMIC || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_VERY_LARGE_CURVED_SLOPE_DYNAMIC - || item.getTrackType() == ItemTCRail.TrackTypes.SUPER_LARGE_CURVED_SLOPE_DYNAMIC || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_SUPER_LARGE_CURVED_SLOPE_DYNAMIC) { - float yaw = MathHelper.wrapAngleTo180_float(player.rotationYaw); - boolean isLeftTurn = item.getTrackOrientation( facing, yaw ).equals("left"); - + } else if (item.getTrackType().getType() == TCRailTypes.CURVED_SLOPE) { if (item.getTrackType() == ItemTCRail.TrackTypes.LARGE_CURVED_SLOPE_DYNAMIC || item.getTrackType() == ItemTCRail.TrackTypes.VERY_LARGE_CURVED_SLOPE_DYNAMIC || item.getTrackType() == ItemTCRail.TrackTypes.SUPER_LARGE_CURVED_SLOPE_DYNAMIC - || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_LARGE_CURVED_SLOPE_DYNAMIC || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_VERY_LARGE_CURVED_SLOPE_DYNAMIC || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_SUPER_LARGE_CURVED_SLOPE_DYNAMIC){ + || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_LARGE_CURVED_SLOPE_DYNAMIC || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_VERY_LARGE_CURVED_SLOPE_DYNAMIC || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_SUPER_LARGE_CURVED_SLOPE_DYNAMIC) { String turnSize = "large"; - if (item.getTrackType() == ItemTCRail.TrackTypes.VERY_LARGE_CURVED_SLOPE_DYNAMIC) + if (item.getTrackType() == ItemTCRail.TrackTypes.VERY_LARGE_CURVED_SLOPE_DYNAMIC) { turnSize = "verylarge"; - else if (item.getTrackType() == ItemTCRail.TrackTypes.SUPER_LARGE_CURVED_SLOPE_DYNAMIC) - turnSize = "superlarge"; - else if (item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_LARGE_CURVED_SLOPE_DYNAMIC) - turnSize = "embedded_large"; - else if (item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_VERY_LARGE_CURVED_SLOPE_DYNAMIC) - turnSize = "embedded_verylarge"; - else if (item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_SUPER_LARGE_CURVED_SLOPE_DYNAMIC) - turnSize = "embedded_superlarge"; - blockInfo(); - if ( isLeftTurn ) - { - RenderTCRail.modelLeftCurvedSlope.render( turnSize, facing, 0, 0, 0, r, g, b, a, ballastMaterial, blockColour ); - } - else - { - RenderTCRail.modelRightCurvedSlope.render( turnSize, facing, 0, 0, 0, r, g, b, a, ballastMaterial, blockColour ); + } else if (item.getTrackType() == ItemTCRail.TrackTypes.SUPER_LARGE_CURVED_SLOPE_DYNAMIC) { + turnSize = "superlarge"; + } else if (item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_LARGE_CURVED_SLOPE_DYNAMIC) { + turnSize = "embedded_large"; + } else if (item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_VERY_LARGE_CURVED_SLOPE_DYNAMIC) { + turnSize = "embedded_verylarge"; + } else if (item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_SUPER_LARGE_CURVED_SLOPE_DYNAMIC) { + turnSize = "embedded_superlarge"; } - } - - } - + blockInfo(); - /** Normal Parallel Curves*/ - - else if (item.getTrackType() == ItemTCRail.TrackTypes.SMALL_PARALLEL_CURVE - || item.getTrackType() == ItemTCRail.TrackTypes.MEDIUM_PARALLEL_CURVE - || item.getTrackType() == ItemTCRail.TrackTypes.LARGE_PARALLEL_CURVE - || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_SMALL_PARALLEL_CURVE - || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_MEDIUM_PARALLEL_CURVE - || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_LARGE_PARALLEL_CURVE) - { - float yaw = MathHelper.wrapAngleTo180_float(player.rotationYaw); - boolean isLeftTurn = item.getTrackOrientation( facing, yaw ).equals("left"); - - if (item.getTrackType() == ItemTCRail.TrackTypes.SMALL_PARALLEL_CURVE - || item.getTrackType() == ItemTCRail.TrackTypes.MEDIUM_PARALLEL_CURVE - || item.getTrackType() == ItemTCRail.TrackTypes.LARGE_PARALLEL_CURVE - || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_SMALL_PARALLEL_CURVE - || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_MEDIUM_PARALLEL_CURVE - || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_LARGE_PARALLEL_CURVE) { - String turnSize = "small"; - if ( item.getTrackType() == ItemTCRail.TrackTypes.MEDIUM_PARALLEL_CURVE || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_MEDIUM_PARALLEL_CURVE ) - turnSize = "medium"; - else if ( item.getTrackType() == ItemTCRail.TrackTypes.LARGE_PARALLEL_CURVE || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_LARGE_PARALLEL_CURVE ) - turnSize = "large"; - if ( isLeftTurn ) - { - RenderTCRail.modelLeftParallelCurve.render( turnSize, variant, facing, 0, 0, 0, r, g, b, a ); - } - else - { - RenderTCRail.modelRightParallelCurve.render( turnSize, variant, facing, 0, 0, 0, r, g, b, a ); + if (item.getTrackOrientation(facing, MathHelper.wrapAngleTo180_float(player.rotationYaw)).equals("left")) { + RenderTCRail.modelLeftCurvedSlope.render(turnSize, facing, 0, 0, 0, r, g, b, a, ballastMaterial, blockColour); + } else { + RenderTCRail.modelRightCurvedSlope.render(turnSize, facing, 0, 0, 0, r, g, b, a, ballastMaterial, blockColour); } } - } - // 45 Degree Turns - - else if (item.getTrackType() == ItemTCRail.TrackTypes.MEDIUM_45DEGREE_TURN || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_MEDIUM_45DEGREE_TURN - || item.getTrackType() == ItemTCRail.TrackTypes.LARGE_45DEGREE_TURN || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_LARGE_45DEGREE_TURN - || item.getTrackType() == ItemTCRail.TrackTypes.VERY_LARGE_45DEGREE_TURN || item.getTrackType() == ItemTCRail.TrackTypes.SUPER_LARGE_45DEGREE_TURN - || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_VERY_LARGE_45DEGREE_TURN || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_SUPER_LARGE_45DEGREE_TURN) { - float yaw = MathHelper.wrapAngleTo180_float(player.rotationYaw); - boolean isLeftTurn = item.getTrackOrientation( facing, yaw ).equals("left"); - String turnSize = "medium"; - if (item.getTrackType() == ItemTCRail.TrackTypes.LARGE_45DEGREE_TURN || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_LARGE_45DEGREE_TURN ) + + // Normal Parallel Curves + } else if (item.getTrackType().getType() == TCRailTypes.CURVE) { + String turnSize = "small"; + if (item.getTrackType() == ItemTCRail.TrackTypes.MEDIUM_PARALLEL_CURVE || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_MEDIUM_PARALLEL_CURVE) { + turnSize = "medium"; + } else if (item.getTrackType() == ItemTCRail.TrackTypes.LARGE_PARALLEL_CURVE || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_LARGE_PARALLEL_CURVE) { turnSize = "large"; - if (item.getTrackType() == ItemTCRail.TrackTypes.VERY_LARGE_45DEGREE_TURN || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_VERY_LARGE_45DEGREE_TURN ) - turnSize = "verylarge"; - if (item.getTrackType() == ItemTCRail.TrackTypes.SUPER_LARGE_45DEGREE_TURN || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_SUPER_LARGE_45DEGREE_TURN ) - turnSize = "superlarge"; - if ( isLeftTurn ) - { - RenderTCRail.model45DegreeLeftTurn.render( turnSize, variant, facing, 0, 0, 0, r, g, b, a ); - } - else - { - RenderTCRail.model45DegreeRightTurn.render( turnSize, variant, facing, 0, 0, 0, r, g, b, a ); - } } + if (item.getTrackOrientation(facing, MathHelper.wrapAngleTo180_float(player.rotationYaw)).equals("left")) { + RenderTCRail.modelLeftParallelCurve.render(turnSize, variant, facing, 0, 0, 0, r, g, b, a); + } else { + RenderTCRail.modelRightParallelCurve.render(turnSize, variant, facing, 0, 0, 0, r, g, b, a); + } + // 45 Degree Turns + } else if (item.getTrackType().getType() == TCRailTypes.SHARP_TURN) { + String turnSize = "medium"; + if (item.getTrackType() == ItemTCRail.TrackTypes.LARGE_45DEGREE_TURN || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_LARGE_45DEGREE_TURN) { + turnSize = "large"; + } + if (item.getTrackType() == ItemTCRail.TrackTypes.VERY_LARGE_45DEGREE_TURN || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_VERY_LARGE_45DEGREE_TURN) { + turnSize = "verylarge"; + } - // Turns - else if (item.getTrackType() == ItemTCRail.TrackTypes.MEDIUM_TURN - || item.getTrackType() == ItemTCRail.TrackTypes.LARGE_TURN - || item.getTrackType() == ItemTCRail.TrackTypes.VERY_LARGE_TURN - || item.getTrackType() == ItemTCRail.TrackTypes.SUPER_LARGE_TURN - || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_MEDIUM_TURN - || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_LARGE_TURN - || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_VERY_LARGE_TURN - || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_SUPER_LARGE_TURN) - - - - { - float yaw = MathHelper.wrapAngleTo180_float(player.rotationYaw); - boolean isLeftTurn = item.getTrackOrientation( facing, yaw ).equals("left"); + if (item.getTrackType() == ItemTCRail.TrackTypes.SUPER_LARGE_45DEGREE_TURN || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_SUPER_LARGE_45DEGREE_TURN) { + turnSize = "superlarge"; + } + if (item.getTrackOrientation(facing, MathHelper.wrapAngleTo180_float(player.rotationYaw)).equals("left")) { + RenderTCRail.model45DegreeLeftTurn.render(turnSize, variant, facing, 0, 0, 0, r, g, b, a); + } else { + RenderTCRail.model45DegreeRightTurn.render(turnSize, variant, facing, 0, 0, 0, r, g, b, a); + } + // Turns + } else if (item.getTrackType().getType() == TCRailTypes.TURN) { if (item.getTrackType() == ItemTCRail.TrackTypes.MEDIUM_TURN || item.getTrackType() == ItemTCRail.TrackTypes.LARGE_TURN - || item.getTrackType() == ItemTCRail.TrackTypes.VERY_LARGE_TURN || item.getTrackType() == ItemTCRail.TrackTypes.SUPER_LARGE_TURN + || item.getTrackType() == ItemTCRail.TrackTypes.VERY_LARGE_TURN || item.getTrackType() == ItemTCRail.TrackTypes.SUPER_LARGE_TURN || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_MEDIUM_TURN || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_LARGE_TURN || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_VERY_LARGE_TURN || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_SUPER_LARGE_TURN) { String turnSize = "medium"; - if ( item.getTrackType() == ItemTCRail.TrackTypes.LARGE_TURN || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_LARGE_TURN) + if (item.getTrackType() == ItemTCRail.TrackTypes.LARGE_TURN || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_LARGE_TURN) turnSize = "large"; - else if ( item.getTrackType() == ItemTCRail.TrackTypes.VERY_LARGE_TURN || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_VERY_LARGE_TURN) + else if (item.getTrackType() == ItemTCRail.TrackTypes.VERY_LARGE_TURN || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_VERY_LARGE_TURN) turnSize = "very_large"; - else if ( item.getTrackType() == ItemTCRail.TrackTypes.SUPER_LARGE_TURN || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_SUPER_LARGE_TURN) + else if (item.getTrackType() == ItemTCRail.TrackTypes.SUPER_LARGE_TURN || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_SUPER_LARGE_TURN) turnSize = "super_large"; - if ( isLeftTurn ) - { - if (item.getTrackType().getLabel().contains("EMBEDDED")) - RenderTCRail.modelLeftTurn.render( "embedded_" + turnSize, facing, 0, 0, 0, r, g, b, a ); - else RenderTCRail.modelLeftTurn.render( turnSize, facing, 0, 0, 0, r, g, b, a ); - } else - { - if (item.getTrackType().getLabel().contains("EMBEDDED")) - RenderTCRail.modelRightTurn.render( "embedded_" + turnSize, facing, 0, 0, 0, r, g, b, a ); - else RenderTCRail.modelRightTurn.render( turnSize, facing, 0, 0, 0, r, g, b, a ); + if (item.getTrackOrientation(facing, MathHelper.wrapAngleTo180_float(player.rotationYaw)).equals("left")) { + RenderTCRail.modelLeftTurn.render((item.getTrackType().getLabel().contains("EMBEDDED") ? "embedded_" : "") + turnSize, facing, 0, 0, 0, r, g, b, a); + } else { + RenderTCRail.modelRightTurn.render((item.getTrackType().getLabel().contains("EMBEDDED") ? "embedded_" : "") + turnSize, facing, 0, 0, 0, r, g, b, a); } } - - - - - - - } - - // switches - else if (item.getTrackType() == ItemTCRail.TrackTypes.MEDIUM_SWITCH - || item.getTrackType() == ItemTCRail.TrackTypes.MEDIUM_PARALLEL_SWITCH - || item.getTrackType() == ItemTCRail.TrackTypes.LARGE_SWITCH - || item.getTrackType() == ItemTCRail.TrackTypes.MEDIUM_45DEGREE_SWITCH - || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_MEDIUM_SWITCH - || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_MEDIUM_PARALLEL_SWITCH - || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_LARGE_SWITCH - || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_MEDIUM_45DEGREE_SWITCH) - - { - float yaw = MathHelper.wrapAngleTo180_float(player.rotationYaw); - boolean isLeftTurn = item.getTrackOrientation( facing, yaw ).equals("left"); - - + // Switches + } else if (item.getTrackType().getType() == TCRailTypes.SWITCH) { + boolean isLeftTurn = item.getTrackOrientation(facing, MathHelper.wrapAngleTo180_float(player.rotationYaw)).equals("left"); float dx = dir.getX(); float dz = dir.getY(); int out_0_start = 3; int out_0_end = 3; - int facing_1 = isLeftTurn ? (facing + 4 - 1)%4 : (facing + 1)%4; + int facing_1 = isLeftTurn ? (facing + 4 - 1) % 4 : (facing + 1) % 4; int out_1_0 = 3; int out_1_1 = 3; String switchType = "medium"; - if ( item.getTrackType() == ItemTCRail.TrackTypes.MEDIUM_PARALLEL_SWITCH || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_MEDIUM_PARALLEL_SWITCH) { + if (item.getTrackType() == ItemTCRail.TrackTypes.MEDIUM_PARALLEL_SWITCH || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_MEDIUM_PARALLEL_SWITCH) { switchType = "medium_parallel"; out_0_start = 5; out_0_end = 10; out_1_0 = 10; - out_1_1 = 3; - } - else if ( item.getTrackType() == ItemTCRail.TrackTypes.LARGE_SWITCH || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_LARGE_SWITCH) { + } else if (item.getTrackType() == ItemTCRail.TrackTypes.LARGE_SWITCH || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_LARGE_SWITCH) { switchType = "large_90"; out_0_start = 5; out_0_end = 5; out_1_0 = 5; out_1_1 = 5; - } - else if ( item.getTrackType() == ItemTCRail.TrackTypes.MEDIUM_45DEGREE_SWITCH || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_MEDIUM_45DEGREE_SWITCH) { + } else if (item.getTrackType() == ItemTCRail.TrackTypes.MEDIUM_45DEGREE_SWITCH || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_MEDIUM_45DEGREE_SWITCH) { switchType = "medium_45degree"; out_0_start = 0; out_0_end = 0; @@ -481,57 +322,57 @@ else if ( item.getTrackType() == ItemTCRail.TrackTypes.MEDIUM_45DEGREE_SWITCH | out_1_1 = 0; } - Vector2f dir_1 = ItemTCRail.getDirectionVector( facing_1 ); + Vector2f dir_1 = ItemTCRail.getDirectionVector(facing_1); float dx_1 = dir_1.getX(); float dz_1 = dir_1.getY(); - // Render straight tracks - - for ( int out_0 = out_0_start; out_0 < out_0_end + 1; out_0++ ) - RenderTCRail.modelSmallStraight.render( variant, facing, dx * out_0, 0, dz * out_0, r, g, b, a ); - - if ( item.getTrackType() == ItemTCRail.TrackTypes.MEDIUM_PARALLEL_SWITCH || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_MEDIUM_PARALLEL_SWITCH) - { - RenderTCRail.modelSmallStraight.render( variant, facing, 0, 0, 0, r, g, b, a ); - RenderTCRail.modelSmallStraight.render( variant, facing, dx * out_1_0 + dx_1 * out_1_1, 0, dz * out_1_0 + dz_1 * out_1_1, r, g, b, a ); + // Render straight tracks + for (int out_0 = out_0_start; out_0 < out_0_end + 1; out_0++) { + RenderTCRail.modelSmallStraight.render(variant, facing, dx * out_0, 0, dz * out_0, r, g, b, a); } - else if ( item.getTrackType() == ItemTCRail.TrackTypes.MEDIUM_45DEGREE_SWITCH || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_MEDIUM_45DEGREE_SWITCH ) - { + if (item.getTrackType() == ItemTCRail.TrackTypes.MEDIUM_PARALLEL_SWITCH || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_MEDIUM_PARALLEL_SWITCH) { + RenderTCRail.modelSmallStraight.render(variant, facing, 0, 0, 0, r, g, b, a); + RenderTCRail.modelSmallStraight.render(variant, facing, dx * out_1_0 + dx_1 * out_1_1, 0, dz * out_1_0 + dz_1 * out_1_1, r, g, b, a); + } else { + RenderTCRail.modelSmallStraight.render(variant, facing, 0, 0, 0, r, g, b, a); + RenderTCRail.modelSmallStraight.render(variant, facing_1, dx * out_1_0 + dx_1 * out_1_1, 0, dz * out_1_0 + dz_1 * out_1_1, r, g, b, a); } - else - { - RenderTCRail.modelSmallStraight.render( variant, facing, 0, 0, 0, r, g, b, a ); - RenderTCRail.modelSmallStraight.render( variant, facing_1, dx * out_1_0 + dx_1 * out_1_1, 0, dz * out_1_0 + dz_1 * out_1_1, r, g, b, a ); - } - - // Render switch - if ( isLeftTurn ) - { - RenderTCRail.modelLeftSwitchTurn.render( switchType, variant, facing, false, dx,0, dz, r, g, b, a ); - } else - { - RenderTCRail.modelRightSwitchTurn.render( switchType, variant, facing, false, dx,0,dz, r, g, b, a ); + // Render switch + if (isLeftTurn) { + RenderTCRail.modelLeftSwitchTurn.render(switchType, variant, facing, false, dx, 0, dz, r, g, b, a); + } else { + RenderTCRail.modelRightSwitchTurn.render(switchType, variant, facing, false, dx, 0, dz, r, g, b, a); } } + GL11.glPopMatrix(); + } + private static int getLength(ItemTCRail item) { + int length = 1; + if (item.getTrackType() == ItemTCRail.TrackTypes.MEDIUM_DIAGONAL_STRAIGHT || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_MEDIUM_DIAGONAL_STRAIGHT) { + length = 3; + } - GL11.glPopMatrix(); + if (item.getTrackType() == ItemTCRail.TrackTypes.LONG_DIAGONAL_STRAIGHT || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_LONG_DIAGONAL_STRAIGHT) { + length = 6; + } else if (item.getTrackType() == ItemTCRail.TrackTypes.VERY_LONG_DIAGONAL_STRAIGHT || item.getTrackType() == ItemTCRail.TrackTypes.EMBEDDED_VERY_LONG_DIAGONAL_STRAIGHT) { + length = 12; + } + return length; } private void blockInfo() { World world = Minecraft.getMinecraft().theWorld; - EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer; - ItemTCRail item = (ItemTCRail) player.getHeldItem().getItem(); int x = Minecraft.getMinecraft().objectMouseOver.blockX; int y = Minecraft.getMinecraft().objectMouseOver.blockY; int z = Minecraft.getMinecraft().objectMouseOver.blockZ; - Block block = world.getBlock(x,y,z); - int metadata = world.getBlockMetadata(x,y,z); + Block block = world.getBlock(x, y, z); + int metadata = world.getBlockMetadata(x, y, z); + blockColour = block.colorMultiplier(world, x, y, z); IIcon icon = block.getIcon(1, metadata); - String iconName = icon.getIconName(); - ballastMaterial = iconName; + ballastMaterial = icon.getIconName(); } } diff --git a/src/main/java/train/client/core/handlers/RecipeBookHandler.java b/src/main/java/train/client/core/handlers/RecipeBookHandler.java index 54fa4bbafc..cad3e0cbe6 100644 --- a/src/main/java/train/client/core/handlers/RecipeBookHandler.java +++ b/src/main/java/train/client/core/handlers/RecipeBookHandler.java @@ -14,63 +14,63 @@ import java.util.Set; public class RecipeBookHandler { - /** - * This is used to show if the recipe can also be crafted in vanilla workbench - */ - public static String[] vanillaWorkTableRecipes = new String[21]; + /** + * This is used to show if the recipe can also be crafted in vanilla workbench + */ + public static String[] vanillaWorkTableRecipes = new String[21]; - public RecipeBookHandler() { - vanillaWorkTableRecipes[0] = BlockIDs.assemblyTableI.block.getUnlocalizedName(); - vanillaWorkTableRecipes[1] = BlockIDs.assemblyTableII.block.getUnlocalizedName(); - vanillaWorkTableRecipes[2] = BlockIDs.assemblyTableIII.block.getUnlocalizedName(); - vanillaWorkTableRecipes[3] = BlockIDs.distilIdle.block.getUnlocalizedName(); - vanillaWorkTableRecipes[4] = BlockIDs.openFurnaceIdle.block.getUnlocalizedName(); - vanillaWorkTableRecipes[5] = BlockIDs.trainWorkbench.block.getUnlocalizedName(); - vanillaWorkTableRecipes[6] = ItemIDs.overalls.item.getUnlocalizedName(); - vanillaWorkTableRecipes[7] = ItemIDs.jacket.item.getUnlocalizedName(); - vanillaWorkTableRecipes[8] = ItemIDs.hat.item.getUnlocalizedName(); - vanillaWorkTableRecipes[11] = ItemIDs.recipeBook.item.getUnlocalizedName(); - vanillaWorkTableRecipes[12] = BlockIDs.lantern.block.getUnlocalizedName(); - vanillaWorkTableRecipes[14] = ItemIDs.pants_driver_paintable.item.getUnlocalizedName(); - vanillaWorkTableRecipes[15] = ItemIDs.pants_ticketMan_paintable.item.getUnlocalizedName(); - vanillaWorkTableRecipes[16] = ItemIDs.hat_driver_paintable.item.getUnlocalizedName(); - vanillaWorkTableRecipes[17] = ItemIDs.hat_ticketMan_paintable.item.getUnlocalizedName(); - vanillaWorkTableRecipes[18] = ItemIDs.jacket_driver_paintable.item.getUnlocalizedName(); - vanillaWorkTableRecipes[19] = ItemIDs.jacket_ticketMan_paintable.item.getUnlocalizedName(); - vanillaWorkTableRecipes[20] = BlockIDs.switchStand.block.getUnlocalizedName(); - } + public RecipeBookHandler() { + vanillaWorkTableRecipes[0] = BlockIDs.assemblyTableI.block.getUnlocalizedName(); + vanillaWorkTableRecipes[1] = BlockIDs.assemblyTableII.block.getUnlocalizedName(); + vanillaWorkTableRecipes[2] = BlockIDs.assemblyTableIII.block.getUnlocalizedName(); + vanillaWorkTableRecipes[3] = BlockIDs.distilIdle.block.getUnlocalizedName(); + vanillaWorkTableRecipes[4] = BlockIDs.openFurnaceIdle.block.getUnlocalizedName(); + vanillaWorkTableRecipes[5] = BlockIDs.trainWorkbench.block.getUnlocalizedName(); + vanillaWorkTableRecipes[6] = ItemIDs.overalls.item.getUnlocalizedName(); + vanillaWorkTableRecipes[7] = ItemIDs.jacket.item.getUnlocalizedName(); + vanillaWorkTableRecipes[8] = ItemIDs.hat.item.getUnlocalizedName(); + vanillaWorkTableRecipes[11] = ItemIDs.recipeBook.item.getUnlocalizedName(); + vanillaWorkTableRecipes[12] = BlockIDs.lantern.block.getUnlocalizedName(); + vanillaWorkTableRecipes[14] = ItemIDs.pants_driver_paintable.item.getUnlocalizedName(); + vanillaWorkTableRecipes[15] = ItemIDs.pants_ticketMan_paintable.item.getUnlocalizedName(); + vanillaWorkTableRecipes[16] = ItemIDs.hat_driver_paintable.item.getUnlocalizedName(); + vanillaWorkTableRecipes[17] = ItemIDs.hat_ticketMan_paintable.item.getUnlocalizedName(); + vanillaWorkTableRecipes[18] = ItemIDs.jacket_driver_paintable.item.getUnlocalizedName(); + vanillaWorkTableRecipes[19] = ItemIDs.jacket_ticketMan_paintable.item.getUnlocalizedName(); + vanillaWorkTableRecipes[20] = BlockIDs.switchStand.block.getUnlocalizedName(); + } - // TODO: Make parameters more specific than List - public static List workbenchListCleaner(List recipeList) { - Set outputs = new HashSet(); - ArrayList cleaned = new ArrayList(); - for(Object r: recipeList) { - if (r instanceof ShapedTrainRecipes || r instanceof ShapelessTrainRecipe) { - ITCRecipe recipe = (ITCRecipe) r; - String output = Item.itemRegistry.getNameForObject(recipe.getRecipeOutput().getItem()); - if (!outputs.contains(output)) { - cleaned.add(recipe); - outputs.add(output); - } - } - } - return cleaned; - } + // TODO: Make parameters more specific than List + public static List workbenchListCleaner(List recipeList) { + Set outputs = new HashSet<>(); + List cleaned = new ArrayList<>(); + for (Object r : recipeList) { + if (r instanceof ShapedTrainRecipes || r instanceof ShapelessTrainRecipe) { + ITCRecipe recipe = (ITCRecipe) r; + String output = Item.itemRegistry.getNameForObject(recipe.getRecipeOutput().getItem()); + if (!outputs.contains(output)) { + cleaned.add(recipe); + outputs.add(output); + } + } + } + return cleaned; + } - // TODO: Make it more generic: TierRecipe -> ITierRecipe - public static List assemblyListCleaner(List recipeList) { - Set outputs = new HashSet(); - ArrayList cleanedList = new ArrayList(); - for(Object r: recipeList) { - if(r instanceof TierRecipe) { - TierRecipe recipe = (TierRecipe) r; - String output = Item.itemRegistry.getNameForObject(recipe.getOutput().getItem()); - if (!outputs.contains(output)) { - cleanedList.add(recipe); - outputs.add(output); - } - } - } - return cleanedList; - } + // TODO: Make it more generic: TierRecipe -> ITierRecipe + public static List assemblyListCleaner(List recipeList) { + Set outputs = new HashSet<>(); + List cleanedList = new ArrayList<>(); + for (Object r : recipeList) { + if (r instanceof TierRecipe) { + TierRecipe recipe = (TierRecipe) r; + String output = Item.itemRegistry.getNameForObject(recipe.getOutput().getItem()); + if (!outputs.contains(output)) { + cleanedList.add(recipe); + outputs.add(output); + } + } + } + return cleanedList; + } } \ No newline at end of file diff --git a/src/main/java/train/client/core/handlers/SoundUpdaterRollingStock.java b/src/main/java/train/client/core/handlers/SoundUpdaterRollingStock.java index e3ab4d6431..26e507d4b0 100644 --- a/src/main/java/train/client/core/handlers/SoundUpdaterRollingStock.java +++ b/src/main/java/train/client/core/handlers/SoundUpdaterRollingStock.java @@ -13,111 +13,51 @@ //TODO Fix the sounds @SideOnly(Side.CLIENT) public class SoundUpdaterRollingStock { - - private SoundHandler theSoundManager; - - /** Minecart which sound is being updated. */ - private EntityRollingStock theMinecart; - - /** The player that is getting the minecart sound updates. */ - private EntityPlayerSP thePlayer; - private boolean riddenByPlayer = false; - private boolean isDead = false; - private boolean isMoving = false; - private boolean flag = false; - private float soundPitch = 0.0F; - private float volume1 = 0.0F; - private float volume2 = 0.0F; - private double cartSpeed = 0.0D; - - public void update(SoundHandler par1SoundManager, EntityRollingStock rollingStock, EntityPlayerSP par3EntityPlayerSP) { - this.theSoundManager = par1SoundManager; - this.theMinecart = rollingStock; - this.thePlayer = par3EntityPlayerSP; - if (this.theSoundManager == null || this.theMinecart == null || this.thePlayer == null) - return; - if (!ConfigHandler.SOUNDS || rollingStock instanceof EntityJukeBoxCart || rollingStock instanceof Locomotive) - return;//it somehow interferes with the music disks - boolean var1 = false; - boolean var2 = this.riddenByPlayer; - boolean var3 = this.isDead; - boolean var4 = this.isMoving; - float var5 = this.volume1; - float var6 = this.soundPitch; - float var7 = this.volume2; - double var8 = this.cartSpeed; - this.riddenByPlayer = this.thePlayer != null && this.theMinecart.riddenByEntity == this.thePlayer; - this.isDead = this.theMinecart.isDead; - //System.out.println(MathHelper.sqrt_double(this.theMinecart.getMotionXClient()*this.theMinecart.getMotionXClient()+this.theMinecart.getMotionZClient()*this.theMinecart.getMotionZClient())/100); - this.cartSpeed = MathHelper.sqrt_double(this.theMinecart.getMotionXClient() * this.theMinecart.getMotionXClient() + this.theMinecart.getMotionZClient() * this.theMinecart.getMotionZClient()) / 100; - this.isMoving = this.cartSpeed >= 0.01D; - //System.out.println(isMoving); - //if (var2 && !this.riddenByPlayer) { - //this.theSoundManager.stopEntitySound(this.thePlayer); - //} - - if (this.isDead || !this.flag && this.volume1 == 0.0F && this.volume2 == 0.0F) { - /*if (!var3) { - //this.theSoundManager.stopEntitySound(this.theMinecart); - if (var2 || this.riddenByPlayer) { - //this.theSoundManager.stopEntitySound(this.thePlayer); - } - }*/ - this.flag = true; - if (this.isDead) { - return; - } - } - - /* - if (!this.theSoundManager.isEntitySoundPlaying(this.theMinecart) && this.volume1 > 0.0F) { - this.theSoundManager.playEntitySound("minecart.base", this.theMinecart, this.volume1, this.soundPitch, false); - this.flag = false; - var1 = true; - } - */ - if (this.isMoving) { - if (this.soundPitch < 1.0F) { - this.soundPitch += 0.0025F; - } - if (this.soundPitch > 1.0F) { - this.soundPitch = 1.0F; - } - float var10 = MathHelper.clamp_float((float) this.cartSpeed, 0.0F, 4.0F) / 4.0F; - this.volume2 = 0.0F + var10 * 0.75F; - var10 = MathHelper.clamp_float(var10 * 2.0F, 0.0F, 1.0F); - this.volume1 = 0.0F + var10 * 0.7F; - } - else if (var4) { - this.volume1 = 0.0F; - this.soundPitch = 0.0F; - this.volume2 = 0.0F; - } - /*if (!this.flag) { - if (this.soundPitch != var6) { - //this.theSoundManager.setEntitySoundPitch(this.theMinecart, this.soundPitch); - } - if (this.volume1 != var5) { - //this.theSoundManager.setEntitySoundVolume(this.theMinecart, this.volume1); - } - if (this.volume2 != var7) { - //this.theSoundManager.setEntitySoundVolume(this.thePlayer, this.volume2); - } - } - if (!var1 && (this.volume1 > 0.0F || this.volume2 > 0.0F)) { - //this.theSoundManager.updateSoundLocation(this.theMinecart); - if (this.riddenByPlayer) { - //this.theSoundManager.updateSoundLocation(this.thePlayer, this.theMinecart); - } - } - else { - if (this.theSoundManager.isEntitySoundPlaying(this.theMinecart)) { - this.theSoundManager.stopEntitySound(this.theMinecart); - } - if (this.theSoundManager.isEntitySoundPlaying(this.thePlayer)) { - this.theSoundManager.stopEntitySound(this.thePlayer); - } - } - */ - } + private boolean isMoving = false; + private boolean flag = false; + private float soundPitch = 0.0F; + private float volume1 = 0.0F; + private float volume2 = 0.0F; + + public void update(SoundHandler par1SoundManager, EntityRollingStock rollingStock, EntityPlayerSP par3EntityPlayerSP) { + if (par1SoundManager == null || rollingStock == null || par3EntityPlayerSP == null) { + return; + } + + if (!ConfigHandler.SOUNDS || rollingStock instanceof EntityJukeBoxCart || rollingStock instanceof Locomotive) { + // Somehow interferes with music discs. + return; + } + + boolean isMoving = this.isMoving; + boolean isDead = rollingStock.isDead; + double cartSpeed = MathHelper.sqrt_double(rollingStock.getMotionXClient() * rollingStock.getMotionXClient() + rollingStock.getMotionZClient() * rollingStock.getMotionZClient()) / 100; + this.isMoving = cartSpeed >= 0.01D; + + if (isDead || !this.flag && this.volume1 == 0.0F && this.volume2 == 0.0F) { + this.flag = true; + if (isDead) { + return; + } + } + + if (this.isMoving) { + if (this.soundPitch < 1.0F) { + this.soundPitch += 0.0025F; + } + + if (this.soundPitch > 1.0F) { + this.soundPitch = 1.0F; + } + + float var10 = MathHelper.clamp_float((float) cartSpeed, 0.0F, 4.0F) / 4.0F; + this.volume2 = 0.0F + var10 * 0.75F; + var10 = MathHelper.clamp_float(var10 * 2.0F, 0.0F, 1.0F); + this.volume1 = 0.0F + var10 * 0.7F; + } else if (isMoving) { + this.volume1 = 0.0F; + this.soundPitch = 0.0F; + this.volume2 = 0.0F; + } + } } \ No newline at end of file diff --git a/src/main/java/train/client/core/handlers/TCKeyHandler.java b/src/main/java/train/client/core/handlers/TCKeyHandler.java index 1d366f203d..b743aa9921 100644 --- a/src/main/java/train/client/core/handlers/TCKeyHandler.java +++ b/src/main/java/train/client/core/handlers/TCKeyHandler.java @@ -18,145 +18,140 @@ import train.common.core.network.PacketKeyPress; public class TCKeyHandler { - public static KeyBinding horn; - public static KeyBinding bell; - public static KeyBinding inventory; - public static KeyBinding up; - public static KeyBinding down; - public static KeyBinding idle; - public static KeyBinding furnace; - public static KeyBinding MTCScreen; - public static KeyBinding toggleATO; - public static KeyBinding mtcOverride; - public static KeyBinding overspeedOverride; - - public TCKeyHandler() { - horn = new KeyBinding("key.traincraft.horn", Keyboard.KEY_H, "key.categories.traincraft"); - ClientRegistry.registerKeyBinding(horn); - inventory = new KeyBinding("key.traincraft.inventory", Keyboard.KEY_R, "key.categories.traincraft"); - ClientRegistry.registerKeyBinding(inventory); - up = new KeyBinding("key.traincraft.up", Keyboard.KEY_Y, "key.categories.traincraft"); - ClientRegistry.registerKeyBinding(up); - down = new KeyBinding("key.traincraft.down", Keyboard.KEY_X, "key.categories.traincraft"); - ClientRegistry.registerKeyBinding(down); - idle = new KeyBinding("key.traincraft.idle", Keyboard.KEY_C, "key.categories.traincraft"); - ClientRegistry.registerKeyBinding(idle); - furnace = new KeyBinding("key.traincraft.furnace", Keyboard.KEY_F, "key.categories.traincraft"); - ClientRegistry.registerKeyBinding(furnace); - bell = new KeyBinding("key.traincraft.bell", Keyboard.KEY_B, "key.categories.traincraft"); - ClientRegistry.registerKeyBinding(bell); - - if (Loader.isModLoaded("ComputerCraft")) { - MTCScreen = new KeyBinding("key.traincraft.showMTCScreen", Keyboard.KEY_M, "key.categories.traincraft"); - ClientRegistry.registerKeyBinding(MTCScreen); - toggleATO = new KeyBinding("key.traincraft.toggleATO", Keyboard.KEY_O, "key.categories.traincraft"); - ClientRegistry.registerKeyBinding(toggleATO); - mtcOverride = new KeyBinding("key.traincraft.mtcOverride", Keyboard.KEY_O, "key.categories.traincraft"); - ClientRegistry.registerKeyBinding(mtcOverride); - overspeedOverride = new KeyBinding("key.traincraft.overspeedOverride", Keyboard.KEY_L, "key.categories.traincraft"); - ClientRegistry.registerKeyBinding(overspeedOverride); - } - } - - @SubscribeEvent - public void onKeyInput(InputEvent.KeyInputEvent event) { - if (!Minecraft.getMinecraft().ingameGUI.getChatGUI().getChatOpen()) { - if (up.getIsKeyPressed()) { - sendKeyControlsPacket(0); - } - if (down.getIsKeyPressed()) { - sendKeyControlsPacket(2); - } - if (idle.getIsKeyPressed()) { - sendKeyControlsPacket(6); - } - if (inventory.getIsKeyPressed()) { - sendKeyControlsPacket(7); - } - if (horn.getIsKeyPressed()) { - sendKeyControlsPacket(8); - } - if (furnace.getIsKeyPressed()) { - sendKeyControlsPacket(9); - } - if (bell.getIsKeyPressed()) { - sendKeyControlsPacket(10); - } - if (Loader.isModLoaded("ComputerCraft")) { - if (MTCScreen.getIsKeyPressed() && !FMLClientHandler.instance().isGUIOpen(GuiMTCInfo.class)) { - if (Minecraft.getMinecraft().thePlayer.ridingEntity != null) { - Minecraft.getMinecraft().displayGuiScreen(new GuiMTCInfo(Minecraft.getMinecraft().thePlayer.ridingEntity)); - } - } - if (toggleATO.getIsKeyPressed() && Minecraft.getMinecraft().thePlayer.ridingEntity instanceof Locomotive) { - sendKeyControlsPacket(16); - Locomotive train = (Locomotive) Minecraft.getMinecraft().thePlayer.ridingEntity; - if (train.mtcStatus != 0 && train.mtcType == 2) { - if (train instanceof SteamTrain && !ConfigHandler.ALLOW_ATO_ON_STEAMERS) { - ((EntityPlayer) train.riddenByEntity).addChatMessage(new ChatComponentText("Automatic Train Operation cannot be used with steam trains")); - } else { - if (train.atoStatus == 1) { - train.atoStatus = 0; - } else { - train.atoStatus = 1; - } - } - - } else { - ((EntityPlayer) train.riddenByEntity).addChatMessage(new ChatComponentText("Automatic Train Operation can only be activated when you are using W-MTC")); - } - - } - - - if (mtcOverride.getIsKeyPressed() && Minecraft.getMinecraft().thePlayer.ridingEntity instanceof Locomotive) { - Locomotive train = (Locomotive) Minecraft.getMinecraft().thePlayer.ridingEntity; - - - if (train.mtcOverridePressed) { - train.mtcOverridePressed = false; - ((EntityPlayer) train.riddenByEntity).addChatMessage(new ChatComponentText("MTC has been enabled and will re-activate when the system receives new data")); - } else { - train.mtcOverridePressed = true; - ((EntityPlayer) train.riddenByEntity).addChatMessage(new ChatComponentText("MTC has been disabled and will not receive speed changes or transmit MTC data")); - train.mtcStatus = 0; - train.speedLimit = 0; - train.nextSpeedLimit = 0; - train.xSpeedLimitChange = 0.0; - train.ySpeedLimitChange = 0.0; - train.zSpeedLimitChange = 0.0; - train.xFromStopPoint = 0.0; - train.yFromStopPoint = 0.0; - train.zFromStopPoint = 0.0; - train.trainLevel = "0"; - - } - sendKeyControlsPacket(17); - } - if (overspeedOverride.getIsKeyPressed() && Minecraft.getMinecraft().thePlayer.ridingEntity instanceof Locomotive) { - Locomotive train = (Locomotive) Minecraft.getMinecraft().thePlayer.ridingEntity; - sendKeyControlsPacket(18); - if (train.mtcStatus == 1 | train.mtcStatus == 2) { - if (train.overspeedOveridePressed) { - train.overspeedOveridePressed = false; - } else { - train.overspeedOveridePressed = true; - } - } - } - - } - } - - if (FMLClientHandler.instance().getClient().gameSettings.keyBindSneak.getIsKeyPressed() && Keyboard.isKeyDown(Keyboard.KEY_F3)) { - sendKeyControlsPacket(404); - } - } - - - - private static void sendKeyControlsPacket(int key) - { - Traincraft.keyChannel.sendToServer(new PacketKeyPress(key)); - } + public static KeyBinding horn; + public static KeyBinding bell; + public static KeyBinding inventory; + public static KeyBinding up; + public static KeyBinding down; + public static KeyBinding idle; + public static KeyBinding furnace; + public static KeyBinding MTCScreen; + public static KeyBinding toggleATO; + public static KeyBinding mtcOverride; + public static KeyBinding overspeedOverride; + + public TCKeyHandler() { + horn = new KeyBinding("key.traincraft.horn", Keyboard.KEY_H, "key.categories.traincraft"); + ClientRegistry.registerKeyBinding(horn); + inventory = new KeyBinding("key.traincraft.inventory", Keyboard.KEY_R, "key.categories.traincraft"); + ClientRegistry.registerKeyBinding(inventory); + up = new KeyBinding("key.traincraft.up", Keyboard.KEY_Y, "key.categories.traincraft"); + ClientRegistry.registerKeyBinding(up); + down = new KeyBinding("key.traincraft.down", Keyboard.KEY_X, "key.categories.traincraft"); + ClientRegistry.registerKeyBinding(down); + idle = new KeyBinding("key.traincraft.idle", Keyboard.KEY_C, "key.categories.traincraft"); + ClientRegistry.registerKeyBinding(idle); + furnace = new KeyBinding("key.traincraft.furnace", Keyboard.KEY_F, "key.categories.traincraft"); + ClientRegistry.registerKeyBinding(furnace); + bell = new KeyBinding("key.traincraft.bell", Keyboard.KEY_B, "key.categories.traincraft"); + ClientRegistry.registerKeyBinding(bell); + + if (Loader.isModLoaded("ComputerCraft")) { + MTCScreen = new KeyBinding("key.traincraft.showMTCScreen", Keyboard.KEY_M, "key.categories.traincraft"); + ClientRegistry.registerKeyBinding(MTCScreen); + toggleATO = new KeyBinding("key.traincraft.toggleATO", Keyboard.KEY_O, "key.categories.traincraft"); + ClientRegistry.registerKeyBinding(toggleATO); + mtcOverride = new KeyBinding("key.traincraft.mtcOverride", Keyboard.KEY_O, "key.categories.traincraft"); + ClientRegistry.registerKeyBinding(mtcOverride); + overspeedOverride = new KeyBinding("key.traincraft.overspeedOverride", Keyboard.KEY_L, "key.categories.traincraft"); + ClientRegistry.registerKeyBinding(overspeedOverride); + } + } + + @SubscribeEvent + public void onKeyInput(InputEvent.KeyInputEvent event) { + if (!Minecraft.getMinecraft().ingameGUI.getChatGUI().getChatOpen()) { + if (up.getIsKeyPressed()) { + sendKeyControlsPacket(0); + } + + if (down.getIsKeyPressed()) { + sendKeyControlsPacket(2); + } + + if (idle.getIsKeyPressed()) { + sendKeyControlsPacket(6); + } + + if (inventory.getIsKeyPressed()) { + sendKeyControlsPacket(7); + } + + if (horn.getIsKeyPressed()) { + sendKeyControlsPacket(8); + } + + if (furnace.getIsKeyPressed()) { + sendKeyControlsPacket(9); + } + + if (bell.getIsKeyPressed()) { + sendKeyControlsPacket(10); + } + + if (Traincraft.hasComputerCraft()) { + if (MTCScreen.getIsKeyPressed() && !FMLClientHandler.instance().isGUIOpen(GuiMTCInfo.class)) { + if (Minecraft.getMinecraft().thePlayer.ridingEntity != null) { + Minecraft.getMinecraft().displayGuiScreen(new GuiMTCInfo(Minecraft.getMinecraft().thePlayer.ridingEntity)); + } + } + + if (toggleATO.getIsKeyPressed() && Minecraft.getMinecraft().thePlayer.ridingEntity instanceof Locomotive) { + sendKeyControlsPacket(16); + Locomotive train = (Locomotive) Minecraft.getMinecraft().thePlayer.ridingEntity; + if (train.mtcStatus != 0 && train.mtcType == 2) { + if (train instanceof SteamTrain && !ConfigHandler.ALLOW_ATO_ON_STEAMERS) { + ((EntityPlayer) train.riddenByEntity).addChatMessage(new ChatComponentText("Automatic Train Operation cannot be used with steam trains")); + } else { + train.atoStatus = train.atoStatus == 1 ? 0 : 1; + } + } else { + ((EntityPlayer) train.riddenByEntity).addChatMessage(new ChatComponentText("Automatic Train Operation can only be activated when you are using W-MTC")); + } + } + + if (mtcOverride.getIsKeyPressed() && Minecraft.getMinecraft().thePlayer.ridingEntity instanceof Locomotive) { + Locomotive train = (Locomotive) Minecraft.getMinecraft().thePlayer.ridingEntity; + + if (train.mtcOverridePressed) { + train.mtcOverridePressed = false; + ((EntityPlayer) train.riddenByEntity).addChatMessage(new ChatComponentText("MTC has been enabled and will re-activate when the system receives new data")); + } else { + train.mtcOverridePressed = true; + ((EntityPlayer) train.riddenByEntity).addChatMessage(new ChatComponentText("MTC has been disabled and will not receive speed changes or transmit MTC data")); + train.mtcStatus = 0; + train.speedLimit = 0; + train.nextSpeedLimit = 0; + train.xSpeedLimitChange = 0.0; + train.ySpeedLimitChange = 0.0; + train.zSpeedLimitChange = 0.0; + train.xFromStopPoint = 0.0; + train.yFromStopPoint = 0.0; + train.zFromStopPoint = 0.0; + train.trainLevel = "0"; + } + + sendKeyControlsPacket(17); + } + + if (overspeedOverride.getIsKeyPressed() && Minecraft.getMinecraft().thePlayer.ridingEntity instanceof Locomotive) { + Locomotive train = (Locomotive) Minecraft.getMinecraft().thePlayer.ridingEntity; + sendKeyControlsPacket(18); + if (train.mtcStatus == 1 || train.mtcStatus == 2) { + train.overspeedOveridePressed = !train.overspeedOveridePressed; + } + } + + } + } + + if (FMLClientHandler.instance().getClient().gameSettings.keyBindSneak.getIsKeyPressed() && Keyboard.isKeyDown(Keyboard.KEY_F3)) { + sendKeyControlsPacket(404); + } + } + + + private static void sendKeyControlsPacket(int key) { + Traincraft.keyChannel.sendToServer(new PacketKeyPress(key)); + } } \ No newline at end of file diff --git a/src/main/java/train/client/core/helpers/CapesHelper.java b/src/main/java/train/client/core/helpers/CapesHelper.java index 2b8bed38a9..dcdb4b37f5 100644 --- a/src/main/java/train/client/core/helpers/CapesHelper.java +++ b/src/main/java/train/client/core/helpers/CapesHelper.java @@ -1,6 +1,6 @@ /******************************************************************************* * Copyright (c) 2013 Mrbrutal. All rights reserved. - * + * * @name Traincraft * @author Mrbrutal ******************************************************************************/ @@ -21,104 +21,100 @@ import java.util.HashMap; public class CapesHelper extends Thread { - - private String username; - public boolean MCCape = true; - - private boolean isStatic = false; + + private final String username; + public boolean MCCape = true; + + private boolean isStatic = false; private boolean isAnimated = false; private String staticUrl; private ArrayList animatedFrameUrls; private ResourceLocation staticRL; private ResourceLocation[] animatedFramesRL; - private ThreadDownloadImageData staticImage; private ThreadDownloadImageData[] animatedFramesImages; private int currFrame; private long lastFrameTime; private int animInterval = 500; - - public static HashMap users = new HashMap(); - public static boolean isLoaded = false; - - public CapesHelper(String username) { - this.username = username; - } - @Override - public void run() { - try { - URL url = new URL("https://dl.dropbox.com/u/25602663/Traincraft/Capes/" + username.toLowerCase() + "_cape.txt"); - BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream())); - String line; - int sub = 3; - while ((line = reader.readLine()) != null) { - if(line.startsWith("SU")) { - isStatic = true; - staticUrl = line.substring(sub); - } - else if(line.startsWith("AU")) { - isAnimated = true; - if(animatedFrameUrls == null) { - animatedFrameUrls = new ArrayList(); - } - animatedFrameUrls.add(line.substring(sub)); - } - else if(line.startsWith("AI")) { - animInterval = Integer.parseInt(line.substring(sub)); - } - } - reader.close(); - dlImages(); - }catch(Exception e) {} - } + public static HashMap users = new HashMap(); + public static boolean isLoaded = false; + + public CapesHelper(String username) { + this.username = username; + } + + @Override + public void run() { + try { + URL url = new URL("https://dl.dropbox.com/u/25602663/Traincraft/Capes/" + username.toLowerCase() + "_cape.txt"); + BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream())); + String line; + int sub = 3; + while ((line = reader.readLine()) != null) { + if (line.startsWith("SU")) { + isStatic = true; + staticUrl = line.substring(sub); + } else if (line.startsWith("AU")) { + isAnimated = true; + if (animatedFrameUrls == null) { + animatedFrameUrls = new ArrayList<>(); + } + animatedFrameUrls.add(line.substring(sub)); + } else if (line.startsWith("AI")) { + animInterval = Integer.parseInt(line.substring(sub)); + } + } + reader.close(); + dlImages(); + } catch (Exception ignored) { + } + } - private void dlImages() { - if(isAnimated) { - animatedFramesRL = new ResourceLocation[animatedFrameUrls.size()]; - animatedFramesImages = new ThreadDownloadImageData[animatedFrameUrls.size()]; - for (int i = 0; i < animatedFrameUrls.size(); i++) { - animatedFramesRL[i] = capeAnimatedRL(username, i+1); - animatedFramesImages[i] = dlImage(animatedFramesRL[i], animatedFrameUrls.get(i)); - } - } - else if(isStatic) { - staticRL = capeStaticRL(username); - staticImage = dlImage(staticRL, staticUrl); - } - else { - MCCape = false; - } - isLoaded = true; - } + private void dlImages() { + if (isAnimated) { + animatedFramesRL = new ResourceLocation[animatedFrameUrls.size()]; + animatedFramesImages = new ThreadDownloadImageData[animatedFrameUrls.size()]; + for (int i = 0; i < animatedFrameUrls.size(); i++) { + animatedFramesRL[i] = capeAnimatedRL(username, i + 1); + animatedFramesImages[i] = dlImage(animatedFramesRL[i], animatedFrameUrls.get(i)); + } + } else if (isStatic) { + staticRL = capeStaticRL(username); + dlImage(staticRL, staticUrl); + } else { + MCCape = false; + } + isLoaded = true; + } - public ResourceLocation getCurrentRL() { - if(isAnimated) { - long time = Minecraft.getSystemTime(); - if(time > lastFrameTime + animInterval) { - lastFrameTime = time; - currFrame++; - if(currFrame >= animatedFramesImages.length) { - currFrame = 0; - } - } - return animatedFramesRL[currFrame]; - } - return staticRL; - } + public ResourceLocation getCurrentRL() { + if (isAnimated) { + long time = Minecraft.getSystemTime(); + if (time > lastFrameTime + animInterval) { + lastFrameTime = time; + currFrame++; + if (currFrame >= animatedFramesImages.length) { + currFrame = 0; + } + } + return animatedFramesRL[currFrame]; + } + return staticRL; + } - private static ResourceLocation capeStaticRL(String username) { - return new ResourceLocation("cloaks/" + StringUtils.stripControlCodes(username)); - } + private static ResourceLocation capeStaticRL(String username) { + return new ResourceLocation("cloaks/" + StringUtils.stripControlCodes(username)); + } - private static ResourceLocation capeAnimatedRL(String username, int frameNumber) { - return new ResourceLocation("cloaks/" + StringUtils.stripControlCodes(username) + "/" + frameNumber); - } + private static ResourceLocation capeAnimatedRL(String username, int frameNumber) { + return new ResourceLocation("cloaks/" + StringUtils.stripControlCodes(username) + "/" + frameNumber); + } - private static ThreadDownloadImageData dlImage(ResourceLocation rl, String url) { - TextureManager textures = Minecraft.getMinecraft().renderEngine; - File file = new File(rl.getResourcePath()); - ThreadDownloadImageData data = new ThreadDownloadImageData(file, url, rl, null); - textures.loadTexture(rl, data); - return data; - } + private static ThreadDownloadImageData dlImage(ResourceLocation rl, String url) { + TextureManager textures = Minecraft.getMinecraft().renderEngine; + File file = new File(rl.getResourcePath()); + ThreadDownloadImageData data = new ThreadDownloadImageData(file, url, rl, null); + textures.loadTexture(rl, data); + return data; + } } diff --git a/src/main/java/train/client/core/helpers/FluidRenderHelper.java b/src/main/java/train/client/core/helpers/FluidRenderHelper.java index 44d851c909..dd471c4ca9 100644 --- a/src/main/java/train/client/core/helpers/FluidRenderHelper.java +++ b/src/main/java/train/client/core/helpers/FluidRenderHelper.java @@ -7,19 +7,28 @@ import net.minecraftforge.fluids.Fluid; public class FluidRenderHelper { - private static final ResourceLocation BLOCK_TEXTURE = TextureMap.locationBlocksTexture; - public static IIcon getFluidTexture(Fluid fluid, boolean flowing) { - if (fluid == null) { - return null; - } - IIcon icon = flowing ? fluid.getFlowingIcon() : fluid.getStillIcon(); - if (icon == null) { - icon = ((TextureMap) Minecraft.getMinecraft().getTextureManager().getTexture(TextureMap.locationBlocksTexture)).getTextureExtry("missingno"); - } - return icon; - } + private static final ResourceLocation BLOCK_TEXTURE = TextureMap.locationBlocksTexture; - public static ResourceLocation getFluidSheet(Fluid liquid) { - return BLOCK_TEXTURE; - } + public static IIcon getFluidTexture(Fluid fluid, boolean flowing) { + if (fluid == null) { + return null; + } + + IIcon icon = flowing ? fluid.getFlowingIcon() : fluid.getStillIcon(); + + if (icon == null) { + icon = ((TextureMap) Minecraft.getMinecraft().getTextureManager().getTexture(TextureMap.locationBlocksTexture)).getTextureExtry("missingno"); + } + + return icon; + } + + /** + * Returns the sheet the fluid texture is on. + * @param liquid The fluid + * @return Resource Location of the sheet + */ + public static ResourceLocation getFluidSheet(Fluid liquid) { + return BLOCK_TEXTURE; + } } diff --git a/src/main/java/train/client/core/helpers/JLayerHook.java b/src/main/java/train/client/core/helpers/JLayerHook.java index 9a5d0d19a4..1c3e1a1dd1 100644 --- a/src/main/java/train/client/core/helpers/JLayerHook.java +++ b/src/main/java/train/client/core/helpers/JLayerHook.java @@ -9,19 +9,20 @@ import java.io.InputStream; public class JLayerHook implements JavaLayerHook { - private final Minecraft mc; - public JLayerHook(Minecraft mc) { - this.mc = mc; - } + private final Minecraft mc; - @Override - public InputStream getResourceAsStream(String name) { - try { - return mc.getResourceManager().getResource(new ResourceLocation(Info.modID, "jlayer/" + name)).getInputStream(); - } catch (IOException e) { - e.printStackTrace(); - return null; - } - } + public JLayerHook(Minecraft mc) { + this.mc = mc; + } + + @Override + public InputStream getResourceAsStream(String name) { + try { + return mc.getResourceManager().getResource(new ResourceLocation(Info.modID, "jlayer/" + name)).getInputStream(); + } catch (IOException e) { + System.err.print("Failed to load JLayer resource: " + name + "!"); + return null; + } + } } diff --git a/src/main/java/train/client/core/helpers/SessionHelper.java b/src/main/java/train/client/core/helpers/SessionHelper.java index 13e63a92ca..7e33ea6903 100644 --- a/src/main/java/train/client/core/helpers/SessionHelper.java +++ b/src/main/java/train/client/core/helpers/SessionHelper.java @@ -1,6 +1,6 @@ /******************************************************************************* * Copyright (c) 2012 Mrbrutal. All rights reserved. - * + * * @name TrainCraft * @author Mrbrutal ******************************************************************************/ @@ -8,13 +8,13 @@ package train.client.core.helpers; public class SessionHelper { - private static Class openedLedger; + private static Class openedLedger; - public static void setOpenedLedger(Class ledgerClass) { - openedLedger = ledgerClass; - } + public static void setOpenedLedger(Class ledgerClass) { + openedLedger = ledgerClass; + } - public static Class getOpenedLedger() { - return openedLedger; - } + public static Class getOpenedLedger() { + return openedLedger; + } } diff --git a/src/main/java/train/common/Traincraft.java b/src/main/java/train/common/Traincraft.java index dcf4801c1d..cd74f6ba3b 100644 --- a/src/main/java/train/common/Traincraft.java +++ b/src/main/java/train/common/Traincraft.java @@ -43,191 +43,198 @@ @Mod(modid = Info.modID, name = Info.modName, version = Info.modVersion) public class Traincraft { - /* TrainCraft instance */ - @Instance(Info.modID) - public static Traincraft instance; - - /* TrainCraft proxy files */ - @SidedProxy(clientSide = "train.client.core.ClientProxy", serverSide = "train.common.core.CommonProxy") - public static CommonProxy proxy; + /* TrainCraft instance */ + @Instance(Info.modID) + public static Traincraft instance; + + /* TrainCraft proxy files */ + @SidedProxy(clientSide = "train.client.core.ClientProxy", serverSide = "train.common.core.CommonProxy") + public static CommonProxy proxy; + + /* TrainCraft Logger */ + public static Logger tcLog = LogManager.getLogger(Info.modName); + + /** + * Network Channel to send packets on + */ + public static SimpleNetworkWrapper modChannel; + public static SimpleNetworkWrapper keyChannel; + public static SimpleNetworkWrapper rotationChannel; + + + public static SimpleNetworkWrapper slotschannel; + public static SimpleNetworkWrapper ignitionChannel; + public static SimpleNetworkWrapper brakeChannel; + public static SimpleNetworkWrapper lockChannel; + public static SimpleNetworkWrapper builderChannel; + public static SimpleNetworkWrapper updateTrainIDChannel = NetworkRegistry.INSTANCE.newSimpleChannel("TrainIDChannel"); + public static SimpleNetworkWrapper updateDestinationChannel = NetworkRegistry.INSTANCE.newSimpleChannel("updateDestnChannel"); - /* TrainCraft Logger */ - public static Logger tcLog = LogManager.getLogger(Info.modName); - /** Network Channel to send packets on */ - public static SimpleNetworkWrapper modChannel; - public static SimpleNetworkWrapper keyChannel; - public static SimpleNetworkWrapper rotationChannel; + public static final SimpleNetworkWrapper itaChannel = NetworkRegistry.INSTANCE.newSimpleChannel("TransmitterAspect"); + public static SimpleNetworkWrapper itsChannel = NetworkRegistry.INSTANCE.newSimpleChannel("TransmitterSpeed"); + //public static SimpleNetworkWrapper mtcsChannel = NetworkRegistry.INSTANCE.newSimpleChannel("MTCSysSetSpeed"); + public static SimpleNetworkWrapper itnsChannel = NetworkRegistry.INSTANCE.newSimpleChannel("TransmitterNextSpeed"); + public static final SimpleNetworkWrapper mtlChannel = NetworkRegistry.INSTANCE.newSimpleChannel("MTCLevelUpdater"); + public static final SimpleNetworkWrapper msChannel = NetworkRegistry.INSTANCE.newSimpleChannel("MTCStatus"); + public static final SimpleNetworkWrapper mscChannel = NetworkRegistry.INSTANCE.newSimpleChannel("MTCStatusToClient"); + public static final SimpleNetworkWrapper atoChannel = NetworkRegistry.INSTANCE.newSimpleChannel("ATOPacket"); + public static final SimpleNetworkWrapper atoDoSlowDownChannel = NetworkRegistry.INSTANCE.newSimpleChannel("ATODoSlowDown"); + public static final SimpleNetworkWrapper atoDoAccelChannel = NetworkRegistry.INSTANCE.newSimpleChannel("ATODoAccel"); + public static final SimpleNetworkWrapper atoSetStopPoint = NetworkRegistry.INSTANCE.newSimpleChannel("ATOSetStopPoint"); + public static final SimpleNetworkWrapper NCSlowDownChannel = NetworkRegistry.INSTANCE.newSimpleChannel("NCDoSlowDown"); + //public static final SimpleNetworkWrapper ctChannel = NetworkRegistry.INSTANCE.newSimpleChannel("ctmChannel"); + public static final SimpleNetworkWrapper gsfsChannel = NetworkRegistry.INSTANCE.newSimpleChannel("gsfsChannel"); + public static final SimpleNetworkWrapper gsfsrChannel = NetworkRegistry.INSTANCE.newSimpleChannel("gsfsReturnChannel"); + + public final TraincraftRegistry traincraftRegistry = new TraincraftRegistry(); + + + public static File configDirectory; + + /* Creative tab for Traincraft */ + public static CreativeTabs tcTab, tcTrainTab; + + public ArmorMaterial armor = EnumHelper.addArmorMaterial("Armor", 5, new int[]{1, 2, 2, 1}, 25); + public ArmorMaterial armorCloth = EnumHelper.addArmorMaterial("TCcloth", 5, new int[]{1, 2, 2, 1}, 25); + public ArmorMaterial armorCompositeSuit = EnumHelper.addArmorMaterial("TCsuit", 70, new int[]{2, 6, 5, 2}, 50); + public static int trainArmor; + public static int trainCloth; + public static int trainCompositeSuit; + + + public static WorldGenWorld worldGen; + + @EventHandler + public void preInit(FMLPreInitializationEvent event) { + TraincraftUtil.dev = (Boolean) Launch.blackboard.get("fml.deobfuscatedEnvironment"); + tcLog.info("Starting Traincraft " + Info.modVersion + "!"); + /* Config handler */ + configDirectory = event.getModConfigurationDirectory(); + ConfigHandler.init(new File(event.getModConfigurationDirectory(), Info.modName + ".cfg")); + + /* Register the KeyBinding Handler */ + proxy.registerKeyBindingHandler(); + + /* Register Items, Blocks, ... */ + tcLog.info("Initialize Blocks, Items, ..."); + tcTab = new CreativeTabTraincraft(CreativeTabs.getNextID(), "Traincraft"); + if (ConfigHandler.SPLIT_CREATIVE) { + tcTrainTab = new CreativeTabTraincraftTrains(CreativeTabs.getNextID(), "Traincraft Trains"); + } + trainArmor = proxy.addArmor("armor"); + trainCloth = proxy.addArmor("Paintable"); + trainCompositeSuit = proxy.addArmor("CompositeSuit"); + TCBlocks.init(); + TCItems.init(); + EntityHandler.init(); + proxy.registerTileEntities(); + proxy.registerSounds(); + proxy.setHook(); // Moved file needed to run JLayer, we need to set a hook in order to retrieve it + + GameRegistry.registerFuelHandler(new FuelHandler()); + AchievementHandler.load(); + AchievementPage.registerAchievementPage(AchievementHandler.tmPage); + GameRegistry.registerWorldGenerator(worldGen = new WorldGenWorld(), 5); + + //Retrogen Handling + RetrogenHandler retroGen = new RetrogenHandler(); + MinecraftForge.EVENT_BUS.register(retroGen); + FMLCommonHandler.instance().bus().register(retroGen); + + MapGenStructureIO.func_143031_a(ComponentVillageTrainstation.class, "Trainstation"); + + if (Loader.isModLoaded("ComputerCraft")) { + try { + proxy.registerComputerCraftPeripherals(); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + } + } + + /* Other Proxy init */ + tcLog.info("Initialize Renderer and Events"); + proxy.registerRenderInformation(); + proxy.registerEvents(event); + + traincraftRegistry.init(); + + + tcLog.info("Finished PreInitialization"); + } + + @Mod.EventHandler + public void init(FMLInitializationEvent event) { + + /* Networking and Packet initialisation, apparently this needs to be in init to prevent conflicts */ + PacketHandler.init(); + } + + @EventHandler + public void load(FMLInitializationEvent event) { + tcLog.info("Start Initialization"); + + //proxy.getCape(); + + /* GUI handler initiation */ + tcLog.info("Initialize Gui"); + NetworkRegistry.INSTANCE.registerGuiHandler(instance, proxy); + FMLCommonHandler.instance().bus().register(new CraftingHandler()); + + /* Ore dictionary */ + OreHandler.registerOres(); + /* Recipes */ + tcLog.info("Initialize Recipes"); + RecipeHandler.initBlockRecipes(); + RecipeHandler.initItemRecipes(); + RecipeHandler.initSmeltingRecipes(); + AssemblyTableRecipes.recipes(); + + /* Register the liquids */ + tcLog.info("Initialize Fluids"); + LiquidManager.getInstance().registerLiquids(); + + /* Liquid FX */ + proxy.registerTextureFX(); + + /*Trainman Villager*/ + tcLog.info("Initialize Station Chief Villager"); + VillagerRegistry.instance().registerVillagerId(ConfigHandler.TRAINCRAFT_VILLAGER_ID); + VillagerTraincraftHandler villageHandler = new VillagerTraincraftHandler(); + VillagerRegistry.instance().registerVillageCreationHandler(villageHandler); + proxy.registerVillagerSkin(ConfigHandler.TRAINCRAFT_VILLAGER_ID, "station_chief.png"); + VillagerRegistry.instance().registerVillageTradeHandler(ConfigHandler.TRAINCRAFT_VILLAGER_ID, villageHandler); + + + proxy.registerBookHandler(); + + + tcLog.info("Finished Initialization"); + } + + @EventHandler + public void postInit(FMLPostInitializationEvent evt) { + tcLog.info("Start to PostInitialize"); + tcLog.info("Register ChunkHandler"); + + tcLog.info("Activation Mod Compatibility"); + TrainModCore.ModsLoaded(); + LiquidManager.getLiquidsFromDictionnary(); + + tcLog.info("Finished PostInitialization"); + } - public static SimpleNetworkWrapper slotschannel; - public static SimpleNetworkWrapper ignitionChannel; - public static SimpleNetworkWrapper brakeChannel; - public static SimpleNetworkWrapper lockChannel; - public static SimpleNetworkWrapper builderChannel; - public static SimpleNetworkWrapper updateTrainIDChannel = NetworkRegistry.INSTANCE.newSimpleChannel("TrainIDChannel"); - public static SimpleNetworkWrapper updateDestinationChannel = NetworkRegistry.INSTANCE.newSimpleChannel("updateDestnChannel"); + @EventHandler + public void serverStop(FMLServerStoppedEvent event) { + CommonProxy.killAllStreams(); + } + public static boolean hasComputerCraft() { + return Loader.isModLoaded("ComputerCraft"); + } - public static final SimpleNetworkWrapper itaChannel = NetworkRegistry.INSTANCE.newSimpleChannel("TransmitterAspect"); - public static SimpleNetworkWrapper itsChannel = NetworkRegistry.INSTANCE.newSimpleChannel("TransmitterSpeed"); - //public static SimpleNetworkWrapper mtcsChannel = NetworkRegistry.INSTANCE.newSimpleChannel("MTCSysSetSpeed"); - public static SimpleNetworkWrapper itnsChannel = NetworkRegistry.INSTANCE.newSimpleChannel("TransmitterNextSpeed"); - public static final SimpleNetworkWrapper mtlChannel = NetworkRegistry.INSTANCE.newSimpleChannel("MTCLevelUpdater"); - public static final SimpleNetworkWrapper msChannel = NetworkRegistry.INSTANCE.newSimpleChannel("MTCStatus"); - public static final SimpleNetworkWrapper mscChannel = NetworkRegistry.INSTANCE.newSimpleChannel("MTCStatusToClient"); - public static final SimpleNetworkWrapper atoChannel = NetworkRegistry.INSTANCE.newSimpleChannel("ATOPacket"); - public static final SimpleNetworkWrapper atoDoSlowDownChannel = NetworkRegistry.INSTANCE.newSimpleChannel("ATODoSlowDown"); - public static final SimpleNetworkWrapper atoDoAccelChannel = NetworkRegistry.INSTANCE.newSimpleChannel("ATODoAccel"); - public static final SimpleNetworkWrapper atoSetStopPoint = NetworkRegistry.INSTANCE.newSimpleChannel("ATOSetStopPoint"); - public static final SimpleNetworkWrapper NCSlowDownChannel = NetworkRegistry.INSTANCE.newSimpleChannel("NCDoSlowDown"); - //public static final SimpleNetworkWrapper ctChannel = NetworkRegistry.INSTANCE.newSimpleChannel("ctmChannel"); - public static final SimpleNetworkWrapper gsfsChannel = NetworkRegistry.INSTANCE.newSimpleChannel("gsfsChannel"); - public static final SimpleNetworkWrapper gsfsrChannel = NetworkRegistry.INSTANCE.newSimpleChannel("gsfsReturnChannel"); - - public final TraincraftRegistry traincraftRegistry = new TraincraftRegistry(); - - - - public static File configDirectory; - - /* Creative tab for Traincraft */ - public static CreativeTabs tcTab, tcTrainTab; - - public ArmorMaterial armor = EnumHelper.addArmorMaterial("Armor", 5, new int[] { 1, 2, 2, 1 }, 25); - public ArmorMaterial armorCloth = EnumHelper.addArmorMaterial("TCcloth", 5, new int[] {1, 2, 2, 1}, 25); - public ArmorMaterial armorCompositeSuit = EnumHelper.addArmorMaterial("TCsuit", 70, new int[] {2, 6, 5, 2}, 50); - public static int trainArmor; - public static int trainCloth; - public static int trainCompositeSuit; - - - public static WorldGenWorld worldGen; - - @EventHandler - public void preInit(FMLPreInitializationEvent event) { - TraincraftUtil.dev = (Boolean) Launch.blackboard.get("fml.deobfuscatedEnvironment"); - tcLog.info("Starting Traincraft " + Info.modVersion + "!"); - /* Config handler */ - configDirectory= event.getModConfigurationDirectory(); - ConfigHandler.init(new File(event.getModConfigurationDirectory(), Info.modName + ".cfg")); - - /* Register the KeyBinding Handler */ - proxy.registerKeyBindingHandler(); - - /* Register Items, Blocks, ... */ - tcLog.info("Initialize Blocks, Items, ..."); - tcTab = new CreativeTabTraincraft(CreativeTabs.getNextID(), "Traincraft"); - if(ConfigHandler.SPLIT_CREATIVE) { - tcTrainTab = new CreativeTabTraincraftTrains(CreativeTabs.getNextID(), "Traincraft Trains"); - } - trainArmor = proxy.addArmor("armor"); - trainCloth = proxy.addArmor("Paintable"); - trainCompositeSuit = proxy.addArmor("CompositeSuit"); - TCBlocks.init(); - TCItems.init(); - EntityHandler.init(); - proxy.registerTileEntities(); - proxy.registerSounds(); - proxy.setHook(); // Moved file needed to run JLayer, we need to set a hook in order to retrieve it - - GameRegistry.registerFuelHandler(new FuelHandler()); - AchievementHandler.load(); - AchievementPage.registerAchievementPage(AchievementHandler.tmPage); - GameRegistry.registerWorldGenerator(worldGen = new WorldGenWorld(),5); - - //Retrogen Handling - RetrogenHandler retroGen = new RetrogenHandler(); - MinecraftForge.EVENT_BUS.register(retroGen); - FMLCommonHandler.instance().bus().register(retroGen); - - MapGenStructureIO.func_143031_a(ComponentVillageTrainstation.class, "Trainstation"); - - if (Loader.isModLoaded("ComputerCraft")) { - try { - proxy.registerComputerCraftPeripherals(); - } catch (ClassNotFoundException e) { - e.printStackTrace(); - } - } - - /* Other Proxy init */ - tcLog.info("Initialize Renderer and Events"); - proxy.registerRenderInformation(); - proxy.registerEvents(event); - - traincraftRegistry.init(); - - - tcLog.info("Finished PreInitialization"); - } - - @Mod.EventHandler - public void init(FMLInitializationEvent event) { - - /* Networking and Packet initialisation, apparently this needs to be in init to prevent conflicts */ - PacketHandler.init(); - } - - @EventHandler - public void load(FMLInitializationEvent event) { - tcLog.info("Start Initialization"); - - //proxy.getCape(); - - /* GUI handler initiation */ - tcLog.info("Initialize Gui"); - NetworkRegistry.INSTANCE.registerGuiHandler(instance, proxy); - FMLCommonHandler.instance().bus().register(new CraftingHandler()); - - /* Ore dictionary */ - OreHandler.registerOres(); - - /* Recipes */ - tcLog.info("Initialize Recipes"); - RecipeHandler.initBlockRecipes(); - RecipeHandler.initItemRecipes(); - RecipeHandler.initSmeltingRecipes(); - AssemblyTableRecipes.recipes(); - - /* Register the liquids */ - tcLog.info("Initialize Fluids"); - LiquidManager.getInstance().registerLiquids(); - - /* Liquid FX */ - proxy.registerTextureFX(); - - /*Trainman Villager*/ - tcLog.info("Initialize Station Chief Villager"); - VillagerRegistry.instance().registerVillagerId(ConfigHandler.TRAINCRAFT_VILLAGER_ID); - VillagerTraincraftHandler villageHandler = new VillagerTraincraftHandler(); - VillagerRegistry.instance().registerVillageCreationHandler(villageHandler); - proxy.registerVillagerSkin(ConfigHandler.TRAINCRAFT_VILLAGER_ID, "station_chief.png"); - VillagerRegistry.instance().registerVillageTradeHandler(ConfigHandler.TRAINCRAFT_VILLAGER_ID, villageHandler); - - - proxy.registerBookHandler(); - - - tcLog.info("Finished Initialization"); - - - } - - @EventHandler - public void postInit(FMLPostInitializationEvent evt) { - tcLog.info("Start to PostInitialize"); - tcLog.info("Register ChunkHandler"); - - tcLog.info("Activation Mod Compatibility"); - TrainModCore.ModsLoaded(); - LiquidManager.getLiquidsFromDictionnary(); - - tcLog.info("Finished PostInitialization"); - } - - @EventHandler - public void serverStop(FMLServerStoppedEvent event) { - proxy.killAllStreams(); - } + public static boolean hasNotEnoughItems() { + return Loader.isModLoaded("NotEnoughItems"); + } } diff --git a/src/main/java/train/common/items/ItemTCRail.java b/src/main/java/train/common/items/ItemTCRail.java index 716cda02a7..100b39006d 100644 --- a/src/main/java/train/common/items/ItemTCRail.java +++ b/src/main/java/train/common/items/ItemTCRail.java @@ -23,6547 +23,6506 @@ import javax.annotation.Nullable; import java.util.List; -public class ItemTCRail extends ItemPart { - - - - private final TrackTypes type; - - private String typeVariantStraight = TrackTypes.SMALL_STRAIGHT.getLabel(); - private String typeVariantDiagonal = TrackTypes.SMALL_DIAGONAL_STRAIGHT.getLabel(); - private String typeVariant90Turn; - private String typeVariantCrossing; - private Item idVariantSwitch; - TrackTypes tempType; - - public enum TrackTypes { - - /**Normal Tracks*/ - - SMALL_STRAIGHT("SMALL_STRAIGHT", "STRAIGHT", ItemIDs.tcRailSmallStraight, "1x1"), - MEDIUM_STRAIGHT("MEDIUM_STRAIGHT", "STRAIGHT", ItemIDs.tcRailMediumStraight, "1x3"), - LONG_STRAIGHT("LONG_STRAIGHT", "STRAIGHT", ItemIDs.tcRailLongStraight, "1x6"), - VERY_LONG_STRAIGHT("VERY_LONG_STRAIGHT", "STRAIGHT", ItemIDs.tcRailVeryLongStraight, "1x12"), - - SMALL_DIAGONAL_STRAIGHT("SMALL_DIAGONAL_STRAIGHT", "DIAGONAL", ItemIDs.tcRailSmallDiagonalStraight, "1x1"), - MEDIUM_DIAGONAL_STRAIGHT("MEDIUM_DIAGONAL_STRAIGHT", "DIAGONAL",ItemIDs.tcRailMediumDiagonalStraight, "1x3"), - LONG_DIAGONAL_STRAIGHT("LONG_DIAGONAL_STRAIGHT", "DIAGONAL",ItemIDs.tcRailLongDiagonalStraight, "1x6"), - VERY_LONG_DIAGONAL_STRAIGHT("VERY_LONG_DIAGONAL_STRAIGHT", "DIAGONAL",ItemIDs.tcRailVeryLongDiagonalStraight, "1x12"), - - - MEDIUM_TURN("MEDIUM_TURN", "TURN", ItemIDs.tcRailMediumTurn, "3x3"), - MEDIUM_RIGHT_TURN("MEDIUM_RIGHT_TURN", "TURN", ItemIDs.tcRailMediumTurn, ""), - MEDIUM_LEFT_TURN("MEDIUM_LEFT_TURN", "TURN", ItemIDs.tcRailMediumTurn, ""), - - LARGE_TURN("LARGE_TURN", "TURN", ItemIDs.tcRailLargeTurn, "5x5"), - LARGE_RIGHT_TURN("LARGE_RIGHT_TURN", "TURN", ItemIDs.tcRailLargeTurn, ""), - LARGE_LEFT_TURN("LARGE_LEFT_TURN", "TURN", ItemIDs.tcRailLargeTurn, ""), - - VERY_LARGE_TURN("VERY_LARGE_TURN", "TURN", ItemIDs.tcRailVeryLargeTurn, "10x10"), - VERY_LARGE_RIGHT_TURN("VERY_LARGE_RIGHT_TURN", "TURN", ItemIDs.tcRailVeryLargeTurn, ""), - VERY_LARGE_LEFT_TURN("VERY_LARGE_LEFT_TURN", "TURN", ItemIDs.tcRailVeryLargeTurn, ""), +import static train.common.items.TCRailTypes.*; - SUPER_LARGE_TURN("SUPER_LARGE_TURN", "TURN", ItemIDs.tcRailSuperLargeTurn, "16x16"), - SUPER_LARGE_LEFT_TURN("SUPER_LARGE_LEFT_TURN", "TURN", ItemIDs.tcRailSuperLargeTurn, ""), - SUPER_LARGE_RIGHT_TURN("SUPER_LARGE_RIGHT_TURN", "TURN", ItemIDs.tcRailSuperLargeTurn, ""), - - MEDIUM_45DEGREE_TURN("MEDIUM_45DEGREE_TURN", "TURN", ItemIDs.tcRailMedium45DegreeTurn, "3x4 hold sneak to attach to the back of another curve"), - MEDIUM_RIGHT_45DEGREE_TURN("MEDIUM_RIGHT_45DEGREE_TURN", "TURN", ItemIDs.tcRailMedium45DegreeTurn, ""), - MEDIUM_LEFT_45DEGREE_TURN("MEDIUM_LEFT_45DEGREE_TURN", "TURN", ItemIDs.tcRailMedium45DegreeTurn, ""), - - LARGE_45DEGREE_TURN("LARGE_45DEGREE_TURN", "TURN", ItemIDs.tcRailLarge45DegreeTurn, "3x6 hold sneak to attach to the back of another curve"), - LARGE_RIGHT_45DEGREE_TURN("LARGE_RIGHT_45DEGREE_TURN", "TURN", ItemIDs.tcRailLarge45DegreeTurn, ""), - LARGE_LEFT_45DEGREE_TURN("LARGE_LEFT_45DEGREE_TURN", "TURN", ItemIDs.tcRailLarge45DegreeTurn, ""), - - VERY_LARGE_45DEGREE_TURN("VERY_LARGE_45DEGREE_TURN", "TURN", ItemIDs.tcRailVeryLarge45DegreeTurn, "4x8 hold sneak to attach to the back of another curve"), - VERY_LARGE_RIGHT_45DEGREE_TURN("VERY_LARGE_RIGHT_45DEGREE_TURN", "TURN", ItemIDs.tcRailVeryLarge45DegreeTurn, ""), - VERY_LARGE_LEFT_45DEGREE_TURN("VERY_LARGE_LEFT_45DEGREE_TURN", "TURN", ItemIDs.tcRailVeryLarge45DegreeTurn, ""), - - SUPER_LARGE_45DEGREE_TURN("SUPER_LARGE_45DEGREE_TURN", "TURN", ItemIDs.tcRailSuperLarge45DegreeTurn, "5x11 hold sneak to attach to the back of another curve"), - SUPER_LARGE_RIGHT_45DEGREE_TURN("SUPER_LARGE_RIGHT_45DEGREE_TURN", "TURN", ItemIDs.tcRailSuperLarge45DegreeTurn, ""), - SUPER_LARGE_LEFT_45DEGREE_TURN("SUPER_LARGE_LEFT_45DEGREE_TURN", "TURN", ItemIDs.tcRailSuperLarge45DegreeTurn, ""), - - SMALL_PARALLEL_CURVE("SMALL_PARALLEL_CURVE", "CURVE", ItemIDs.tcRailSmallParallelCurve, "2x8"), - SMALL_RIGHT_PARALLEL_CURVE("SMALL_RIGHT_PARALLEL_CURVE", "CURVE", ItemIDs.tcRailSmallParallelCurve, ""), - SMALL_LEFT_PARALLEL_CURVE("SMALL_LEFT_PARALLEL_CURVE", "CURVE", ItemIDs.tcRailSmallParallelCurve, ""), - - MEDIUM_PARALLEL_CURVE("MEDIUM_PARALLEL_CURVE", "CURVE", ItemIDs.tcRailMediumParallelCurve, "3x12"), - MEDIUM_RIGHT_PARALLEL_CURVE("MEDIUM_RIGHT_PARALLEL_CURVE", "CURVE", ItemIDs.tcRailMediumParallelCurve, ""), - MEDIUM_LEFT_PARALLEL_CURVE("MEDIUM_LEFT_PARALLEL_CURVE", "CURVE", ItemIDs.tcRailMediumParallelCurve, ""), - - LARGE_PARALLEL_CURVE("LARGE_PARALLEL_CURVE", "CURVE", ItemIDs.tcRailLargeParallelCurve, "4x16"), - LARGE_RIGHT_PARALLEL_CURVE("LARGE_RIGHT_PARALLEL_CURVE", "CURVE", ItemIDs.tcRailLargeParallelCurve, ""), - LARGE_LEFT_PARALLEL_CURVE("LARGE_LEFT_PARALLEL_CURVE", "CURVE", ItemIDs.tcRailLargeParallelCurve, ""), - - TWO_WAYS_CROSSING("TWO_WAYS_CROSSING", "CROSSING", ItemIDs.tcRailTwoWaysCrossing, "3x3"), +public class ItemTCRail extends ItemPart { - DIAMOND_CROSSING("DIAMOND_CROSSING", "DIAGONAL_CROSSING", ItemIDs.tcRailDiamondCrossing, "3x3"), - RIGHT_DIAMOND_CROSSING("RIGHT_DIAMOND_CROSSING", "DIAGONAL_CROSSING", ItemIDs.tcRailDiamondCrossing, "3x3"), - LEFT_DIAMOND_CROSSING("LEFT_DIAMOND_CROSSING", "DIAGONAL_CROSSING", ItemIDs.tcRailDiamondCrossing, "3x3"), - DOUBLE_DIAMOND_CROSSING("DOUBLE_DIAMOND_CROSSING", "DIAGONAL_CROSSING", ItemIDs.tcRailDoubleDiamondCrossing, "3x3"), - DIAGONAL_TWO_WAYS_CROSSING("DIAGONAL_TWO_WAYS_CROSSING", "DIAGONAL_CROSSING", ItemIDs.tcRailDiagonalTwoWaysCrossing, "3x3"), - FOUR_WAYS_CROSSING("FOUR_WAYS_CROSSING", "DIAGONAL_CROSSING", ItemIDs.tcRailFourWaysCrossing, "3x3"), + private final TrackTypes type; - MEDIUM_SWITCH("MEDIUM_RIGHT_SWITCH", "SWITCH", ItemIDs.tcRailMediumSwitch, "4x4"), - MEDIUM_RIGHT_SWITCH("MEDIUM_SWITCH", "SWITCH", ItemIDs.tcRailMediumSwitch, ""), - MEDIUM_LEFT_SWITCH("MEDIUM_LEFT_SWITCH", "SWITCH", ItemIDs.tcRailMediumSwitch, ""), + private String typeVariantStraight = TrackTypes.SMALL_STRAIGHT.getLabel(); + private String typeVariantDiagonal = TrackTypes.SMALL_DIAGONAL_STRAIGHT.getLabel(); + private String typeVariant90Turn; + private String typeVariantCrossing; + private Item idVariantSwitch; + TrackTypes tempType; - LARGE_SWITCH("LARGE_SWITCH", "SWITCH", ItemIDs.tcRailLargeSwitch, "6x6"), - LARGE_RIGHT_SWITCH("LARGE_RIGHT_SWITCH", "SWITCH", ItemIDs.tcRailLargeSwitch, ""), - LARGE_LEFT_SWITCH("LARGE_LEFT_SWITCH", "SWITCH", ItemIDs.tcRailLargeSwitch, ""), + public enum TrackTypes { + /** + * Normal Tracks + */ + SMALL_STRAIGHT("SMALL_STRAIGHT", STRAIGHT, ItemIDs.tcRailSmallStraight, "1x1"), + MEDIUM_STRAIGHT("MEDIUM_STRAIGHT", STRAIGHT, ItemIDs.tcRailMediumStraight, "1x3"), + LONG_STRAIGHT("LONG_STRAIGHT", STRAIGHT, ItemIDs.tcRailLongStraight, "1x6"), + VERY_LONG_STRAIGHT("VERY_LONG_STRAIGHT", STRAIGHT, ItemIDs.tcRailVeryLongStraight, "1x12"), - MEDIUM_PARALLEL_SWITCH("MEDIUM_PARALLEL_SWITCH", "SWITCH", ItemIDs.tcRailMediumParallelSwitch, "4x11"), - MEDIUM_RIGHT_PARALLEL_SWITCH("MEDIUM_RIGHT_PARALLEL_SWITCH", "SWITCH", ItemIDs.tcRailMediumParallelSwitch, ""), - MEDIUM_LEFT_PARALLEL_SWITCH("MEDIUM_LEFT_PARALLEL_SWITCH", "SWITCH", ItemIDs.tcRailMediumParallelSwitch, ""), + SMALL_DIAGONAL_STRAIGHT("SMALL_DIAGONAL_STRAIGHT", DIAGONAL, ItemIDs.tcRailSmallDiagonalStraight, "1x1"), + MEDIUM_DIAGONAL_STRAIGHT("MEDIUM_DIAGONAL_STRAIGHT", DIAGONAL, ItemIDs.tcRailMediumDiagonalStraight, "1x3"), + LONG_DIAGONAL_STRAIGHT("LONG_DIAGONAL_STRAIGHT", DIAGONAL, ItemIDs.tcRailLongDiagonalStraight, "1x6"), + VERY_LONG_DIAGONAL_STRAIGHT("VERY_LONG_DIAGONAL_STRAIGHT", DIAGONAL, ItemIDs.tcRailVeryLongDiagonalStraight, "1x12"), - MEDIUM_45DEGREE_SWITCH("MEDIUM_45DEGREE_SWITCH", "SWITCH", ItemIDs.tcRailMedium45DegreeSwitch,"3x5 hold sneak to attach to the back of another curve"), - MEDIUM_RIGHT_45DEGREE_SWITCH("MEDIUM_RIGHT_45DEGREE_SWITCH", "SWITCH", ItemIDs.tcRailMedium45DegreeSwitch,""), - MEDIUM_LEFT_45DEGREE_SWITCH("MEDIUM_LEFT_45DEGREE_SWITCH", "SWITCH", ItemIDs.tcRailMedium45DegreeSwitch,""), - SLOPE_WOOD("SLOPE_WOOD", "SLOPE", ItemIDs.tcRailSlopeWood, "1x6"), - LARGE_SLOPE_WOOD("LARGE_SLOPE_WOOD", "SLOPE", ItemIDs.tcRailLargeSlopeWood, "1x12"), - VERY_LARGE_SLOPE_WOOD("VERY_LARGE_SLOPE_WOOD", "SLOPE", ItemIDs.tcRailVeryLargeSlopeWood, "1x18"), + MEDIUM_TURN("MEDIUM_TURN", TURN, ItemIDs.tcRailMediumTurn, "3x3"), + MEDIUM_RIGHT_TURN("MEDIUM_RIGHT_TURN", TURN, ItemIDs.tcRailMediumTurn, ""), + MEDIUM_LEFT_TURN("MEDIUM_LEFT_TURN", TURN, ItemIDs.tcRailMediumTurn, ""), - SLOPE_GRAVEL("SLOPE_GRAVEL", "SLOPE", ItemIDs.tcRailSlopeGravel, "1x6"), - LARGE_SLOPE_GRAVEL("LARGE_SLOPE_GRAVEL", "SLOPE", ItemIDs.tcRailLargeSlopeGravel, "1x12"), - VERY_LARGE_SLOPE_GRAVEL("VERY_LARGE_SLOPE_GRAVEL", "SLOPE", ItemIDs.tcRailVeryLargeSlopeGravel, "1x18"), + LARGE_TURN("LARGE_TURN", TURN, ItemIDs.tcRailLargeTurn, "5x5"), + LARGE_RIGHT_TURN("LARGE_RIGHT_TURN", TURN, ItemIDs.tcRailLargeTurn, ""), + LARGE_LEFT_TURN("LARGE_LEFT_TURN", TURN, ItemIDs.tcRailLargeTurn, ""), - SLOPE_BALLAST("SLOPE_BALLAST", "SLOPE", ItemIDs.tcRailSlopeBallast, "1x6"), - LARGE_SLOPE_BALLAST("LARGE_SLOPE_BALLAST", "SLOPE", ItemIDs.tcRailLargeSlopeBallast, "1x12"), - VERY_LARGE_SLOPE_BALLAST("VERY_LARGE_SLOPE_BALLAST", "SLOPE", ItemIDs.tcRailVeryLargeSlopeBallast, "1x18"), + VERY_LARGE_TURN("VERY_LARGE_TURN", TURN, ItemIDs.tcRailVeryLargeTurn, "10x10"), + VERY_LARGE_RIGHT_TURN("VERY_LARGE_RIGHT_TURN", TURN, ItemIDs.tcRailVeryLargeTurn, ""), + VERY_LARGE_LEFT_TURN("VERY_LARGE_LEFT_TURN", TURN, ItemIDs.tcRailVeryLargeTurn, ""), - SLOPE_SNOW_GRAVEL("SLOPE_SNOW_GRAVEL", "SLOPE", ItemIDs.tcRailSlopeSnowGravel, "1x6"), - LARGE_SLOPE_SNOW_GRAVEL("LARGE_SLOPE_SNOW_GRAVEL", "SLOPE", ItemIDs.tcRailLargeSlopeSnowGravel, "1x12"), - VERY_LARGE_SLOPE_SNOW_GRAVEL("VERY_LARGE_SLOPE_SNOW_GRAVEL", "SLOPE", ItemIDs.tcRailVeryLargeSlopeSnowGravel, "1x18"), + SUPER_LARGE_TURN("SUPER_LARGE_TURN", TURN, ItemIDs.tcRailSuperLargeTurn, "16x16"), + SUPER_LARGE_LEFT_TURN("SUPER_LARGE_LEFT_TURN", TURN, ItemIDs.tcRailSuperLargeTurn, ""), + SUPER_LARGE_RIGHT_TURN("SUPER_LARGE_RIGHT_TURN", TURN, ItemIDs.tcRailSuperLargeTurn, ""), - SLOPE_DYNAMIC("SLOPE_DYNAMIC", "SLOPE", ItemIDs.tcRailSlopeDynamic, "1x6 " + EnumChatFormatting.YELLOW + "Grabs texture from block " + EnumChatFormatting.DARK_PURPLE + "-TheDoctor1138"), - LARGE_SLOPE_DYNAMIC("LARGE_SLOPE_DYNAMIC", "SLOPE", ItemIDs.tcRailLargeSlopeDynamic, "1x12 " + EnumChatFormatting.YELLOW + "Grabs texture from block " + EnumChatFormatting.DARK_PURPLE + "-TheDoctor1138") , - VERY_LARGE_SLOPE_DYNAMIC("VERY_LARGE_SLOPE_DYNAMIC", "SLOPE", ItemIDs.tcRailVeryLargeSlopeDynamic, "1x18 " + EnumChatFormatting.YELLOW + "Grabs texture from block " + EnumChatFormatting.DARK_PURPLE + "-TheDoctor1138"), + MEDIUM_45DEGREE_TURN("MEDIUM_45DEGREE_TURN", SHARP_TURN, ItemIDs.tcRailMedium45DegreeTurn, "3x4 hold sneak to attach to the back of another curve"), + MEDIUM_RIGHT_45DEGREE_TURN("MEDIUM_RIGHT_45DEGREE_TURN", SHARP_TURN, ItemIDs.tcRailMedium45DegreeTurn, ""), + MEDIUM_LEFT_45DEGREE_TURN("MEDIUM_LEFT_45DEGREE_TURN", SHARP_TURN, ItemIDs.tcRailMedium45DegreeTurn, ""), - LARGE_CURVED_SLOPE_DYNAMIC("LARGE_CURVED_SLOPE_DYNAMIC", "CURVED_SLOPE", ItemIDs.tcRailLargeCurvedSlopeDynamic, "5x5"), - LARGE_RIGHT_CURVED_SLOPE_DYNAMIC("LARGE_RIGHT_CURVED_SLOPE_DYNAMIC", "CURVED_SLOPE", ItemIDs.tcRailLargeCurvedSlopeDynamic, "xxx"), - LARGE_LEFT_CURVED_SLOPE_DYNAMIC("LARGE_LEFT_CURVED_SLOPE_DYNAMIC", "CURVED_SLOPE", ItemIDs.tcRailLargeCurvedSlopeDynamic, "xxx"), + LARGE_45DEGREE_TURN("LARGE_45DEGREE_TURN", SHARP_TURN, ItemIDs.tcRailLarge45DegreeTurn, "3x6 hold sneak to attach to the back of another curve"), + LARGE_RIGHT_45DEGREE_TURN("LARGE_RIGHT_45DEGREE_TURN", SHARP_TURN, ItemIDs.tcRailLarge45DegreeTurn, ""), + LARGE_LEFT_45DEGREE_TURN("LARGE_LEFT_45DEGREE_TURN", SHARP_TURN, ItemIDs.tcRailLarge45DegreeTurn, ""), - VERY_LARGE_CURVED_SLOPE_DYNAMIC("VERY_LARGE_CURVED_SLOPE_DYNAMIC", "CURVED_SLOPE", ItemIDs.tcRailVeryLargeCurvedSlopeDynamic, "9x9"), - VERY_LARGE_RIGHT_CURVED_SLOPE_DYNAMIC("VERY_LARGE_RIGHT_CURVED_SLOPE_DYNAMIC", "CURVED_SLOPE", ItemIDs.tcRailVeryLargeSlopeDynamic, "xxx"), - VERY_LARGE_LEFT_CURVED_SLOPE_DYNAMIC("VERY_LARGE_LEFT_CURVED_SLOPE_DYNAMIC", "CURVED_SLOPE", ItemIDs.tcRailVeryLargeCurvedSlopeDynamic, "xxx"), + VERY_LARGE_45DEGREE_TURN("VERY_LARGE_45DEGREE_TURN", SHARP_TURN, ItemIDs.tcRailVeryLarge45DegreeTurn, "4x8 hold sneak to attach to the back of another curve"), + VERY_LARGE_RIGHT_45DEGREE_TURN("VERY_LARGE_RIGHT_45DEGREE_TURN", SHARP_TURN, ItemIDs.tcRailVeryLarge45DegreeTurn, ""), + VERY_LARGE_LEFT_45DEGREE_TURN("VERY_LARGE_LEFT_45DEGREE_TURN", SHARP_TURN, ItemIDs.tcRailVeryLarge45DegreeTurn, ""), - SUPER_LARGE_CURVED_SLOPE_DYNAMIC("SUPER_LARGE_CURVED_SLOPE_DYNAMIC", "CURVED_SLOPE", ItemIDs.tcRailSuperLargeCurvedSlopeDynamic, "16x16"), - SUPER_LARGE_RIGHT_CURVED_SLOPE_DYNAMIC("SUPER_LARGE_RIGHT_CURVED_SLOPE_DYNAMIC", "CURVED_SLOPE", ItemIDs.tcRailSuperLargeCurvedSlopeDynamic, "xxx"), - SUPER_LARGE_LEFT_CURVED_SLOPE_DYNAMIC("SUPER_LARGE_LEFT_CURVED_SLOPE_DYNAMIC", "CURVED_SLOPE", ItemIDs.tcRailSuperLargeCurvedSlopeDynamic, "xxx"), - /**Embedded Tracks*/ + SUPER_LARGE_45DEGREE_TURN("SUPER_LARGE_45DEGREE_TURN", SHARP_TURN, ItemIDs.tcRailSuperLarge45DegreeTurn, "5x11 hold sneak to attach to the back of another curve"), + SUPER_LARGE_RIGHT_45DEGREE_TURN("SUPER_LARGE_RIGHT_45DEGREE_TURN", SHARP_TURN, ItemIDs.tcRailSuperLarge45DegreeTurn, ""), + SUPER_LARGE_LEFT_45DEGREE_TURN("SUPER_LARGE_LEFT_45DEGREE_TURN", SHARP_TURN, ItemIDs.tcRailSuperLarge45DegreeTurn, ""), - EMBEDDED_SMALL_STRAIGHT("EMBEDDED_SMALL_STRAIGHT","STRAIGHT" ,ItemIDs.tcRailEmbeddedSmallStraight, "1x1"), - EMBEDDED_MEDIUM_STRAIGHT("EMBEDDED_MEDIUM_STRAIGHT", "STRAIGHT", ItemIDs.tcRailEmbeddedMediumStraight, "1x3"), - EMBEDDED_LONG_STRAIGHT("EMBEDDED_LONG_STRAIGHT", "STRAIGHT", ItemIDs.tcRailEmbeddedLongStraight, "1x6"), - EMBEDDED_VERY_LONG_STRAIGHT("EMBEDDED_VERY_LONG_STRAIGHT", "STRAIGHT", ItemIDs.tcRailEmbeddedVeryLongStraight, "1x12"), + SMALL_PARALLEL_CURVE("SMALL_PARALLEL_CURVE", CURVE, ItemIDs.tcRailSmallParallelCurve, "2x8"), + SMALL_RIGHT_PARALLEL_CURVE("SMALL_RIGHT_PARALLEL_CURVE", CURVE, ItemIDs.tcRailSmallParallelCurve, ""), + SMALL_LEFT_PARALLEL_CURVE("SMALL_LEFT_PARALLEL_CURVE", CURVE, ItemIDs.tcRailSmallParallelCurve, ""), - EMBEDDED_SMALL_DIAGONAL_STRAIGHT("EMBEDDED_SMALL_DIAGONAL_STRAIGHT", "DIAGONAL", ItemIDs.tcRailEmbeddedSmallDiagonalStraight, "1x1"), - EMBEDDED_MEDIUM_DIAGONAL_STRAIGHT("EMBEDDED_MEDIUM_DIAGONAL_STRAIGHT", "DIAGONAL", ItemIDs.tcRailEmbeddedMediumDiagonalStraight, "1x3"), - EMBEDDED_LONG_DIAGONAL_STRAIGHT("EMBEDDED_LONG_DIAGONAL_STRAIGHT", "DIAGONAL", ItemIDs.tcRailEmbeddedLongDiagonalStraight, "1x6"), - EMBEDDED_VERY_LONG_DIAGONAL_STRAIGHT("EMBEDDED_VERY_LONG_DIAGONAL_STRAIGHT", "DIAGONAL", ItemIDs.tcRailEmbeddedVeryLongDiagonalStraight, "1x12"), + MEDIUM_PARALLEL_CURVE("MEDIUM_PARALLEL_CURVE", CURVE, ItemIDs.tcRailMediumParallelCurve, "3x12"), + MEDIUM_RIGHT_PARALLEL_CURVE("MEDIUM_RIGHT_PARALLEL_CURVE", CURVE, ItemIDs.tcRailMediumParallelCurve, ""), + MEDIUM_LEFT_PARALLEL_CURVE("MEDIUM_LEFT_PARALLEL_CURVE", CURVE, ItemIDs.tcRailMediumParallelCurve, ""), - EMBEDDED_MEDIUM_TURN("EMBEDDED_MEDIUM_TURN", "TURN", ItemIDs.tcRailEmbeddedMediumTurn, "3x3"), - EMBEDDED_MEDIUM_RIGHT_TURN("EMBEDDED_MEDIUM_RIGHT_TURN", "TURN", ItemIDs.tcRailEmbeddedMediumTurn, ""), - EMBEDDED_MEDIUM_LEFT_TURN("EMBEDDED_MEDIUM_LEFT_TURN", "TURN", ItemIDs.tcRailEmbeddedMediumTurn, ""), + LARGE_PARALLEL_CURVE("LARGE_PARALLEL_CURVE", CURVE, ItemIDs.tcRailLargeParallelCurve, "4x16"), + LARGE_RIGHT_PARALLEL_CURVE("LARGE_RIGHT_PARALLEL_CURVE", CURVE, ItemIDs.tcRailLargeParallelCurve, ""), + LARGE_LEFT_PARALLEL_CURVE("LARGE_LEFT_PARALLEL_CURVE", CURVE, ItemIDs.tcRailLargeParallelCurve, ""), - EMBEDDED_LARGE_TURN("EMBEDDED_LARGE_TURN", "TURN", ItemIDs.tcRailEmbeddedLargeTurn, "5x5"), - EMBEDDED_LARGE_RIGHT_TURN("EMBEDDED_LARGE_RIGHT_TURN", "TURN", ItemIDs.tcRailEmbeddedLargeTurn, ""), - EMBEDDED_LARGE_LEFT_TURN("EMBEDDED_LARGE_LEFT_TURN", "TURN", ItemIDs.tcRailEmbeddedLargeTurn, ""), + TWO_WAYS_CROSSING("TWO_WAYS_CROSSING", CROSSING, ItemIDs.tcRailTwoWaysCrossing, "3x3"), + + DIAMOND_CROSSING("DIAMOND_CROSSING", DIAGONAL_CROSSING, ItemIDs.tcRailDiamondCrossing, "3x3"), + RIGHT_DIAMOND_CROSSING("RIGHT_DIAMOND_CROSSING", DIAGONAL_CROSSING, ItemIDs.tcRailDiamondCrossing, "3x3"), + LEFT_DIAMOND_CROSSING("LEFT_DIAMOND_CROSSING", DIAGONAL_CROSSING, ItemIDs.tcRailDiamondCrossing, "3x3"), + + DOUBLE_DIAMOND_CROSSING("DOUBLE_DIAMOND_CROSSING", DIAGONAL_CROSSING, ItemIDs.tcRailDoubleDiamondCrossing, "3x3"), + DIAGONAL_TWO_WAYS_CROSSING("DIAGONAL_TWO_WAYS_CROSSING", DIAGONAL_CROSSING, ItemIDs.tcRailDiagonalTwoWaysCrossing, "3x3"), + FOUR_WAYS_CROSSING("FOUR_WAYS_CROSSING", DIAGONAL_CROSSING, ItemIDs.tcRailFourWaysCrossing, "3x3"), + + MEDIUM_SWITCH("MEDIUM_RIGHT_SWITCH", SWITCH, ItemIDs.tcRailMediumSwitch, "4x4"), + MEDIUM_RIGHT_SWITCH("MEDIUM_SWITCH", SWITCH, ItemIDs.tcRailMediumSwitch, ""), + MEDIUM_LEFT_SWITCH("MEDIUM_LEFT_SWITCH", SWITCH, ItemIDs.tcRailMediumSwitch, ""), + + LARGE_SWITCH("LARGE_SWITCH", SWITCH, ItemIDs.tcRailLargeSwitch, "6x6"), + LARGE_RIGHT_SWITCH("LARGE_RIGHT_SWITCH", SWITCH, ItemIDs.tcRailLargeSwitch, ""), + LARGE_LEFT_SWITCH("LARGE_LEFT_SWITCH", SWITCH, ItemIDs.tcRailLargeSwitch, ""), + + MEDIUM_PARALLEL_SWITCH("MEDIUM_PARALLEL_SWITCH", SWITCH, ItemIDs.tcRailMediumParallelSwitch, "4x11"), + MEDIUM_RIGHT_PARALLEL_SWITCH("MEDIUM_RIGHT_PARALLEL_SWITCH", SWITCH, ItemIDs.tcRailMediumParallelSwitch, ""), + MEDIUM_LEFT_PARALLEL_SWITCH("MEDIUM_LEFT_PARALLEL_SWITCH", SWITCH, ItemIDs.tcRailMediumParallelSwitch, ""), + + MEDIUM_45DEGREE_SWITCH("MEDIUM_45DEGREE_SWITCH", SWITCH, ItemIDs.tcRailMedium45DegreeSwitch, "3x5 hold sneak to attach to the back of another curve"), + MEDIUM_RIGHT_45DEGREE_SWITCH("MEDIUM_RIGHT_45DEGREE_SWITCH", SWITCH, ItemIDs.tcRailMedium45DegreeSwitch, ""), + MEDIUM_LEFT_45DEGREE_SWITCH("MEDIUM_LEFT_45DEGREE_SWITCH", SWITCH, ItemIDs.tcRailMedium45DegreeSwitch, ""), - EMBEDDED_VERY_LARGE_TURN("EMBEDDED_VERY_LARGE_TURN", "TURN", ItemIDs.tcRailEmbeddedVeryLargeTurn, "10x10"), - EMBEDDED_VERY_LARGE_RIGHT_TURN("EMBEDDED_VERY_LARGE_RIGHT_TURN", "TURN", ItemIDs.tcRailEmbeddedVeryLargeTurn, ""), - EMBEDDED_VERY_LARGE_LEFT_TURN("EMBEDDED_VERY_LARGE_LEFT_TURN", "TURN", ItemIDs.tcRailEmbeddedVeryLargeTurn, ""), + SLOPE_WOOD("SLOPE_WOOD", SLOPE, ItemIDs.tcRailSlopeWood, "1x6"), + LARGE_SLOPE_WOOD("LARGE_SLOPE_WOOD", SLOPE, ItemIDs.tcRailLargeSlopeWood, "1x12"), + VERY_LARGE_SLOPE_WOOD("VERY_LARGE_SLOPE_WOOD", SLOPE, ItemIDs.tcRailVeryLargeSlopeWood, "1x18"), - EMBEDDED_SUPER_LARGE_TURN("EMBEDDED_SUPER_LARGE_TURN", "TURN", ItemIDs.tcRailEmbeddedSuperLargeTurn, "16x16"), - EMBEDDED_SUPER_LARGE_RIGHT_TURN("EMBEDDED_SUPER_LARGE_RIGHT_TURN", "TURN", ItemIDs.tcRailEmbeddedSuperLargeTurn, ""), - EMBEDDED_SUPER_LARGE_LEFT_TURN("EMBEDDED_SUPER_LARGE_LEFT_TURN", "TURN", ItemIDs.tcRailEmbeddedSuperLargeTurn, ""), + SLOPE_GRAVEL("SLOPE_GRAVEL", SLOPE, ItemIDs.tcRailSlopeGravel, "1x6"), + LARGE_SLOPE_GRAVEL("LARGE_SLOPE_GRAVEL", SLOPE, ItemIDs.tcRailLargeSlopeGravel, "1x12"), + VERY_LARGE_SLOPE_GRAVEL("VERY_LARGE_SLOPE_GRAVEL", SLOPE, ItemIDs.tcRailVeryLargeSlopeGravel, "1x18"), + + SLOPE_BALLAST("SLOPE_BALLAST", SLOPE, ItemIDs.tcRailSlopeBallast, "1x6"), + LARGE_SLOPE_BALLAST("LARGE_SLOPE_BALLAST", SLOPE, ItemIDs.tcRailLargeSlopeBallast, "1x12"), + VERY_LARGE_SLOPE_BALLAST("VERY_LARGE_SLOPE_BALLAST", SLOPE, ItemIDs.tcRailVeryLargeSlopeBallast, "1x18"), + + SLOPE_SNOW_GRAVEL("SLOPE_SNOW_GRAVEL", SLOPE, ItemIDs.tcRailSlopeSnowGravel, "1x6"), + LARGE_SLOPE_SNOW_GRAVEL("LARGE_SLOPE_SNOW_GRAVEL", SLOPE, ItemIDs.tcRailLargeSlopeSnowGravel, "1x12"), + VERY_LARGE_SLOPE_SNOW_GRAVEL("VERY_LARGE_SLOPE_SNOW_GRAVEL", SLOPE, ItemIDs.tcRailVeryLargeSlopeSnowGravel, "1x18"), + + SLOPE_DYNAMIC("SLOPE_DYNAMIC", SLOPE, ItemIDs.tcRailSlopeDynamic, "1x6 " + EnumChatFormatting.YELLOW + "Grabs texture from block " + EnumChatFormatting.DARK_PURPLE + "-TheDoctor1138"), + LARGE_SLOPE_DYNAMIC("LARGE_SLOPE_DYNAMIC", SLOPE, ItemIDs.tcRailLargeSlopeDynamic, "1x12 " + EnumChatFormatting.YELLOW + "Grabs texture from block " + EnumChatFormatting.DARK_PURPLE + "-TheDoctor1138"), + VERY_LARGE_SLOPE_DYNAMIC("VERY_LARGE_SLOPE_DYNAMIC", SLOPE, ItemIDs.tcRailVeryLargeSlopeDynamic, "1x18 " + EnumChatFormatting.YELLOW + "Grabs texture from block " + EnumChatFormatting.DARK_PURPLE + "-TheDoctor1138"), - EMBEDDED_MEDIUM_45DEGREE_TURN("EMBEDDED_MEDIUM_45DEGREE_TURN", "TURN", ItemIDs.tcRailEmbeddedMedium45DegreeTurn, "3x4 hold sneak to attach to the back of another curve"), - EMBEDDED_MEDIUM_RIGHT_45DEGREE_TURN("EMBEDDED_MEDIUM_RIGHT_45DEGREE_TURN", "TURN", ItemIDs.tcRailEmbeddedMedium45DegreeTurn, ""), - EMBEDDED_MEDIUM_LEFT_45DEGREE_TURN("EMBEDDED_MEDIUM_LEFT_45DEGREE_TURN", "TURN", ItemIDs.tcRailEmbeddedMedium45DegreeTurn, ""), + LARGE_CURVED_SLOPE_DYNAMIC("LARGE_CURVED_SLOPE_DYNAMIC", CURVED_SLOPE, ItemIDs.tcRailLargeCurvedSlopeDynamic, "5x5"), + LARGE_RIGHT_CURVED_SLOPE_DYNAMIC("LARGE_RIGHT_CURVED_SLOPE_DYNAMIC", CURVED_SLOPE, ItemIDs.tcRailLargeCurvedSlopeDynamic, "xxx"), + LARGE_LEFT_CURVED_SLOPE_DYNAMIC("LARGE_LEFT_CURVED_SLOPE_DYNAMIC", CURVED_SLOPE, ItemIDs.tcRailLargeCurvedSlopeDynamic, "xxx"), - EMBEDDED_LARGE_45DEGREE_TURN("EMBEDDED_LARGE_45DEGREE_TURN", "TURN", ItemIDs.tcRailEmbeddedLarge45DegreeTurn, "3x6 hold sneak to attach to the back of another curve"), - EMBEDDED_LARGE_RIGHT_45DEGREE_TURN("EMBEDDED_LARGE_RIGHT_45DEGREE_TURN", "TURN", ItemIDs.tcRailEmbeddedLarge45DegreeTurn, ""), - EMBEDDED_LARGE_LEFT_45DEGREE_TURN("EMBEDDED_LARGE_LEFT_45DEGREE_TURN", "TURN", ItemIDs.tcRailEmbeddedLarge45DegreeTurn, ""), + VERY_LARGE_CURVED_SLOPE_DYNAMIC("VERY_LARGE_CURVED_SLOPE_DYNAMIC", CURVED_SLOPE, ItemIDs.tcRailVeryLargeCurvedSlopeDynamic, "9x9"), + VERY_LARGE_RIGHT_CURVED_SLOPE_DYNAMIC("VERY_LARGE_RIGHT_CURVED_SLOPE_DYNAMIC", CURVED_SLOPE, ItemIDs.tcRailVeryLargeSlopeDynamic, "xxx"), + VERY_LARGE_LEFT_CURVED_SLOPE_DYNAMIC("VERY_LARGE_LEFT_CURVED_SLOPE_DYNAMIC", CURVED_SLOPE, ItemIDs.tcRailVeryLargeCurvedSlopeDynamic, "xxx"), - EMBEDDED_VERY_LARGE_45DEGREE_TURN("EMBEDDED_VERY_LARGE_45DEGREE_TURN", "TURN", ItemIDs.tcRailEmbeddedVeryLarge45DegreeTurn, "4x8 hold sneak to attach to the back of another curve"), - EMBEDDED_VERY_LARGE_RIGHT_45DEGREE_TURN("EMBEDDED_VERY_LARGE_RIGHT_45DEGREE_TURN", "TURN", ItemIDs.tcRailEmbeddedVeryLarge45DegreeTurn, ""), - EMBEDDED_VERY_LARGE_LEFT_45DEGREE_TURN("EMBEDDED_VERY_LARGE_LEFT_45DEGREE_TURN", "TURN", ItemIDs.tcRailEmbeddedVeryLarge45DegreeTurn, ""), + SUPER_LARGE_CURVED_SLOPE_DYNAMIC("SUPER_LARGE_CURVED_SLOPE_DYNAMIC", CURVED_SLOPE, ItemIDs.tcRailSuperLargeCurvedSlopeDynamic, "16x16"), + SUPER_LARGE_RIGHT_CURVED_SLOPE_DYNAMIC("SUPER_LARGE_RIGHT_CURVED_SLOPE_DYNAMIC", CURVED_SLOPE, ItemIDs.tcRailSuperLargeCurvedSlopeDynamic, "xxx"), + SUPER_LARGE_LEFT_CURVED_SLOPE_DYNAMIC("SUPER_LARGE_LEFT_CURVED_SLOPE_DYNAMIC", CURVED_SLOPE, ItemIDs.tcRailSuperLargeCurvedSlopeDynamic, "xxx"), + /** + * Embedded Tracks + */ - EMBEDDED_SUPER_LARGE_45DEGREE_TURN("EMBEDDED_SUPER_LARGE_45DEGREE_TURN", "TURN", ItemIDs.tcRailEmbeddedSuperLarge45DegreeTurn, "5x11 hold sneak to attach to the back of another curve"), - EMBEDDED_SUPER_LARGE_RIGHT_45DEGREE_TURN("EMBEDDED_SUPER_LARGE_RIGHT_45DEGREE_TURN", "TURN", ItemIDs.tcRailEmbeddedSuperLarge45DegreeTurn, ""), - EMBEDDED_SUPER_LARGE_LEFT_45DEGREE_TURN("EMBEDDED_SUPER_LARGE_LEFT_45DEGREE_TURN", "TURN", ItemIDs.tcRailEmbeddedSuperLarge45DegreeTurn, ""), + EMBEDDED_SMALL_STRAIGHT("EMBEDDED_SMALL_STRAIGHT", STRAIGHT, ItemIDs.tcRailEmbeddedSmallStraight, "1x1"), + EMBEDDED_MEDIUM_STRAIGHT("EMBEDDED_MEDIUM_STRAIGHT", STRAIGHT, ItemIDs.tcRailEmbeddedMediumStraight, "1x3"), + EMBEDDED_LONG_STRAIGHT("EMBEDDED_LONG_STRAIGHT", STRAIGHT, ItemIDs.tcRailEmbeddedLongStraight, "1x6"), + EMBEDDED_VERY_LONG_STRAIGHT("EMBEDDED_VERY_LONG_STRAIGHT", STRAIGHT, ItemIDs.tcRailEmbeddedVeryLongStraight, "1x12"), - EMBEDDED_SMALL_PARALLEL_CURVE("EMBEDDED_SMALL_PARALLEL_CURVE", "CURVE", ItemIDs.tcRailEmbeddedSmallParallelCurve, "2x8"), - EMBEDDED_SMALL_RIGHT_PARALLEL_CURVE("EMBEDDED_SMALL_RIGHT_PARALLEL_CURVE", "CURVE", ItemIDs.tcRailEmbeddedSmallParallelCurve, ""), - EMBEDDED_SMALL_LEFT_PARALLEL_CURVE("EMBEDDED_SMALL_LEFT_PARALLEL_CURVE", "CURVE", ItemIDs.tcRailEmbeddedSmallParallelCurve, ""), + EMBEDDED_SMALL_DIAGONAL_STRAIGHT("EMBEDDED_SMALL_DIAGONAL_STRAIGHT", DIAGONAL, ItemIDs.tcRailEmbeddedSmallDiagonalStraight, "1x1"), + EMBEDDED_MEDIUM_DIAGONAL_STRAIGHT("EMBEDDED_MEDIUM_DIAGONAL_STRAIGHT", DIAGONAL, ItemIDs.tcRailEmbeddedMediumDiagonalStraight, "1x3"), + EMBEDDED_LONG_DIAGONAL_STRAIGHT("EMBEDDED_LONG_DIAGONAL_STRAIGHT", DIAGONAL, ItemIDs.tcRailEmbeddedLongDiagonalStraight, "1x6"), + EMBEDDED_VERY_LONG_DIAGONAL_STRAIGHT("EMBEDDED_VERY_LONG_DIAGONAL_STRAIGHT", DIAGONAL, ItemIDs.tcRailEmbeddedVeryLongDiagonalStraight, "1x12"), - EMBEDDED_MEDIUM_PARALLEL_CURVE("EMBEDDED_MEDIUM_PARALLEL_CURVE", "CURVE", ItemIDs.tcRailEmbeddedMediumParallelCurve, "3x12"), - EMBEDDED_MEDIUM_RIGHT_PARALLEL_CURVE("EMBEDDED_MEDIUM_RIGHT_PARALLEL_CURVE", "CURVE", ItemIDs.tcRailEmbeddedMediumParallelCurve, ""), - EMBEDDED_MEDIUM_LEFT_PARALLEL_CURVE("EMBEDDED_MEDIUM_LEFT_PARALLEL_CURVE", "CURVE", ItemIDs.tcRailEmbeddedMediumParallelCurve, ""), + EMBEDDED_MEDIUM_TURN("EMBEDDED_MEDIUM_TURN", TURN, ItemIDs.tcRailEmbeddedMediumTurn, "3x3"), + EMBEDDED_MEDIUM_RIGHT_TURN("EMBEDDED_MEDIUM_RIGHT_TURN", TURN, ItemIDs.tcRailEmbeddedMediumTurn, ""), + EMBEDDED_MEDIUM_LEFT_TURN("EMBEDDED_MEDIUM_LEFT_TURN", TURN, ItemIDs.tcRailEmbeddedMediumTurn, ""), - EMBEDDED_LARGE_PARALLEL_CURVE("EMBEDDED_LARGE_PARALLEL_CURVE", "CURVE", ItemIDs.tcRailEmbeddedLargeParallelCurve, "4x16"), - EMBEDDED_LARGE_RIGHT_PARALLEL_CURVE("EMBEDDED_LARGE_RIGHT_PARALLEL_CURVE", "CURVE", ItemIDs.tcRailEmbeddedLargeParallelCurve, ""), - EMBEDDED_LARGE_LEFT_PARALLEL_CURVE("EMBEDDED_LARGE_LEFT_PARALLEL_CURVE", "CURVE", ItemIDs.tcRailEmbeddedLargeParallelCurve, ""), + EMBEDDED_LARGE_TURN("EMBEDDED_LARGE_TURN", TURN, ItemIDs.tcRailEmbeddedLargeTurn, "5x5"), + EMBEDDED_LARGE_RIGHT_TURN("EMBEDDED_LARGE_RIGHT_TURN", TURN, ItemIDs.tcRailEmbeddedLargeTurn, ""), + EMBEDDED_LARGE_LEFT_TURN("EMBEDDED_LARGE_LEFT_TURN", TURN, ItemIDs.tcRailEmbeddedLargeTurn, ""), - EMBEDDED_TWO_WAYS_CROSSING("EMBEDDED_TWO_WAYS_CROSSING", "CROSSING", ItemIDs.tcRailEmbeddedTwoWaysCrossing, "3x3"), - EMBEDDED_DIAGONAL_TWO_WAYS_CROSSING("EMBEDDED_DIAGONAL_TWO_WAYS_CROSSING", "DIAGONAL_CROSSING", ItemIDs.tcRailEmbeddedDiagonalTwoWaysCrossing, "3x3"), - EMBEDDED_FOUR_WAYS_CROSSING("EMBEDDED_FOUR_WAYS_CROSSING", "DIAGONAL_CROSSING", ItemIDs.tcRailEmbeddedFourWaysCrossing, "3x3"), + EMBEDDED_VERY_LARGE_TURN("EMBEDDED_VERY_LARGE_TURN", TURN, ItemIDs.tcRailEmbeddedVeryLargeTurn, "10x10"), + EMBEDDED_VERY_LARGE_RIGHT_TURN("EMBEDDED_VERY_LARGE_RIGHT_TURN", TURN, ItemIDs.tcRailEmbeddedVeryLargeTurn, ""), + EMBEDDED_VERY_LARGE_LEFT_TURN("EMBEDDED_VERY_LARGE_LEFT_TURN", TURN, ItemIDs.tcRailEmbeddedVeryLargeTurn, ""), - EMBEDDED_DIAMOND_CROSSING("EMBEDDED_DIAMOND_CROSSING", "DIAGONAL_CROSSING", ItemIDs.tcRailEmbeddedDiamondCrossing, "3x3"), - EMBEDDED_RIGHT_DIAMOND_CROSSING("EMBEDDED_RIGHT_DIAMOND_CROSSING", "DIAGONAL_CROSSING", ItemIDs.tcRailEmbeddedDiamondCrossing, "3x3"), - EMBEDDED_LEFT_DIAMOND_CROSSING("EMBEDDED_LEFT_DIAMOND_CROSSING", "DIAGONAL_CROSSING", ItemIDs.tcRailEmbeddedDiamondCrossing, "3x3"), - EMBEDDED_DOUBLE_DIAMOND_CROSSING("EMBEDDED_DOUBLE_DIAMOND_CROSSING", "DIAGONAL_CROSSING", ItemIDs.tcRailEmbeddedDoubleDiamondCrossing, "3x3"), + EMBEDDED_SUPER_LARGE_TURN("EMBEDDED_SUPER_LARGE_TURN", TURN, ItemIDs.tcRailEmbeddedSuperLargeTurn, "16x16"), + EMBEDDED_SUPER_LARGE_RIGHT_TURN("EMBEDDED_SUPER_LARGE_RIGHT_TURN", TURN, ItemIDs.tcRailEmbeddedSuperLargeTurn, ""), + EMBEDDED_SUPER_LARGE_LEFT_TURN("EMBEDDED_SUPER_LARGE_LEFT_TURN", TURN, ItemIDs.tcRailEmbeddedSuperLargeTurn, ""), + EMBEDDED_MEDIUM_45DEGREE_TURN("EMBEDDED_MEDIUM_45DEGREE_TURN", SHARP_TURN, ItemIDs.tcRailEmbeddedMedium45DegreeTurn, "3x4 hold sneak to attach to the back of another curve"), + EMBEDDED_MEDIUM_RIGHT_45DEGREE_TURN("EMBEDDED_MEDIUM_RIGHT_45DEGREE_TURN", SHARP_TURN, ItemIDs.tcRailEmbeddedMedium45DegreeTurn, ""), + EMBEDDED_MEDIUM_LEFT_45DEGREE_TURN("EMBEDDED_MEDIUM_LEFT_45DEGREE_TURN", SHARP_TURN, ItemIDs.tcRailEmbeddedMedium45DegreeTurn, ""), - EMBEDDED_MEDIUM_SWITCH("EMBEDDED_MEDIUM_RIGHT_SWITCH", "SWITCH", ItemIDs.tcRailEmbeddedMediumSwitch, "4x4"), - EMBEDDED_MEDIUM_RIGHT_SWITCH("EMBEDDED_MEDIUM_SWITCH", "SWITCH", ItemIDs.tcRailEmbeddedMediumSwitch, ""), - EMBEDDED_MEDIUM_LEFT_SWITCH("EMBEDDED_MEDIUM_LEFT_SWITCH", "SWITCH", ItemIDs.tcRailEmbeddedMediumSwitch, ""), - - EMBEDDED_LARGE_SWITCH("EMBEDDED_LARGE_SWITCH", "SWITCH", ItemIDs.tcRailEmbeddedLargeSwitch, "6x6"), - EMBEDDED_LARGE_RIGHT_SWITCH("EMBEDDED_LARGE_RIGHT_SWITCH", "SWITCH", ItemIDs.tcRailEmbeddedLargeSwitch, ""), - EMBEDDED_LARGE_LEFT_SWITCH("EMBEDDED_LARGE_LEFT_SWITCH", "SWITCH", ItemIDs.tcRailEmbeddedLargeSwitch, ""), - - EMBEDDED_MEDIUM_PARALLEL_SWITCH("EMBEDDED_", "SWITCH", ItemIDs.tcRailEmbeddedMediumParallelSwitch, "4x11"), - EMBEDDED_MEDIUM_RIGHT_PARALLEL_SWITCH("EMBEDDED_MEDIUM_RIGHT_PARALLEL_SWITCH", "SWITCH", ItemIDs.tcRailEmbeddedMediumParallelSwitch, ""), - EMBEDDED_MEDIUM_LEFT_PARALLEL_SWITCH("EMBEDDED_MEDIUM_LEFT_PARALLEL_SWITCH", "SWITCH", ItemIDs.tcRailEmbeddedMediumParallelSwitch, ""), - - EMBEDDED_MEDIUM_45DEGREE_SWITCH("EMBEDDED_MEDIUM_45DEGREE_SWITCH", "SWITCH", ItemIDs.tcRailEmbeddedMedium45DegreeSwitch,"3x5 hold sneak to attach to the back of another curve"), - EMBEDDED_MEDIUM_RIGHT_45DEGREE_SWITCH("EMBEDDED_MEDIUM_RIGHT_45DEGREE_SWITCH", "SWITCH", ItemIDs.tcRailEmbeddedMedium45DegreeSwitch,""), - EMBEDDED_MEDIUM_LEFT_45DEGREE_SWITCH("EMBEDDED_MEDIUM_LEFT_45DEGREE_SWITCH", "SWITCH", ItemIDs.tcRailEmbeddedMedium45DegreeSwitch,""), - - EMBEDDED_SLOPE_DYNAMIC("EMBEDDED_SLOPE_DYNAMIC", "SLOPE", ItemIDs.tcRailEmbeddedSlopeDynamic, "1x6 " + EnumChatFormatting.YELLOW + "Grabs texture from block " + EnumChatFormatting.DARK_PURPLE + "-TheDoctor1138"), - EMBEDDED_LARGE_SLOPE_DYNAMIC("EMBEDDED_LARGE_SLOPE_DYNAMIC", "SLOPE", ItemIDs.tcRailEmbeddedLargeSlopeDynamic, "1x12 " + EnumChatFormatting.YELLOW + "Grabs texture from block " + EnumChatFormatting.DARK_PURPLE + "-TheDoctor1138") , - EMBEDDED_VERY_LARGE_SLOPE_DYNAMIC("EMBEDDED_VERY_LARGE_SLOPE_DYNAMIC", "SLOPE", ItemIDs.tcRailEmbeddedVeryLargeSlopeDynamic, "1x18 " + EnumChatFormatting.YELLOW + "Grabs texture from block " + EnumChatFormatting.DARK_PURPLE + "-TheDoctor1138"), - - EMBEDDED_LARGE_CURVED_SLOPE_DYNAMIC("EMBEDDED_LARGE_CURVED_SLOPE_DYNAMIC", "CURVED_SLOPE", ItemIDs.tcRailEmbeddedLargeCurvedSlopeDynamic, "5x5"), - EMBEDDED_LARGE_RIGHT_CURVED_SLOPE_DYNAMIC("EMBEDDED_LARGE_RIGHT_CURVED_SLOPE_DYNAMIC", "CURVED_SLOPE", ItemIDs.tcRailEmbeddedLargeCurvedSlopeDynamic, "xxx"), - EMBEDDED_LARGE_LEFT_CURVED_SLOPE_DYNAMIC("EMBEDDED_LARGE_LEFT_CURVED_SLOPE_DYNAMIC", "CURVED_SLOPE", ItemIDs.tcRailEmbeddedLargeCurvedSlopeDynamic, "xxx"), - - EMBEDDED_VERY_LARGE_CURVED_SLOPE_DYNAMIC("EMBEDDED_VERY_LARGE_CURVED_SLOPE_DYNAMIC", "CURVED_SLOPE", ItemIDs.tcRailEmbeddedVeryLargeCurvedSlopeDynamic, "9x9"), - EMBEDDED_VERY_LARGE_RIGHT_CURVED_SLOPE_DYNAMIC("EMBEDDED_VERY_LARGE_RIGHT_CURVED_SLOPE_DYNAMIC", "CURVED_SLOPE", ItemIDs.tcRailEmbeddedVeryLargeCurvedSlopeDynamic, "xxx"), - EMBEDDED_VERY_LARGE_LEFT_CURVED_SLOPE_DYNAMIC("EMBEDDED_VERY_LARGE_LEFT_CURVED_SLOPE_DYNAMIC", "CURVED_SLOPE", ItemIDs.tcRailEmbeddedVeryLargeCurvedSlopeDynamic, "xxx"), - - EMBEDDED_SUPER_LARGE_CURVED_SLOPE_DYNAMIC("EMBEDDED_SUPER_LARGE_CURVED_SLOPE_DYNAMIC", "CURVED_SLOPE", ItemIDs.tcRailEmbeddedSuperLargeCurvedSlopeDynamic, "16x16"), - EMBEDDED_SUPER_LARGE_RIGHT_CURVED_SLOPE_DYNAMIC("EMBEDDED_SUPER_LARGE_RIGHT_CURVED_SLOPE_DYNAMIC", "CURVED_SLOPE", ItemIDs.tcRailEmbeddedSuperLargeCurvedSlopeDynamic, "xxx"), - EMBEDDED_SUPER_LARGE_LEFT_CURVED_SLOPE_DYNAMIC("EMBEDDED_SUPER_LARGE_LEFT_CURVED_SLOPE_DYNAMIC", "CURVED_SLOPE", ItemIDs.tcRailEmbeddedSuperLargeCurvedSlopeDynamic, "xxx"), - - SMALL_ROAD_CROSSING("SMALL_ROAD_CROSSING", "STRAIGHT", ItemIDs.tcRailSmallRoadCrossing, "1x1"), - SMALL_ROAD_CROSSING_1("SMALL_ROAD_CROSSING_1", "STRAIGHT", ItemIDs.tcRailSmallRoadCrossing1, "1x1"), - SMALL_ROAD_CROSSING_2("SMALL_ROAD_CROSSING_2", "STRAIGHT", ItemIDs.tcRailSmallRoadCrossing2, "1x1"); - - - - - - - - - - - private final String label; - private final String type; - private final ItemIDs item; - private final String tooltip; - - TrackTypes(String label, String type, ItemIDs item, String tooltip) { - this.label = label; - this.type = type; - this.item = item; - this.tooltip = tooltip; - } - - public String getLabel() { - return this.label; - } - - public String getType() { - return this.type; - } - - public ItemIDs getItem() { - return this.item; - } - - public String getTooltip() { - return this.tooltip; - } - - } - - public static boolean isTCTurnTrack(TileTCRail tile) { - if (tile == null || tile.getType() == null) { - return false; - } - return (tile.getType().equals(TrackTypes.MEDIUM_LEFT_SWITCH.getLabel()) && tile.getSwitchState()) - || (tile.getType().equals(TrackTypes.MEDIUM_RIGHT_SWITCH.getLabel()) && tile.getSwitchState()) - || (tile.getType().equals(TrackTypes.LARGE_LEFT_SWITCH.getLabel()) && tile.getSwitchState()) - || (tile.getType().equals(TrackTypes.LARGE_RIGHT_SWITCH.getLabel()) && tile.getSwitchState()) - || (tile.getType().equals(TrackTypes.MEDIUM_RIGHT_PARALLEL_SWITCH.getLabel()) && tile.getSwitchState()) - || (tile.getType().equals(TrackTypes.MEDIUM_LEFT_PARALLEL_SWITCH.getLabel()) && tile.getSwitchState()) - || (tile.getType().equals(TrackTypes.MEDIUM_RIGHT_45DEGREE_SWITCH.getLabel()) && tile.getSwitchState()) - || (tile.getType().equals(TrackTypes.MEDIUM_LEFT_45DEGREE_SWITCH.getLabel()) && tile.getSwitchState()) - || tile.getType().equals(TrackTypes.MEDIUM_RIGHT_TURN.getLabel()) - || tile.getType().equals(TrackTypes.MEDIUM_LEFT_TURN.getLabel()) - || tile.getType().equals(TrackTypes.LARGE_RIGHT_TURN.getLabel()) - || tile.getType().equals(TrackTypes.LARGE_LEFT_TURN.getLabel()) - || tile.getType().equals(TrackTypes.VERY_LARGE_RIGHT_TURN.getLabel()) - || tile.getType().equals(TrackTypes.VERY_LARGE_LEFT_TURN.getLabel()) - || tile.getType().equals(TrackTypes.SUPER_LARGE_RIGHT_TURN.getLabel()) - || tile.getType().equals(TrackTypes.SUPER_LARGE_LEFT_TURN.getLabel()) - || tile.getType().equals(TrackTypes.SMALL_RIGHT_PARALLEL_CURVE.getLabel()) - || tile.getType().equals(TrackTypes.SMALL_LEFT_PARALLEL_CURVE.getLabel()) - || tile.getType().equals(TrackTypes.MEDIUM_RIGHT_PARALLEL_CURVE.getLabel()) - || tile.getType().equals(TrackTypes.MEDIUM_LEFT_PARALLEL_CURVE.getLabel()) - || tile.getType().equals(TrackTypes.LARGE_RIGHT_PARALLEL_CURVE.getLabel()) - || tile.getType().equals(TrackTypes.LARGE_LEFT_PARALLEL_CURVE.getLabel()) - || tile.getType().equals(TrackTypes.MEDIUM_RIGHT_45DEGREE_TURN.getLabel()) - || tile.getType().equals(TrackTypes.MEDIUM_LEFT_45DEGREE_TURN.getLabel()) - || tile.getType().equals(TrackTypes.LARGE_RIGHT_45DEGREE_TURN.getLabel()) - || tile.getType().equals(TrackTypes.LARGE_LEFT_45DEGREE_TURN.getLabel()) - || tile.getType().equals(TrackTypes.VERY_LARGE_RIGHT_45DEGREE_TURN.getLabel()) - || tile.getType().equals(TrackTypes.VERY_LARGE_LEFT_45DEGREE_TURN.getLabel()) - || tile.getType().equals(TrackTypes.SUPER_LARGE_RIGHT_45DEGREE_TURN.getLabel()) - || tile.getType().equals(TrackTypes.SUPER_LARGE_LEFT_45DEGREE_TURN.getLabel()) - || (tile.getType().equals(TrackTypes.EMBEDDED_MEDIUM_LEFT_SWITCH.getLabel()) && tile.getSwitchState()) - || (tile.getType().equals(TrackTypes.EMBEDDED_MEDIUM_RIGHT_SWITCH.getLabel()) && tile.getSwitchState()) - || (tile.getType().equals(TrackTypes.EMBEDDED_LARGE_LEFT_SWITCH.getLabel()) && tile.getSwitchState()) - || (tile.getType().equals(TrackTypes.EMBEDDED_LARGE_RIGHT_SWITCH.getLabel()) && tile.getSwitchState()) - || (tile.getType().equals(TrackTypes.EMBEDDED_MEDIUM_RIGHT_PARALLEL_SWITCH.getLabel()) && tile.getSwitchState()) - || (tile.getType().equals(TrackTypes.EMBEDDED_MEDIUM_LEFT_PARALLEL_SWITCH.getLabel()) && tile.getSwitchState()) - || (tile.getType().equals(TrackTypes.EMBEDDED_MEDIUM_RIGHT_45DEGREE_SWITCH.getLabel()) && tile.getSwitchState()) - || (tile.getType().equals(TrackTypes.EMBEDDED_MEDIUM_LEFT_45DEGREE_SWITCH.getLabel()) && tile.getSwitchState()) - || tile.getType().equals(TrackTypes.EMBEDDED_MEDIUM_RIGHT_TURN.getLabel()) - || tile.getType().equals(TrackTypes.EMBEDDED_MEDIUM_LEFT_TURN.getLabel()) - || tile.getType().equals(TrackTypes.EMBEDDED_LARGE_RIGHT_TURN.getLabel()) - || tile.getType().equals(TrackTypes.EMBEDDED_LARGE_LEFT_TURN.getLabel()) - || tile.getType().equals(TrackTypes.EMBEDDED_VERY_LARGE_RIGHT_TURN.getLabel()) - || tile.getType().equals(TrackTypes.EMBEDDED_VERY_LARGE_LEFT_TURN.getLabel()) - || tile.getType().equals(TrackTypes.EMBEDDED_SUPER_LARGE_RIGHT_TURN.getLabel()) - || tile.getType().equals(TrackTypes.EMBEDDED_SUPER_LARGE_LEFT_TURN.getLabel()) - || tile.getType().equals(TrackTypes.EMBEDDED_SMALL_RIGHT_PARALLEL_CURVE.getLabel()) - || tile.getType().equals(TrackTypes.EMBEDDED_SMALL_LEFT_PARALLEL_CURVE.getLabel()) - || tile.getType().equals(TrackTypes.EMBEDDED_MEDIUM_RIGHT_PARALLEL_CURVE.getLabel()) - || tile.getType().equals(TrackTypes.EMBEDDED_MEDIUM_LEFT_PARALLEL_CURVE.getLabel()) - || tile.getType().equals(TrackTypes.EMBEDDED_LARGE_RIGHT_PARALLEL_CURVE.getLabel()) - || tile.getType().equals(TrackTypes.EMBEDDED_LARGE_LEFT_PARALLEL_CURVE.getLabel()) - || tile.getType().equals(TrackTypes.EMBEDDED_MEDIUM_RIGHT_45DEGREE_TURN.getLabel()) - || tile.getType().equals(TrackTypes.EMBEDDED_MEDIUM_LEFT_45DEGREE_TURN.getLabel()) - || tile.getType().equals(TrackTypes.EMBEDDED_LARGE_RIGHT_45DEGREE_TURN.getLabel()) - || tile.getType().equals(TrackTypes.EMBEDDED_LARGE_LEFT_45DEGREE_TURN.getLabel()) - || tile.getType().equals(TrackTypes.EMBEDDED_VERY_LARGE_RIGHT_45DEGREE_TURN.getLabel()) - || tile.getType().equals(TrackTypes.EMBEDDED_VERY_LARGE_LEFT_45DEGREE_TURN.getLabel()) - || tile.getType().equals(TrackTypes.EMBEDDED_SUPER_LARGE_RIGHT_45DEGREE_TURN.getLabel()) - || tile.getType().equals(TrackTypes.EMBEDDED_SUPER_LARGE_45DEGREE_TURN.getLabel()) - - ; - - } - - public static boolean isTCStraightTrack(TileTCRail tile) { - if(tile==null || tile.getType()==null){return false;} - return (tile.getType().equals(TrackTypes.MEDIUM_LEFT_SWITCH.getLabel()) && !tile.getSwitchState()) - || (tile.getType().equals(TrackTypes.MEDIUM_RIGHT_SWITCH.getLabel()) && !tile.getSwitchState()) - || (tile.getType().equals(TrackTypes.LARGE_LEFT_SWITCH.getLabel()) && !tile.getSwitchState()) - || (tile.getType().equals(TrackTypes.LARGE_RIGHT_SWITCH.getLabel()) && !tile.getSwitchState()) - || (tile.getType().equals(TrackTypes.MEDIUM_RIGHT_PARALLEL_SWITCH.getLabel()) && !tile.getSwitchState()) - || (tile.getType().equals(TrackTypes.MEDIUM_LEFT_PARALLEL_SWITCH.getLabel()) && !tile.getSwitchState()) - || (tile.getType().equals(TrackTypes.MEDIUM_RIGHT_45DEGREE_SWITCH.getLabel())&& !tile.getSwitchState()) - || (tile.getType().equals(TrackTypes.MEDIUM_LEFT_45DEGREE_SWITCH.getLabel())&& !tile.getSwitchState()) - || tile.getType().equals(TrackTypes.MEDIUM_STRAIGHT.getLabel()) - || tile.getType().equals(TrackTypes.VERY_LONG_STRAIGHT.getLabel()) - || tile.getType().equals(TrackTypes.LONG_STRAIGHT.getLabel()) - || tile.getType().equals(TrackTypes.SMALL_STRAIGHT.getLabel()) - || (tile.getType().equals(TrackTypes.EMBEDDED_MEDIUM_LEFT_SWITCH.getLabel()) && !tile.getSwitchState()) - || (tile.getType().equals(TrackTypes.EMBEDDED_MEDIUM_RIGHT_SWITCH.getLabel()) && !tile.getSwitchState()) - || (tile.getType().equals(TrackTypes.EMBEDDED_LARGE_LEFT_SWITCH.getLabel()) && !tile.getSwitchState()) - || (tile.getType().equals(TrackTypes.EMBEDDED_LARGE_RIGHT_SWITCH.getLabel()) && !tile.getSwitchState()) - || (tile.getType().equals(TrackTypes.EMBEDDED_MEDIUM_RIGHT_PARALLEL_SWITCH.getLabel()) && !tile.getSwitchState()) - || (tile.getType().equals(TrackTypes.EMBEDDED_MEDIUM_LEFT_PARALLEL_SWITCH.getLabel()) && !tile.getSwitchState()) - || (tile.getType().equals(TrackTypes.EMBEDDED_MEDIUM_RIGHT_45DEGREE_SWITCH.getLabel()) && !tile.getSwitchState()) - || (tile.getType().equals(TrackTypes.EMBEDDED_MEDIUM_LEFT_45DEGREE_SWITCH.getLabel()) && !tile.getSwitchState()) - || tile.getType().equals(TrackTypes.EMBEDDED_SMALL_STRAIGHT.getLabel()) - || tile.getType().equals(TrackTypes.EMBEDDED_MEDIUM_STRAIGHT.getLabel()) - || tile.getType().equals(TrackTypes.EMBEDDED_LONG_STRAIGHT.getLabel()) - || tile.getType().equals(TrackTypes.EMBEDDED_VERY_LONG_STRAIGHT.getLabel()) - || tile.getType().equals(TrackTypes.SMALL_ROAD_CROSSING.getLabel()) - || tile.getType().equals(TrackTypes.SMALL_ROAD_CROSSING_1.getLabel()) - || tile.getType().equals(TrackTypes.SMALL_ROAD_CROSSING_2.getLabel()) - - ; - } - - public static boolean isTCTwoWaysCrossingTrack(TileTCRail tile) { - if(tile==null || tile.getType()==null){return false;} - return (tile.getType().equals(TrackTypes.TWO_WAYS_CROSSING.getLabel())) || (tile.getType().equals(TrackTypes.EMBEDDED_TWO_WAYS_CROSSING.getLabel())); - } - - public static boolean isTCDiagonalCrossingTrack(TileTCRail tile) { - if(tile==null || tile.getType()==null){return false;} - return (tile.getType().equals(TrackTypes.RIGHT_DIAMOND_CROSSING.getLabel())) - || (tile.getType().equals(TrackTypes.LEFT_DIAMOND_CROSSING.getLabel())) - || (tile.getType().equals(TrackTypes.DOUBLE_DIAMOND_CROSSING.getLabel())) - || (tile.getType().equals(TrackTypes.EMBEDDED_RIGHT_DIAMOND_CROSSING.getLabel())) - || (tile.getType().equals(TrackTypes.EMBEDDED_LEFT_DIAMOND_CROSSING.getLabel())) - || (tile.getType().equals(TrackTypes.EMBEDDED_DOUBLE_DIAMOND_CROSSING.getLabel())) - || (tile.getType().equals(TrackTypes.DIAGONAL_TWO_WAYS_CROSSING.getLabel())) - || (tile.getType().equals(TrackTypes.EMBEDDED_DIAGONAL_TWO_WAYS_CROSSING.getLabel())) - || (tile.getType().equals(TrackTypes.FOUR_WAYS_CROSSING.getLabel())) - || (tile.getType().equals(TrackTypes.EMBEDDED_FOUR_WAYS_CROSSING.getLabel())) - ; - } - - public static boolean isTCSwitch(TileTCRail tile) { - if(tile==null || tile.getType()==null){return false;} - return (tile.getType().equals(TrackTypes.MEDIUM_LEFT_SWITCH.getLabel())) - || (tile.getType().equals(TrackTypes.MEDIUM_RIGHT_SWITCH.getLabel())) - || (tile.getType().equals(TrackTypes.LARGE_LEFT_SWITCH.getLabel())) - || (tile.getType().equals(TrackTypes.LARGE_RIGHT_SWITCH.getLabel())) - || (tile.getType().equals(TrackTypes.MEDIUM_RIGHT_PARALLEL_SWITCH.getLabel())) - || (tile.getType().equals(TrackTypes.MEDIUM_LEFT_PARALLEL_SWITCH.getLabel())) - || (tile.getType().equals(TrackTypes.MEDIUM_RIGHT_45DEGREE_SWITCH.getLabel())) - || (tile.getType().equals(TrackTypes.MEDIUM_LEFT_45DEGREE_SWITCH.getLabel())) - || (tile.getType().equals(TrackTypes.EMBEDDED_MEDIUM_LEFT_SWITCH.getLabel())) - || (tile.getType().equals(TrackTypes.EMBEDDED_MEDIUM_RIGHT_SWITCH.getLabel())) - || (tile.getType().equals(TrackTypes.EMBEDDED_LARGE_LEFT_SWITCH.getLabel())) - || (tile.getType().equals(TrackTypes.EMBEDDED_LARGE_RIGHT_SWITCH.getLabel())) - || (tile.getType().equals(TrackTypes.EMBEDDED_MEDIUM_RIGHT_PARALLEL_SWITCH.getLabel())) - || (tile.getType().equals(TrackTypes.EMBEDDED_MEDIUM_LEFT_PARALLEL_SWITCH.getLabel())) - || (tile.getType().equals(TrackTypes.EMBEDDED_MEDIUM_RIGHT_45DEGREE_SWITCH.getLabel())) - || (tile.getType().equals(TrackTypes.EMBEDDED_MEDIUM_LEFT_45DEGREE_SWITCH.getLabel())); - } - - public static boolean isTCSlopeTrack(TileTCRail tile) { - if(tile==null || tile.getType()==null){return false;} - return tile.getType().equals(TrackTypes.SLOPE_WOOD.getLabel()) - || tile.getType().equals(TrackTypes.SLOPE_GRAVEL.getLabel()) - || tile.getType().equals(TrackTypes.SLOPE_BALLAST.getLabel()) - || tile.getType().equals(TrackTypes.SLOPE_SNOW_GRAVEL.getLabel()) - || tile.getType().equals(TrackTypes.SLOPE_DYNAMIC.getLabel()) - || tile.getType().equals(TrackTypes.LARGE_SLOPE_WOOD.getLabel()) - || tile.getType().equals(TrackTypes.LARGE_SLOPE_GRAVEL.getLabel()) - || tile.getType().equals(TrackTypes.LARGE_SLOPE_BALLAST.getLabel()) - || tile.getType().equals(TrackTypes.LARGE_SLOPE_DYNAMIC.getLabel()) - || tile.getType().equals(TrackTypes.LARGE_SLOPE_SNOW_GRAVEL.getLabel()) - || tile.getType().equals(TrackTypes.VERY_LARGE_SLOPE_WOOD.getLabel()) - || tile.getType().equals(TrackTypes.VERY_LARGE_SLOPE_GRAVEL.getLabel()) - || tile.getType().equals(TrackTypes.VERY_LARGE_SLOPE_BALLAST.getLabel()) - || tile.getType().equals(TrackTypes.VERY_LARGE_SLOPE_SNOW_GRAVEL.getLabel()) - || tile.getType().equals(TrackTypes.VERY_LARGE_SLOPE_DYNAMIC.getLabel()) - || tile.getType().equals(TrackTypes.EMBEDDED_SLOPE_DYNAMIC.getLabel()) - || tile.getType().equals(TrackTypes.EMBEDDED_LARGE_SLOPE_DYNAMIC.getLabel()) - || tile.getType().equals(TrackTypes.EMBEDDED_VERY_LARGE_SLOPE_DYNAMIC.getLabel()) - ; - } - - public static boolean isTCCurvedSlopeTrack(TileTCRail tile) { - if(tile==null || tile.getType()==null){return false;} - return tile.getType().equals(TrackTypes.LARGE_RIGHT_CURVED_SLOPE_DYNAMIC.getLabel()) - || tile.getType().equals(TrackTypes.LARGE_LEFT_CURVED_SLOPE_DYNAMIC.getLabel()) - || tile.getType().equals(TrackTypes.EMBEDDED_LARGE_RIGHT_CURVED_SLOPE_DYNAMIC.getLabel()) - || tile.getType().equals(TrackTypes.EMBEDDED_LARGE_LEFT_CURVED_SLOPE_DYNAMIC.getLabel()) - || tile.getType().equals(TrackTypes.VERY_LARGE_RIGHT_CURVED_SLOPE_DYNAMIC.getLabel()) - || tile.getType().equals(TrackTypes.VERY_LARGE_LEFT_CURVED_SLOPE_DYNAMIC.getLabel()) - || tile.getType().equals(TrackTypes.EMBEDDED_VERY_LARGE_RIGHT_CURVED_SLOPE_DYNAMIC.getLabel()) - || tile.getType().equals(TrackTypes.EMBEDDED_VERY_LARGE_LEFT_CURVED_SLOPE_DYNAMIC.getLabel()) - || tile.getType().equals(TrackTypes.SUPER_LARGE_RIGHT_CURVED_SLOPE_DYNAMIC.getLabel()) - || tile.getType().equals(TrackTypes.SUPER_LARGE_LEFT_CURVED_SLOPE_DYNAMIC.getLabel()) - || tile.getType().equals(TrackTypes.EMBEDDED_SUPER_LARGE_RIGHT_CURVED_SLOPE_DYNAMIC.getLabel()) - || tile.getType().equals(TrackTypes.EMBEDDED_SUPER_LARGE_LEFT_CURVED_SLOPE_DYNAMIC.getLabel()) - ; - } - - public static boolean isTCDiagonalStraightTrack(TileTCRail tile) { - if(tile==null || tile.getType()==null){return false;} - return tile.getType().equals(TrackTypes.SMALL_DIAGONAL_STRAIGHT.getLabel()) - || tile.getType().equals(TrackTypes.MEDIUM_DIAGONAL_STRAIGHT.getLabel()) - || tile.getType().equals(TrackTypes.LONG_DIAGONAL_STRAIGHT.getLabel()) - || tile.getType().equals(TrackTypes.VERY_LONG_DIAGONAL_STRAIGHT.getLabel()) - || tile.getType().equals(TrackTypes.EMBEDDED_SMALL_DIAGONAL_STRAIGHT.getLabel()) - || tile.getType().equals(TrackTypes.EMBEDDED_MEDIUM_DIAGONAL_STRAIGHT.getLabel()) - || tile.getType().equals(TrackTypes.EMBEDDED_LONG_DIAGONAL_STRAIGHT.getLabel()) - || tile.getType().equals(TrackTypes.EMBEDDED_VERY_LONG_DIAGONAL_STRAIGHT.getLabel()) - - ; - } - - - - public ItemTCRail(TrackTypes t) { - super(t.getItem().iconName); - this.overridePath("tracks"); - this.type = t; - } - - private boolean canPlaceTrack(EntityPlayer player, World world, int x, int y, int z) { - Block l1 = world.getBlock(x, y - 1, z); - - if(player !=null && (!player.canPlayerEdit(x, y - 1, z, 0, player.getCurrentEquippedItem()) || - !player.canPlayerEdit(x, y, z, 0, player.getCurrentEquippedItem())) - ){ - return false; - } - - return canBeReplaced(world, x, y, z) && (World.doesBlockHaveSolidTopSurface(world ,x, y - 1, z) || l1 == BlockIDs.bridgePillar.block); - } - - private boolean canBeReplaced(World world, int x, int y, int z){ - Block block = world.getBlock(x, y, z); - return block == null || block.isReplaceable(world, x, y, z) || block instanceof BlockFlower - || block == Blocks.double_plant || block instanceof BlockMushroom; - } - - /** - * - * @param world - * @param x - * @param y - * @param z - * //@param posX[] array of gag - * //@param posZ[] array of gag - * @param l orientation - * @param exitFacing - * @param posExitX - * @param posExitZ - * @param r ray - * @param cx circle center - * @param cy circle center - * @param cz circle center - * @param type - * @return - */ - private boolean putDownTurn(@Nullable EntityPlayer player, World world, boolean putDownEnterTrack, int x, int y, int z, int[] posX, int[] posZ, - int l, boolean putDownExitTrack, int exitFacing, int posExitX, int posExitZ, double r, double cx, double cy, - double cz, String type, Item idDrop) { - - - - - if (type.contains("EMBEDDED")) { - typeVariantStraight = TrackTypes.EMBEDDED_SMALL_STRAIGHT.getLabel(); - } - - - TileTCRailGag[] tileGag = new TileTCRailGag[posX.length - 1]; - - /* check if first straight rail can be placed */ - if (putDownEnterTrack && !canPlaceTrack(player, world, x, y + 1, z)) { - return false; - } - - /* check if Gag rails can be placed */ - for (int gag = 0; gag < posX.length; gag++) { - if (!canPlaceTrack(player, world, posX[gag], y + 1, posZ[gag])) { - return false; - } - } - /* Check last block */ - if (putDownExitTrack && !canPlaceTrack(player, world, posExitX, y + 1, posExitZ)) { - return false; - } - if (putDownEnterTrack) { - /* first rail of the turn is a 1 block straight */ - placeTrack(world,x, y + 1, z, BlockIDs.tcRail.block, l); - TileTCRail tcRailStart = (TileTCRail) world.getTileEntity(x, y + 1, z); - tcRailStart.setType(typeVariantStraight); - tcRailStart.setFacing(l); - tcRailStart.isLinkedToRail = true; - tcRailStart.linkedX = posX[0]; - tcRailStart.linkedY = y + 1; - tcRailStart.linkedZ = posZ[0]; - } - - /* the turn starts with this rail */ - placeTrack(world,posX[0], y + 1, posZ[0], BlockIDs.tcRail.block, l); - TileTCRail tcRail = (TileTCRail) world.getTileEntity(posX[0], y + 1, posZ[0]); - tcRail.setFacing(l); - tcRail.r = r; - tcRail.cx = cx; - tcRail.cy = cy; - tcRail.cz = cz; - tcRail.setType(type); - tcRail.idDrop = idDrop; - - /* Gag rails containing reference to first turn rail */ - for (int gag = 1; gag < posX.length; gag++) { - placeTrack(world,posX[gag], y + 1, posZ[gag], BlockIDs.tcRailGag.block, 0); - tileGag[gag - 1] = (TileTCRailGag) world.getTileEntity(posX[gag], y + 1, posZ[gag]); - } - - if (putDownExitTrack) { - /* Last rail is a 1 block straight */ - placeTrack(world,posExitX, y + 1, posExitZ, BlockIDs.tcRail.block, exitFacing); - TileTCRail tcRailEnd = (TileTCRail) world.getTileEntity(posExitX, y + 1, posExitZ); - tcRailEnd.setFacing(exitFacing); - tcRailEnd.setType(typeVariantStraight); - tcRailEnd.isLinkedToRail = true; - tcRailEnd.linkedX = posX[0]; - tcRailEnd.linkedY = y + 1; - tcRailEnd.linkedZ = posZ[0]; - } - - for (TileTCRailGag tileTCRailGag : tileGag) { - tileTCRailGag.originX = posX[0]; - tileTCRailGag.originY = y + 1; - tileTCRailGag.originZ = posZ[0]; - tileTCRailGag.type = type; - } - return true; - } - - private boolean putDownSlopedTurn(@Nullable EntityPlayer player, World world, int x, int y, int z, int[] posX, int[] posZ, - int l, double r, double cx, double cy, double cz, float slopeAngle, double slopeLength, String type, Item idDrop) { - - - if (world.getBlock(x, y, z) == BlockIDs.bridgePillar.block){ - return false; - } - - TileTCRailGag[] tileGag = new TileTCRailGag[posX.length - 1]; - - /** check if Gag rails can be placed */ - for (int gag = 0; gag < posX.length; gag++) { - if (!canPlaceTrack(player, world, posX[gag], y + 1, posZ[gag])) { - return false; - } - } - - /** the turn starts with this rail */ - placeTrack(world,posX[0], y + 1, posZ[0], BlockIDs.tcRail.block, l); - TileTCRail tcRail = (TileTCRail) world.getTileEntity(posX[0], y + 1, posZ[0]); - tcRail.setFacing(l); - tcRail.r = r; - tcRail.cx = cx; - tcRail.cy = cy; - tcRail.cz = cz; - tcRail.setType(type); - tcRail.idDrop = idDrop; - tcRail.slopeAngle = slopeAngle; - tcRail.slopeHeight = 1; - tcRail.slopeLength = slopeLength; - Block block = world.getBlock(x, y, z); - int blockID = Block.getIdFromBlock(block); - tcRail.setBallastMaterial(blockID); - tcRail.ballastMetadata = world.getBlockMetadata(x,y,z); - System.out.println(tcRail.cx + " ," + tcRail.cz + " , " + tcRail.r); - /** Gag rails containing reference to first turn rail */ - for (int gag = 1; gag <= posX.length - 1; gag++) { - placeTrack(world, posX[gag], y + 1, posZ[gag], BlockIDs.tcRailGag.block, 0); - tileGag[gag - 1] = (TileTCRailGag) world.getTileEntity(posX[gag], y + 1, posZ[gag]); - //tileGag[gag - 1].bbHeight = Math.max(0.125f, Math.min(1f, (gag - 1) / (float) (posX.length - 1))); - tileGag[gag - 1].bbHeight = Math.max(0.125f, Math.min(1f, gag / (float) (posX.length - 1 ))); - - } - for (TileTCRailGag tileTCRailGag : tileGag) { - tileTCRailGag.originX = posX[0]; - tileTCRailGag.originY = y + 1; - tileTCRailGag.originZ = posZ[0]; - tileTCRailGag.type = type; - } - - return true; - } - - private void putDownSingleRail(World world, int posX, int posY, int posZ, int l, double cx, double cy, double cz, double r, String label, boolean hasModel, int linkedX, int linkedY, int linkedZ, boolean canTypeBeModifiedBySwitch, boolean shouldDrop) { - /** Switch rail */ - placeTrack(world,posX, posY, posZ, BlockIDs.tcRail.block, l); - TileTCRail tcRail = (TileTCRail) world.getTileEntity(posX, posY, posZ); - //world.setBlockMetadataWithNotify(posX, posY, posZ, l, 2); - tcRail.setFacing(l); - tcRail.cx = cx; - tcRail.cy = cy; - tcRail.cz = cz; - tcRail.r = r; - tcRail.setType(label); - tcRail.hasModel = hasModel; - tcRail.isLinkedToRail = true; - tcRail.linkedX = linkedX; - tcRail.linkedY = linkedY; - tcRail.linkedZ = linkedZ; - tcRail.canTypeBeModifiedBySwitch = canTypeBeModifiedBySwitch; - if(shouldDrop)tcRail.idDrop = ItemIDs.tcRailSmallStraight.item; - } - - public String getTrackOrientation(int l, float yaw) { - if (l == 2 && yaw >= -180 && yaw <= -135) { - return "right"; - } - if (l == 2 && yaw <= 180 && yaw >= 135) { - return "left"; - } - if (l == 3 && yaw > -135 && yaw <= -90) { - return "left"; - } - if (l == 3 && yaw > -90 && yaw <= -45) { - return "right"; - } - if (l == 0 && yaw > -45 && yaw <= 0) { - return "left"; - } - if (l == 0 && yaw > 0 && yaw <= 45) { - return "right"; - } - if (l == 1 && yaw > 45 && yaw <= 90) { - return "left"; - } - if (l == 1 && yaw > 90 && yaw <= 135) { - return "right"; - } - return ""; - } - - - public static Vector2f getDirectionVector(int facing) - { - Matrix2f nrot90 = new Matrix2f(); - nrot90.m00 = +0; nrot90.m01 = +1; - nrot90.m10 = -1; nrot90.m11 = +0; - - Vector2f vec = new Vector2f(); - vec.x = 0; vec.y = 1; - - for ( int i = 0; i < facing; i++ ) - { - Vector2f nvec = new Vector2f(); - nvec.x = vec.x * nrot90.m00 + vec.y * nrot90.m10; - nvec.y = vec.x * nrot90.m01 + vec.y * nrot90.m11; - vec = nvec; - } - return vec; - - } - - private int[][] getUsedSpaceFromType( TrackTypes type, @Nullable EntityPlayer player) - { - /** Straights */ - if ( type == TrackTypes.SMALL_STRAIGHT - || type == TrackTypes.SMALL_ROAD_CROSSING - || type == TrackTypes.SMALL_ROAD_CROSSING_1 - || type == TrackTypes.SMALL_ROAD_CROSSING_2 - || type == TrackTypes.EMBEDDED_SMALL_STRAIGHT) - return new int[][]{ {0,0} }; - else if ( type == TrackTypes.MEDIUM_STRAIGHT || type == TrackTypes.EMBEDDED_MEDIUM_STRAIGHT) - return new int[][]{ {0,0}, {1,0}, {2,0} }; - else if ( type == TrackTypes.LONG_STRAIGHT || type == TrackTypes.EMBEDDED_LONG_STRAIGHT) - return new int[][]{ {0,0}, {1,0}, {2,0}, {3,0}, {4,0}, {5,0} }; - else if ( type == TrackTypes.VERY_LONG_STRAIGHT || type == TrackTypes.EMBEDDED_VERY_LONG_STRAIGHT) - return new int[][]{ {0,0}, {1,0}, {2,0}, {3,0}, {4,0}, {5,0}, {6,0}, {7,0}, {8,0}, {9,0}, {10,0}, {11,0}}; - /** Diagonals*/ - else if (type == TrackTypes.SMALL_DIAGONAL_STRAIGHT || type == TrackTypes.EMBEDDED_SMALL_DIAGONAL_STRAIGHT) - return new int [][]{{0,0}, {1,0}, {0,1}}; - else if (type == TrackTypes.MEDIUM_DIAGONAL_STRAIGHT || type == TrackTypes.EMBEDDED_MEDIUM_DIAGONAL_STRAIGHT) - return new int [][]{{0,0}, {1,0}, {0,1}, {1,1}, {2,1}, {1,2},{2,2}, {3,2}, {2,3}}; - else if (type == TrackTypes.LONG_DIAGONAL_STRAIGHT || type == TrackTypes.EMBEDDED_LONG_DIAGONAL_STRAIGHT) - return new int [][]{{0,0}, {1,0}, {0,1}, {1,1}, {2,1}, {1,2}, {2,2}, {3,2}, {2,3},{3,3}, {4,3},{3,4}, {4,4}, {4,5}, {5,4}, {5,5}, {6,5}, {5,6}}; - else if (type == TrackTypes.VERY_LONG_DIAGONAL_STRAIGHT || type == TrackTypes.EMBEDDED_VERY_LONG_DIAGONAL_STRAIGHT) - return new int [][]{{0,0}, {1,0}, {0,1}, {1,1}, {2,1}, {1,2}, {2,2}, {3,2}, {2,3},{3,3}, {4,3},{3,4}, {4,4}, {4,5}, {5,4}, {5,5}, {6,5}, {5,6}, - {6,6},{6,7},{7,6},{7,7},{8,7},{7,8}, {8,8}, {9,8}, {8,9}, {9,9}, {10,9}, {9,10}, {10,10}, {11,10}, {10,11}, {11,11}, {12,11}, {11,12}}; - /** Slopes */ - else if ( type == TrackTypes.SLOPE_BALLAST - || type == TrackTypes.SLOPE_GRAVEL - || type == TrackTypes.SLOPE_WOOD - || type == TrackTypes.SLOPE_SNOW_GRAVEL - || type == TrackTypes.SLOPE_DYNAMIC - || type == TrackTypes.EMBEDDED_SLOPE_DYNAMIC - ) - return new int[][]{ {0,0}, {1,0}, {2,0}, {3,0}, {4,0}, {5,0} }; - - else if ( type == TrackTypes.LARGE_SLOPE_BALLAST - || type == TrackTypes.LARGE_SLOPE_GRAVEL - || type == TrackTypes.LARGE_SLOPE_WOOD - || type == TrackTypes.LARGE_SLOPE_SNOW_GRAVEL - || type == TrackTypes.LARGE_SLOPE_DYNAMIC - || type == TrackTypes.EMBEDDED_LARGE_SLOPE_DYNAMIC) - return new int[][]{ {0,0}, {1,0}, {2,0}, {3,0}, {4,0}, {5,0}, {6,0}, {7,0}, {8,0}, {9,0}, {10,0}, {11,0} }; - else if ( type == TrackTypes.VERY_LARGE_SLOPE_BALLAST - || type == TrackTypes.VERY_LARGE_SLOPE_GRAVEL - || type == TrackTypes.VERY_LARGE_SLOPE_WOOD - || type == TrackTypes.VERY_LARGE_SLOPE_SNOW_GRAVEL - || type == TrackTypes.VERY_LARGE_SLOPE_DYNAMIC - || type == TrackTypes.EMBEDDED_VERY_LARGE_SLOPE_DYNAMIC - ) - return new int[][]{ {0,0}, {1,0}, {2,0}, {3,0}, {4,0}, {5,0}, {6,0}, {7,0}, {8,0}, {9,0}, {10,0}, {11,0}, - {12,0}, {13,0}, {14,0}, {15,0}, {16,0}, {17,0}}; - /** Crossing */ - else if ( type == TrackTypes.TWO_WAYS_CROSSING || type == TrackTypes.EMBEDDED_TWO_WAYS_CROSSING) - return new int[][] { {0,0}, {1,0}, {2,0}, {1,1}, {1,-1} }; - else if ( type == TrackTypes.DIAMOND_CROSSING || type == TrackTypes.EMBEDDED_DIAMOND_CROSSING) - return new int[][] { {0,0}, {1,0}, {2,0}, {0,-1}, {2,1} }; - else if ( type == TrackTypes.DOUBLE_DIAMOND_CROSSING || type == TrackTypes.EMBEDDED_DOUBLE_DIAMOND_CROSSING) - return new int[][] { {0,0}, {1,0}, {2,0}, {0,-1}, {2,-1},{0,1},{2,1}}; - else if ( type == TrackTypes.DIAGONAL_TWO_WAYS_CROSSING || type == TrackTypes.EMBEDDED_DIAGONAL_TWO_WAYS_CROSSING) - return new int[][] { {0,0}, {-1,-1}, {1,-1},{1,1},{-1,1}}; - else if ( type == TrackTypes.FOUR_WAYS_CROSSING || type == TrackTypes.EMBEDDED_FOUR_WAYS_CROSSING) - return new int[][] { {0,0}, {1,0}, {-1,0}, {0,-1},{1,-1}, {-1,-1},{0,1},{1,1},{-1,1}}; - /** Turns */ - else if ( type == TrackTypes.MEDIUM_TURN || type == TrackTypes.EMBEDDED_MEDIUM_TURN ) - return new int[][] { {0,0}, {1,0}, {1,1}, {2,1}, {2,2} }; - else if ( type == TrackTypes.LARGE_TURN || type == TrackTypes.EMBEDDED_LARGE_TURN) - return new int[][] { {0,0}, {1,0}, {2,0}, {1,1}, {2,1}, {3,1}, {2,2}, {3,2}, {4,2}, {3,3}, {4,3}, {4,4} }; - else if ( type == TrackTypes.VERY_LARGE_TURN || type == TrackTypes.EMBEDDED_VERY_LARGE_TURN) - return new int[][] { {0,0}, {1,0}, {2,0}, {3,0}, {4,0}, {2,1}, {3,1}, {4,1}, {5,1}, {4,2}, {5,2}, {6,2}, - {6,3}, {7,3}, {7,4}, {8,4}, {7,5}, {8,5}, {9,5}, {8,6}, {9,6}, {8,7}, {9,7}, {9,8}, {9,9} }; - else if ( type == TrackTypes.SUPER_LARGE_TURN || type == TrackTypes.EMBEDDED_SUPER_LARGE_TURN) - return new int[][]{ {0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0}, {1, 1}, {2, 1}, {3, 1}, {4, 1}, {5, 1}, {6, 1}, {5, 2}, {6, 2}, {7, 2}, {8, 2}, - {7, 3}, {8, 3}, {9, 3}, {10, 3}, {9, 4}, {10, 4}, {11, 4}, {10, 5}, {11, 5}, {12, 5}, {11, 6}, {12, 6}, {13, 6}, {12, 7}, {13, 7}, - {12, 8}, {13, 8}, {14, 8}, {13, 9}, {14, 9}, {13, 10}, {14, 10}, {15, 10}, {14, 11}, {15, 11}, {14, 12}, {15, 12}, {14, 12,}, {15, 13}, {15, 14}, {15, 15}}; - - /** Switches*/ - else if ( type == TrackTypes.MEDIUM_PARALLEL_SWITCH || type == TrackTypes.EMBEDDED_MEDIUM_PARALLEL_SWITCH ) - return new int[][] { {0,0}, {1,0}, {2,0}, {3,0}, {4,0}, {5,0}, {6,0}, {7,0}, {8,0}, {9,0}, {10,0}, - {2,1}, {3,1}, {4,1}, {5,1}, {4,2}, {5,2}, {6,2}, {7,2}, {8,2}, {6,3}, {7,3}, {8,3}, {9,3}, {10,3}}; - else if ( type == TrackTypes.MEDIUM_SWITCH || type == TrackTypes.EMBEDDED_MEDIUM_SWITCH ) - return new int[][] { {0,0}, {1,0}, {2,0}, {3,0}, {2,1}, {3,1}, {3,2}, {3,3} }; - else if ( type == TrackTypes.LARGE_SWITCH || type == TrackTypes.EMBEDDED_LARGE_SWITCH) - return new int[][] { {0,0}, {1,0}, {2,0}, {3,0}, {4,0}, {5,0}, - {2,1}, {3,1}, {4,1}, {3,2}, {4,2}, {5,2}, {4,3}, {5,3}, {5,4}, {5,5}}; + EMBEDDED_LARGE_45DEGREE_TURN("EMBEDDED_LARGE_45DEGREE_TURN", SHARP_TURN, ItemIDs.tcRailEmbeddedLarge45DegreeTurn, "3x6 hold sneak to attach to the back of another curve"), + EMBEDDED_LARGE_RIGHT_45DEGREE_TURN("EMBEDDED_LARGE_RIGHT_45DEGREE_TURN", SHARP_TURN, ItemIDs.tcRailEmbeddedLarge45DegreeTurn, ""), + EMBEDDED_LARGE_LEFT_45DEGREE_TURN("EMBEDDED_LARGE_LEFT_45DEGREE_TURN", SHARP_TURN, ItemIDs.tcRailEmbeddedLarge45DegreeTurn, ""), + + EMBEDDED_VERY_LARGE_45DEGREE_TURN("EMBEDDED_VERY_LARGE_45DEGREE_TURN", SHARP_TURN, ItemIDs.tcRailEmbeddedVeryLarge45DegreeTurn, "4x8 hold sneak to attach to the back of another curve"), + EMBEDDED_VERY_LARGE_RIGHT_45DEGREE_TURN("EMBEDDED_VERY_LARGE_RIGHT_45DEGREE_TURN", SHARP_TURN, ItemIDs.tcRailEmbeddedVeryLarge45DegreeTurn, ""), + EMBEDDED_VERY_LARGE_LEFT_45DEGREE_TURN("EMBEDDED_VERY_LARGE_LEFT_45DEGREE_TURN", SHARP_TURN, ItemIDs.tcRailEmbeddedVeryLarge45DegreeTurn, ""), + + EMBEDDED_SUPER_LARGE_45DEGREE_TURN("EMBEDDED_SUPER_LARGE_45DEGREE_TURN", SHARP_TURN, ItemIDs.tcRailEmbeddedSuperLarge45DegreeTurn, "5x11 hold sneak to attach to the back of another curve"), + EMBEDDED_SUPER_LARGE_RIGHT_45DEGREE_TURN("EMBEDDED_SUPER_LARGE_RIGHT_45DEGREE_TURN", SHARP_TURN, ItemIDs.tcRailEmbeddedSuperLarge45DegreeTurn, ""), + EMBEDDED_SUPER_LARGE_LEFT_45DEGREE_TURN("EMBEDDED_SUPER_LARGE_LEFT_45DEGREE_TURN", SHARP_TURN, ItemIDs.tcRailEmbeddedSuperLarge45DegreeTurn, ""), + + EMBEDDED_SMALL_PARALLEL_CURVE("EMBEDDED_SMALL_PARALLEL_CURVE", CURVE, ItemIDs.tcRailEmbeddedSmallParallelCurve, "2x8"), + EMBEDDED_SMALL_RIGHT_PARALLEL_CURVE("EMBEDDED_SMALL_RIGHT_PARALLEL_CURVE", CURVE, ItemIDs.tcRailEmbeddedSmallParallelCurve, ""), + EMBEDDED_SMALL_LEFT_PARALLEL_CURVE("EMBEDDED_SMALL_LEFT_PARALLEL_CURVE", CURVE, ItemIDs.tcRailEmbeddedSmallParallelCurve, ""), + + EMBEDDED_MEDIUM_PARALLEL_CURVE("EMBEDDED_MEDIUM_PARALLEL_CURVE", CURVE, ItemIDs.tcRailEmbeddedMediumParallelCurve, "3x12"), + EMBEDDED_MEDIUM_RIGHT_PARALLEL_CURVE("EMBEDDED_MEDIUM_RIGHT_PARALLEL_CURVE", CURVE, ItemIDs.tcRailEmbeddedMediumParallelCurve, ""), + EMBEDDED_MEDIUM_LEFT_PARALLEL_CURVE("EMBEDDED_MEDIUM_LEFT_PARALLEL_CURVE", CURVE, ItemIDs.tcRailEmbeddedMediumParallelCurve, ""), + + EMBEDDED_LARGE_PARALLEL_CURVE("EMBEDDED_LARGE_PARALLEL_CURVE", CURVE, ItemIDs.tcRailEmbeddedLargeParallelCurve, "4x16"), + EMBEDDED_LARGE_RIGHT_PARALLEL_CURVE("EMBEDDED_LARGE_RIGHT_PARALLEL_CURVE", CURVE, ItemIDs.tcRailEmbeddedLargeParallelCurve, ""), + EMBEDDED_LARGE_LEFT_PARALLEL_CURVE("EMBEDDED_LARGE_LEFT_PARALLEL_CURVE", CURVE, ItemIDs.tcRailEmbeddedLargeParallelCurve, ""), + + EMBEDDED_TWO_WAYS_CROSSING("EMBEDDED_TWO_WAYS_CROSSING", CROSSING, ItemIDs.tcRailEmbeddedTwoWaysCrossing, "3x3"), + EMBEDDED_DIAGONAL_TWO_WAYS_CROSSING("EMBEDDED_DIAGONAL_TWO_WAYS_CROSSING", DIAGONAL_CROSSING, ItemIDs.tcRailEmbeddedDiagonalTwoWaysCrossing, "3x3"), + EMBEDDED_FOUR_WAYS_CROSSING("EMBEDDED_FOUR_WAYS_CROSSING", DIAGONAL_CROSSING, ItemIDs.tcRailEmbeddedFourWaysCrossing, "3x3"), + + EMBEDDED_DIAMOND_CROSSING("EMBEDDED_DIAMOND_CROSSING", DIAGONAL_CROSSING, ItemIDs.tcRailEmbeddedDiamondCrossing, "3x3"), + EMBEDDED_RIGHT_DIAMOND_CROSSING("EMBEDDED_RIGHT_DIAMOND_CROSSING", DIAGONAL_CROSSING, ItemIDs.tcRailEmbeddedDiamondCrossing, "3x3"), + EMBEDDED_LEFT_DIAMOND_CROSSING("EMBEDDED_LEFT_DIAMOND_CROSSING", DIAGONAL_CROSSING, ItemIDs.tcRailEmbeddedDiamondCrossing, "3x3"), + EMBEDDED_DOUBLE_DIAMOND_CROSSING("EMBEDDED_DOUBLE_DIAMOND_CROSSING", DIAGONAL_CROSSING, ItemIDs.tcRailEmbeddedDoubleDiamondCrossing, "3x3"), + + + EMBEDDED_MEDIUM_SWITCH("EMBEDDED_MEDIUM_RIGHT_SWITCH", SWITCH, ItemIDs.tcRailEmbeddedMediumSwitch, "4x4"), + EMBEDDED_MEDIUM_RIGHT_SWITCH("EMBEDDED_MEDIUM_SWITCH", SWITCH, ItemIDs.tcRailEmbeddedMediumSwitch, ""), + EMBEDDED_MEDIUM_LEFT_SWITCH("EMBEDDED_MEDIUM_LEFT_SWITCH", SWITCH, ItemIDs.tcRailEmbeddedMediumSwitch, ""), + + EMBEDDED_LARGE_SWITCH("EMBEDDED_LARGE_SWITCH", SWITCH, ItemIDs.tcRailEmbeddedLargeSwitch, "6x6"), + EMBEDDED_LARGE_RIGHT_SWITCH("EMBEDDED_LARGE_RIGHT_SWITCH", SWITCH, ItemIDs.tcRailEmbeddedLargeSwitch, ""), + EMBEDDED_LARGE_LEFT_SWITCH("EMBEDDED_LARGE_LEFT_SWITCH", SWITCH, ItemIDs.tcRailEmbeddedLargeSwitch, ""), + + EMBEDDED_MEDIUM_PARALLEL_SWITCH("EMBEDDED_", SWITCH, ItemIDs.tcRailEmbeddedMediumParallelSwitch, "4x11"), + EMBEDDED_MEDIUM_RIGHT_PARALLEL_SWITCH("EMBEDDED_MEDIUM_RIGHT_PARALLEL_SWITCH", SWITCH, ItemIDs.tcRailEmbeddedMediumParallelSwitch, ""), + EMBEDDED_MEDIUM_LEFT_PARALLEL_SWITCH("EMBEDDED_MEDIUM_LEFT_PARALLEL_SWITCH", SWITCH, ItemIDs.tcRailEmbeddedMediumParallelSwitch, ""), + + EMBEDDED_MEDIUM_45DEGREE_SWITCH("EMBEDDED_MEDIUM_45DEGREE_SWITCH", SWITCH, ItemIDs.tcRailEmbeddedMedium45DegreeSwitch, "3x5 hold sneak to attach to the back of another curve"), + EMBEDDED_MEDIUM_RIGHT_45DEGREE_SWITCH("EMBEDDED_MEDIUM_RIGHT_45DEGREE_SWITCH", SWITCH, ItemIDs.tcRailEmbeddedMedium45DegreeSwitch, ""), + EMBEDDED_MEDIUM_LEFT_45DEGREE_SWITCH("EMBEDDED_MEDIUM_LEFT_45DEGREE_SWITCH", SWITCH, ItemIDs.tcRailEmbeddedMedium45DegreeSwitch, ""), + + EMBEDDED_SLOPE_DYNAMIC("EMBEDDED_SLOPE_DYNAMIC", SLOPE, ItemIDs.tcRailEmbeddedSlopeDynamic, "1x6 " + EnumChatFormatting.YELLOW + "Grabs texture from block " + EnumChatFormatting.DARK_PURPLE + "-TheDoctor1138"), + EMBEDDED_LARGE_SLOPE_DYNAMIC("EMBEDDED_LARGE_SLOPE_DYNAMIC", SLOPE, ItemIDs.tcRailEmbeddedLargeSlopeDynamic, "1x12 " + EnumChatFormatting.YELLOW + "Grabs texture from block " + EnumChatFormatting.DARK_PURPLE + "-TheDoctor1138"), + EMBEDDED_VERY_LARGE_SLOPE_DYNAMIC("EMBEDDED_VERY_LARGE_SLOPE_DYNAMIC", SLOPE, ItemIDs.tcRailEmbeddedVeryLargeSlopeDynamic, "1x18 " + EnumChatFormatting.YELLOW + "Grabs texture from block " + EnumChatFormatting.DARK_PURPLE + "-TheDoctor1138"), + + EMBEDDED_LARGE_CURVED_SLOPE_DYNAMIC("EMBEDDED_LARGE_CURVED_SLOPE_DYNAMIC", CURVED_SLOPE, ItemIDs.tcRailEmbeddedLargeCurvedSlopeDynamic, "5x5"), + EMBEDDED_LARGE_RIGHT_CURVED_SLOPE_DYNAMIC("EMBEDDED_LARGE_RIGHT_CURVED_SLOPE_DYNAMIC", CURVED_SLOPE, ItemIDs.tcRailEmbeddedLargeCurvedSlopeDynamic, "xxx"), + EMBEDDED_LARGE_LEFT_CURVED_SLOPE_DYNAMIC("EMBEDDED_LARGE_LEFT_CURVED_SLOPE_DYNAMIC", CURVED_SLOPE, ItemIDs.tcRailEmbeddedLargeCurvedSlopeDynamic, "xxx"), + + EMBEDDED_VERY_LARGE_CURVED_SLOPE_DYNAMIC("EMBEDDED_VERY_LARGE_CURVED_SLOPE_DYNAMIC", CURVED_SLOPE, ItemIDs.tcRailEmbeddedVeryLargeCurvedSlopeDynamic, "9x9"), + EMBEDDED_VERY_LARGE_RIGHT_CURVED_SLOPE_DYNAMIC("EMBEDDED_VERY_LARGE_RIGHT_CURVED_SLOPE_DYNAMIC", CURVED_SLOPE, ItemIDs.tcRailEmbeddedVeryLargeCurvedSlopeDynamic, "xxx"), + EMBEDDED_VERY_LARGE_LEFT_CURVED_SLOPE_DYNAMIC("EMBEDDED_VERY_LARGE_LEFT_CURVED_SLOPE_DYNAMIC", CURVED_SLOPE, ItemIDs.tcRailEmbeddedVeryLargeCurvedSlopeDynamic, "xxx"), + + EMBEDDED_SUPER_LARGE_CURVED_SLOPE_DYNAMIC("EMBEDDED_SUPER_LARGE_CURVED_SLOPE_DYNAMIC", CURVED_SLOPE, ItemIDs.tcRailEmbeddedSuperLargeCurvedSlopeDynamic, "16x16"), + EMBEDDED_SUPER_LARGE_RIGHT_CURVED_SLOPE_DYNAMIC("EMBEDDED_SUPER_LARGE_RIGHT_CURVED_SLOPE_DYNAMIC", CURVED_SLOPE, ItemIDs.tcRailEmbeddedSuperLargeCurvedSlopeDynamic, "xxx"), + EMBEDDED_SUPER_LARGE_LEFT_CURVED_SLOPE_DYNAMIC("EMBEDDED_SUPER_LARGE_LEFT_CURVED_SLOPE_DYNAMIC", CURVED_SLOPE, ItemIDs.tcRailEmbeddedSuperLargeCurvedSlopeDynamic, "xxx"), + + SMALL_ROAD_CROSSING("SMALL_ROAD_CROSSING", STRAIGHT, ItemIDs.tcRailSmallRoadCrossing, "1x1"), + SMALL_ROAD_CROSSING_1("SMALL_ROAD_CROSSING_1", STRAIGHT, ItemIDs.tcRailSmallRoadCrossing1, "1x1"), + SMALL_ROAD_CROSSING_2("SMALL_ROAD_CROSSING_2", STRAIGHT, ItemIDs.tcRailSmallRoadCrossing2, "1x1"); + + + private final String label; + private final TCRailTypes type; + private final ItemIDs item; + private final String tooltip; + + TrackTypes(String label, TCRailTypes type, ItemIDs item, String tooltip) { + this.label = label; + this.type = type; + this.item = item; + this.tooltip = tooltip; + } + + public String getLabel() { + return this.label; + } + + public TCRailTypes getType() { + return this.type; + } + + public ItemIDs getItem() { + return this.item; + } + + public String getTooltip() { + return this.tooltip; + } + } + + public static boolean isTCTurnTrack(TileTCRail tile) { + if (tile == null || tile.getType() == null) { + return false; + } + + return (tile.getType().equals(TrackTypes.MEDIUM_LEFT_SWITCH.getLabel()) && tile.getSwitchState()) + || (tile.getType().equals(TrackTypes.MEDIUM_RIGHT_SWITCH.getLabel()) && tile.getSwitchState()) + || (tile.getType().equals(TrackTypes.LARGE_LEFT_SWITCH.getLabel()) && tile.getSwitchState()) + || (tile.getType().equals(TrackTypes.LARGE_RIGHT_SWITCH.getLabel()) && tile.getSwitchState()) + || (tile.getType().equals(TrackTypes.MEDIUM_RIGHT_PARALLEL_SWITCH.getLabel()) && tile.getSwitchState()) + || (tile.getType().equals(TrackTypes.MEDIUM_LEFT_PARALLEL_SWITCH.getLabel()) && tile.getSwitchState()) + || (tile.getType().equals(TrackTypes.MEDIUM_RIGHT_45DEGREE_SWITCH.getLabel()) && tile.getSwitchState()) + || (tile.getType().equals(TrackTypes.MEDIUM_LEFT_45DEGREE_SWITCH.getLabel()) && tile.getSwitchState()) + || tile.getType().equals(TrackTypes.MEDIUM_RIGHT_TURN.getLabel()) + || tile.getType().equals(TrackTypes.MEDIUM_LEFT_TURN.getLabel()) + || tile.getType().equals(TrackTypes.LARGE_RIGHT_TURN.getLabel()) + || tile.getType().equals(TrackTypes.LARGE_LEFT_TURN.getLabel()) + || tile.getType().equals(TrackTypes.VERY_LARGE_RIGHT_TURN.getLabel()) + || tile.getType().equals(TrackTypes.VERY_LARGE_LEFT_TURN.getLabel()) + || tile.getType().equals(TrackTypes.SUPER_LARGE_RIGHT_TURN.getLabel()) + || tile.getType().equals(TrackTypes.SUPER_LARGE_LEFT_TURN.getLabel()) + || tile.getType().equals(TrackTypes.SMALL_RIGHT_PARALLEL_CURVE.getLabel()) + || tile.getType().equals(TrackTypes.SMALL_LEFT_PARALLEL_CURVE.getLabel()) + || tile.getType().equals(TrackTypes.MEDIUM_RIGHT_PARALLEL_CURVE.getLabel()) + || tile.getType().equals(TrackTypes.MEDIUM_LEFT_PARALLEL_CURVE.getLabel()) + || tile.getType().equals(TrackTypes.LARGE_RIGHT_PARALLEL_CURVE.getLabel()) + || tile.getType().equals(TrackTypes.LARGE_LEFT_PARALLEL_CURVE.getLabel()) + || tile.getType().equals(TrackTypes.MEDIUM_RIGHT_45DEGREE_TURN.getLabel()) + || tile.getType().equals(TrackTypes.MEDIUM_LEFT_45DEGREE_TURN.getLabel()) + || tile.getType().equals(TrackTypes.LARGE_RIGHT_45DEGREE_TURN.getLabel()) + || tile.getType().equals(TrackTypes.LARGE_LEFT_45DEGREE_TURN.getLabel()) + || tile.getType().equals(TrackTypes.VERY_LARGE_RIGHT_45DEGREE_TURN.getLabel()) + || tile.getType().equals(TrackTypes.VERY_LARGE_LEFT_45DEGREE_TURN.getLabel()) + || tile.getType().equals(TrackTypes.SUPER_LARGE_RIGHT_45DEGREE_TURN.getLabel()) + || tile.getType().equals(TrackTypes.SUPER_LARGE_LEFT_45DEGREE_TURN.getLabel()) + || (tile.getType().equals(TrackTypes.EMBEDDED_MEDIUM_LEFT_SWITCH.getLabel()) && tile.getSwitchState()) + || (tile.getType().equals(TrackTypes.EMBEDDED_MEDIUM_RIGHT_SWITCH.getLabel()) && tile.getSwitchState()) + || (tile.getType().equals(TrackTypes.EMBEDDED_LARGE_LEFT_SWITCH.getLabel()) && tile.getSwitchState()) + || (tile.getType().equals(TrackTypes.EMBEDDED_LARGE_RIGHT_SWITCH.getLabel()) && tile.getSwitchState()) + || (tile.getType().equals(TrackTypes.EMBEDDED_MEDIUM_RIGHT_PARALLEL_SWITCH.getLabel()) && tile.getSwitchState()) + || (tile.getType().equals(TrackTypes.EMBEDDED_MEDIUM_LEFT_PARALLEL_SWITCH.getLabel()) && tile.getSwitchState()) + || (tile.getType().equals(TrackTypes.EMBEDDED_MEDIUM_RIGHT_45DEGREE_SWITCH.getLabel()) && tile.getSwitchState()) + || (tile.getType().equals(TrackTypes.EMBEDDED_MEDIUM_LEFT_45DEGREE_SWITCH.getLabel()) && tile.getSwitchState()) + || tile.getType().equals(TrackTypes.EMBEDDED_MEDIUM_RIGHT_TURN.getLabel()) + || tile.getType().equals(TrackTypes.EMBEDDED_MEDIUM_LEFT_TURN.getLabel()) + || tile.getType().equals(TrackTypes.EMBEDDED_LARGE_RIGHT_TURN.getLabel()) + || tile.getType().equals(TrackTypes.EMBEDDED_LARGE_LEFT_TURN.getLabel()) + || tile.getType().equals(TrackTypes.EMBEDDED_VERY_LARGE_RIGHT_TURN.getLabel()) + || tile.getType().equals(TrackTypes.EMBEDDED_VERY_LARGE_LEFT_TURN.getLabel()) + || tile.getType().equals(TrackTypes.EMBEDDED_SUPER_LARGE_RIGHT_TURN.getLabel()) + || tile.getType().equals(TrackTypes.EMBEDDED_SUPER_LARGE_LEFT_TURN.getLabel()) + || tile.getType().equals(TrackTypes.EMBEDDED_SMALL_RIGHT_PARALLEL_CURVE.getLabel()) + || tile.getType().equals(TrackTypes.EMBEDDED_SMALL_LEFT_PARALLEL_CURVE.getLabel()) + || tile.getType().equals(TrackTypes.EMBEDDED_MEDIUM_RIGHT_PARALLEL_CURVE.getLabel()) + || tile.getType().equals(TrackTypes.EMBEDDED_MEDIUM_LEFT_PARALLEL_CURVE.getLabel()) + || tile.getType().equals(TrackTypes.EMBEDDED_LARGE_RIGHT_PARALLEL_CURVE.getLabel()) + || tile.getType().equals(TrackTypes.EMBEDDED_LARGE_LEFT_PARALLEL_CURVE.getLabel()) + || tile.getType().equals(TrackTypes.EMBEDDED_MEDIUM_RIGHT_45DEGREE_TURN.getLabel()) + || tile.getType().equals(TrackTypes.EMBEDDED_MEDIUM_LEFT_45DEGREE_TURN.getLabel()) + || tile.getType().equals(TrackTypes.EMBEDDED_LARGE_RIGHT_45DEGREE_TURN.getLabel()) + || tile.getType().equals(TrackTypes.EMBEDDED_LARGE_LEFT_45DEGREE_TURN.getLabel()) + || tile.getType().equals(TrackTypes.EMBEDDED_VERY_LARGE_RIGHT_45DEGREE_TURN.getLabel()) + || tile.getType().equals(TrackTypes.EMBEDDED_VERY_LARGE_LEFT_45DEGREE_TURN.getLabel()) + || tile.getType().equals(TrackTypes.EMBEDDED_SUPER_LARGE_RIGHT_45DEGREE_TURN.getLabel()) + || tile.getType().equals(TrackTypes.EMBEDDED_SUPER_LARGE_45DEGREE_TURN.getLabel()) + + ; + + } + + public static boolean isTCStraightTrack(TileTCRail tile) { + if (tile == null || tile.getType() == null) { + return false; + } + return (tile.getType().equals(TrackTypes.MEDIUM_LEFT_SWITCH.getLabel()) && !tile.getSwitchState()) + || (tile.getType().equals(TrackTypes.MEDIUM_RIGHT_SWITCH.getLabel()) && !tile.getSwitchState()) + || (tile.getType().equals(TrackTypes.LARGE_LEFT_SWITCH.getLabel()) && !tile.getSwitchState()) + || (tile.getType().equals(TrackTypes.LARGE_RIGHT_SWITCH.getLabel()) && !tile.getSwitchState()) + || (tile.getType().equals(TrackTypes.MEDIUM_RIGHT_PARALLEL_SWITCH.getLabel()) && !tile.getSwitchState()) + || (tile.getType().equals(TrackTypes.MEDIUM_LEFT_PARALLEL_SWITCH.getLabel()) && !tile.getSwitchState()) + || (tile.getType().equals(TrackTypes.MEDIUM_RIGHT_45DEGREE_SWITCH.getLabel()) && !tile.getSwitchState()) + || (tile.getType().equals(TrackTypes.MEDIUM_LEFT_45DEGREE_SWITCH.getLabel()) && !tile.getSwitchState()) + || tile.getType().equals(TrackTypes.MEDIUM_STRAIGHT.getLabel()) + || tile.getType().equals(TrackTypes.VERY_LONG_STRAIGHT.getLabel()) + || tile.getType().equals(TrackTypes.LONG_STRAIGHT.getLabel()) + || tile.getType().equals(TrackTypes.SMALL_STRAIGHT.getLabel()) + || (tile.getType().equals(TrackTypes.EMBEDDED_MEDIUM_LEFT_SWITCH.getLabel()) && !tile.getSwitchState()) + || (tile.getType().equals(TrackTypes.EMBEDDED_MEDIUM_RIGHT_SWITCH.getLabel()) && !tile.getSwitchState()) + || (tile.getType().equals(TrackTypes.EMBEDDED_LARGE_LEFT_SWITCH.getLabel()) && !tile.getSwitchState()) + || (tile.getType().equals(TrackTypes.EMBEDDED_LARGE_RIGHT_SWITCH.getLabel()) && !tile.getSwitchState()) + || (tile.getType().equals(TrackTypes.EMBEDDED_MEDIUM_RIGHT_PARALLEL_SWITCH.getLabel()) && !tile.getSwitchState()) + || (tile.getType().equals(TrackTypes.EMBEDDED_MEDIUM_LEFT_PARALLEL_SWITCH.getLabel()) && !tile.getSwitchState()) + || (tile.getType().equals(TrackTypes.EMBEDDED_MEDIUM_RIGHT_45DEGREE_SWITCH.getLabel()) && !tile.getSwitchState()) + || (tile.getType().equals(TrackTypes.EMBEDDED_MEDIUM_LEFT_45DEGREE_SWITCH.getLabel()) && !tile.getSwitchState()) + || tile.getType().equals(TrackTypes.EMBEDDED_SMALL_STRAIGHT.getLabel()) + || tile.getType().equals(TrackTypes.EMBEDDED_MEDIUM_STRAIGHT.getLabel()) + || tile.getType().equals(TrackTypes.EMBEDDED_LONG_STRAIGHT.getLabel()) + || tile.getType().equals(TrackTypes.EMBEDDED_VERY_LONG_STRAIGHT.getLabel()) + || tile.getType().equals(TrackTypes.SMALL_ROAD_CROSSING.getLabel()) + || tile.getType().equals(TrackTypes.SMALL_ROAD_CROSSING_1.getLabel()) + || tile.getType().equals(TrackTypes.SMALL_ROAD_CROSSING_2.getLabel()) + + ; + } + + public static boolean isTCTwoWaysCrossingTrack(TileTCRail tile) { + if (tile == null || tile.getType() == null) { + return false; + } + return (tile.getType().equals(TrackTypes.TWO_WAYS_CROSSING.getLabel())) || (tile.getType().equals(TrackTypes.EMBEDDED_TWO_WAYS_CROSSING.getLabel())); + } + + public static boolean isTCDiagonalCrossingTrack(TileTCRail tile) { + if (tile == null || tile.getType() == null) { + return false; + } + return (tile.getType().equals(TrackTypes.RIGHT_DIAMOND_CROSSING.getLabel())) + || (tile.getType().equals(TrackTypes.LEFT_DIAMOND_CROSSING.getLabel())) + || (tile.getType().equals(TrackTypes.DOUBLE_DIAMOND_CROSSING.getLabel())) + || (tile.getType().equals(TrackTypes.EMBEDDED_RIGHT_DIAMOND_CROSSING.getLabel())) + || (tile.getType().equals(TrackTypes.EMBEDDED_LEFT_DIAMOND_CROSSING.getLabel())) + || (tile.getType().equals(TrackTypes.EMBEDDED_DOUBLE_DIAMOND_CROSSING.getLabel())) + || (tile.getType().equals(TrackTypes.DIAGONAL_TWO_WAYS_CROSSING.getLabel())) + || (tile.getType().equals(TrackTypes.EMBEDDED_DIAGONAL_TWO_WAYS_CROSSING.getLabel())) + || (tile.getType().equals(TrackTypes.FOUR_WAYS_CROSSING.getLabel())) + || (tile.getType().equals(TrackTypes.EMBEDDED_FOUR_WAYS_CROSSING.getLabel())) + ; + } + + public static boolean isTCSwitch(TileTCRail tile) { + if (tile == null || tile.getType() == null) { + return false; + } + return (tile.getType().equals(TrackTypes.MEDIUM_LEFT_SWITCH.getLabel())) + || (tile.getType().equals(TrackTypes.MEDIUM_RIGHT_SWITCH.getLabel())) + || (tile.getType().equals(TrackTypes.LARGE_LEFT_SWITCH.getLabel())) + || (tile.getType().equals(TrackTypes.LARGE_RIGHT_SWITCH.getLabel())) + || (tile.getType().equals(TrackTypes.MEDIUM_RIGHT_PARALLEL_SWITCH.getLabel())) + || (tile.getType().equals(TrackTypes.MEDIUM_LEFT_PARALLEL_SWITCH.getLabel())) + || (tile.getType().equals(TrackTypes.MEDIUM_RIGHT_45DEGREE_SWITCH.getLabel())) + || (tile.getType().equals(TrackTypes.MEDIUM_LEFT_45DEGREE_SWITCH.getLabel())) + || (tile.getType().equals(TrackTypes.EMBEDDED_MEDIUM_LEFT_SWITCH.getLabel())) + || (tile.getType().equals(TrackTypes.EMBEDDED_MEDIUM_RIGHT_SWITCH.getLabel())) + || (tile.getType().equals(TrackTypes.EMBEDDED_LARGE_LEFT_SWITCH.getLabel())) + || (tile.getType().equals(TrackTypes.EMBEDDED_LARGE_RIGHT_SWITCH.getLabel())) + || (tile.getType().equals(TrackTypes.EMBEDDED_MEDIUM_RIGHT_PARALLEL_SWITCH.getLabel())) + || (tile.getType().equals(TrackTypes.EMBEDDED_MEDIUM_LEFT_PARALLEL_SWITCH.getLabel())) + || (tile.getType().equals(TrackTypes.EMBEDDED_MEDIUM_RIGHT_45DEGREE_SWITCH.getLabel())) + || (tile.getType().equals(TrackTypes.EMBEDDED_MEDIUM_LEFT_45DEGREE_SWITCH.getLabel())); + } + + public static boolean isTCSlopeTrack(TileTCRail tile) { + if (tile == null || tile.getType() == null) { + return false; + } + return tile.getType().equals(TrackTypes.SLOPE_WOOD.getLabel()) + || tile.getType().equals(TrackTypes.SLOPE_GRAVEL.getLabel()) + || tile.getType().equals(TrackTypes.SLOPE_BALLAST.getLabel()) + || tile.getType().equals(TrackTypes.SLOPE_SNOW_GRAVEL.getLabel()) + || tile.getType().equals(TrackTypes.SLOPE_DYNAMIC.getLabel()) + || tile.getType().equals(TrackTypes.LARGE_SLOPE_WOOD.getLabel()) + || tile.getType().equals(TrackTypes.LARGE_SLOPE_GRAVEL.getLabel()) + || tile.getType().equals(TrackTypes.LARGE_SLOPE_BALLAST.getLabel()) + || tile.getType().equals(TrackTypes.LARGE_SLOPE_DYNAMIC.getLabel()) + || tile.getType().equals(TrackTypes.LARGE_SLOPE_SNOW_GRAVEL.getLabel()) + || tile.getType().equals(TrackTypes.VERY_LARGE_SLOPE_WOOD.getLabel()) + || tile.getType().equals(TrackTypes.VERY_LARGE_SLOPE_GRAVEL.getLabel()) + || tile.getType().equals(TrackTypes.VERY_LARGE_SLOPE_BALLAST.getLabel()) + || tile.getType().equals(TrackTypes.VERY_LARGE_SLOPE_SNOW_GRAVEL.getLabel()) + || tile.getType().equals(TrackTypes.VERY_LARGE_SLOPE_DYNAMIC.getLabel()) + || tile.getType().equals(TrackTypes.EMBEDDED_SLOPE_DYNAMIC.getLabel()) + || tile.getType().equals(TrackTypes.EMBEDDED_LARGE_SLOPE_DYNAMIC.getLabel()) + || tile.getType().equals(TrackTypes.EMBEDDED_VERY_LARGE_SLOPE_DYNAMIC.getLabel()) + ; + } + + public static boolean isTCCurvedSlopeTrack(TileTCRail tile) { + if (tile == null || tile.getType() == null) { + return false; + } + return tile.getType().equals(TrackTypes.LARGE_RIGHT_CURVED_SLOPE_DYNAMIC.getLabel()) + || tile.getType().equals(TrackTypes.LARGE_LEFT_CURVED_SLOPE_DYNAMIC.getLabel()) + || tile.getType().equals(TrackTypes.EMBEDDED_LARGE_RIGHT_CURVED_SLOPE_DYNAMIC.getLabel()) + || tile.getType().equals(TrackTypes.EMBEDDED_LARGE_LEFT_CURVED_SLOPE_DYNAMIC.getLabel()) + || tile.getType().equals(TrackTypes.VERY_LARGE_RIGHT_CURVED_SLOPE_DYNAMIC.getLabel()) + || tile.getType().equals(TrackTypes.VERY_LARGE_LEFT_CURVED_SLOPE_DYNAMIC.getLabel()) + || tile.getType().equals(TrackTypes.EMBEDDED_VERY_LARGE_RIGHT_CURVED_SLOPE_DYNAMIC.getLabel()) + || tile.getType().equals(TrackTypes.EMBEDDED_VERY_LARGE_LEFT_CURVED_SLOPE_DYNAMIC.getLabel()) + || tile.getType().equals(TrackTypes.SUPER_LARGE_RIGHT_CURVED_SLOPE_DYNAMIC.getLabel()) + || tile.getType().equals(TrackTypes.SUPER_LARGE_LEFT_CURVED_SLOPE_DYNAMIC.getLabel()) + || tile.getType().equals(TrackTypes.EMBEDDED_SUPER_LARGE_RIGHT_CURVED_SLOPE_DYNAMIC.getLabel()) + || tile.getType().equals(TrackTypes.EMBEDDED_SUPER_LARGE_LEFT_CURVED_SLOPE_DYNAMIC.getLabel()) + ; + } + + public static boolean isTCDiagonalStraightTrack(TileTCRail tile) { + if (tile == null || tile.getType() == null) { + return false; + } + return tile.getType().equals(TrackTypes.SMALL_DIAGONAL_STRAIGHT.getLabel()) + || tile.getType().equals(TrackTypes.MEDIUM_DIAGONAL_STRAIGHT.getLabel()) + || tile.getType().equals(TrackTypes.LONG_DIAGONAL_STRAIGHT.getLabel()) + || tile.getType().equals(TrackTypes.VERY_LONG_DIAGONAL_STRAIGHT.getLabel()) + || tile.getType().equals(TrackTypes.EMBEDDED_SMALL_DIAGONAL_STRAIGHT.getLabel()) + || tile.getType().equals(TrackTypes.EMBEDDED_MEDIUM_DIAGONAL_STRAIGHT.getLabel()) + || tile.getType().equals(TrackTypes.EMBEDDED_LONG_DIAGONAL_STRAIGHT.getLabel()) + || tile.getType().equals(TrackTypes.EMBEDDED_VERY_LONG_DIAGONAL_STRAIGHT.getLabel()) + + ; + } + + + public ItemTCRail(TrackTypes t) { + super(t.getItem().iconName); + this.overridePath("tracks"); + this.type = t; + } + + private boolean canPlaceTrack(EntityPlayer player, World world, int x, int y, int z) { + Block l1 = world.getBlock(x, y - 1, z); + + if (player != null && (!player.canPlayerEdit(x, y - 1, z, 0, player.getCurrentEquippedItem()) || + !player.canPlayerEdit(x, y, z, 0, player.getCurrentEquippedItem())) + ) { + return false; + } + + return canBeReplaced(world, x, y, z) && (World.doesBlockHaveSolidTopSurface(world, x, y - 1, z) || l1 == BlockIDs.bridgePillar.block); + } + + private boolean canBeReplaced(World world, int x, int y, int z) { + Block block = world.getBlock(x, y, z); + return block == null || block.isReplaceable(world, x, y, z) || block instanceof BlockFlower + || block == Blocks.double_plant || block instanceof BlockMushroom; + } + + /** + * @param world + * @param x + * @param y + * @param z //@param posX[] array of gag + * //@param posZ[] array of gag + * @param l orientation + * @param exitFacing + * @param posExitX + * @param posExitZ + * @param r ray + * @param cx circle center + * @param cy circle center + * @param cz circle center + * @param type + * @return + */ + private boolean putDownTurn(@Nullable EntityPlayer player, World world, boolean putDownEnterTrack, int x, int y, int z, int[] posX, int[] posZ, + int l, boolean putDownExitTrack, int exitFacing, int posExitX, int posExitZ, double r, double cx, double cy, + double cz, String type, Item idDrop) { + + + if (type.contains("EMBEDDED")) { + typeVariantStraight = TrackTypes.EMBEDDED_SMALL_STRAIGHT.getLabel(); + } + + + TileTCRailGag[] tileGag = new TileTCRailGag[posX.length - 1]; + + /* check if first straight rail can be placed */ + if (putDownEnterTrack && !canPlaceTrack(player, world, x, y + 1, z)) { + return false; + } + + /* check if Gag rails can be placed */ + for (int gag = 0; gag < posX.length; gag++) { + if (!canPlaceTrack(player, world, posX[gag], y + 1, posZ[gag])) { + return false; + } + } + /* Check last block */ + if (putDownExitTrack && !canPlaceTrack(player, world, posExitX, y + 1, posExitZ)) { + return false; + } + if (putDownEnterTrack) { + /* first rail of the turn is a 1 block straight */ + placeTrack(world, x, y + 1, z, BlockIDs.tcRail.block, l); + TileTCRail tcRailStart = (TileTCRail) world.getTileEntity(x, y + 1, z); + tcRailStart.setType(typeVariantStraight); + tcRailStart.setFacing(l); + tcRailStart.isLinkedToRail = true; + tcRailStart.linkedX = posX[0]; + tcRailStart.linkedY = y + 1; + tcRailStart.linkedZ = posZ[0]; + } + + /* the turn starts with this rail */ + placeTrack(world, posX[0], y + 1, posZ[0], BlockIDs.tcRail.block, l); + TileTCRail tcRail = (TileTCRail) world.getTileEntity(posX[0], y + 1, posZ[0]); + tcRail.setFacing(l); + tcRail.r = r; + tcRail.cx = cx; + tcRail.cy = cy; + tcRail.cz = cz; + tcRail.setType(type); + tcRail.idDrop = idDrop; + + /* Gag rails containing reference to first turn rail */ + for (int gag = 1; gag < posX.length; gag++) { + placeTrack(world, posX[gag], y + 1, posZ[gag], BlockIDs.tcRailGag.block, 0); + tileGag[gag - 1] = (TileTCRailGag) world.getTileEntity(posX[gag], y + 1, posZ[gag]); + } + + if (putDownExitTrack) { + /* Last rail is a 1 block straight */ + placeTrack(world, posExitX, y + 1, posExitZ, BlockIDs.tcRail.block, exitFacing); + TileTCRail tcRailEnd = (TileTCRail) world.getTileEntity(posExitX, y + 1, posExitZ); + tcRailEnd.setFacing(exitFacing); + tcRailEnd.setType(typeVariantStraight); + tcRailEnd.isLinkedToRail = true; + tcRailEnd.linkedX = posX[0]; + tcRailEnd.linkedY = y + 1; + tcRailEnd.linkedZ = posZ[0]; + } + + for (TileTCRailGag tileTCRailGag : tileGag) { + tileTCRailGag.originX = posX[0]; + tileTCRailGag.originY = y + 1; + tileTCRailGag.originZ = posZ[0]; + tileTCRailGag.type = type; + } + return true; + } + + private boolean putDownSlopedTurn(@Nullable EntityPlayer player, World world, int x, int y, int z, int[] posX, int[] posZ, + int l, double r, double cx, double cy, double cz, float slopeAngle, double slopeLength, String type, Item idDrop) { + + + if (world.getBlock(x, y, z) == BlockIDs.bridgePillar.block) { + return false; + } + + TileTCRailGag[] tileGag = new TileTCRailGag[posX.length - 1]; + + /** check if Gag rails can be placed */ + for (int gag = 0; gag < posX.length; gag++) { + if (!canPlaceTrack(player, world, posX[gag], y + 1, posZ[gag])) { + return false; + } + } + + /** the turn starts with this rail */ + placeTrack(world, posX[0], y + 1, posZ[0], BlockIDs.tcRail.block, l); + TileTCRail tcRail = (TileTCRail) world.getTileEntity(posX[0], y + 1, posZ[0]); + tcRail.setFacing(l); + tcRail.r = r; + tcRail.cx = cx; + tcRail.cy = cy; + tcRail.cz = cz; + tcRail.setType(type); + tcRail.idDrop = idDrop; + tcRail.slopeAngle = slopeAngle; + tcRail.slopeHeight = 1; + tcRail.slopeLength = slopeLength; + Block block = world.getBlock(x, y, z); + int blockID = Block.getIdFromBlock(block); + tcRail.setBallastMaterial(blockID); + tcRail.ballastMetadata = world.getBlockMetadata(x, y, z); + System.out.println(tcRail.cx + " ," + tcRail.cz + " , " + tcRail.r); + /** Gag rails containing reference to first turn rail */ + for (int gag = 1; gag <= posX.length - 1; gag++) { + placeTrack(world, posX[gag], y + 1, posZ[gag], BlockIDs.tcRailGag.block, 0); + tileGag[gag - 1] = (TileTCRailGag) world.getTileEntity(posX[gag], y + 1, posZ[gag]); + //tileGag[gag - 1].bbHeight = Math.max(0.125f, Math.min(1f, (gag - 1) / (float) (posX.length - 1))); + tileGag[gag - 1].bbHeight = Math.max(0.125f, Math.min(1f, gag / (float) (posX.length - 1))); + + } + for (TileTCRailGag tileTCRailGag : tileGag) { + tileTCRailGag.originX = posX[0]; + tileTCRailGag.originY = y + 1; + tileTCRailGag.originZ = posZ[0]; + tileTCRailGag.type = type; + } + + return true; + } + + private void putDownSingleRail(World world, int posX, int posY, int posZ, int l, double cx, double cy, double cz, double r, String label, boolean hasModel, int linkedX, int linkedY, int linkedZ, boolean canTypeBeModifiedBySwitch, boolean shouldDrop) { + /** Switch rail */ + placeTrack(world, posX, posY, posZ, BlockIDs.tcRail.block, l); + TileTCRail tcRail = (TileTCRail) world.getTileEntity(posX, posY, posZ); + //world.setBlockMetadataWithNotify(posX, posY, posZ, l, 2); + tcRail.setFacing(l); + tcRail.cx = cx; + tcRail.cy = cy; + tcRail.cz = cz; + tcRail.r = r; + tcRail.setType(label); + tcRail.hasModel = hasModel; + tcRail.isLinkedToRail = true; + tcRail.linkedX = linkedX; + tcRail.linkedY = linkedY; + tcRail.linkedZ = linkedZ; + tcRail.canTypeBeModifiedBySwitch = canTypeBeModifiedBySwitch; + if (shouldDrop) tcRail.idDrop = ItemIDs.tcRailSmallStraight.item; + } + + public String getTrackOrientation(int l, float yaw) { + if (l == 2 && yaw >= -180 && yaw <= -135) { + return "right"; + } + if (l == 2 && yaw <= 180 && yaw >= 135) { + return "left"; + } + if (l == 3 && yaw > -135 && yaw <= -90) { + return "left"; + } + if (l == 3 && yaw > -90 && yaw <= -45) { + return "right"; + } + if (l == 0 && yaw > -45 && yaw <= 0) { + return "left"; + } + if (l == 0 && yaw > 0 && yaw <= 45) { + return "right"; + } + if (l == 1 && yaw > 45 && yaw <= 90) { + return "left"; + } + if (l == 1 && yaw > 90 && yaw <= 135) { + return "right"; + } + return ""; + } + + + public static Vector2f getDirectionVector(int facing) { + Matrix2f nrot90 = new Matrix2f(); + nrot90.m00 = +0; + nrot90.m01 = +1; + nrot90.m10 = -1; + nrot90.m11 = +0; + + Vector2f vec = new Vector2f(); + vec.x = 0; + vec.y = 1; + + for (int i = 0; i < facing; i++) { + Vector2f nvec = new Vector2f(); + nvec.x = vec.x * nrot90.m00 + vec.y * nrot90.m10; + nvec.y = vec.x * nrot90.m01 + vec.y * nrot90.m11; + vec = nvec; + } + return vec; + + } + + private int[][] getUsedSpaceFromType(TrackTypes type, @Nullable EntityPlayer player) { + /** Straights */ + if (type == TrackTypes.SMALL_STRAIGHT + || type == TrackTypes.SMALL_ROAD_CROSSING + || type == TrackTypes.SMALL_ROAD_CROSSING_1 + || type == TrackTypes.SMALL_ROAD_CROSSING_2 + || type == TrackTypes.EMBEDDED_SMALL_STRAIGHT) + return new int[][]{{0, 0}}; + else if (type == TrackTypes.MEDIUM_STRAIGHT || type == TrackTypes.EMBEDDED_MEDIUM_STRAIGHT) + return new int[][]{{0, 0}, {1, 0}, {2, 0}}; + else if (type == TrackTypes.LONG_STRAIGHT || type == TrackTypes.EMBEDDED_LONG_STRAIGHT) + return new int[][]{{0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0}, {5, 0}}; + else if (type == TrackTypes.VERY_LONG_STRAIGHT || type == TrackTypes.EMBEDDED_VERY_LONG_STRAIGHT) + return new int[][]{{0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0}, {5, 0}, {6, 0}, {7, 0}, {8, 0}, {9, 0}, {10, 0}, {11, 0}}; + /** Diagonals*/ + else if (type == TrackTypes.SMALL_DIAGONAL_STRAIGHT || type == TrackTypes.EMBEDDED_SMALL_DIAGONAL_STRAIGHT) + return new int[][]{{0, 0}, {1, 0}, {0, 1}}; + else if (type == TrackTypes.MEDIUM_DIAGONAL_STRAIGHT || type == TrackTypes.EMBEDDED_MEDIUM_DIAGONAL_STRAIGHT) + return new int[][]{{0, 0}, {1, 0}, {0, 1}, {1, 1}, {2, 1}, {1, 2}, {2, 2}, {3, 2}, {2, 3}}; + else if (type == TrackTypes.LONG_DIAGONAL_STRAIGHT || type == TrackTypes.EMBEDDED_LONG_DIAGONAL_STRAIGHT) + return new int[][]{{0, 0}, {1, 0}, {0, 1}, {1, 1}, {2, 1}, {1, 2}, {2, 2}, {3, 2}, {2, 3}, {3, 3}, {4, 3}, {3, 4}, {4, 4}, {4, 5}, {5, 4}, {5, 5}, {6, 5}, {5, 6}}; + else if (type == TrackTypes.VERY_LONG_DIAGONAL_STRAIGHT || type == TrackTypes.EMBEDDED_VERY_LONG_DIAGONAL_STRAIGHT) + return new int[][]{{0, 0}, {1, 0}, {0, 1}, {1, 1}, {2, 1}, {1, 2}, {2, 2}, {3, 2}, {2, 3}, {3, 3}, {4, 3}, {3, 4}, {4, 4}, {4, 5}, {5, 4}, {5, 5}, {6, 5}, {5, 6}, + {6, 6}, {6, 7}, {7, 6}, {7, 7}, {8, 7}, {7, 8}, {8, 8}, {9, 8}, {8, 9}, {9, 9}, {10, 9}, {9, 10}, {10, 10}, {11, 10}, {10, 11}, {11, 11}, {12, 11}, {11, 12}}; + /** Slopes */ + else if (type == TrackTypes.SLOPE_BALLAST + || type == TrackTypes.SLOPE_GRAVEL + || type == TrackTypes.SLOPE_WOOD + || type == TrackTypes.SLOPE_SNOW_GRAVEL + || type == TrackTypes.SLOPE_DYNAMIC + || type == TrackTypes.EMBEDDED_SLOPE_DYNAMIC + ) + return new int[][]{{0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0}, {5, 0}}; + + else if (type == TrackTypes.LARGE_SLOPE_BALLAST + || type == TrackTypes.LARGE_SLOPE_GRAVEL + || type == TrackTypes.LARGE_SLOPE_WOOD + || type == TrackTypes.LARGE_SLOPE_SNOW_GRAVEL + || type == TrackTypes.LARGE_SLOPE_DYNAMIC + || type == TrackTypes.EMBEDDED_LARGE_SLOPE_DYNAMIC) + return new int[][]{{0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0}, {5, 0}, {6, 0}, {7, 0}, {8, 0}, {9, 0}, {10, 0}, {11, 0}}; + else if (type == TrackTypes.VERY_LARGE_SLOPE_BALLAST + || type == TrackTypes.VERY_LARGE_SLOPE_GRAVEL + || type == TrackTypes.VERY_LARGE_SLOPE_WOOD + || type == TrackTypes.VERY_LARGE_SLOPE_SNOW_GRAVEL + || type == TrackTypes.VERY_LARGE_SLOPE_DYNAMIC + || type == TrackTypes.EMBEDDED_VERY_LARGE_SLOPE_DYNAMIC + ) + return new int[][]{{0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0}, {5, 0}, {6, 0}, {7, 0}, {8, 0}, {9, 0}, {10, 0}, {11, 0}, + {12, 0}, {13, 0}, {14, 0}, {15, 0}, {16, 0}, {17, 0}}; + /** Crossing */ + else if (type == TrackTypes.TWO_WAYS_CROSSING || type == TrackTypes.EMBEDDED_TWO_WAYS_CROSSING) + return new int[][]{{0, 0}, {1, 0}, {2, 0}, {1, 1}, {1, -1}}; + else if (type == TrackTypes.DIAMOND_CROSSING || type == TrackTypes.EMBEDDED_DIAMOND_CROSSING) + return new int[][]{{0, 0}, {1, 0}, {2, 0}, {0, -1}, {2, 1}}; + else if (type == TrackTypes.DOUBLE_DIAMOND_CROSSING || type == TrackTypes.EMBEDDED_DOUBLE_DIAMOND_CROSSING) + return new int[][]{{0, 0}, {1, 0}, {2, 0}, {0, -1}, {2, -1}, {0, 1}, {2, 1}}; + else if (type == TrackTypes.DIAGONAL_TWO_WAYS_CROSSING || type == TrackTypes.EMBEDDED_DIAGONAL_TWO_WAYS_CROSSING) + return new int[][]{{0, 0}, {-1, -1}, {1, -1}, {1, 1}, {-1, 1}}; + else if (type == TrackTypes.FOUR_WAYS_CROSSING || type == TrackTypes.EMBEDDED_FOUR_WAYS_CROSSING) + return new int[][]{{0, 0}, {1, 0}, {-1, 0}, {0, -1}, {1, -1}, {-1, -1}, {0, 1}, {1, 1}, {-1, 1}}; + /** Turns */ + else if (type == TrackTypes.MEDIUM_TURN || type == TrackTypes.EMBEDDED_MEDIUM_TURN) + return new int[][]{{0, 0}, {1, 0}, {1, 1}, {2, 1}, {2, 2}}; + else if (type == TrackTypes.LARGE_TURN || type == TrackTypes.EMBEDDED_LARGE_TURN) + return new int[][]{{0, 0}, {1, 0}, {2, 0}, {1, 1}, {2, 1}, {3, 1}, {2, 2}, {3, 2}, {4, 2}, {3, 3}, {4, 3}, {4, 4}}; + else if (type == TrackTypes.VERY_LARGE_TURN || type == TrackTypes.EMBEDDED_VERY_LARGE_TURN) + return new int[][]{{0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0}, {2, 1}, {3, 1}, {4, 1}, {5, 1}, {4, 2}, {5, 2}, {6, 2}, + {6, 3}, {7, 3}, {7, 4}, {8, 4}, {7, 5}, {8, 5}, {9, 5}, {8, 6}, {9, 6}, {8, 7}, {9, 7}, {9, 8}, {9, 9}}; + else if (type == TrackTypes.SUPER_LARGE_TURN || type == TrackTypes.EMBEDDED_SUPER_LARGE_TURN) + return new int[][]{{0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0}, {1, 1}, {2, 1}, {3, 1}, {4, 1}, {5, 1}, {6, 1}, {5, 2}, {6, 2}, {7, 2}, {8, 2}, + {7, 3}, {8, 3}, {9, 3}, {10, 3}, {9, 4}, {10, 4}, {11, 4}, {10, 5}, {11, 5}, {12, 5}, {11, 6}, {12, 6}, {13, 6}, {12, 7}, {13, 7}, + {12, 8}, {13, 8}, {14, 8}, {13, 9}, {14, 9}, {13, 10}, {14, 10}, {15, 10}, {14, 11}, {15, 11}, {14, 12}, {15, 12}, {14, 12,}, {15, 13}, {15, 14}, {15, 15}}; + + /** Switches*/ + else if (type == TrackTypes.MEDIUM_PARALLEL_SWITCH || type == TrackTypes.EMBEDDED_MEDIUM_PARALLEL_SWITCH) + return new int[][]{{0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0}, {5, 0}, {6, 0}, {7, 0}, {8, 0}, {9, 0}, {10, 0}, + {2, 1}, {3, 1}, {4, 1}, {5, 1}, {4, 2}, {5, 2}, {6, 2}, {7, 2}, {8, 2}, {6, 3}, {7, 3}, {8, 3}, {9, 3}, {10, 3}}; + else if (type == TrackTypes.MEDIUM_SWITCH || type == TrackTypes.EMBEDDED_MEDIUM_SWITCH) + return new int[][]{{0, 0}, {1, 0}, {2, 0}, {3, 0}, {2, 1}, {3, 1}, {3, 2}, {3, 3}}; + else if (type == TrackTypes.LARGE_SWITCH || type == TrackTypes.EMBEDDED_LARGE_SWITCH) + return new int[][]{{0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0}, {5, 0}, + {2, 1}, {3, 1}, {4, 1}, {3, 2}, {4, 2}, {5, 2}, {4, 3}, {5, 3}, {5, 4}, {5, 5}}; /*else if ( type == TrackTypes.VERY_LARGE_SWITCH ) return new int[][] { {0,0}, {1,0}, {2,0}, {3,0}, {4,0}, {5,0}, {6,0}, {7,0}, {8,0}, {9,0}, {10,0}, {2,1}, {3,1}, {4,1}, {5,1}, {4,2}, {5,2}, {6,2}, {6,3}, {7,3}, {7,4}, {8,4}, {7,5}, {8,5}, {9,5}, {8,6}, {9,6}, {8,7}, {9,7}, {9,8}, {9,9}}; */ - /** Parallel Curves */ - else if (type == TrackTypes.SMALL_PARALLEL_CURVE || type == TrackTypes.EMBEDDED_SMALL_PARALLEL_CURVE) - return new int[][] { {0,0}, {1,0}, {2,0}, {3,0}, {4,0}, {5,0}, {2,1}, {3,1}, {4,1}, {5,1}, {6,1}, {7,1}}; - else if (type == TrackTypes.MEDIUM_PARALLEL_CURVE || type == TrackTypes.EMBEDDED_MEDIUM_PARALLEL_CURVE) - return new int[][] { {0,0}, {1,0}, {2,0}, {3,0}, {4,0}, {3,1}, {4,1}, {5,1}, {6,1}, {7,1}, {8,1}, {7,2}, {8,2}, {9,2}, {10,2}, {11,2}}; - else if (type == TrackTypes.LARGE_PARALLEL_CURVE || type == TrackTypes.EMBEDDED_LARGE_PARALLEL_CURVE) - return new int[][] { {0,0}, {1,0}, {2,0}, {3,0}, {4,0}, {5,0}, {4,1}, {5,1}, {6,1}, {7,1}, {8,1}, {7,2}, {8,2}, {9,2}, {10,2}, {11,2}, {10,3}, {11,3}, {12,3}, {13,3}, {14,3}, {15,3}}; - /**45 degree curves*/ - else if ((type == TrackTypes.MEDIUM_45DEGREE_TURN || type == TrackTypes.EMBEDDED_MEDIUM_45DEGREE_TURN) && !player.isSneaking()) - return new int[][] {{0,0}, {1,0}, {2,0}, {1,1}, {2,1}, {3,1}, {2,2}}; - else if ((type == TrackTypes.LARGE_45DEGREE_TURN || type == TrackTypes.EMBEDDED_LARGE_45DEGREE_TURN) && !player.isSneaking()) - return new int[][] {{0,0}, {1,0}, {2,0}, {3,0}, {1,1}, {2,1}, {3,1}, {4,1}, {5,1},{4,2}, {5,2}, {6,2}, {5,3}}; - else if ((type == TrackTypes.VERY_LARGE_45DEGREE_TURN || type == TrackTypes.EMBEDDED_VERY_LARGE_45DEGREE_TURN) && !player.isSneaking()) - return new int[][]{{0,0},{1,0},{2,0},{3,0},{4,0},{1,1},{2,1},{3,1},{4,1},{5,1},{6,1},{4,2},{5,2},{6,2},{7,2},{6,3},{7,3},{8,3}, {7,4}}; - else if ((type == TrackTypes.SUPER_LARGE_45DEGREE_TURN || type == TrackTypes.EMBEDDED_SUPER_LARGE_45DEGREE_TURN) && !player.isSneaking()) - return new int[][] {{0,0}, {1,0}, {2,0}, {3,0},{4,0},{5,0},{1,1},{2,1},{3,1}, {4,1}, {5,1}, {6,1}, {7,1}, {5,2}, {6,2},{7,2},{8,2},{9,2},{7,3},{8,3},{9,3},{10,3},{9,4},{10,4},{11,4},{10,5}}; - else if (( type == TrackTypes.MEDIUM_45DEGREE_SWITCH || type == TrackTypes.EMBEDDED_MEDIUM_45DEGREE_SWITCH) && !player.isSneaking()) - return new int[][] {{0,0}, {1,0},{2,0},{3,0},{2,1},{3,1}, {4,1}, {3,2}}; - else if ((type == TrackTypes.MEDIUM_45DEGREE_TURN || type == TrackTypes.EMBEDDED_MEDIUM_45DEGREE_TURN) && player.isSneaking()) - return new int[][] {{0,0}, {1,0}, {2,0}, {1,1}, {2,1}}; - else if ((type == TrackTypes.LARGE_45DEGREE_TURN || type == TrackTypes.EMBEDDED_LARGE_45DEGREE_TURN) && player.isSneaking()) - return new int[][] {{0,0}, {1,0}, {2,0}, {3,0}, {1,1}, {2,1}, {3,1}, {4,1}, {5,1},{4,2}, {5,2}}; - else if ((type == TrackTypes.VERY_LARGE_45DEGREE_TURN || type == TrackTypes.EMBEDDED_VERY_LARGE_45DEGREE_TURN) && player.isSneaking()) - return new int[][]{{0,0},{1,0},{2,0},{3,0},{4,0},{1,1},{2,1},{3,1},{4,1},{5,1},{6,1},{4,2},{5,2},{6,2},{7,2},{6,3},{7,3}}; - else if ((type == TrackTypes.SUPER_LARGE_45DEGREE_TURN || type == TrackTypes.EMBEDDED_SUPER_LARGE_45DEGREE_TURN) && player.isSneaking()) - return new int[][] {{0,0}, {1,0}, {2,0}, {3,0},{4,0},{5,0},{1,1},{2,1},{3,1}, {4,1}, {5,1}, {6,1}, {7,1}, {5,2}, {6,2},{7,2},{8,2},{9,2},{7,3},{8,3},{9,3},{10,3},{9,4},{10,4}}; - else if (( type == TrackTypes.MEDIUM_45DEGREE_SWITCH || type == TrackTypes.EMBEDDED_MEDIUM_45DEGREE_SWITCH) && player.isSneaking()) - return new int[][] {{0,0}, {1,0},{2,0},{3,0},{2,1},{3,1}}; - else if ( type == TrackTypes.LARGE_CURVED_SLOPE_DYNAMIC || type == TrackTypes.EMBEDDED_LARGE_CURVED_SLOPE_DYNAMIC) - return new int[][] {{0,0},{1,0},{1,1},{2,0},{2,1},{3,1},{2,2},{3,2},{3,3},{4,3},{4,4}}; - else if ( type == TrackTypes.VERY_LARGE_CURVED_SLOPE_DYNAMIC || type == TrackTypes.EMBEDDED_VERY_LARGE_CURVED_SLOPE_DYNAMIC) - return new int[][] {{0,0},{1,0},{2,0},{3,0},{4,0},{2,1},{3,1},{4,1},{5,1},{4,2},{5,2},{6,2},{5,3},{6,3},{7,3},{6,4},{7,4},{7,5},{8,5},{7,6},{8,7},{8,8}}; - else if ( type == TrackTypes.SUPER_LARGE_CURVED_SLOPE_DYNAMIC || type == TrackTypes.EMBEDDED_SUPER_LARGE_CURVED_SLOPE_DYNAMIC) - return new int[][] {{0,0},{1,0},{2,0},{3,0},{4,0},{5,0},{2,1},{3,1},{4,1},{5,1},{6,1},{7,1},{5,2},{6,2},{7,2},{8,2},{9,2},{8,3},{9,3},{10,3},{9,4},{10,4},{11,4},{10,5},{11,5},{12,5},{11,6},{12,6},{13,6},{12,7},{13,7},{12,8},{13,8},{14,8},{13,9},{14,9},{13,10},{14,10},{15,10},{14,11},{15,11},{14,12},{15,12},{14,13},{15,13},{15,14},{15,15}}; - - else{ - return null; - } - - } - - public boolean tryToPlaceTrack( ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, boolean changeWorld ) - { - if ( !(itemStack.getItem() instanceof ItemTCRail) ) - return false; - - y = getPlacementHeight(world, x, y, z); - - ItemTCRail item = (ItemTCRail) itemStack.getItem(); - if (world.getBlock(x, y, z) == BlockIDs.bridgePillar.block && item.getTrackType().getLabel().contains("DYNAMIC")){ - return false; - } - int facing0 = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3; - Vector2f dir0 = ItemTCRail.getDirectionVector(facing0); - - float yaw = MathHelper.wrapAngleTo180_float(player.rotationYaw); - boolean isLeftTurn = item.getTrackOrientation( facing0, yaw ).equals("left"); - int facing1 = isLeftTurn ? (facing0 + 4 - 1)%4 : (facing0 + 1)%4; - Vector2f dir1 = getDirectionVector( facing1 ); - - int[][] trackPositions = getUsedSpaceFromType( item.getTrackType() , player); - - if ( trackPositions != null ) - { - - for ( int[] pos : trackPositions ) - { - int dx = (int) (pos[0] * dir0.getX() + pos[1] * dir1.getX()); - int dz = (int) (pos[0] * dir0.getY() + pos[1] * dir1.getY()); - - if( !canPlaceTrack(player, world, x + dx, y+1, z + dz )) - return false; - } - - return true; - }else { - return false; - } - } - - public int getPlacementHeight( World world, int x, int y, int z ) - { - if(canBeReplaced(world, x, y, z)){ - y--; - } - return y; - } - /**changes the sign of an array and adds the current world pos to it */ - public int[] flipArraySign(int[] array, int pos, boolean needsConverting) { - if (needsConverting) - for (int i = 0; i < array.length; i++) { - array[i] = (array[i] * -1) + pos; - } - else{ - for (int i = 0; i < array.length; i++) { - array[i] = (array[i]+ pos); - } - } - - return array; - } - - @Override - public boolean onItemUse(ItemStack itemstack, EntityPlayer player, World world, int x, int y, int z, int par7, float par8, float par9, float par10) { - if (!world.isRemote) { - - - y = getPlacementHeight(world, x, y, z); - int l; - - if (type.getType().equals("DIAGONAL")) { - l = MathHelper.floor_double((player!=null?player.rotationYaw:par10) * 4.0F / 360.0F) & 3; - l += 4; - } - else { - l = MathHelper.floor_double((player!=null?player.rotationYaw:par10) * 4.0F / 360.0F + 0.5D) & 3; - } - - tempType = getPlacementDirection(player, world, l, par10); - - - - /** This code below actually places the stuff - * l = direction - * l = 0 = south - * l = 1 = west - * l = 2 = north - * l = 3 = east - * l = 4 = south-west - * l = 5 = north-west - * l = 6 = north-east - * l = 7 = south-east - **/ - - if (type == TrackTypes.SMALL_STRAIGHT || type == TrackTypes.EMBEDDED_SMALL_STRAIGHT || type == TrackTypes.SMALL_ROAD_CROSSING || type == TrackTypes.SMALL_ROAD_CROSSING_1 || type == TrackTypes.SMALL_ROAD_CROSSING_2 ) { - - if (!smallStraight(player, world, x, y, z, l, type)) - return false; - - if (player ==null || !player.capabilities.isCreativeMode) { - --itemstack.stackSize; - } - return true; - } - else if (type == TrackTypes.MEDIUM_STRAIGHT || type == TrackTypes.LONG_STRAIGHT || type == TrackTypes.VERY_LONG_STRAIGHT || - type == TrackTypes.EMBEDDED_MEDIUM_STRAIGHT || type == TrackTypes.EMBEDDED_LONG_STRAIGHT || type == TrackTypes.EMBEDDED_VERY_LONG_STRAIGHT) { - - if (!straight(player, world, x, y, z, l, type)) - return false; - - if (player ==null || !player.capabilities.isCreativeMode) { - --itemstack.stackSize; - } - return true; - } - else if (type == TrackTypes.SMALL_DIAGONAL_STRAIGHT || type == TrackTypes.EMBEDDED_SMALL_DIAGONAL_STRAIGHT) { - - - if (!smallDiagonalStraight(player, world, x, y, z, l, type)){ - return false; - } - - if (player ==null || !player.capabilities.isCreativeMode) { - --itemstack.stackSize; - } - return true; - } - else if (type == TrackTypes.MEDIUM_DIAGONAL_STRAIGHT || type == TrackTypes.LONG_DIAGONAL_STRAIGHT || type == TrackTypes.VERY_LONG_DIAGONAL_STRAIGHT || type == TrackTypes.EMBEDDED_MEDIUM_DIAGONAL_STRAIGHT || type == TrackTypes.EMBEDDED_LONG_DIAGONAL_STRAIGHT || type == TrackTypes.EMBEDDED_VERY_LONG_DIAGONAL_STRAIGHT) { - - if (!diagonalStraight(player, world, x, y, z, l, type)){ - - return false; - } - if (player ==null || !player.capabilities.isCreativeMode) { - --itemstack.stackSize; - } - return true; - } - else if (tempType == TrackTypes.MEDIUM_RIGHT_45DEGREE_TURN || tempType == TrackTypes.EMBEDDED_MEDIUM_RIGHT_45DEGREE_TURN) { - - if (!mediumRight45DegreeTurn(player, world, x, y, z, l, tempType)){ - return false; - } - - if (player==null || !player.capabilities.isCreativeMode) { - --itemstack.stackSize; - } - return true; - } - else if (tempType == TrackTypes.MEDIUM_LEFT_45DEGREE_TURN || tempType == TrackTypes.EMBEDDED_MEDIUM_LEFT_45DEGREE_TURN) { - - if (!mediumLeft45DegreeTurn(player, world, x, y, z, l, tempType)){ - return false; - } - if (player==null || !player.capabilities.isCreativeMode) { - --itemstack.stackSize; - } - return true; - } - else if (tempType == TrackTypes.LARGE_RIGHT_45DEGREE_TURN || tempType == TrackTypes.EMBEDDED_LARGE_RIGHT_45DEGREE_TURN) { - - if (!largeRight45DegreeTurn(player, world, x, y, z, l, tempType)){ - return false; - } - - if (player==null || !player.capabilities.isCreativeMode) { - --itemstack.stackSize; - } - return true; - } - else if (tempType == TrackTypes.LARGE_LEFT_45DEGREE_TURN || tempType == TrackTypes.EMBEDDED_LARGE_LEFT_45DEGREE_TURN) { - - if (!largeLeft45DegreeTurn(player, world, x, y, z, l, tempType)){ - return false; - } - if (player==null || !player.capabilities.isCreativeMode) { - --itemstack.stackSize; - } - return true; - } - else if (tempType == TrackTypes.VERY_LARGE_RIGHT_45DEGREE_TURN || tempType == TrackTypes.EMBEDDED_VERY_LARGE_RIGHT_45DEGREE_TURN) { - - if (!veryLargeRight45DegreeTurn(player, world, x, y, z, l, tempType)){ - return false; - } - if (player == null || !player.capabilities.isCreativeMode) { - --itemstack.stackSize; - } - return true; - } - else if (tempType == TrackTypes.VERY_LARGE_LEFT_45DEGREE_TURN || tempType == TrackTypes.EMBEDDED_VERY_LARGE_LEFT_45DEGREE_TURN) { - - if (!veryLargeLeft45DegreeTurn(player, world, x, y, z, l, tempType)){ - return false; - } - if (player == null || !player.capabilities.isCreativeMode) { - --itemstack.stackSize; - } - return true; - } - else if (tempType == TrackTypes.SUPER_LARGE_RIGHT_45DEGREE_TURN || tempType == TrackTypes.EMBEDDED_SUPER_LARGE_RIGHT_45DEGREE_TURN) { - - if (!superLargeRight45DegreeTurn(player, world, x, y, z, l, tempType)){ - return false; - } - if (player == null || !player.capabilities.isCreativeMode) { - --itemstack.stackSize; - } - return true; - } - else if (tempType == TrackTypes.SUPER_LARGE_LEFT_45DEGREE_TURN || tempType == TrackTypes.EMBEDDED_SUPER_LARGE_LEFT_45DEGREE_TURN) { - - if (!superLargeLeft45DegreeTurn(player, world, x, y, z, l, tempType)){ - return false; - } - if (player == null || !player.capabilities.isCreativeMode) { - --itemstack.stackSize; - } - return true; - } - else if (tempType == TrackTypes.LARGE_RIGHT_CURVED_SLOPE_DYNAMIC || tempType == TrackTypes.EMBEDDED_LARGE_RIGHT_CURVED_SLOPE_DYNAMIC) { - if(!largeRightCurvedSlope(player, world, x, y, z, l, tempType)) { - return false; - } - if (player == null || !player.capabilities.isCreativeMode) { - --itemstack.stackSize; - } - return true; - } - else if (tempType == TrackTypes.LARGE_LEFT_CURVED_SLOPE_DYNAMIC || tempType == TrackTypes.EMBEDDED_LARGE_LEFT_CURVED_SLOPE_DYNAMIC) { - if(!largeLeftCurvedSlope(player, world, x, y, z, l, tempType)) { - return false; - } - if (player == null || !player.capabilities.isCreativeMode) { - --itemstack.stackSize; - } - return true; - } - else if (tempType == TrackTypes.VERY_LARGE_RIGHT_CURVED_SLOPE_DYNAMIC || tempType == TrackTypes.EMBEDDED_VERY_LARGE_RIGHT_CURVED_SLOPE_DYNAMIC) { - if(!veryLargeRightCurvedSlope(player, world, x, y, z, l, tempType)) { - return false; - } - if (player == null || !player.capabilities.isCreativeMode) { - --itemstack.stackSize; - } - return true; - } - else if (tempType == TrackTypes.VERY_LARGE_LEFT_CURVED_SLOPE_DYNAMIC || tempType == TrackTypes.EMBEDDED_VERY_LARGE_LEFT_CURVED_SLOPE_DYNAMIC) { - if(!veryLargeLeftCurvedSlope(player, world, x, y, z, l, tempType)) { - return false; - } - if (player == null || !player.capabilities.isCreativeMode) { - --itemstack.stackSize; - } - return true; - } - else if (tempType == TrackTypes.SUPER_LARGE_RIGHT_CURVED_SLOPE_DYNAMIC || tempType == TrackTypes.EMBEDDED_SUPER_LARGE_RIGHT_CURVED_SLOPE_DYNAMIC) { - if(!superLargeRightCurvedSlope(player, world, x, y, z, l, tempType)) { - return false; - } - if (player == null || !player.capabilities.isCreativeMode) { - --itemstack.stackSize; - } - return true; - } - else if (tempType == TrackTypes.SUPER_LARGE_LEFT_CURVED_SLOPE_DYNAMIC || tempType == TrackTypes.EMBEDDED_SUPER_LARGE_LEFT_CURVED_SLOPE_DYNAMIC) { - if(!superLargeLeftCurvedSlope(player, world, x, y, z, l, tempType)) { - return false; - } - if (player == null || !player.capabilities.isCreativeMode) { - --itemstack.stackSize; - } - return true; - } - else if (tempType == TrackTypes.SMALL_RIGHT_PARALLEL_CURVE || tempType == TrackTypes.EMBEDDED_SMALL_RIGHT_PARALLEL_CURVE) { - if (!smallRightParallelCurve(player, world, x, y, z, l, tempType)) { - return false; - } - if (player == null || !player.capabilities.isCreativeMode) { - --itemstack.stackSize; - } - return true; - } - else if (tempType == TrackTypes.SMALL_LEFT_PARALLEL_CURVE || tempType == TrackTypes.EMBEDDED_SMALL_LEFT_PARALLEL_CURVE) { - if (!smallLeftParallelCurve(player, world, x, y, z, l, tempType)) { - return false; - } - if (player == null || !player.capabilities.isCreativeMode) { - --itemstack.stackSize; - } - return true; - } - else if (tempType == TrackTypes.RIGHT_DIAMOND_CROSSING || tempType == TrackTypes.EMBEDDED_RIGHT_DIAMOND_CROSSING){ - if (!rightDiamondCrossing(player, world, x, y, z, l, tempType)) { - return false; - } - if (player == null || !player.capabilities.isCreativeMode) { - --itemstack.stackSize; - } - return true; - } - else if (tempType == TrackTypes.LEFT_DIAMOND_CROSSING || tempType == TrackTypes.EMBEDDED_LEFT_DIAMOND_CROSSING) { - if (!leftDiamondCrossing(player, world, x, y, z, l, tempType)) { - return false; - } - if (player == null || !player.capabilities.isCreativeMode) { - --itemstack.stackSize; - } - return true; - } - else if (type == TrackTypes.DOUBLE_DIAMOND_CROSSING || type == TrackTypes.EMBEDDED_DOUBLE_DIAMOND_CROSSING) { - if (!doubleDiamondCrossing(player, world, x, y, z, l, type)){ - return false; - } - if (player == null || !player.capabilities.isCreativeMode) { - --itemstack.stackSize; - } - return true; - } - else if (type == TrackTypes.DIAGONAL_TWO_WAYS_CROSSING || type == TrackTypes.EMBEDDED_DIAGONAL_TWO_WAYS_CROSSING) { - if (!diagonalTwoWaysCrossing(player, world, x, y, z, l, type)){ - return false; - } - if (player == null || !player.capabilities.isCreativeMode) { - --itemstack.stackSize; - } - return true; - } - else if (type == TrackTypes.FOUR_WAYS_CROSSING || type == TrackTypes.EMBEDDED_FOUR_WAYS_CROSSING) { - if (!fourWaysCrossing(player, world, x, y, z, l, type)){ - return false; - } - if (player == null || !player.capabilities.isCreativeMode) { - --itemstack.stackSize; - } - return true; - } - else if (tempType == TrackTypes.MEDIUM_RIGHT_PARALLEL_CURVE || tempType == TrackTypes.EMBEDDED_MEDIUM_RIGHT_PARALLEL_CURVE) { - - if (!mediumRightParallelCurve(player, world, x, y, z, l, tempType)){ - return false; - } - if (player == null || !player.capabilities.isCreativeMode) { - --itemstack.stackSize; - } - return true; - - - } - else if (tempType == TrackTypes.MEDIUM_LEFT_PARALLEL_CURVE || tempType == TrackTypes.EMBEDDED_MEDIUM_LEFT_PARALLEL_CURVE) { - - - if (!mediumLeftParallelCurve(player, world, x, y, z, l, tempType)){ - return false; - } - if (player == null || !player.capabilities.isCreativeMode) { - --itemstack.stackSize; - } - return true; - - } - else if (tempType == TrackTypes.LARGE_RIGHT_PARALLEL_CURVE || tempType == TrackTypes.EMBEDDED_LARGE_RIGHT_PARALLEL_CURVE) { - - if (!largeRightParallelCurve(player, world, x, y, z, l, tempType)){ - return false; - } - if (player==null || !player.capabilities.isCreativeMode) { - --itemstack.stackSize; - } - return true; - } - else if (tempType == TrackTypes.LARGE_LEFT_PARALLEL_CURVE|| tempType == TrackTypes.EMBEDDED_LARGE_LEFT_PARALLEL_CURVE) { - - if (!largeLeftParallelCurve(player, world, x, y, z, l, tempType)){ - return false; - } - - if (player==null || !player.capabilities.isCreativeMode) { - --itemstack.stackSize; - } - return true; - - } - else if (tempType == TrackTypes.MEDIUM_RIGHT_45DEGREE_SWITCH || tempType == TrackTypes.EMBEDDED_MEDIUM_RIGHT_45DEGREE_SWITCH) { - switch (tempType) { - case MEDIUM_RIGHT_45DEGREE_SWITCH: - typeVariantStraight = TrackTypes.SMALL_STRAIGHT.getLabel(); - typeVariant90Turn = TrackTypes.MEDIUM_RIGHT_TURN.getLabel(); - idVariantSwitch = ItemIDs.tcRailMedium45DegreeSwitch.item; - break; - case EMBEDDED_MEDIUM_RIGHT_45DEGREE_SWITCH: - typeVariantStraight = TrackTypes.EMBEDDED_SMALL_STRAIGHT.getLabel(); - typeVariant90Turn = TrackTypes.EMBEDDED_MEDIUM_RIGHT_TURN.getLabel(); - idVariantSwitch = ItemIDs.tcRailEmbeddedMedium45DegreeSwitch.item; - break; - } - - if (player.isSneaking()) { - if (l == 2) { - int[] xArray = {x + 1, x + 1}; - int[] zArray = {z - 2, z - 3}; - if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, false, 3, x + 1, z - 3, 3.75, x + 4.25, y + 1, - z, typeVariant90Turn, idVariantSwitch)) - return false; - TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x + 1, y + 1, z - 2); - if (tcRailTurn != null) { - tcRailTurn.hasModel = false; - } - - world.setBlockMetadataWithNotify(x + 1, y + 1, z - 2, l, 2);//to force client update - /** Switch rail 1 **/ - putDownSingleRail(world, x, y + 1, z - 1, l, x + 4.25, y + 1, z, 3.75, tempType.getLabel(), true, x + 1, y + 1, z - 2, true, false); - /** Switch rail 2 **/ - putDownSingleRail(world, x, y + 1, z - 2, l, x + 4.25, y + 1, z, 3.75, typeVariantStraight, false, x + 1, y + 1, z - 2, true, false); - /** Put down straight exit **/ - putDownSingleRail(world, x, y + 1, z - 3, l, x, y + 1, z, 0, typeVariantStraight, false, x + 1, y + 1, z - 2, false, false); - } - - if (l == 0) { - int[] xArray = {x - 1, x - 1}; - int[] zArray = {z + 2, z + 3}; - if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, false, 1, x - 1, z + 3, 3.75, x - 3.25, y + 1, - z + 1, typeVariant90Turn, idVariantSwitch)) - return false; - TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x - 1, y + 1, z + 2); - if (tcRailTurn != null) { - tcRailTurn.hasModel = false; - } - - world.setBlockMetadataWithNotify(x - 1, y + 1, z + 2, l, 2);//to force client update - /** Switch rail 1 **/ - putDownSingleRail(world, x, y + 1, z + 1, l, x - 3.25, y + 1, z + 1, 3.75, tempType.getLabel(), true, x - 1, y + 1, z + 2, true, false); - /** Switch rail 2 **/ - putDownSingleRail(world, x, y + 1, z + 2, l, x - 3.25, y + 1, z + 1, 3.75, typeVariantStraight, false, x - 1, y + 1, z + 2, true, false); - /** Put down straight exit **/ - putDownSingleRail(world, x, y + 1, z + 3, l, x, y + 1, z, 0, typeVariantStraight, false, x - 1, y + 1, z + 2, false, false); - } - if (l == 1) { - int[] xArray = {x - 2, x - 3}; - int[] zArray = {z - 1, z - 1}; - if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, false, 2, x - 3, z -1, 3.75, x , y + 1, - z - 3.25, typeVariant90Turn, idVariantSwitch)) - return false; - TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x - 2 , y + 1, z - 1); - if (tcRailTurn != null) { - tcRailTurn.hasModel = false; - } - - world.setBlockMetadataWithNotify(x - 2, y + 1, z - 1, l, 2);//to force client update - /** Switch rail 1 **/ - putDownSingleRail(world, x - 1, y + 1, z , l, x , y + 1, z - 3.25, 3.75, tempType.getLabel(), true, x - 2, y + 1, z - 1, true, false); - /** Switch rail 2 **/ - putDownSingleRail(world, x - 2, y + 1, z , l, x , y + 1, z - 3.25, 3.75, typeVariantStraight, false, x - 2, y + 1, z - 1, true, false); - /** Put down straight exit **/ - putDownSingleRail(world, x - 3, y + 1, z , l, x, y + 1, z, 0, typeVariantStraight, false, x - 2, y + 1, z - 1, false, false); - } - if (l == 3) { - int[] xArray = {x + 2, x + 3}; - int[] zArray = {z + 1, z + 1}; - if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, false, 2, x + 3, z +1, 3.75, x + 1 , y + 1, - z + 4.25, typeVariant90Turn, idVariantSwitch)) - return false; - TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x + 2 , y + 1, z + 1); - if (tcRailTurn != null) { - tcRailTurn.hasModel = false; - } - - world.setBlockMetadataWithNotify(x + 2, y + 1, z + 1, l, 2);//to force client update - /** Switch rail 1 **/ - putDownSingleRail(world, x + 1, y + 1, z , l, x + 1 , y + 1, z + 4.25, 3.75, tempType.getLabel(), true, x + 2, y + 1, z + 1, true, false); - /** Switch rail 2 **/ - putDownSingleRail(world, x + 2, y + 1, z , l, x + 1 , y + 1, z + 4.25, 3.75, typeVariantStraight, false, x + 2, y + 1, z + 1, true, false); - /** Put down straight exit **/ - putDownSingleRail(world, x + 3, y + 1, z , l, x + 1, y + 1, z, 0, typeVariantStraight, false, x + 2, y + 1, z + 1, false, false); - } - } - else { - if (l == 2) { - int[] xArray = {x + 1, x + 1, x + 1, x + 2}; - int[] zArray = {z - 2, z - 3, z - 4, z - 3}; - if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, false, 3, x + 1, z - 3, 3.75, x + 4.25, y + 1, - z, typeVariant90Turn, idVariantSwitch)) - return false; - TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x + 1, y + 1, z - 2); - if (tcRailTurn != null) { - tcRailTurn.hasModel = false; - } - - world.setBlockMetadataWithNotify(x + 1, y + 1, z - 2, l, 2);//to force client update - /** Switch rail 1 **/ - putDownSingleRail(world, x, y + 1, z - 1, l, x + 4.25, y + 1, z, 3.75, tempType.getLabel(), true, x + 1, y + 1, z - 2, true, false); - /** Switch rail 2 **/ - putDownSingleRail(world, x, y + 1, z - 2, l, x + 4.25, y + 1, z, 3.75, typeVariantStraight, false, x + 1, y + 1, z - 2, true, false); - /** Put down straight exit **/ - putDownSingleRail(world, x, y + 1, z - 3, l, x, y + 1, z, 0, typeVariantStraight, false, x + 1, y + 1, z - 2, false, false); - } - - if (l == 0) { - int[] xArray = {x - 1, x - 1, x - 1, x - 2}; - int[] zArray = {z + 2, z + 3, z + 4, z + 3}; - if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, false, 1, x - 1, z + 3, 3.75, x - 3.25, y + 1, - z + 1, typeVariant90Turn, idVariantSwitch)) - return false; - TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x - 1, y + 1, z + 2); - if (tcRailTurn != null) { - tcRailTurn.hasModel = false; - } - - world.setBlockMetadataWithNotify(x - 1, y + 1, z + 2, l, 2);//to force client update - /** Switch rail 1 **/ - putDownSingleRail(world, x, y + 1, z + 1, l, x - 3.25, y + 1, z + 1, 3.75, tempType.getLabel(), true, x - 1, y + 1, z + 2, true, false); - /** Switch rail 2 **/ - putDownSingleRail(world, x, y + 1, z + 2, l, x - 3.25, y + 1, z + 1, 3.75, typeVariantStraight, false, x - 1, y + 1, z + 2, true, false); - /** Put down straight exit **/ - putDownSingleRail(world, x, y + 1, z + 3, l, x, y + 1, z, 0, typeVariantStraight, false, x - 1, y + 1, z + 2, false, false); - } - if (l == 1) { - int[] xArray = {x - 2, x - 3, x - 4, x - 3}; - int[] zArray = {z - 1, z - 1, z - 1, z - 2}; - if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, false, 2, x - 3, z - 1, 3.75, x, y + 1, - z - 3.25, typeVariant90Turn, idVariantSwitch)) - return false; - TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x - 2, y + 1, z - 1); - if (tcRailTurn != null) { - tcRailTurn.hasModel = false; - } - - world.setBlockMetadataWithNotify(x - 2, y + 1, z - 1, l, 2);//to force client update - /** Switch rail 1 **/ - putDownSingleRail(world, x - 1, y + 1, z, l, x, y + 1, z - 3.25, 3.75, tempType.getLabel(), true, x - 2, y + 1, z - 1, true, false); - /** Switch rail 2 **/ - putDownSingleRail(world, x - 2, y + 1, z, l, x, y + 1, z - 3.25, 3.75, typeVariantStraight, false, x - 2, y + 1, z - 1, true, false); - /** Put down straight exit **/ - putDownSingleRail(world, x - 3, y + 1, z, l, x, y + 1, z, 0, typeVariantStraight, false, x - 2, y + 1, z - 1, false, false); - } - if (l == 3) { - int[] xArray = {x + 2, x + 3, x + 4, x + 3}; - int[] zArray = {z + 1, z + 1, z + 1, z + 2}; - if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, false, 0, x + 3, z + 1, 3.75, x + 1, y + 1, - z + 4.25, typeVariant90Turn, idVariantSwitch)) - return false; - TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x + 2, y + 1, z + 1); - if (tcRailTurn != null) { - tcRailTurn.hasModel = false; - } - - world.setBlockMetadataWithNotify(x + 2, y + 1, z + 1, l, 2);//to force client update - /** Switch rail 1 **/ - putDownSingleRail(world, x + 1, y + 1, z, l, x + 1, y + 1, z + 4.25, 3.75, tempType.getLabel(), true, x + 2, y + 1, z + 1, true, false); - /** Switch rail 2 **/ - putDownSingleRail(world, x + 2, y + 1, z, l, x + 1, y + 1, z + 4.25, 3.75, typeVariantStraight, false, x + 2, y + 1, z + 1, true, false); - /** Put down straight exit **/ - putDownSingleRail(world, x + 3, y + 1, z, l, x + 1, y + 1, z, 0, typeVariantStraight, false, x + 2, y + 1, z + 1, false, false); - } - - } - - - if (player==null || !player.capabilities.isCreativeMode) { - --itemstack.stackSize; - } - return true; - } - else if (tempType == TrackTypes.MEDIUM_LEFT_45DEGREE_SWITCH || tempType == TrackTypes.EMBEDDED_MEDIUM_LEFT_45DEGREE_SWITCH) { - switch (tempType) { - case MEDIUM_LEFT_45DEGREE_SWITCH: - typeVariantStraight = TrackTypes.SMALL_STRAIGHT.getLabel(); - typeVariant90Turn = TrackTypes.MEDIUM_LEFT_TURN.getLabel(); - idVariantSwitch = ItemIDs.tcRailMedium45DegreeSwitch.item; - break; - case EMBEDDED_MEDIUM_LEFT_45DEGREE_SWITCH: - typeVariantStraight = TrackTypes.EMBEDDED_SMALL_STRAIGHT.getLabel(); - typeVariant90Turn = TrackTypes.EMBEDDED_MEDIUM_LEFT_TURN.getLabel(); - idVariantSwitch = ItemIDs.tcRailEmbeddedMedium45DegreeSwitch.item; - break; - } - if (player.isSneaking()) { - if (l == 2) { - int[] xArray = {x - 1, x - 1}; - int[] zArray = {z - 2, z - 3}; - if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, false, 1, x - 1, z - 3, 3.75, x - 3.25, y + 1, - z, typeVariant90Turn, idVariantSwitch)) - return false; - TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x - 1, y + 1, z - 2); - if (tcRailTurn != null) { - tcRailTurn.hasModel = false; - } - - world.setBlockMetadataWithNotify(x - 1, y + 1, z - 2, l, 2);//to force client update - /** Switch rail 1 **/ - putDownSingleRail(world, x, y + 1, z - 1, l, x - 3.25, y + 1, z, 3.75, tempType.getLabel(), true, x - 1, y + 1, z - 2, true, false); - /** Switch rail 2 **/ - putDownSingleRail(world, x, y + 1, z - 2, l, x - 3.25, y + 1, z, 3.75, typeVariantStraight, false, x - 1, y + 1, z - 2, true, false); - /** Put down straight exit **/ - putDownSingleRail(world, x, y + 1, z - 3, l, x, y + 1, z, 0, typeVariantStraight, false, x - 1, y + 1, z - 2, false, false); - } - - if (l == 0) { - int[] xArray = {x + 1, x + 1}; - int[] zArray = {z + 2, z + 3}; - if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, false, 3, x + 1, z + 3, 3.75, x + 4.25, y + 1, - z + 1, typeVariant90Turn, idVariantSwitch)) - return false; - TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x + 1, y + 1, z + 2); - if (tcRailTurn != null) { - tcRailTurn.hasModel = false; - } - - world.setBlockMetadataWithNotify(x + 1, y + 1, z + 2, l, 2);//to force client update - /** Switch rail 1 **/ - putDownSingleRail(world, x, y + 1, z + 1, l, x + 4.25, y + 1, z + 1, 3.75, tempType.getLabel(), true, x + 1, y + 1, z + 2, true, false); - /** Switch rail 2 **/ - putDownSingleRail(world, x, y + 1, z + 2, l, x + 4.25, y + 1, z + 1, 3.75, typeVariantStraight, false, x + 1, y + 1, z + 2, true, false); - /** Put down straight exit **/ - putDownSingleRail(world, x, y + 1, z + 3, l, x, y + 1, z, 0, typeVariantStraight, false, x + 1, y + 1, z + 2, false, false); - } - if (l == 1) { - int[] xArray = {x - 2, x - 3}; - int[] zArray = {z + 1, z + 1}; - if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, false, 0, x - 3, z + 1, 3.75, x, y + 1, - z + 4.25, typeVariant90Turn, idVariantSwitch)) - return false; - TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x - 2, y + 1, z + 1); - if (tcRailTurn != null) { - tcRailTurn.hasModel = false; - } - - world.setBlockMetadataWithNotify(x - 2, y + 1, z + 1, l, 2);//to force client update - /** Switch rail 1 **/ - putDownSingleRail(world, x - 1, y + 1, z, l, x, y + 1, z + 4.25, 3.75, tempType.getLabel(), true, x - 2, y + 1, z + 1, true, false); - /** Switch rail 2 **/ - putDownSingleRail(world, x - 2, y + 1, z, l, x, y + 1, z + 4.25, 3.75, typeVariantStraight, false, x - 2, y + 1, z + 1, true, false); - /** Put down straight exit **/ - putDownSingleRail(world, x - 3, y + 1, z, l, x, y + 1, z, 0, typeVariantStraight, false, x - 2, y + 1, z + 1, false, false); - } - if (l == 3) { - int[] xArray = {x + 2, x + 3}; - int[] zArray = {z - 1, z - 1}; - if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, false, 2, x + 3, z - 1, 3.75, x + 1, y + 1, - z - 3.25, typeVariant90Turn, idVariantSwitch)) - return false; - TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x + 2, y + 1, z - 1); - if (tcRailTurn != null) { - tcRailTurn.hasModel = false; - } - - world.setBlockMetadataWithNotify(x + 2, y + 1, z + 1, l, 2);//to force client update - /** Switch rail 1 **/ - putDownSingleRail(world, x + 1, y + 1, z, l, x + 1, y + 1, z - 3.25, 3.75, tempType.getLabel(), true, x + 2, y + 1, z - 1, true, false); - /** Switch rail 2 **/ - putDownSingleRail(world, x + 2, y + 1, z, l, x + 1, y + 1, z - 3.25, 3.75, typeVariantStraight, false, x + 2, y + 1, z - 1, true, false); - /** Put down straight exit **/ - putDownSingleRail(world, x + 3, y + 1, z, l, x + 1, y + 1, z, 0, typeVariantStraight, false, x + 2, y + 1, z - 1, false, false); - } - } - - else { - if (l == 2) { - int[] xArray = {x - 1, x - 1, x - 1, x - 2}; - int[] zArray = {z - 2, z - 3, z - 4, z - 3}; - if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, false, 1, x - 1, z - 3, 3.75, x - 3.25, y + 1, - z, typeVariant90Turn, idVariantSwitch)) - return false; - TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x - 1, y + 1, z - 2); - if (tcRailTurn != null) { - tcRailTurn.hasModel = false; - } - - world.setBlockMetadataWithNotify(x - 1, y + 1, z - 2, l, 2);//to force client update - /** Switch rail 1 **/ - putDownSingleRail(world, x, y + 1, z - 1, l, x - 3.25, y + 1, z, 3.75, tempType.getLabel(), true, x - 1, y + 1, z - 2, true, false); - /** Switch rail 2 **/ - putDownSingleRail(world, x, y + 1, z - 2, l, x - 3.25, y + 1, z, 3.75, typeVariantStraight, false, x - 1, y + 1, z - 2, true, false); - /** Put down straight exit **/ - putDownSingleRail(world, x, y + 1, z - 3, l, x, y + 1, z, 0, typeVariantStraight, false, x - 1, y + 1, z - 2, false, false); - } - - if (l == 0) { - int[] xArray = {x + 1, x + 1, x + 1, x + 2}; - int[] zArray = {z + 2, z + 3, z + 4, z + 3}; - if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, false, 3, x + 1, z + 3, 3.75, x + 4.25, y + 1, - z + 1, typeVariant90Turn, idVariantSwitch)) - return false; - TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x + 1, y + 1, z + 2); - if (tcRailTurn != null) { - tcRailTurn.hasModel = false; - } - - world.setBlockMetadataWithNotify(x + 1, y + 1, z + 2, l, 2);//to force client update - /** Switch rail 1 **/ - putDownSingleRail(world, x, y + 1, z + 1, l, x + 4.25, y + 1, z + 1, 3.75, tempType.getLabel(), true, x + 1, y + 1, z + 2, true, false); - /** Switch rail 2 **/ - putDownSingleRail(world, x, y + 1, z + 2, l, x + 4.25, y + 1, z + 1, 3.75, typeVariantStraight, false, x + 1, y + 1, z + 2, true, false); - /** Put down straight exit **/ - putDownSingleRail(world, x, y + 1, z + 3, l, x, y + 1, z, 0, typeVariantStraight, false, x + 1, y + 1, z + 2, false, false); - } - if (l == 1) { - int[] xArray = {x - 2, x - 3, x - 4, x - 3}; - int[] zArray = {z + 1, z + 1, z + 1, z + 2}; - if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, false, 0, x - 3, z + 1, 3.75, x , y + 1, - z + 4.25, typeVariant90Turn, idVariantSwitch)) - return false; - TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x - 2 , y + 1, z + 1); - if (tcRailTurn != null) { - tcRailTurn.hasModel = false; - } - - world.setBlockMetadataWithNotify(x - 2, y + 1, z + 1, l, 2);//to force client update - /** Switch rail 1 **/ - putDownSingleRail(world, x - 1, y + 1, z , l, x , y + 1, z + 4.25, 3.75, tempType.getLabel(), true, x - 2, y + 1, z + 1, true, false); - /** Switch rail 2 **/ - putDownSingleRail(world, x - 2, y + 1, z , l, x , y + 1, z + 4.25, 3.75, typeVariantStraight, false, x - 2, y + 1, z + 1, true, false); - /** Put down straight exit **/ - putDownSingleRail(world, x - 3, y + 1, z , l, x, y + 1, z, 0, typeVariantStraight, false, x - 2, y + 1, z + 1, false, false); - } - if (l == 3) { - int[] xArray = {x + 2, x + 3, x + 4, x + 3}; - int[] zArray = {z - 1, z - 1, z - 1, z - 2}; - if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, false, 2, x + 3, z - 1, 3.75, x + 1 , y + 1, - z - 3.25, typeVariant90Turn, idVariantSwitch)) - return false; - TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x + 2 , y + 1, z - 1); - if (tcRailTurn != null) { - tcRailTurn.hasModel = false; - } - - world.setBlockMetadataWithNotify(x + 2, y + 1, z + 1, l, 2);//to force client update - /** Switch rail 1 **/ - putDownSingleRail(world, x + 1, y + 1, z , l, x + 1 , y + 1, z - 3.25, 3.75, tempType.getLabel(), true, x + 2, y + 1, z - 1, true, false); - /** Switch rail 2 **/ - putDownSingleRail(world, x + 2, y + 1, z , l, x + 1 , y + 1, z - 3.25, 3.75, typeVariantStraight, false, x + 2, y + 1, z - 1, true, false); - /** Put down straight exit **/ - putDownSingleRail(world, x + 3, y + 1, z , l, x + 1, y + 1, z, 0, typeVariantStraight, false, x + 2, y + 1, z - 1, false, false); - } - } - - - if (player==null || !player.capabilities.isCreativeMode) { - --itemstack.stackSize; - } - return true; - } - else if (tempType == TrackTypes.MEDIUM_RIGHT_SWITCH || tempType == TrackTypes.EMBEDDED_MEDIUM_RIGHT_SWITCH) { - - switch (tempType){ - case MEDIUM_RIGHT_SWITCH: - idVariantSwitch = ItemIDs.tcRailMediumSwitch.item; - typeVariant90Turn = TrackTypes.MEDIUM_RIGHT_TURN.getLabel(); - typeVariantStraight = TrackTypes.SMALL_STRAIGHT.getLabel(); - break; - case EMBEDDED_MEDIUM_RIGHT_SWITCH: - idVariantSwitch = ItemIDs.tcRailEmbeddedMediumSwitch.item; - typeVariant90Turn = TrackTypes.EMBEDDED_MEDIUM_RIGHT_TURN.getLabel(); - typeVariantStraight = TrackTypes.EMBEDDED_SMALL_STRAIGHT.getLabel(); - break; - } - - - if (l == 2) { - /** Check if straight exit can be put down */ - if (!canPlaceTrack(player, world, x, y + 1, z - 3) || !canPlaceTrack(player, world, x, y + 1, z - 2) || !canPlaceTrack(player, world, x, y + 1, z - 1)) { - return false; - } - - int[] xArray = { x + 1, x + 1, x + 2 }; - int[] zArray = { z - 2, z - 3, z - 3 }; - if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, true, 1, x + 3, z - 3, 2.5, x + 3, y + 1, - z, typeVariant90Turn, idVariantSwitch)) - return false; - TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x + 1, y + 1, z - 2); - if (tcRailTurn != null) { - tcRailTurn.hasModel = false; - } - world.setBlockMetadataWithNotify(x + 1, y + 1, z - 2, l, 2);//to force client update - /** Switch rail 1 */ - putDownSingleRail(world, x, y + 1, z - 1, l, x + 3, y + 1, z, 2.5, tempType.getLabel(), true, x + 1, y + 1, z - 2, true, false); - - /** Switch rail 2 **/ - putDownSingleRail(world, x, y + 1, z - 2, l, x + 3, y + 1, z, 2.5, typeVariantStraight, false, x + 1, y + 1, z - 2, true, false); - - /** Put down straight exit **/ - putDownSingleRail(world, x, y + 1, z - 3, l, x, y + 1, z, 0, typeVariantStraight, true, x + 1, y + 1, z - 2, false, false); - } - if (l == 0) { - /** Check if straight exit can be put down */ - if (!canPlaceTrack(player, world, x, y + 1, z + 3) || !canPlaceTrack(player, world, x, y + 1, z + 2) || !canPlaceTrack(player, world, x, y + 1, z + 1)) { - return false; - } - - int[] xArray = { x - 1, x - 1, x - 2 }; - int[] zArray = { z + 2, z + 3, z + 3 }; - if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, true, 1, x - 3, z + 3, 2.5, x - 2, y + 1, - z + 1, typeVariant90Turn, idVariantSwitch)) - return false; - TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x - 1, y + 1, z + 2); - if (tcRailTurn != null) - tcRailTurn.hasModel = false; - world.setBlockMetadataWithNotify(x - 1, y + 1, z + 2, l, 2);//to force client update - - /** Switch rail 1 */ - putDownSingleRail(world, x, y + 1, z + 1, l, x - 2, y + 1, z + 1, 2.5, tempType.getLabel(), true, x - 1, y + 1, z + 2, true, false); - - /** Switch rail 2 **/ - putDownSingleRail(world, x, y + 1, z + 2, l, x - 2, y + 1, z + 1, 2.5, typeVariantStraight, false, x - 1, y + 1, z + 2, true, false); - - /** Put down straight exit **/ - putDownSingleRail(world, x, y + 1, z + 3, l, x, y + 1, z, 0, typeVariantStraight, true, x - 1, y + 1, z + 2, false, false); - - } - if (l == 1) { - /** Check if straight exit can be put down */ - if (!canPlaceTrack(player, world, x - 3, y + 1, z) || !canPlaceTrack(player, world, x - 2, y + 1, z) || !canPlaceTrack(player, world, x - 1, y + 1, z)) { - return false; - } - - int[] xArray = { x - 2, x - 3, x - 3 }; - int[] zArray = { z - 1, z - 1, z - 2 }; - if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, true, 2, x - 3, z - 3, 2.5, x, y + 1, - z - 2, typeVariant90Turn, idVariantSwitch)) - return false; - TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x - 2, y + 1, z - 1); - if (tcRailTurn != null) - tcRailTurn.hasModel = false; - world.setBlockMetadataWithNotify(x - 2, y + 1, z - 1, l, 2);//to force client update - - /** Switch rail 1 */ - putDownSingleRail(world, x - 1, y + 1, z, l, x, y + 1, z - 2, 2.5, tempType.getLabel(), true, x - 2, y + 1, z - 1, true, false); - - /** Switch rail 2 **/ - putDownSingleRail(world, x - 2, y + 1, z, l, x, y + 1, z - 2, 2.5, typeVariantStraight, false, x - 2, y + 1, z - 1, true, false); - - /** Put down straight exit **/ - putDownSingleRail(world, x - 3, y + 1, z, l, x, y + 1, z, 0, typeVariantStraight, true, x - 2, y + 1, z - 1, false, false); - - } - if (l == 3) { - /** Check if straight exit can be put down */ - if (!canPlaceTrack(player, world, x + 3, y + 1, z) || !canPlaceTrack(player, world, x + 2, y + 1, z) || !canPlaceTrack(player, world, x + 1, y + 1, z)) { - return false; - } - - int[] xArray = { x + 2, x + 3, x + 3 }; - int[] zArray = { z + 1, z + 1, z + 2 }; - if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, true, 0, x + 3, z + 3, 2.5, x + 1, y + 1, - z + 3, typeVariant90Turn, idVariantSwitch)) - return false; - TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x + 2, y + 1, z + 1); - if (tcRailTurn != null) - tcRailTurn.hasModel = false; - world.setBlockMetadataWithNotify(x + 2, y + 1, z + 1, l, 2);//to force client update - - /** Switch rail 1 */ - putDownSingleRail(world, x + 1, y + 1, z, l, x + 1, y + 1, z + 3, 2.5, tempType.getLabel(), true, x + 2, y + 1, z + 1, true, false); - - /** Switch rail 2 **/ - putDownSingleRail(world, x + 2, y + 1, z, l, x + 1, y + 1, z + 3, 2.5, typeVariantStraight, false, x + 2, y + 1, z + 1, true, false); - - /** Put down straight exit **/ - putDownSingleRail(world, x + 3, y + 1, z, l, x, y + 1, z, 0, typeVariantStraight, true, x + 2, y + 1, z + 1, false, false); - - } - - if (player==null || !player.capabilities.isCreativeMode) { - --itemstack.stackSize; - } - return true; - } - - else if (tempType == TrackTypes.MEDIUM_LEFT_SWITCH || tempType == TrackTypes.EMBEDDED_MEDIUM_LEFT_SWITCH) { - switch (tempType){ - case MEDIUM_LEFT_SWITCH: - idVariantSwitch = ItemIDs.tcRailMediumSwitch.item; - typeVariant90Turn = TrackTypes.MEDIUM_LEFT_TURN.getLabel(); - typeVariantStraight = TrackTypes.SMALL_STRAIGHT.getLabel(); - break; - case EMBEDDED_MEDIUM_LEFT_SWITCH: - idVariantSwitch = ItemIDs.tcRailEmbeddedMediumSwitch.item; - typeVariant90Turn = TrackTypes.EMBEDDED_MEDIUM_LEFT_TURN.getLabel(); - typeVariantStraight = TrackTypes.EMBEDDED_SMALL_STRAIGHT.getLabel(); - break; - } - if (l == 2) { - /** Check if straight exit can be put down */ - if (!canPlaceTrack(player, world, x, y + 1, z - 3) || !canPlaceTrack(player, world, x, y + 1, z - 2) || !canPlaceTrack(player, world, x, y + 1, z - 1)) { - return false; - } - - int[] xArray = { x - 1, x - 1, x - 2 }; - int[] zArray = { z - 2, z - 3, z - 3 }; - if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, true, 1, x - 3, z - 3, 2.5, x - 2, y + 1, - z, typeVariant90Turn, idVariantSwitch)) - return false; - TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x - 1, y + 1, z - 2); - if (tcRailTurn != null) { - tcRailTurn.hasModel = false; - } - world.setBlockMetadataWithNotify(x - 1, y + 1, z - 2, l, 2);//to force client update - - /** Switch rail 1 */ - putDownSingleRail(world, x, y + 1, z - 1, l, x - 2, y + 1, z, 2.5, tempType.getLabel(), true, x - 1, y + 1, z - 2, true, false); - - /** Switch rail 2 **/ - putDownSingleRail(world, x, y + 1, z - 2, l, x - 2, y + 1, z, 2.5, typeVariantStraight, false, x - 1, y + 1, z - 2, true, false); - - /** Put down straight exit **/ - putDownSingleRail(world, x, y + 1, z - 3, l, x, y + 1, z, 0, typeVariantStraight, true, x - 1, y + 1, z - 2, false, false); - - } - if (l == 0) { - /** Check if straight exit can be put down */ - if (!canPlaceTrack(player, world, x, y + 1, z + 3) || !canPlaceTrack(player, world, x, y + 1, z + 2) || !canPlaceTrack(player, world, x, y + 1, z + 1)) { - return false; - } - int[] xArray = { x + 1, x + 1, x + 2 }; - int[] zArray = { z + 2, z + 3, z + 3 }; - if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, true, 3, x + 3, z + 3, 2.5, x + 3, y + 1, - z + 1, typeVariant90Turn, idVariantSwitch)) - return false; - TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x + 1, y + 1, z + 2); - if (tcRailTurn != null) - tcRailTurn.hasModel = false; - world.setBlockMetadataWithNotify(x + 1, y + 1, z + 2, l, 2);//to force client update - - /** Switch rail 1 */ - putDownSingleRail(world, x, y + 1, z + 1, l, x + 3, y + 1, z + 1, 2.5, tempType.getLabel(), true, x + 1, y + 1, z + 2, true, false); - - /** Switch rail 2 **/ - putDownSingleRail(world, x, y + 1, z + 2, l, x + 3, y + 1, z + 1, 2.5, typeVariantStraight, false, x + 1, y + 1, z + 2, true, false); - - /** Put down straight exit **/ - putDownSingleRail(world, x, y + 1, z + 3, l, x, y + 1, z, 0, typeVariantStraight, true, x + 1, y + 1, z + 2, false, false); - - } - if (l == 1) { - /** Check if straight exit can be put down */ - if (!canPlaceTrack(player, world, x - 3, y + 1, z) || !canPlaceTrack(player, world, x - 2, y + 1, z) || !canPlaceTrack(player, world, x - 1, y + 1, z)) { - return false; - } - int[] xArray = { x - 2, x - 3, x - 3 }; - int[] zArray = { z + 1, z + 1, z + 2 }; - if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, true, 0, x - 3, z + 3, 2.5, x, y + 1, - z + 3, typeVariant90Turn, idVariantSwitch)) - return false; - - TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x - 2, y + 1, z + 1); - if (tcRailTurn != null) - tcRailTurn.hasModel = false; - world.setBlockMetadataWithNotify(x - 2, y + 1, z + 1, l, 2);//to force client update - - /** Switch rail 1 */ - putDownSingleRail(world, x - 1, y + 1, z, l, x, y + 1, z + 3, 2.5, tempType.getLabel(), true, x - 2, y + 1, z + 1, true, false); - - /** Switch rail 2 **/ - putDownSingleRail(world, x - 2, y + 1, z, l, x, y + 1, z + 3, 2.5, typeVariantStraight, false, x - 2, y + 1, z + 1, true, false); - - /** Put down straight exit **/ - putDownSingleRail(world, x - 3, y + 1, z, l, x, y + 1, z, 0, typeVariantStraight, true, x - 2, y + 1, z + 1, false, false); - - } - if (l == 3) { - /** Check if straight exit can be put down */ - if (!canPlaceTrack(player, world, x + 3, y + 1, z) || !canPlaceTrack(player, world, x + 2, y + 1, z) || !canPlaceTrack(player, world, x + 1, y + 1, z)) { - return false; - } - int[] xArray = { x + 2, x + 3, x + 3 }; - int[] zArray = { z - 1, z - 1, z - 2 }; - if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, true, 2, x + 3, z - 3, 2.5, x + 1, y + 1, - z - 2, typeVariant90Turn, idVariantSwitch)) - return false; - TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x + 2, y + 1, z - 1); - if (tcRailTurn != null) - tcRailTurn.hasModel = false; - world.setBlockMetadataWithNotify(x + 2, y + 1, z - 1, l, 2);//to force client update - - /** Switch rail 1 */ - putDownSingleRail(world, x + 1, y + 1, z, l, x + 1, y + 1, z - 2, 2.5, tempType.getLabel(), true, x + 2, y + 1, z - 1, true, false); - - /** Switch rail 2 **/ - putDownSingleRail(world, x + 2, y + 1, z, l, x + 1, y + 1, z - 2, 2.5, typeVariantStraight, false, x + 2, y + 1, z - 1, true, false); - - /** Put down straight exit **/ - putDownSingleRail(world, x + 3, y + 1, z, l, x, y + 1, z, 0, typeVariantStraight, true, x + 2, y + 1, z - 1, false, false); - - } - if (player ==null || !player.capabilities.isCreativeMode) { - --itemstack.stackSize; - } - return true; - } - - else if (tempType == TrackTypes.LARGE_RIGHT_SWITCH || tempType == TrackTypes.EMBEDDED_LARGE_RIGHT_SWITCH) { - switch (tempType){ - case LARGE_RIGHT_SWITCH: - idVariantSwitch = ItemIDs.tcRailLargeSwitch.item; - typeVariant90Turn = TrackTypes.LARGE_RIGHT_TURN.getLabel(); - typeVariantStraight = TrackTypes.SMALL_STRAIGHT.getLabel(); - break; - case EMBEDDED_LARGE_RIGHT_SWITCH: - idVariantSwitch = ItemIDs.tcRailEmbeddedLargeSwitch.item; - typeVariant90Turn = TrackTypes.EMBEDDED_LARGE_RIGHT_TURN.getLabel(); - typeVariantStraight = TrackTypes.EMBEDDED_SMALL_STRAIGHT.getLabel(); - break; - } - if (l == 2) { - /** Check if straight exit can be put down */ - if (!canPlaceTrack(player, world, x, y + 1, z - 5) || !canPlaceTrack(player, world, x, y + 1, z - 4) || !canPlaceTrack(player, world, x, y + 1, z - 3) || !canPlaceTrack(player, world, x, y + 1, z - 2) || !canPlaceTrack(player, world, x, y + 1, z - 1)) { - return false; - } - int[] xArray = { x + 1, x + 1, x + 2, x + 1, x + 2, x + 3, x + 4, x + 3, x + 2 }; - int[] zArray = { z - 2, z - 3, z - 3, z - 4, z - 4, z - 4, z - 5, z - 5, z - 5 }; - if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, true, 1, x + 5, z - 5, 4.5, x + 5, y + 1, - z, typeVariant90Turn, idVariantSwitch)) - return false; - TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x + 1, y + 1, z - 2); - if (tcRailTurn != null) - tcRailTurn.hasModel = false; - world.setBlockMetadataWithNotify(x + 1, y + 1, z - 2, l, 2);//to force client update - /** Switch rail 1 */ - putDownSingleRail(world, x, y + 1, z - 1, l, x + 5, y + 1, z, 4.5, tempType.getLabel(), true, x + 1, y + 1, z - 2, true, false); - - /** Switch rail 2 **/ - putDownSingleRail(world, x, y + 1, z - 2, l, x + 5, y + 1, z, 4.5, typeVariantStraight, false, x + 1, y + 1, z - 2, true, false); - - /** Switch rail 3 **/ - putDownSingleRail(world, x, y + 1, z - 3, l, x + 5, y + 1, z, 4.5, typeVariantStraight, false, x + 1, y + 1, z - 2, true, false); - - /** Put down straight exit **/ - putDownSingleRail(world, x, y + 1, z - 4, l, x, y + 1, z, 0, typeVariantStraight, false, x + 1, y + 1, z - 2, false, false); - - /** Put down straight exit **/ - putDownSingleRail(world, x, y + 1, z - 5, l, x, y + 1, z, 0, typeVariantStraight, true, x + 1, y + 1, z - 2, false, false); - - } - if (l == 0) { - /** Check if straight exit can be put down */ - if (!canPlaceTrack(player, world, x, y + 1, z + 5) || !canPlaceTrack(player, world, x, y + 1, z + 4) || !canPlaceTrack(player, world, x, y + 1, z + 3) || !canPlaceTrack(player, world, x, y + 1, z + 2) || !canPlaceTrack(player, world, x, y + 1, z + 1)) { - return false; - } - - int[] xArray = { x - 1, x - 1, x - 2, x - 1, x - 2, x - 3, x - 2, x - 3, x - 4 }; - int[] zArray = { z + 2, z + 3, z + 3, z + 4, z + 4, z + 4, z + 5, z + 5, z + 5 }; - if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, true, 1, x - 5, z + 5, 4.5, x - 4, y + 1, - z + 1, typeVariant90Turn, idVariantSwitch)) - return false; - TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x - 1, y + 1, z + 2); - if (tcRailTurn != null) - tcRailTurn.hasModel = false; - world.setBlockMetadataWithNotify(x - 1, y + 1, z + 2, l, 2);//to force client update - - /** Switch rail 1 */ - putDownSingleRail(world, x, y + 1, z + 1, l, x - 4, y + 1, z + 1, 4.5, tempType.getLabel(), true, x - 1, y + 1, z + 2, true, false); - - /** Switch rail 2 **/ - putDownSingleRail(world, x, y + 1, z + 2, l, x - 4, y + 1, z + 1, 4.5, typeVariantStraight, false, x - 1, y + 1, z + 2, true, false); - - /** Switch rail 3 **/ - putDownSingleRail(world, x, y + 1, z + 3, l, x - 4, y + 1, z + 1, 4.5, typeVariantStraight, false, x - 1, y + 1, z + 2, true, false); - - /** Put down straight exit **/ - putDownSingleRail(world, x, y + 1, z + 4, l, x, y + 1, z, 0, typeVariantStraight, false, x - 1, y + 1, z + 2, false, false); - - /** Put down straight exit **/ - putDownSingleRail(world, x, y + 1, z + 5, l, x, y + 1, z, 0, typeVariantStraight, true, x - 1, y + 1, z + 2, false, false); - - } - if (l == 1) { - /** Check if straight exit can be put down */ - if (!canPlaceTrack(player, world, x - 5, y + 1, z) || !canPlaceTrack(player, world, x - 4, y + 1, z) || !canPlaceTrack(player, world, x - 3, y + 1, z) || !canPlaceTrack(player, world, x - 2, y + 1, z) || !canPlaceTrack(player, world, x - 1, y + 1, z)) { - return false; - } - int[] xArray = { x - 2, x - 3, x - 3, x - 4, x - 4, x - 4, x - 5, x - 5, x - 5 }; - int[] zArray = { z - 1, z - 1, z - 2, z - 1, z - 2, z - 3, z - 2, z - 3, z - 4 }; - if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, true, 2, x - 5, z - 5, 4.5, x, y + 1, - z - 4, typeVariant90Turn, idVariantSwitch)) - return false; - TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x - 2, y + 1, z - 1); - if (tcRailTurn != null) - tcRailTurn.hasModel = false; - world.setBlockMetadataWithNotify(x - 2, y + 1, z - 1, l, 2);//to force client update - - /** Switch rail 1 */ - putDownSingleRail(world, x - 1, y + 1, z, l, x, y + 1, z - 4, 4.5, tempType.getLabel(), true, x - 2, y + 1, z - 1, true, false); - - /** Switch rail 2 **/ - putDownSingleRail(world, x - 2, y + 1, z, l, x, y + 1, z - 4, 4.5, typeVariantStraight, false, x - 2, y + 1, z - 1, true, false); - - /** Switch rail 3 **/ - putDownSingleRail(world, x - 3, y + 1, z, l, x, y + 1, z - 4, 4.5, typeVariantStraight, false, x - 2, y + 1, z - 1, true, false); - - /** Put down straight exit **/ - putDownSingleRail(world, x - 4, y + 1, z, l, x, y + 1, z, 0, typeVariantStraight, false, x - 2, y + 1, z - 1, false, false); - - /** Put down straight exit **/ - putDownSingleRail(world, x - 5, y + 1, z, l, x, y + 1, z, 0, typeVariantStraight, true, x - 2, y + 1, z - 1, false, false); - - } - if (l == 3) { - /** Check if straight exit can be put down */ - if (!canPlaceTrack(player, world, x + 5, y + 1, z) || !canPlaceTrack(player, world, x + 4, y + 1, z) || !canPlaceTrack(player, world, x + 3, y + 1, z) || !canPlaceTrack(player, world, x + 2, y + 1, z) || !canPlaceTrack(player, world, x + 1, y + 1, z)) { - return false; - } - int[] xArray = { x + 2, x + 3, x + 3, x + 4, x + 4, x + 4, x + 5, x + 5, x + 5 }; - int[] zArray = { z + 1, z + 1, z + 2, z + 1, z + 2, z + 3, z + 2, z + 3, z + 4 }; - if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, true, 0, x + 5, z + 5, 4.5, x + 1, y + 1, - z + 5, typeVariant90Turn, idVariantSwitch)) - return false; - - TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x + 2, y + 1, z + 1); - if (tcRailTurn != null) - tcRailTurn.hasModel = false; - world.setBlockMetadataWithNotify(x + 2, y + 1, z + 1, l, 2);//to force client update - - /** Switch rail 1 */ - putDownSingleRail(world, x + 1, y + 1, z, l, x + 1, y + 1, z + 5, 4.5, tempType.getLabel(), true, x + 2, y + 1, z + 1, true, false); - - /** Switch rail 2 **/ - putDownSingleRail(world, x + 2, y + 1, z, l, x + 1, y + 1, z + 5, 4.5, typeVariantStraight, false, x + 2, y + 1, z + 1, true, false); - - /** Switch rail 3 **/ - putDownSingleRail(world, x + 3, y + 1, z, l, x + 1, y + 1, z + 5, 4.5, typeVariantStraight, false, x + 2, y + 1, z + 1, true, false); - - /** Put down straight exit **/ - putDownSingleRail(world, x + 4, y + 1, z, l, x, y + 1, z, 0, typeVariantStraight, false, x + 2, y + 1, z + 1, false, false); - - /** Put down straight exit **/ - putDownSingleRail(world, x + 5, y + 1, z, l, x, y + 1, z, 0, typeVariantStraight, true, x + 2, y + 1, z + 1, false, false); - - } - - if (player ==null || !player.capabilities.isCreativeMode) { - --itemstack.stackSize; - } - return true; - } - - else if (tempType == TrackTypes.LARGE_LEFT_SWITCH || tempType == TrackTypes.EMBEDDED_LARGE_LEFT_SWITCH) { - switch (tempType){ - case LARGE_LEFT_SWITCH: - idVariantSwitch = ItemIDs.tcRailLargeSwitch.item; - typeVariant90Turn = TrackTypes.LARGE_LEFT_TURN.getLabel(); - typeVariantStraight = TrackTypes.SMALL_STRAIGHT.getLabel(); - break; - case EMBEDDED_LARGE_LEFT_SWITCH: - idVariantSwitch = ItemIDs.tcRailEmbeddedLargeSwitch.item; - typeVariant90Turn = TrackTypes.EMBEDDED_LARGE_LEFT_TURN.getLabel(); - typeVariantStraight = TrackTypes.EMBEDDED_SMALL_STRAIGHT.getLabel(); - break; - } - if (l == 2) { - /** Check if straight exit can be put down */ - if (!canPlaceTrack(player, world, x, y + 1, z - 5) || !canPlaceTrack(player, world, x, y + 1, z - 4) || !canPlaceTrack(player, world, x, y + 1, z - 3) || !canPlaceTrack(player, world, x, y + 1, z - 2) || !canPlaceTrack(player, world, x, y + 1, z - 1)) { - return false; - } - int[] xArray = { x - 1, x - 1, x - 2, x - 1, x - 2, x - 3, x - 4, x - 3, x - 2 }; - int[] zArray = { z - 2, z - 3, z - 3, z - 4, z - 4, z - 4, z - 5, z - 5, z - 5 }; - if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, true, 1, x - 5, z - 5, 4.5, x - 4, y + 1, - z, typeVariant90Turn, idVariantSwitch)) - return false; - TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x - 1, y + 1, z - 2); - if (tcRailTurn != null) - tcRailTurn.hasModel = false; - world.setBlockMetadataWithNotify(x - 1, y + 1, z - 2, l, 2);//to force client update - - /** Switch rail 1 */ - putDownSingleRail(world, x, y + 1, z - 1, l, x - 4, y + 1, z, 4.5, tempType.getLabel(), true, x - 1, y + 1, z - 2, true, false); - - /** Switch rail 2 **/ - putDownSingleRail(world, x, y + 1, z - 2, l, x - 4, y + 1, z, 4.5, typeVariantStraight, false, x - 1, y + 1, z - 2, true, false); - - /** Switch rail 3 **/ - putDownSingleRail(world, x, y + 1, z - 3, l, x - 4, y + 1, z, 4.5, typeVariantStraight, false, x - 1, y + 1, z - 2, true, false); - - /** Put down straight exit **/ - putDownSingleRail(world, x, y + 1, z - 4, l, x, y + 1, z, 0, typeVariantStraight, false, x - 1, y + 1, z - 2, false, false); - - /** Put down straight exit **/ - putDownSingleRail(world, x, y + 1, z - 5, l, x, y + 1, z, 0, typeVariantStraight, true, x - 1, y + 1, z - 2, false, false); - - } - if (l == 0) { - /** Check if straight exit can be put down */ - if (!canPlaceTrack(player, world, x, y + 1, z + 5) || !canPlaceTrack(player, world, x, y + 1, z + 4) || !canPlaceTrack(player, world, x, y + 1, z + 3) || !canPlaceTrack(player, world, x, y + 1, z + 2) || !canPlaceTrack(player, world, x, y + 1, z + 1)) { - return false; - } - int[] xArray = { x + 1, x + 1, x + 2, x + 1, x + 2, x + 3, x + 2, x + 3, x + 4 }; - int[] zArray = { z + 2, z + 3, z + 3, z + 4, z + 4, z + 4, z + 5, z + 5, z + 5 }; - if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, true, 1, x + 5, z + 5, 4.5, x + 5, y + 1, - z + 1, typeVariant90Turn, idVariantSwitch)) - return false; - - TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x + 1, y + 1, z + 2); - if (tcRailTurn != null) - tcRailTurn.hasModel = false; - world.setBlockMetadataWithNotify(x + 1, y + 1, z + 2, l, 2);//to force client update - - /** Switch rail 1 */ - putDownSingleRail(world, x, y + 1, z + 1, l, x + 5, y + 1, z + 1, 4.5, tempType.getLabel(), true, x + 1, y + 1, z + 2, true, false); - - /** Switch rail 2 **/ - putDownSingleRail(world, x, y + 1, z + 2, l, x + 5, y + 1, z + 1, 4.5, typeVariantStraight, false, x + 1, y + 1, z + 2, true, false); - - /** Switch rail 3 **/ - putDownSingleRail(world, x, y + 1, z + 3, l, x + 5, y + 1, z + 1, 4.5, typeVariantStraight, false, x + 1, y + 1, z + 2, true, false); - - /** Put down straight exit **/ - putDownSingleRail(world, x, y + 1, z + 4, l, x, y + 1, z, 0, typeVariantStraight, false, x + 1, y + 1, z + 2, false, false); - - /** Put down straight exit **/ - putDownSingleRail(world, x, y + 1, z + 5, l, x, y + 1, z, 0, typeVariantStraight, true, x + 1, y + 1, z + 2, false, false); - - } - if (l == 1) { - /** Check if straight exit can be put down */ - if (!canPlaceTrack(player, world, x - 5, y + 1, z) || !canPlaceTrack(player, world, x - 4, y + 1, z) || !canPlaceTrack(player, world, x - 3, y + 1, z) || !canPlaceTrack(player, world, x - 2, y + 1, z) || !canPlaceTrack(player, world, x - 1, y + 1, z)) { - return false; - } - int[] xArray = { x - 2, x - 3, x - 3, x - 4, x - 4, x - 4, x - 5, x - 5, x - 5 }; - int[] zArray = { z + 1, z + 1, z + 2, z + 1, z + 2, z + 3, z + 2, z + 3, z + 4 }; - if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, true, 2, x - 5, z + 5, 4.5, x, y + 1, - z + 5, typeVariant90Turn, idVariantSwitch)) - return false; - - TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x - 2, y + 1, z + 1); - if (tcRailTurn != null) - tcRailTurn.hasModel = false; - world.setBlockMetadataWithNotify(x - 2, y + 1, z + 1, l, 2);//to force client update - - /** Switch rail 1 */ - putDownSingleRail(world, x - 1, y + 1, z, l, x, y + 1, z + 5, 4.5, tempType.getLabel(), true, x - 2, y + 1, z + 1, true, false); - - /** Switch rail 2 **/ - putDownSingleRail(world, x - 2, y + 1, z, l, x, y + 1, z + 5, 4.5, typeVariantStraight, false, x - 2, y + 1, z + 1, true, false); - - /** Switch rail 3 **/ - putDownSingleRail(world, x - 3, y + 1, z, l, x, y + 1, z + 5, 4.5, typeVariantStraight, false, x - 2, y + 1, z + 1, true, false); - - /** Put down straight exit **/ - putDownSingleRail(world, x - 4, y + 1, z, l, x, y + 1, z, 0, typeVariantStraight, false, x - 2, y + 1, z + 1, false, false); - - /** Put down straight exit **/ - putDownSingleRail(world, x - 5, y + 1, z, l, x, y + 1, z, 0, typeVariantStraight, true, x - 2, y + 1, z + 1, false, false); - - } - if (l == 3) { - /** Check if straight exit can be put down */ - if (!canPlaceTrack(player, world, x + 5, y + 1, z) || !canPlaceTrack(player, world, x + 4, y + 1, z) || !canPlaceTrack(player, world, x + 3, y + 1, z) || !canPlaceTrack(player, world, x + 2, y + 1, z) || !canPlaceTrack(player, world, x + 1, y + 1, z)) { - return false; - } - int[] xArray = { x + 2, x + 3, x + 3, x + 4, x + 4, x + 4, x + 5, x + 5, x + 5 }; - int[] zArray = { z - 1, z - 1, z - 2, z - 1, z - 2, z - 3, z - 2, z - 3, z - 4 }; - if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, true, 0, x + 5, z - 5, 4.5, x + 1, y + 1, - z - 4, typeVariant90Turn, idVariantSwitch)) - return false; - - TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x + 2, y + 1, z - 1); - if (tcRailTurn != null) - tcRailTurn.hasModel = false; - world.setBlockMetadataWithNotify(x + 2, y + 1, z - 1, l, 2);//to force client update - - /** Switch rail 1 */ - putDownSingleRail(world, x + 1, y + 1, z, l, x + 1, y + 1, z - 4, 4.5, tempType.getLabel(), true, x + 2, y + 1, z - 1, true, false); - - /** Switch rail 2 **/ - putDownSingleRail(world, x + 2, y + 1, z, l, x + 1, y + 1, z - 4, 4.5, typeVariantStraight, false, x + 2, y + 1, z - 1, true, false); - - /** Switch rail 3 **/ - putDownSingleRail(world, x + 3, y + 1, z, l, x + 1, y + 1, z - 4, 4.5, typeVariantStraight, false, x + 2, y + 1, z - 1, true, false); - - /** Put down straight exit **/ - putDownSingleRail(world, x + 4, y + 1, z, l, x, y + 1, z, 0, typeVariantStraight, true, x + 2, y + 1, z - 1, false, false); - - /** Put down straight exit **/ - putDownSingleRail(world, x + 5, y + 1, z, l, x, y + 1, z, 0, typeVariantStraight, - true, x + 2, y + 1, z - 1, false, false); - - } - if (player ==null || !player.capabilities.isCreativeMode) { - --itemstack.stackSize; - } - return true; - } - - else if (tempType == TrackTypes.MEDIUM_RIGHT_PARALLEL_SWITCH || tempType == TrackTypes.EMBEDDED_MEDIUM_RIGHT_PARALLEL_SWITCH) { - switch (tempType){ - case MEDIUM_RIGHT_PARALLEL_SWITCH: - typeVariantStraight = TrackTypes.SMALL_STRAIGHT.getLabel(); - idVariantSwitch = ItemIDs.tcRailMediumParallelSwitch.item; - break; - case EMBEDDED_MEDIUM_RIGHT_PARALLEL_SWITCH: - typeVariantStraight = TrackTypes.EMBEDDED_SMALL_STRAIGHT.getLabel(); - idVariantSwitch = ItemIDs.tcRailEmbeddedMediumParallelSwitch.item; - break; - } - - if (l == 2) { - if (!parallelRightSwitchNorth(player, world, x, y, z, l, tempType, typeVariantStraight, idVariantSwitch)) - return false; - } - if (l == 0) { - if (!parallelRightSwitchSouth(player, world, x, y, z, l, tempType, typeVariantStraight, idVariantSwitch)) - return false; - } - if (l == 1) { - if (!parallelRightSwitchWest(player, world, x, y, z, l, tempType, typeVariantStraight, idVariantSwitch)) - return false; - } - if (l == 3) { - if (!parallelRightSwitchEast(player, world, x, y, z, l, tempType, typeVariantStraight, idVariantSwitch)) - return false; - } - if (player ==null || !player.capabilities.isCreativeMode) { - --itemstack.stackSize; - } - return true; - } - - else if (tempType == TrackTypes.MEDIUM_LEFT_PARALLEL_SWITCH || tempType == TrackTypes.EMBEDDED_MEDIUM_LEFT_PARALLEL_SWITCH) { - switch (tempType) { - case MEDIUM_LEFT_PARALLEL_SWITCH: - typeVariantStraight = TrackTypes.SMALL_STRAIGHT.getLabel(); - idVariantSwitch = ItemIDs.tcRailMediumParallelSwitch.item; - break; - case EMBEDDED_MEDIUM_LEFT_PARALLEL_SWITCH: - typeVariantStraight = TrackTypes.EMBEDDED_SMALL_STRAIGHT.getLabel(); - idVariantSwitch = ItemIDs.tcRailEmbeddedMediumParallelSwitch.item; - break; - } - if (l == 2) { - if (!parallelLeftSwitchNorth(player, world, x, y, z, l, tempType, typeVariantStraight, idVariantSwitch)) - return false; - } - if (l == 0) { - if (!parallelLeftSwitchSouth(player, world, x, y, z, l, tempType, typeVariantStraight, idVariantSwitch)) - return false; - } - if (l == 1) { - if (!parallelLeftSwitchWest(player, world, x, y, z, l, tempType, typeVariantStraight, idVariantSwitch)) - return false; - } - if (l == 3) { - if (!parallelLeftSwitchEast(player, world, x, y, z, l, tempType, typeVariantStraight, idVariantSwitch)) - return false; - } - if (player ==null || !player.capabilities.isCreativeMode) { - --itemstack.stackSize; - } - return true; - } - - else if (tempType == TrackTypes.MEDIUM_RIGHT_TURN || tempType == TrackTypes.EMBEDDED_MEDIUM_RIGHT_TURN) { - - if (!mediumRightTurn(player, world, x, y, z, l, tempType)){ - return false; - } - - if (player==null || !player.capabilities.isCreativeMode) { - --itemstack.stackSize; - } - return true; - } - - else if (tempType == TrackTypes.MEDIUM_LEFT_TURN || tempType == TrackTypes.EMBEDDED_MEDIUM_LEFT_TURN) { - - if (!mediumLeftTurn(player, world, x, y, z, l, tempType)){ - return false; - } - - if (player==null || !player.capabilities.isCreativeMode) { - --itemstack.stackSize; - } - return true; - } - - else if (tempType == TrackTypes.LARGE_RIGHT_TURN || tempType == TrackTypes.EMBEDDED_LARGE_RIGHT_TURN) { - - if (!largeRightTurn(player, world, x, y, z, l, tempType)){ - return false; - } - if (player ==null || !player.capabilities.isCreativeMode) { - --itemstack.stackSize; - } - return true; - } - - else if (tempType == TrackTypes.LARGE_LEFT_TURN || tempType == TrackTypes.EMBEDDED_LARGE_LEFT_TURN) { - - if (!largeLeftTurn(player, world, x, y, z, l, tempType)){ - return false; - } - - if (player ==null || !player.capabilities.isCreativeMode) { - --itemstack.stackSize; - } - return true; - } - - else if (tempType == TrackTypes.VERY_LARGE_RIGHT_TURN || tempType == TrackTypes.EMBEDDED_VERY_LARGE_RIGHT_TURN) { - - if (!veryLargeRightTurn(player, world, x, y, z, l, tempType)){ - return false; - } - - if (player ==null || !player.capabilities.isCreativeMode) { - --itemstack.stackSize; - } - return true; - } - - else if (tempType == TrackTypes.VERY_LARGE_LEFT_TURN || tempType == TrackTypes.EMBEDDED_VERY_LARGE_LEFT_TURN) { - - if (!veryLargeLeftTurn(player, world, x, y, z, l, tempType)){ - return false; - } - - if (player ==null || !player.capabilities.isCreativeMode) { - --itemstack.stackSize; - } - return true; - } - - else if (tempType == TrackTypes.SUPER_LARGE_RIGHT_TURN || tempType == TrackTypes.EMBEDDED_SUPER_LARGE_RIGHT_TURN) { - - if (!superLargeRightTurn(player, world, x, y, z, l, tempType)){ - return false; - } - - if (player ==null || !player.capabilities.isCreativeMode) { - --itemstack.stackSize; - } - return true; - } - - else if (tempType == TrackTypes.SUPER_LARGE_LEFT_TURN || tempType == TrackTypes.EMBEDDED_SUPER_LARGE_LEFT_TURN) { - - - if (!superLargeLeftTurn(player, world, x, y, z, l, tempType)){ - return false; - } - - if (player ==null || !player.capabilities.isCreativeMode) { - --itemstack.stackSize; - } - return true; - } - - else if (type == TrackTypes.SLOPE_WOOD || type == TrackTypes.SLOPE_GRAVEL || type == TrackTypes.SLOPE_BALLAST - || type == TrackTypes.SLOPE_SNOW_GRAVEL || type == TrackTypes.SLOPE_DYNAMIC || type == TrackTypes.EMBEDDED_SLOPE_DYNAMIC - || type == TrackTypes.LARGE_SLOPE_WOOD || type == TrackTypes.LARGE_SLOPE_GRAVEL - || type == TrackTypes.LARGE_SLOPE_BALLAST || type == TrackTypes.LARGE_SLOPE_SNOW_GRAVEL - || type == TrackTypes.LARGE_SLOPE_DYNAMIC || type == TrackTypes.EMBEDDED_LARGE_SLOPE_DYNAMIC - || type == TrackTypes.VERY_LARGE_SLOPE_WOOD || type == TrackTypes.VERY_LARGE_SLOPE_GRAVEL - || type == TrackTypes.VERY_LARGE_SLOPE_BALLAST || type == TrackTypes.VERY_LARGE_SLOPE_SNOW_GRAVEL - || type == TrackTypes.VERY_LARGE_SLOPE_DYNAMIC || type == TrackTypes.EMBEDDED_VERY_LARGE_SLOPE_DYNAMIC - ) { - if (!canPlaceTrack(player, world, x, y + 1, z)) { - return false; - } - if ( type.getLabel().contains("DYNAMIC") && world.getBlock(x, y, z) == BlockIDs.bridgePillar.block){ - return false; - } - - - int gagEnd = 0; - double slopeAngle = 0; - /** - * Explanation: normally you would devide 100 by (gagEnd+1) but this seems to be - * against TCs own brain. you need to devide 100 by (gagEnd+1) - **/ - if (type == TrackTypes.SLOPE_WOOD || type == TrackTypes.SLOPE_GRAVEL - || type == TrackTypes.SLOPE_BALLAST || type == TrackTypes.SLOPE_SNOW_GRAVEL - || type == TrackTypes.SLOPE_DYNAMIC || type == TrackTypes.EMBEDDED_SLOPE_DYNAMIC) { - gagEnd = 5; - slopeAngle = 0.13; - } - - if (type == TrackTypes.LARGE_SLOPE_WOOD || type == TrackTypes.LARGE_SLOPE_GRAVEL - || type == TrackTypes.LARGE_SLOPE_BALLAST || type == TrackTypes.LARGE_SLOPE_SNOW_GRAVEL - || type == TrackTypes.LARGE_SLOPE_DYNAMIC || type == TrackTypes.EMBEDDED_LARGE_SLOPE_DYNAMIC){ - gagEnd = 11; - slopeAngle = 0.0666; - } - - if (type == TrackTypes.VERY_LARGE_SLOPE_WOOD || type == TrackTypes.VERY_LARGE_SLOPE_GRAVEL - || type == TrackTypes.VERY_LARGE_SLOPE_BALLAST || type == TrackTypes.VERY_LARGE_SLOPE_SNOW_GRAVEL - || type == TrackTypes.VERY_LARGE_SLOPE_DYNAMIC || type == TrackTypes.EMBEDDED_VERY_LARGE_SLOPE_DYNAMIC) { - gagEnd = 17; - slopeAngle = 0.0444; - } - - - - - Item idDropped = this.type.getItem().item; - TileTCRailGag[] tileGag = new TileTCRailGag[gagEnd]; - - for (int i = 1; i <= gagEnd; i++) { - if (l == 2) { - if (!canPlaceTrack(player, world, x, y + 1, z - i)) { - return false; - } - } - if (l == 0) { - if (!canPlaceTrack(player, world, x, y + 1, z + i)) { - return false; - } - } - if (l == 1) { - if (!canPlaceTrack(player, world, x - i, y + 1, z)) { - return false; - } - } - if (l == 3) { - if (!canPlaceTrack(player, world, x + i, y + 1, z)) { - return false; - } - } - } - placeTrack(world,x, y + 1, z, BlockIDs.tcRail.block, l); - TileTCRail tcRail = (TileTCRail) world.getTileEntity(x, y + 1, z); - tcRail.setFacing(l); - tcRail.setType(type.getLabel()); - tcRail.idDrop = idDropped; - tcRail.slopeHeight = 1; - tcRail.slopeAngle = slopeAngle; - tcRail.slopeLength = gagEnd + 1; - - Block block = world.getBlock(x, y, z); - int blockID = Block.getIdFromBlock(block); - tcRail.setBallastMaterial(blockID); - tcRail.ballastMetadata = world.getBlockMetadata(x,y,z); - - - - - - - for (int i2 = 1; i2 <= gagEnd; i2++) { - if (l == 2) { - placeTrack(world,x, y + 1, z - i2, BlockIDs.tcRailGag.block, l); - tileGag[i2 - 1] = (TileTCRailGag) world.getTileEntity(x, y + 1, z - i2); - tileGag[i2 - 1].bbHeight = Math.max(0.125f, Math.min(1f, i2 / (float) gagEnd )); - } - if (l == 0) { - placeTrack(world,x, y + 1, z + i2, BlockIDs.tcRailGag.block, l); - tileGag[i2 - 1] = (TileTCRailGag) world.getTileEntity(x, y + 1, z + i2); - tileGag[i2 - 1].bbHeight = Math.max(0.125f, Math.min(1f, i2 / (float) gagEnd)); - } - if (l == 1) { - placeTrack(world,x - i2, y + 1, z, BlockIDs.tcRailGag.block, l); - tileGag[i2 - 1] = (TileTCRailGag) world.getTileEntity(x - i2, y + 1, z); - tileGag[i2 - 1].bbHeight = Math.max(0.125f, Math.min(1f, i2 / (float) gagEnd)); - } - if (l == 3) { - placeTrack(world,x + i2, y + 1, z, BlockIDs.tcRailGag.block, l); - tileGag[i2 - 1] = (TileTCRailGag) world.getTileEntity(x + i2, y + 1, z); - tileGag[i2 - 1].bbHeight = Math.max(0.125f, Math.min(1f, i2 / (float) gagEnd)); - } - } - for (int i = 0; i < tileGag.length; i++) { - if (player != null && tileGag[i] == null) { - player.addChatMessage(new ChatComponentText( - "There was a problem when placing the track. Possibly too many tracks around")); - return false; - } - tileGag[i].originX = x; - tileGag[i].originY = y + 1; - tileGag[i].originZ = z; - tileGag[i].type = type.getLabel(); - } - if (player ==null || !player.capabilities.isCreativeMode) { - --itemstack.stackSize; - } - return true; - - - - } - - - - - - else if (type == TrackTypes.TWO_WAYS_CROSSING || type == TrackTypes.EMBEDDED_TWO_WAYS_CROSSING) { - switch (type) { - case TWO_WAYS_CROSSING: - typeVariantStraight = TrackTypes.SMALL_STRAIGHT.getLabel(); - typeVariantCrossing = TrackTypes.TWO_WAYS_CROSSING.getLabel(); - break; - - case EMBEDDED_TWO_WAYS_CROSSING: - typeVariantStraight = TrackTypes.EMBEDDED_SMALL_STRAIGHT.getLabel(); - typeVariantCrossing = TrackTypes.EMBEDDED_TWO_WAYS_CROSSING.getLabel(); - break; - - - } - - - if (!canPlaceTrack(player, world, x, y + 1, z)) { - return false; - } - - int zDisplace = 0; - int xDisplace = 0; - int xSideDisplace = 0; - int zSideDisplace = 0; - int sideFacing = l; - - if (l == 2) { - zDisplace = -1; - xSideDisplace = 1; - sideFacing=1; - } - if (l == 3) { - xDisplace = 1; - zSideDisplace=1; - sideFacing=2; - } - if (l == 0) { - zDisplace = 1; - xSideDisplace = 1; - sideFacing = 1; - } - if (l == 1) { - xDisplace = -1; - zSideDisplace=1; - sideFacing=2; - } - - if (!canPlaceTrack(player, world, x + xDisplace, y + 1, z + zDisplace) || !canPlaceTrack(player, world, x + (xDisplace * 2), y + 1, z + (zDisplace * 2))) { - return false; - } - if (!canPlaceTrack(player, world, x + (xDisplace) + (xSideDisplace), y + 1, - z + (zDisplace) + (zSideDisplace))) { - return false; - } - if (!canPlaceTrack(player, world, x + (xDisplace) - (xSideDisplace), y + 1, - z + (zDisplace) - (zSideDisplace))) { - return false; - } - - /* - * Top - */ - - putDownSingleRail(world, x + (xDisplace * 2), y + 1, z + (zDisplace * 2), l, x + (xDisplace * 2), y + 1, - z + (zDisplace * 2), 0, typeVariantStraight, true, x + (xDisplace), y + 1, - z + (zDisplace), false, false); - - // putDownSingleRail(world, x+(xDisplace*4), y + 1, z+(zDisplace*4), l, - // x+(xDisplace*4) , y + 1, z+(zDisplace*4), 0, - // TrackTypes.SMALL_STRAIGHT.getLabel(), true, x+(xDisplace*3), y + 1, - // z+(zDisplace*3), false, false); - - //Main - - placeTrack(world,x + (xDisplace), y + 1, z + (zDisplace), BlockIDs.tcRail.block, l); - TileTCRail tcRail2 = (TileTCRail) world.getTileEntity(x + (xDisplace), y + 1, z + (zDisplace)); - tcRail2.setFacing(l); - tcRail2.cx = x + (xDisplace); - tcRail2.cy = y + 1; - tcRail2.cz = z + (zDisplace); - tcRail2.setType(typeVariantCrossing); - tcRail2.idDrop = this.type.getItem().item; - - /* - * Bottom - */ - - // putDownSingleRail(world, x + (xDisplace), y + 1, z + (zDisplace), l, x + - // (xDisplace), y + 1, - // z + (zDisplace), 0, TrackTypes.SMALL_STRAIGHT.getLabel(), true, x + - // (xDisplace * 2), y + 1, - // z + (zDisplace * 2), false, false); - - putDownSingleRail(world, x, y + 1, z, l, x, y + 1, z, 0, typeVariantStraight, true, - x + (xDisplace), y + 1, z + (zDisplace), false, false); - - /* - * Right - */ - - putDownSingleRail(world, x + (xDisplace) + (xSideDisplace), y + 1, - z + (zDisplace) + (zSideDisplace), sideFacing, - x + (xDisplace) + (xSideDisplace), y + 1, z + (zDisplace) + (zSideDisplace), 0, - typeVariantStraight, true, x + (xDisplace), y + 1, z + (zDisplace), - false, false); - - // putDownSingleRail(world, x + (xDisplace * 2) + (xSideDisplace * 2), y + 1, - // z + (zDisplace * 2) + (zSideDisplace * 2), sideFacing, - // x + (xDisplace * 2) + (xSideDisplace * 2), y + 1, z + (zDisplace * 2) + - // (zSideDisplace * 2), 0, - // TrackTypes.SMALL_STRAIGHT.getLabel(), true, x + (xDisplace * 2) + (xSideDisplace - //), y + 1, - // z + (zDisplace * 2) + (zSideDisplace), false, false); - - /* - * Left - */ - - putDownSingleRail(world, x + (xDisplace) - (xSideDisplace), y + 1, - z + (zDisplace) - (zSideDisplace), sideFacing, - x + (xDisplace) - (xSideDisplace), y + 1, z + (zDisplace) - (zSideDisplace), 0, - typeVariantStraight, true, x + (xDisplace), y + 1, z + (zDisplace), - false, false); + /** Parallel Curves */ + else if (type == TrackTypes.SMALL_PARALLEL_CURVE || type == TrackTypes.EMBEDDED_SMALL_PARALLEL_CURVE) + return new int[][]{{0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0}, {5, 0}, {2, 1}, {3, 1}, {4, 1}, {5, 1}, {6, 1}, {7, 1}}; + else if (type == TrackTypes.MEDIUM_PARALLEL_CURVE || type == TrackTypes.EMBEDDED_MEDIUM_PARALLEL_CURVE) + return new int[][]{{0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0}, {3, 1}, {4, 1}, {5, 1}, {6, 1}, {7, 1}, {8, 1}, {7, 2}, {8, 2}, {9, 2}, {10, 2}, {11, 2}}; + else if (type == TrackTypes.LARGE_PARALLEL_CURVE || type == TrackTypes.EMBEDDED_LARGE_PARALLEL_CURVE) + return new int[][]{{0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0}, {5, 0}, {4, 1}, {5, 1}, {6, 1}, {7, 1}, {8, 1}, {7, 2}, {8, 2}, {9, 2}, {10, 2}, {11, 2}, {10, 3}, {11, 3}, {12, 3}, {13, 3}, {14, 3}, {15, 3}}; + /**45 degree curves*/ + else if ((type == TrackTypes.MEDIUM_45DEGREE_TURN || type == TrackTypes.EMBEDDED_MEDIUM_45DEGREE_TURN) && !player.isSneaking()) + return new int[][]{{0, 0}, {1, 0}, {2, 0}, {1, 1}, {2, 1}, {3, 1}, {2, 2}}; + else if ((type == TrackTypes.LARGE_45DEGREE_TURN || type == TrackTypes.EMBEDDED_LARGE_45DEGREE_TURN) && !player.isSneaking()) + return new int[][]{{0, 0}, {1, 0}, {2, 0}, {3, 0}, {1, 1}, {2, 1}, {3, 1}, {4, 1}, {5, 1}, {4, 2}, {5, 2}, {6, 2}, {5, 3}}; + else if ((type == TrackTypes.VERY_LARGE_45DEGREE_TURN || type == TrackTypes.EMBEDDED_VERY_LARGE_45DEGREE_TURN) && !player.isSneaking()) + return new int[][]{{0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0}, {1, 1}, {2, 1}, {3, 1}, {4, 1}, {5, 1}, {6, 1}, {4, 2}, {5, 2}, {6, 2}, {7, 2}, {6, 3}, {7, 3}, {8, 3}, {7, 4}}; + else if ((type == TrackTypes.SUPER_LARGE_45DEGREE_TURN || type == TrackTypes.EMBEDDED_SUPER_LARGE_45DEGREE_TURN) && !player.isSneaking()) + return new int[][]{{0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0}, {5, 0}, {1, 1}, {2, 1}, {3, 1}, {4, 1}, {5, 1}, {6, 1}, {7, 1}, {5, 2}, {6, 2}, {7, 2}, {8, 2}, {9, 2}, {7, 3}, {8, 3}, {9, 3}, {10, 3}, {9, 4}, {10, 4}, {11, 4}, {10, 5}}; + else if ((type == TrackTypes.MEDIUM_45DEGREE_SWITCH || type == TrackTypes.EMBEDDED_MEDIUM_45DEGREE_SWITCH) && !player.isSneaking()) + return new int[][]{{0, 0}, {1, 0}, {2, 0}, {3, 0}, {2, 1}, {3, 1}, {4, 1}, {3, 2}}; + else if ((type == TrackTypes.MEDIUM_45DEGREE_TURN || type == TrackTypes.EMBEDDED_MEDIUM_45DEGREE_TURN) && player.isSneaking()) + return new int[][]{{0, 0}, {1, 0}, {2, 0}, {1, 1}, {2, 1}}; + else if ((type == TrackTypes.LARGE_45DEGREE_TURN || type == TrackTypes.EMBEDDED_LARGE_45DEGREE_TURN) && player.isSneaking()) + return new int[][]{{0, 0}, {1, 0}, {2, 0}, {3, 0}, {1, 1}, {2, 1}, {3, 1}, {4, 1}, {5, 1}, {4, 2}, {5, 2}}; + else if ((type == TrackTypes.VERY_LARGE_45DEGREE_TURN || type == TrackTypes.EMBEDDED_VERY_LARGE_45DEGREE_TURN) && player.isSneaking()) + return new int[][]{{0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0}, {1, 1}, {2, 1}, {3, 1}, {4, 1}, {5, 1}, {6, 1}, {4, 2}, {5, 2}, {6, 2}, {7, 2}, {6, 3}, {7, 3}}; + else if ((type == TrackTypes.SUPER_LARGE_45DEGREE_TURN || type == TrackTypes.EMBEDDED_SUPER_LARGE_45DEGREE_TURN) && player.isSneaking()) + return new int[][]{{0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0}, {5, 0}, {1, 1}, {2, 1}, {3, 1}, {4, 1}, {5, 1}, {6, 1}, {7, 1}, {5, 2}, {6, 2}, {7, 2}, {8, 2}, {9, 2}, {7, 3}, {8, 3}, {9, 3}, {10, 3}, {9, 4}, {10, 4}}; + else if ((type == TrackTypes.MEDIUM_45DEGREE_SWITCH || type == TrackTypes.EMBEDDED_MEDIUM_45DEGREE_SWITCH) && player.isSneaking()) + return new int[][]{{0, 0}, {1, 0}, {2, 0}, {3, 0}, {2, 1}, {3, 1}}; + else if (type == TrackTypes.LARGE_CURVED_SLOPE_DYNAMIC || type == TrackTypes.EMBEDDED_LARGE_CURVED_SLOPE_DYNAMIC) + return new int[][]{{0, 0}, {1, 0}, {1, 1}, {2, 0}, {2, 1}, {3, 1}, {2, 2}, {3, 2}, {3, 3}, {4, 3}, {4, 4}}; + else if (type == TrackTypes.VERY_LARGE_CURVED_SLOPE_DYNAMIC || type == TrackTypes.EMBEDDED_VERY_LARGE_CURVED_SLOPE_DYNAMIC) + return new int[][]{{0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0}, {2, 1}, {3, 1}, {4, 1}, {5, 1}, {4, 2}, {5, 2}, {6, 2}, {5, 3}, {6, 3}, {7, 3}, {6, 4}, {7, 4}, {7, 5}, {8, 5}, {7, 6}, {8, 7}, {8, 8}}; + else if (type == TrackTypes.SUPER_LARGE_CURVED_SLOPE_DYNAMIC || type == TrackTypes.EMBEDDED_SUPER_LARGE_CURVED_SLOPE_DYNAMIC) + return new int[][]{{0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0}, {5, 0}, {2, 1}, {3, 1}, {4, 1}, {5, 1}, {6, 1}, {7, 1}, {5, 2}, {6, 2}, {7, 2}, {8, 2}, {9, 2}, {8, 3}, {9, 3}, {10, 3}, {9, 4}, {10, 4}, {11, 4}, {10, 5}, {11, 5}, {12, 5}, {11, 6}, {12, 6}, {13, 6}, {12, 7}, {13, 7}, {12, 8}, {13, 8}, {14, 8}, {13, 9}, {14, 9}, {13, 10}, {14, 10}, {15, 10}, {14, 11}, {15, 11}, {14, 12}, {15, 12}, {14, 13}, {15, 13}, {15, 14}, {15, 15}}; + + else { + return null; + } + + } + + public boolean tryToPlaceTrack(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, boolean changeWorld) { + if (!(itemStack.getItem() instanceof ItemTCRail)) + return false; + + y = getPlacementHeight(world, x, y, z); + + ItemTCRail item = (ItemTCRail) itemStack.getItem(); + if (world.getBlock(x, y, z) == BlockIDs.bridgePillar.block && item.getTrackType().getLabel().contains("DYNAMIC")) { + return false; + } + int facing0 = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3; + Vector2f dir0 = ItemTCRail.getDirectionVector(facing0); + + float yaw = MathHelper.wrapAngleTo180_float(player.rotationYaw); + boolean isLeftTurn = item.getTrackOrientation(facing0, yaw).equals("left"); + int facing1 = isLeftTurn ? (facing0 + 4 - 1) % 4 : (facing0 + 1) % 4; + Vector2f dir1 = getDirectionVector(facing1); + + int[][] trackPositions = getUsedSpaceFromType(item.getTrackType(), player); + + if (trackPositions != null) { + + for (int[] pos : trackPositions) { + int dx = (int) (pos[0] * dir0.getX() + pos[1] * dir1.getX()); + int dz = (int) (pos[0] * dir0.getY() + pos[1] * dir1.getY()); + + if (!canPlaceTrack(player, world, x + dx, y + 1, z + dz)) + return false; + } + + return true; + } else { + return false; + } + } + + public int getPlacementHeight(World world, int x, int y, int z) { + if (canBeReplaced(world, x, y, z)) { + y--; + } + return y; + } + + /** + * changes the sign of an array and adds the current world pos to it + */ + public int[] flipArraySign(int[] array, int pos, boolean needsConverting) { + if (needsConverting) + for (int i = 0; i < array.length; i++) { + array[i] = (array[i] * -1) + pos; + } + else { + for (int i = 0; i < array.length; i++) { + array[i] = (array[i] + pos); + } + } + + return array; + } + + @Override + public boolean onItemUse(ItemStack itemstack, EntityPlayer player, World world, int x, int y, int z, int par7, float par8, float par9, float par10) { + if (!world.isRemote) { + + + y = getPlacementHeight(world, x, y, z); + int l; + + if (type.getType().equals(DIAGONAL)) { + l = MathHelper.floor_double((player != null ? player.rotationYaw : par10) * 4.0F / 360.0F) & 3; + l += 4; + } else { + l = MathHelper.floor_double((player != null ? player.rotationYaw : par10) * 4.0F / 360.0F + 0.5D) & 3; + } + + tempType = getPlacementDirection(player, world, l, par10); + + + /** This code below actually places the stuff + * l = direction + * l = 0 = south + * l = 1 = west + * l = 2 = north + * l = 3 = east + * l = 4 = south-west + * l = 5 = north-west + * l = 6 = north-east + * l = 7 = south-east + **/ + + if (type == TrackTypes.SMALL_STRAIGHT || type == TrackTypes.EMBEDDED_SMALL_STRAIGHT || type == TrackTypes.SMALL_ROAD_CROSSING || type == TrackTypes.SMALL_ROAD_CROSSING_1 || type == TrackTypes.SMALL_ROAD_CROSSING_2) { + + if (!smallStraight(player, world, x, y, z, l, type)) + return false; + + if (player == null || !player.capabilities.isCreativeMode) { + --itemstack.stackSize; + } + return true; + } else if (type == TrackTypes.MEDIUM_STRAIGHT || type == TrackTypes.LONG_STRAIGHT || type == TrackTypes.VERY_LONG_STRAIGHT || + type == TrackTypes.EMBEDDED_MEDIUM_STRAIGHT || type == TrackTypes.EMBEDDED_LONG_STRAIGHT || type == TrackTypes.EMBEDDED_VERY_LONG_STRAIGHT) { + + if (!straight(player, world, x, y, z, l, type)) + return false; + + if (player == null || !player.capabilities.isCreativeMode) { + --itemstack.stackSize; + } + return true; + } else if (type == TrackTypes.SMALL_DIAGONAL_STRAIGHT || type == TrackTypes.EMBEDDED_SMALL_DIAGONAL_STRAIGHT) { + + + if (!smallDiagonalStraight(player, world, x, y, z, l, type)) { + return false; + } + + if (player == null || !player.capabilities.isCreativeMode) { + --itemstack.stackSize; + } + return true; + } else if (type == TrackTypes.MEDIUM_DIAGONAL_STRAIGHT || type == TrackTypes.LONG_DIAGONAL_STRAIGHT || type == TrackTypes.VERY_LONG_DIAGONAL_STRAIGHT || type == TrackTypes.EMBEDDED_MEDIUM_DIAGONAL_STRAIGHT || type == TrackTypes.EMBEDDED_LONG_DIAGONAL_STRAIGHT || type == TrackTypes.EMBEDDED_VERY_LONG_DIAGONAL_STRAIGHT) { + + if (!diagonalStraight(player, world, x, y, z, l, type)) { + + return false; + } + if (player == null || !player.capabilities.isCreativeMode) { + --itemstack.stackSize; + } + return true; + } else if (tempType == TrackTypes.MEDIUM_RIGHT_45DEGREE_TURN || tempType == TrackTypes.EMBEDDED_MEDIUM_RIGHT_45DEGREE_TURN) { + + if (!mediumRight45DegreeTurn(player, world, x, y, z, l, tempType)) { + return false; + } + + if (player == null || !player.capabilities.isCreativeMode) { + --itemstack.stackSize; + } + return true; + } else if (tempType == TrackTypes.MEDIUM_LEFT_45DEGREE_TURN || tempType == TrackTypes.EMBEDDED_MEDIUM_LEFT_45DEGREE_TURN) { + + if (!mediumLeft45DegreeTurn(player, world, x, y, z, l, tempType)) { + return false; + } + if (player == null || !player.capabilities.isCreativeMode) { + --itemstack.stackSize; + } + return true; + } else if (tempType == TrackTypes.LARGE_RIGHT_45DEGREE_TURN || tempType == TrackTypes.EMBEDDED_LARGE_RIGHT_45DEGREE_TURN) { + + if (!largeRight45DegreeTurn(player, world, x, y, z, l, tempType)) { + return false; + } + + if (player == null || !player.capabilities.isCreativeMode) { + --itemstack.stackSize; + } + return true; + } else if (tempType == TrackTypes.LARGE_LEFT_45DEGREE_TURN || tempType == TrackTypes.EMBEDDED_LARGE_LEFT_45DEGREE_TURN) { + + if (!largeLeft45DegreeTurn(player, world, x, y, z, l, tempType)) { + return false; + } + if (player == null || !player.capabilities.isCreativeMode) { + --itemstack.stackSize; + } + return true; + } else if (tempType == TrackTypes.VERY_LARGE_RIGHT_45DEGREE_TURN || tempType == TrackTypes.EMBEDDED_VERY_LARGE_RIGHT_45DEGREE_TURN) { + + if (!veryLargeRight45DegreeTurn(player, world, x, y, z, l, tempType)) { + return false; + } + if (player == null || !player.capabilities.isCreativeMode) { + --itemstack.stackSize; + } + return true; + } else if (tempType == TrackTypes.VERY_LARGE_LEFT_45DEGREE_TURN || tempType == TrackTypes.EMBEDDED_VERY_LARGE_LEFT_45DEGREE_TURN) { + + if (!veryLargeLeft45DegreeTurn(player, world, x, y, z, l, tempType)) { + return false; + } + if (player == null || !player.capabilities.isCreativeMode) { + --itemstack.stackSize; + } + return true; + } else if (tempType == TrackTypes.SUPER_LARGE_RIGHT_45DEGREE_TURN || tempType == TrackTypes.EMBEDDED_SUPER_LARGE_RIGHT_45DEGREE_TURN) { + + if (!superLargeRight45DegreeTurn(player, world, x, y, z, l, tempType)) { + return false; + } + if (player == null || !player.capabilities.isCreativeMode) { + --itemstack.stackSize; + } + return true; + } else if (tempType == TrackTypes.SUPER_LARGE_LEFT_45DEGREE_TURN || tempType == TrackTypes.EMBEDDED_SUPER_LARGE_LEFT_45DEGREE_TURN) { + + if (!superLargeLeft45DegreeTurn(player, world, x, y, z, l, tempType)) { + return false; + } + if (player == null || !player.capabilities.isCreativeMode) { + --itemstack.stackSize; + } + return true; + } else if (tempType == TrackTypes.LARGE_RIGHT_CURVED_SLOPE_DYNAMIC || tempType == TrackTypes.EMBEDDED_LARGE_RIGHT_CURVED_SLOPE_DYNAMIC) { + if (!largeRightCurvedSlope(player, world, x, y, z, l, tempType)) { + return false; + } + if (player == null || !player.capabilities.isCreativeMode) { + --itemstack.stackSize; + } + return true; + } else if (tempType == TrackTypes.LARGE_LEFT_CURVED_SLOPE_DYNAMIC || tempType == TrackTypes.EMBEDDED_LARGE_LEFT_CURVED_SLOPE_DYNAMIC) { + if (!largeLeftCurvedSlope(player, world, x, y, z, l, tempType)) { + return false; + } + if (player == null || !player.capabilities.isCreativeMode) { + --itemstack.stackSize; + } + return true; + } else if (tempType == TrackTypes.VERY_LARGE_RIGHT_CURVED_SLOPE_DYNAMIC || tempType == TrackTypes.EMBEDDED_VERY_LARGE_RIGHT_CURVED_SLOPE_DYNAMIC) { + if (!veryLargeRightCurvedSlope(player, world, x, y, z, l, tempType)) { + return false; + } + if (player == null || !player.capabilities.isCreativeMode) { + --itemstack.stackSize; + } + return true; + } else if (tempType == TrackTypes.VERY_LARGE_LEFT_CURVED_SLOPE_DYNAMIC || tempType == TrackTypes.EMBEDDED_VERY_LARGE_LEFT_CURVED_SLOPE_DYNAMIC) { + if (!veryLargeLeftCurvedSlope(player, world, x, y, z, l, tempType)) { + return false; + } + if (player == null || !player.capabilities.isCreativeMode) { + --itemstack.stackSize; + } + return true; + } else if (tempType == TrackTypes.SUPER_LARGE_RIGHT_CURVED_SLOPE_DYNAMIC || tempType == TrackTypes.EMBEDDED_SUPER_LARGE_RIGHT_CURVED_SLOPE_DYNAMIC) { + if (!superLargeRightCurvedSlope(player, world, x, y, z, l, tempType)) { + return false; + } + if (player == null || !player.capabilities.isCreativeMode) { + --itemstack.stackSize; + } + return true; + } else if (tempType == TrackTypes.SUPER_LARGE_LEFT_CURVED_SLOPE_DYNAMIC || tempType == TrackTypes.EMBEDDED_SUPER_LARGE_LEFT_CURVED_SLOPE_DYNAMIC) { + if (!superLargeLeftCurvedSlope(player, world, x, y, z, l, tempType)) { + return false; + } + if (player == null || !player.capabilities.isCreativeMode) { + --itemstack.stackSize; + } + return true; + } else if (tempType == TrackTypes.SMALL_RIGHT_PARALLEL_CURVE || tempType == TrackTypes.EMBEDDED_SMALL_RIGHT_PARALLEL_CURVE) { + if (!smallRightParallelCurve(player, world, x, y, z, l, tempType)) { + return false; + } + if (player == null || !player.capabilities.isCreativeMode) { + --itemstack.stackSize; + } + return true; + } else if (tempType == TrackTypes.SMALL_LEFT_PARALLEL_CURVE || tempType == TrackTypes.EMBEDDED_SMALL_LEFT_PARALLEL_CURVE) { + if (!smallLeftParallelCurve(player, world, x, y, z, l, tempType)) { + return false; + } + if (player == null || !player.capabilities.isCreativeMode) { + --itemstack.stackSize; + } + return true; + } else if (tempType == TrackTypes.RIGHT_DIAMOND_CROSSING || tempType == TrackTypes.EMBEDDED_RIGHT_DIAMOND_CROSSING) { + if (!rightDiamondCrossing(player, world, x, y, z, l, tempType)) { + return false; + } + if (player == null || !player.capabilities.isCreativeMode) { + --itemstack.stackSize; + } + return true; + } else if (tempType == TrackTypes.LEFT_DIAMOND_CROSSING || tempType == TrackTypes.EMBEDDED_LEFT_DIAMOND_CROSSING) { + if (!leftDiamondCrossing(player, world, x, y, z, l, tempType)) { + return false; + } + if (player == null || !player.capabilities.isCreativeMode) { + --itemstack.stackSize; + } + return true; + } else if (type == TrackTypes.DOUBLE_DIAMOND_CROSSING || type == TrackTypes.EMBEDDED_DOUBLE_DIAMOND_CROSSING) { + if (!doubleDiamondCrossing(player, world, x, y, z, l, type)) { + return false; + } + if (player == null || !player.capabilities.isCreativeMode) { + --itemstack.stackSize; + } + return true; + } else if (type == TrackTypes.DIAGONAL_TWO_WAYS_CROSSING || type == TrackTypes.EMBEDDED_DIAGONAL_TWO_WAYS_CROSSING) { + if (!diagonalTwoWaysCrossing(player, world, x, y, z, l, type)) { + return false; + } + if (player == null || !player.capabilities.isCreativeMode) { + --itemstack.stackSize; + } + return true; + } else if (type == TrackTypes.FOUR_WAYS_CROSSING || type == TrackTypes.EMBEDDED_FOUR_WAYS_CROSSING) { + if (!fourWaysCrossing(player, world, x, y, z, l, type)) { + return false; + } + if (player == null || !player.capabilities.isCreativeMode) { + --itemstack.stackSize; + } + return true; + } else if (tempType == TrackTypes.MEDIUM_RIGHT_PARALLEL_CURVE || tempType == TrackTypes.EMBEDDED_MEDIUM_RIGHT_PARALLEL_CURVE) { + + if (!mediumRightParallelCurve(player, world, x, y, z, l, tempType)) { + return false; + } + if (player == null || !player.capabilities.isCreativeMode) { + --itemstack.stackSize; + } + return true; + + + } else if (tempType == TrackTypes.MEDIUM_LEFT_PARALLEL_CURVE || tempType == TrackTypes.EMBEDDED_MEDIUM_LEFT_PARALLEL_CURVE) { + + + if (!mediumLeftParallelCurve(player, world, x, y, z, l, tempType)) { + return false; + } + if (player == null || !player.capabilities.isCreativeMode) { + --itemstack.stackSize; + } + return true; + + } else if (tempType == TrackTypes.LARGE_RIGHT_PARALLEL_CURVE || tempType == TrackTypes.EMBEDDED_LARGE_RIGHT_PARALLEL_CURVE) { + + if (!largeRightParallelCurve(player, world, x, y, z, l, tempType)) { + return false; + } + if (player == null || !player.capabilities.isCreativeMode) { + --itemstack.stackSize; + } + return true; + } else if (tempType == TrackTypes.LARGE_LEFT_PARALLEL_CURVE || tempType == TrackTypes.EMBEDDED_LARGE_LEFT_PARALLEL_CURVE) { + + if (!largeLeftParallelCurve(player, world, x, y, z, l, tempType)) { + return false; + } + + if (player == null || !player.capabilities.isCreativeMode) { + --itemstack.stackSize; + } + return true; + + } else if (tempType == TrackTypes.MEDIUM_RIGHT_45DEGREE_SWITCH || tempType == TrackTypes.EMBEDDED_MEDIUM_RIGHT_45DEGREE_SWITCH) { + switch (tempType) { + case MEDIUM_RIGHT_45DEGREE_SWITCH: + typeVariantStraight = TrackTypes.SMALL_STRAIGHT.getLabel(); + typeVariant90Turn = TrackTypes.MEDIUM_RIGHT_TURN.getLabel(); + idVariantSwitch = ItemIDs.tcRailMedium45DegreeSwitch.item; + break; + case EMBEDDED_MEDIUM_RIGHT_45DEGREE_SWITCH: + typeVariantStraight = TrackTypes.EMBEDDED_SMALL_STRAIGHT.getLabel(); + typeVariant90Turn = TrackTypes.EMBEDDED_MEDIUM_RIGHT_TURN.getLabel(); + idVariantSwitch = ItemIDs.tcRailEmbeddedMedium45DegreeSwitch.item; + break; + } + + if (player.isSneaking()) { + if (l == 2) { + int[] xArray = {x + 1, x + 1}; + int[] zArray = {z - 2, z - 3}; + if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, false, 3, x + 1, z - 3, 3.75, x + 4.25, y + 1, + z, typeVariant90Turn, idVariantSwitch)) + return false; + TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x + 1, y + 1, z - 2); + if (tcRailTurn != null) { + tcRailTurn.hasModel = false; + } + + world.setBlockMetadataWithNotify(x + 1, y + 1, z - 2, l, 2);//to force client update + /** Switch rail 1 **/ + putDownSingleRail(world, x, y + 1, z - 1, l, x + 4.25, y + 1, z, 3.75, tempType.getLabel(), true, x + 1, y + 1, z - 2, true, false); + /** Switch rail 2 **/ + putDownSingleRail(world, x, y + 1, z - 2, l, x + 4.25, y + 1, z, 3.75, typeVariantStraight, false, x + 1, y + 1, z - 2, true, false); + /** Put down straight exit **/ + putDownSingleRail(world, x, y + 1, z - 3, l, x, y + 1, z, 0, typeVariantStraight, false, x + 1, y + 1, z - 2, false, false); + } + + if (l == 0) { + int[] xArray = {x - 1, x - 1}; + int[] zArray = {z + 2, z + 3}; + if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, false, 1, x - 1, z + 3, 3.75, x - 3.25, y + 1, + z + 1, typeVariant90Turn, idVariantSwitch)) + return false; + TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x - 1, y + 1, z + 2); + if (tcRailTurn != null) { + tcRailTurn.hasModel = false; + } + + world.setBlockMetadataWithNotify(x - 1, y + 1, z + 2, l, 2);//to force client update + /** Switch rail 1 **/ + putDownSingleRail(world, x, y + 1, z + 1, l, x - 3.25, y + 1, z + 1, 3.75, tempType.getLabel(), true, x - 1, y + 1, z + 2, true, false); + /** Switch rail 2 **/ + putDownSingleRail(world, x, y + 1, z + 2, l, x - 3.25, y + 1, z + 1, 3.75, typeVariantStraight, false, x - 1, y + 1, z + 2, true, false); + /** Put down straight exit **/ + putDownSingleRail(world, x, y + 1, z + 3, l, x, y + 1, z, 0, typeVariantStraight, false, x - 1, y + 1, z + 2, false, false); + } + if (l == 1) { + int[] xArray = {x - 2, x - 3}; + int[] zArray = {z - 1, z - 1}; + if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, false, 2, x - 3, z - 1, 3.75, x, y + 1, + z - 3.25, typeVariant90Turn, idVariantSwitch)) + return false; + TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x - 2, y + 1, z - 1); + if (tcRailTurn != null) { + tcRailTurn.hasModel = false; + } + + world.setBlockMetadataWithNotify(x - 2, y + 1, z - 1, l, 2);//to force client update + /** Switch rail 1 **/ + putDownSingleRail(world, x - 1, y + 1, z, l, x, y + 1, z - 3.25, 3.75, tempType.getLabel(), true, x - 2, y + 1, z - 1, true, false); + /** Switch rail 2 **/ + putDownSingleRail(world, x - 2, y + 1, z, l, x, y + 1, z - 3.25, 3.75, typeVariantStraight, false, x - 2, y + 1, z - 1, true, false); + /** Put down straight exit **/ + putDownSingleRail(world, x - 3, y + 1, z, l, x, y + 1, z, 0, typeVariantStraight, false, x - 2, y + 1, z - 1, false, false); + } + if (l == 3) { + int[] xArray = {x + 2, x + 3}; + int[] zArray = {z + 1, z + 1}; + if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, false, 2, x + 3, z + 1, 3.75, x + 1, y + 1, + z + 4.25, typeVariant90Turn, idVariantSwitch)) + return false; + TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x + 2, y + 1, z + 1); + if (tcRailTurn != null) { + tcRailTurn.hasModel = false; + } + + world.setBlockMetadataWithNotify(x + 2, y + 1, z + 1, l, 2);//to force client update + /** Switch rail 1 **/ + putDownSingleRail(world, x + 1, y + 1, z, l, x + 1, y + 1, z + 4.25, 3.75, tempType.getLabel(), true, x + 2, y + 1, z + 1, true, false); + /** Switch rail 2 **/ + putDownSingleRail(world, x + 2, y + 1, z, l, x + 1, y + 1, z + 4.25, 3.75, typeVariantStraight, false, x + 2, y + 1, z + 1, true, false); + /** Put down straight exit **/ + putDownSingleRail(world, x + 3, y + 1, z, l, x + 1, y + 1, z, 0, typeVariantStraight, false, x + 2, y + 1, z + 1, false, false); + } + } else { + if (l == 2) { + int[] xArray = {x + 1, x + 1, x + 1, x + 2}; + int[] zArray = {z - 2, z - 3, z - 4, z - 3}; + if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, false, 3, x + 1, z - 3, 3.75, x + 4.25, y + 1, + z, typeVariant90Turn, idVariantSwitch)) + return false; + TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x + 1, y + 1, z - 2); + if (tcRailTurn != null) { + tcRailTurn.hasModel = false; + } + + world.setBlockMetadataWithNotify(x + 1, y + 1, z - 2, l, 2);//to force client update + /** Switch rail 1 **/ + putDownSingleRail(world, x, y + 1, z - 1, l, x + 4.25, y + 1, z, 3.75, tempType.getLabel(), true, x + 1, y + 1, z - 2, true, false); + /** Switch rail 2 **/ + putDownSingleRail(world, x, y + 1, z - 2, l, x + 4.25, y + 1, z, 3.75, typeVariantStraight, false, x + 1, y + 1, z - 2, true, false); + /** Put down straight exit **/ + putDownSingleRail(world, x, y + 1, z - 3, l, x, y + 1, z, 0, typeVariantStraight, false, x + 1, y + 1, z - 2, false, false); + } + + if (l == 0) { + int[] xArray = {x - 1, x - 1, x - 1, x - 2}; + int[] zArray = {z + 2, z + 3, z + 4, z + 3}; + if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, false, 1, x - 1, z + 3, 3.75, x - 3.25, y + 1, + z + 1, typeVariant90Turn, idVariantSwitch)) + return false; + TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x - 1, y + 1, z + 2); + if (tcRailTurn != null) { + tcRailTurn.hasModel = false; + } + + world.setBlockMetadataWithNotify(x - 1, y + 1, z + 2, l, 2);//to force client update + /** Switch rail 1 **/ + putDownSingleRail(world, x, y + 1, z + 1, l, x - 3.25, y + 1, z + 1, 3.75, tempType.getLabel(), true, x - 1, y + 1, z + 2, true, false); + /** Switch rail 2 **/ + putDownSingleRail(world, x, y + 1, z + 2, l, x - 3.25, y + 1, z + 1, 3.75, typeVariantStraight, false, x - 1, y + 1, z + 2, true, false); + /** Put down straight exit **/ + putDownSingleRail(world, x, y + 1, z + 3, l, x, y + 1, z, 0, typeVariantStraight, false, x - 1, y + 1, z + 2, false, false); + } + if (l == 1) { + int[] xArray = {x - 2, x - 3, x - 4, x - 3}; + int[] zArray = {z - 1, z - 1, z - 1, z - 2}; + if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, false, 2, x - 3, z - 1, 3.75, x, y + 1, + z - 3.25, typeVariant90Turn, idVariantSwitch)) + return false; + TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x - 2, y + 1, z - 1); + if (tcRailTurn != null) { + tcRailTurn.hasModel = false; + } + + world.setBlockMetadataWithNotify(x - 2, y + 1, z - 1, l, 2);//to force client update + /** Switch rail 1 **/ + putDownSingleRail(world, x - 1, y + 1, z, l, x, y + 1, z - 3.25, 3.75, tempType.getLabel(), true, x - 2, y + 1, z - 1, true, false); + /** Switch rail 2 **/ + putDownSingleRail(world, x - 2, y + 1, z, l, x, y + 1, z - 3.25, 3.75, typeVariantStraight, false, x - 2, y + 1, z - 1, true, false); + /** Put down straight exit **/ + putDownSingleRail(world, x - 3, y + 1, z, l, x, y + 1, z, 0, typeVariantStraight, false, x - 2, y + 1, z - 1, false, false); + } + if (l == 3) { + int[] xArray = {x + 2, x + 3, x + 4, x + 3}; + int[] zArray = {z + 1, z + 1, z + 1, z + 2}; + if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, false, 0, x + 3, z + 1, 3.75, x + 1, y + 1, + z + 4.25, typeVariant90Turn, idVariantSwitch)) + return false; + TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x + 2, y + 1, z + 1); + if (tcRailTurn != null) { + tcRailTurn.hasModel = false; + } + + world.setBlockMetadataWithNotify(x + 2, y + 1, z + 1, l, 2);//to force client update + /** Switch rail 1 **/ + putDownSingleRail(world, x + 1, y + 1, z, l, x + 1, y + 1, z + 4.25, 3.75, tempType.getLabel(), true, x + 2, y + 1, z + 1, true, false); + /** Switch rail 2 **/ + putDownSingleRail(world, x + 2, y + 1, z, l, x + 1, y + 1, z + 4.25, 3.75, typeVariantStraight, false, x + 2, y + 1, z + 1, true, false); + /** Put down straight exit **/ + putDownSingleRail(world, x + 3, y + 1, z, l, x + 1, y + 1, z, 0, typeVariantStraight, false, x + 2, y + 1, z + 1, false, false); + } + + } + + + if (player == null || !player.capabilities.isCreativeMode) { + --itemstack.stackSize; + } + return true; + } else if (tempType == TrackTypes.MEDIUM_LEFT_45DEGREE_SWITCH || tempType == TrackTypes.EMBEDDED_MEDIUM_LEFT_45DEGREE_SWITCH) { + switch (tempType) { + case MEDIUM_LEFT_45DEGREE_SWITCH: + typeVariantStraight = TrackTypes.SMALL_STRAIGHT.getLabel(); + typeVariant90Turn = TrackTypes.MEDIUM_LEFT_TURN.getLabel(); + idVariantSwitch = ItemIDs.tcRailMedium45DegreeSwitch.item; + break; + case EMBEDDED_MEDIUM_LEFT_45DEGREE_SWITCH: + typeVariantStraight = TrackTypes.EMBEDDED_SMALL_STRAIGHT.getLabel(); + typeVariant90Turn = TrackTypes.EMBEDDED_MEDIUM_LEFT_TURN.getLabel(); + idVariantSwitch = ItemIDs.tcRailEmbeddedMedium45DegreeSwitch.item; + break; + } + if (player.isSneaking()) { + if (l == 2) { + int[] xArray = {x - 1, x - 1}; + int[] zArray = {z - 2, z - 3}; + if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, false, 1, x - 1, z - 3, 3.75, x - 3.25, y + 1, + z, typeVariant90Turn, idVariantSwitch)) + return false; + TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x - 1, y + 1, z - 2); + if (tcRailTurn != null) { + tcRailTurn.hasModel = false; + } + + world.setBlockMetadataWithNotify(x - 1, y + 1, z - 2, l, 2);//to force client update + /** Switch rail 1 **/ + putDownSingleRail(world, x, y + 1, z - 1, l, x - 3.25, y + 1, z, 3.75, tempType.getLabel(), true, x - 1, y + 1, z - 2, true, false); + /** Switch rail 2 **/ + putDownSingleRail(world, x, y + 1, z - 2, l, x - 3.25, y + 1, z, 3.75, typeVariantStraight, false, x - 1, y + 1, z - 2, true, false); + /** Put down straight exit **/ + putDownSingleRail(world, x, y + 1, z - 3, l, x, y + 1, z, 0, typeVariantStraight, false, x - 1, y + 1, z - 2, false, false); + } + + if (l == 0) { + int[] xArray = {x + 1, x + 1}; + int[] zArray = {z + 2, z + 3}; + if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, false, 3, x + 1, z + 3, 3.75, x + 4.25, y + 1, + z + 1, typeVariant90Turn, idVariantSwitch)) + return false; + TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x + 1, y + 1, z + 2); + if (tcRailTurn != null) { + tcRailTurn.hasModel = false; + } + + world.setBlockMetadataWithNotify(x + 1, y + 1, z + 2, l, 2);//to force client update + /** Switch rail 1 **/ + putDownSingleRail(world, x, y + 1, z + 1, l, x + 4.25, y + 1, z + 1, 3.75, tempType.getLabel(), true, x + 1, y + 1, z + 2, true, false); + /** Switch rail 2 **/ + putDownSingleRail(world, x, y + 1, z + 2, l, x + 4.25, y + 1, z + 1, 3.75, typeVariantStraight, false, x + 1, y + 1, z + 2, true, false); + /** Put down straight exit **/ + putDownSingleRail(world, x, y + 1, z + 3, l, x, y + 1, z, 0, typeVariantStraight, false, x + 1, y + 1, z + 2, false, false); + } + if (l == 1) { + int[] xArray = {x - 2, x - 3}; + int[] zArray = {z + 1, z + 1}; + if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, false, 0, x - 3, z + 1, 3.75, x, y + 1, + z + 4.25, typeVariant90Turn, idVariantSwitch)) + return false; + TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x - 2, y + 1, z + 1); + if (tcRailTurn != null) { + tcRailTurn.hasModel = false; + } + + world.setBlockMetadataWithNotify(x - 2, y + 1, z + 1, l, 2);//to force client update + /** Switch rail 1 **/ + putDownSingleRail(world, x - 1, y + 1, z, l, x, y + 1, z + 4.25, 3.75, tempType.getLabel(), true, x - 2, y + 1, z + 1, true, false); + /** Switch rail 2 **/ + putDownSingleRail(world, x - 2, y + 1, z, l, x, y + 1, z + 4.25, 3.75, typeVariantStraight, false, x - 2, y + 1, z + 1, true, false); + /** Put down straight exit **/ + putDownSingleRail(world, x - 3, y + 1, z, l, x, y + 1, z, 0, typeVariantStraight, false, x - 2, y + 1, z + 1, false, false); + } + if (l == 3) { + int[] xArray = {x + 2, x + 3}; + int[] zArray = {z - 1, z - 1}; + if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, false, 2, x + 3, z - 1, 3.75, x + 1, y + 1, + z - 3.25, typeVariant90Turn, idVariantSwitch)) + return false; + TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x + 2, y + 1, z - 1); + if (tcRailTurn != null) { + tcRailTurn.hasModel = false; + } + + world.setBlockMetadataWithNotify(x + 2, y + 1, z + 1, l, 2);//to force client update + /** Switch rail 1 **/ + putDownSingleRail(world, x + 1, y + 1, z, l, x + 1, y + 1, z - 3.25, 3.75, tempType.getLabel(), true, x + 2, y + 1, z - 1, true, false); + /** Switch rail 2 **/ + putDownSingleRail(world, x + 2, y + 1, z, l, x + 1, y + 1, z - 3.25, 3.75, typeVariantStraight, false, x + 2, y + 1, z - 1, true, false); + /** Put down straight exit **/ + putDownSingleRail(world, x + 3, y + 1, z, l, x + 1, y + 1, z, 0, typeVariantStraight, false, x + 2, y + 1, z - 1, false, false); + } + } else { + if (l == 2) { + int[] xArray = {x - 1, x - 1, x - 1, x - 2}; + int[] zArray = {z - 2, z - 3, z - 4, z - 3}; + if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, false, 1, x - 1, z - 3, 3.75, x - 3.25, y + 1, + z, typeVariant90Turn, idVariantSwitch)) + return false; + TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x - 1, y + 1, z - 2); + if (tcRailTurn != null) { + tcRailTurn.hasModel = false; + } + + world.setBlockMetadataWithNotify(x - 1, y + 1, z - 2, l, 2);//to force client update + /** Switch rail 1 **/ + putDownSingleRail(world, x, y + 1, z - 1, l, x - 3.25, y + 1, z, 3.75, tempType.getLabel(), true, x - 1, y + 1, z - 2, true, false); + /** Switch rail 2 **/ + putDownSingleRail(world, x, y + 1, z - 2, l, x - 3.25, y + 1, z, 3.75, typeVariantStraight, false, x - 1, y + 1, z - 2, true, false); + /** Put down straight exit **/ + putDownSingleRail(world, x, y + 1, z - 3, l, x, y + 1, z, 0, typeVariantStraight, false, x - 1, y + 1, z - 2, false, false); + } + + if (l == 0) { + int[] xArray = {x + 1, x + 1, x + 1, x + 2}; + int[] zArray = {z + 2, z + 3, z + 4, z + 3}; + if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, false, 3, x + 1, z + 3, 3.75, x + 4.25, y + 1, + z + 1, typeVariant90Turn, idVariantSwitch)) + return false; + TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x + 1, y + 1, z + 2); + if (tcRailTurn != null) { + tcRailTurn.hasModel = false; + } + + world.setBlockMetadataWithNotify(x + 1, y + 1, z + 2, l, 2);//to force client update + /** Switch rail 1 **/ + putDownSingleRail(world, x, y + 1, z + 1, l, x + 4.25, y + 1, z + 1, 3.75, tempType.getLabel(), true, x + 1, y + 1, z + 2, true, false); + /** Switch rail 2 **/ + putDownSingleRail(world, x, y + 1, z + 2, l, x + 4.25, y + 1, z + 1, 3.75, typeVariantStraight, false, x + 1, y + 1, z + 2, true, false); + /** Put down straight exit **/ + putDownSingleRail(world, x, y + 1, z + 3, l, x, y + 1, z, 0, typeVariantStraight, false, x + 1, y + 1, z + 2, false, false); + } + if (l == 1) { + int[] xArray = {x - 2, x - 3, x - 4, x - 3}; + int[] zArray = {z + 1, z + 1, z + 1, z + 2}; + if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, false, 0, x - 3, z + 1, 3.75, x, y + 1, + z + 4.25, typeVariant90Turn, idVariantSwitch)) + return false; + TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x - 2, y + 1, z + 1); + if (tcRailTurn != null) { + tcRailTurn.hasModel = false; + } + + world.setBlockMetadataWithNotify(x - 2, y + 1, z + 1, l, 2);//to force client update + /** Switch rail 1 **/ + putDownSingleRail(world, x - 1, y + 1, z, l, x, y + 1, z + 4.25, 3.75, tempType.getLabel(), true, x - 2, y + 1, z + 1, true, false); + /** Switch rail 2 **/ + putDownSingleRail(world, x - 2, y + 1, z, l, x, y + 1, z + 4.25, 3.75, typeVariantStraight, false, x - 2, y + 1, z + 1, true, false); + /** Put down straight exit **/ + putDownSingleRail(world, x - 3, y + 1, z, l, x, y + 1, z, 0, typeVariantStraight, false, x - 2, y + 1, z + 1, false, false); + } + if (l == 3) { + int[] xArray = {x + 2, x + 3, x + 4, x + 3}; + int[] zArray = {z - 1, z - 1, z - 1, z - 2}; + if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, false, 2, x + 3, z - 1, 3.75, x + 1, y + 1, + z - 3.25, typeVariant90Turn, idVariantSwitch)) + return false; + TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x + 2, y + 1, z - 1); + if (tcRailTurn != null) { + tcRailTurn.hasModel = false; + } + + world.setBlockMetadataWithNotify(x + 2, y + 1, z + 1, l, 2);//to force client update + /** Switch rail 1 **/ + putDownSingleRail(world, x + 1, y + 1, z, l, x + 1, y + 1, z - 3.25, 3.75, tempType.getLabel(), true, x + 2, y + 1, z - 1, true, false); + /** Switch rail 2 **/ + putDownSingleRail(world, x + 2, y + 1, z, l, x + 1, y + 1, z - 3.25, 3.75, typeVariantStraight, false, x + 2, y + 1, z - 1, true, false); + /** Put down straight exit **/ + putDownSingleRail(world, x + 3, y + 1, z, l, x + 1, y + 1, z, 0, typeVariantStraight, false, x + 2, y + 1, z - 1, false, false); + } + } + + + if (player == null || !player.capabilities.isCreativeMode) { + --itemstack.stackSize; + } + return true; + } else if (tempType == TrackTypes.MEDIUM_RIGHT_SWITCH || tempType == TrackTypes.EMBEDDED_MEDIUM_RIGHT_SWITCH) { + + switch (tempType) { + case MEDIUM_RIGHT_SWITCH: + idVariantSwitch = ItemIDs.tcRailMediumSwitch.item; + typeVariant90Turn = TrackTypes.MEDIUM_RIGHT_TURN.getLabel(); + typeVariantStraight = TrackTypes.SMALL_STRAIGHT.getLabel(); + break; + case EMBEDDED_MEDIUM_RIGHT_SWITCH: + idVariantSwitch = ItemIDs.tcRailEmbeddedMediumSwitch.item; + typeVariant90Turn = TrackTypes.EMBEDDED_MEDIUM_RIGHT_TURN.getLabel(); + typeVariantStraight = TrackTypes.EMBEDDED_SMALL_STRAIGHT.getLabel(); + break; + } + + + if (l == 2) { + /** Check if straight exit can be put down */ + if (!canPlaceTrack(player, world, x, y + 1, z - 3) || !canPlaceTrack(player, world, x, y + 1, z - 2) || !canPlaceTrack(player, world, x, y + 1, z - 1)) { + return false; + } + + int[] xArray = {x + 1, x + 1, x + 2}; + int[] zArray = {z - 2, z - 3, z - 3}; + if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, true, 1, x + 3, z - 3, 2.5, x + 3, y + 1, + z, typeVariant90Turn, idVariantSwitch)) + return false; + TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x + 1, y + 1, z - 2); + if (tcRailTurn != null) { + tcRailTurn.hasModel = false; + } + world.setBlockMetadataWithNotify(x + 1, y + 1, z - 2, l, 2);//to force client update + /** Switch rail 1 */ + putDownSingleRail(world, x, y + 1, z - 1, l, x + 3, y + 1, z, 2.5, tempType.getLabel(), true, x + 1, y + 1, z - 2, true, false); + + /** Switch rail 2 **/ + putDownSingleRail(world, x, y + 1, z - 2, l, x + 3, y + 1, z, 2.5, typeVariantStraight, false, x + 1, y + 1, z - 2, true, false); + + /** Put down straight exit **/ + putDownSingleRail(world, x, y + 1, z - 3, l, x, y + 1, z, 0, typeVariantStraight, true, x + 1, y + 1, z - 2, false, false); + } + if (l == 0) { + /** Check if straight exit can be put down */ + if (!canPlaceTrack(player, world, x, y + 1, z + 3) || !canPlaceTrack(player, world, x, y + 1, z + 2) || !canPlaceTrack(player, world, x, y + 1, z + 1)) { + return false; + } + + int[] xArray = {x - 1, x - 1, x - 2}; + int[] zArray = {z + 2, z + 3, z + 3}; + if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, true, 1, x - 3, z + 3, 2.5, x - 2, y + 1, + z + 1, typeVariant90Turn, idVariantSwitch)) + return false; + TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x - 1, y + 1, z + 2); + if (tcRailTurn != null) + tcRailTurn.hasModel = false; + world.setBlockMetadataWithNotify(x - 1, y + 1, z + 2, l, 2);//to force client update + + /** Switch rail 1 */ + putDownSingleRail(world, x, y + 1, z + 1, l, x - 2, y + 1, z + 1, 2.5, tempType.getLabel(), true, x - 1, y + 1, z + 2, true, false); + + /** Switch rail 2 **/ + putDownSingleRail(world, x, y + 1, z + 2, l, x - 2, y + 1, z + 1, 2.5, typeVariantStraight, false, x - 1, y + 1, z + 2, true, false); + + /** Put down straight exit **/ + putDownSingleRail(world, x, y + 1, z + 3, l, x, y + 1, z, 0, typeVariantStraight, true, x - 1, y + 1, z + 2, false, false); + + } + if (l == 1) { + /** Check if straight exit can be put down */ + if (!canPlaceTrack(player, world, x - 3, y + 1, z) || !canPlaceTrack(player, world, x - 2, y + 1, z) || !canPlaceTrack(player, world, x - 1, y + 1, z)) { + return false; + } + + int[] xArray = {x - 2, x - 3, x - 3}; + int[] zArray = {z - 1, z - 1, z - 2}; + if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, true, 2, x - 3, z - 3, 2.5, x, y + 1, + z - 2, typeVariant90Turn, idVariantSwitch)) + return false; + TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x - 2, y + 1, z - 1); + if (tcRailTurn != null) + tcRailTurn.hasModel = false; + world.setBlockMetadataWithNotify(x - 2, y + 1, z - 1, l, 2);//to force client update + + /** Switch rail 1 */ + putDownSingleRail(world, x - 1, y + 1, z, l, x, y + 1, z - 2, 2.5, tempType.getLabel(), true, x - 2, y + 1, z - 1, true, false); + + /** Switch rail 2 **/ + putDownSingleRail(world, x - 2, y + 1, z, l, x, y + 1, z - 2, 2.5, typeVariantStraight, false, x - 2, y + 1, z - 1, true, false); + + /** Put down straight exit **/ + putDownSingleRail(world, x - 3, y + 1, z, l, x, y + 1, z, 0, typeVariantStraight, true, x - 2, y + 1, z - 1, false, false); + + } + if (l == 3) { + /** Check if straight exit can be put down */ + if (!canPlaceTrack(player, world, x + 3, y + 1, z) || !canPlaceTrack(player, world, x + 2, y + 1, z) || !canPlaceTrack(player, world, x + 1, y + 1, z)) { + return false; + } + + int[] xArray = {x + 2, x + 3, x + 3}; + int[] zArray = {z + 1, z + 1, z + 2}; + if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, true, 0, x + 3, z + 3, 2.5, x + 1, y + 1, + z + 3, typeVariant90Turn, idVariantSwitch)) + return false; + TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x + 2, y + 1, z + 1); + if (tcRailTurn != null) + tcRailTurn.hasModel = false; + world.setBlockMetadataWithNotify(x + 2, y + 1, z + 1, l, 2);//to force client update + + /** Switch rail 1 */ + putDownSingleRail(world, x + 1, y + 1, z, l, x + 1, y + 1, z + 3, 2.5, tempType.getLabel(), true, x + 2, y + 1, z + 1, true, false); + + /** Switch rail 2 **/ + putDownSingleRail(world, x + 2, y + 1, z, l, x + 1, y + 1, z + 3, 2.5, typeVariantStraight, false, x + 2, y + 1, z + 1, true, false); + + /** Put down straight exit **/ + putDownSingleRail(world, x + 3, y + 1, z, l, x, y + 1, z, 0, typeVariantStraight, true, x + 2, y + 1, z + 1, false, false); + + } + + if (player == null || !player.capabilities.isCreativeMode) { + --itemstack.stackSize; + } + return true; + } else if (tempType == TrackTypes.MEDIUM_LEFT_SWITCH || tempType == TrackTypes.EMBEDDED_MEDIUM_LEFT_SWITCH) { + switch (tempType) { + case MEDIUM_LEFT_SWITCH: + idVariantSwitch = ItemIDs.tcRailMediumSwitch.item; + typeVariant90Turn = TrackTypes.MEDIUM_LEFT_TURN.getLabel(); + typeVariantStraight = TrackTypes.SMALL_STRAIGHT.getLabel(); + break; + case EMBEDDED_MEDIUM_LEFT_SWITCH: + idVariantSwitch = ItemIDs.tcRailEmbeddedMediumSwitch.item; + typeVariant90Turn = TrackTypes.EMBEDDED_MEDIUM_LEFT_TURN.getLabel(); + typeVariantStraight = TrackTypes.EMBEDDED_SMALL_STRAIGHT.getLabel(); + break; + } + if (l == 2) { + /** Check if straight exit can be put down */ + if (!canPlaceTrack(player, world, x, y + 1, z - 3) || !canPlaceTrack(player, world, x, y + 1, z - 2) || !canPlaceTrack(player, world, x, y + 1, z - 1)) { + return false; + } + + int[] xArray = {x - 1, x - 1, x - 2}; + int[] zArray = {z - 2, z - 3, z - 3}; + if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, true, 1, x - 3, z - 3, 2.5, x - 2, y + 1, + z, typeVariant90Turn, idVariantSwitch)) + return false; + TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x - 1, y + 1, z - 2); + if (tcRailTurn != null) { + tcRailTurn.hasModel = false; + } + world.setBlockMetadataWithNotify(x - 1, y + 1, z - 2, l, 2);//to force client update + + /** Switch rail 1 */ + putDownSingleRail(world, x, y + 1, z - 1, l, x - 2, y + 1, z, 2.5, tempType.getLabel(), true, x - 1, y + 1, z - 2, true, false); + + /** Switch rail 2 **/ + putDownSingleRail(world, x, y + 1, z - 2, l, x - 2, y + 1, z, 2.5, typeVariantStraight, false, x - 1, y + 1, z - 2, true, false); + + /** Put down straight exit **/ + putDownSingleRail(world, x, y + 1, z - 3, l, x, y + 1, z, 0, typeVariantStraight, true, x - 1, y + 1, z - 2, false, false); + + } + if (l == 0) { + /** Check if straight exit can be put down */ + if (!canPlaceTrack(player, world, x, y + 1, z + 3) || !canPlaceTrack(player, world, x, y + 1, z + 2) || !canPlaceTrack(player, world, x, y + 1, z + 1)) { + return false; + } + int[] xArray = {x + 1, x + 1, x + 2}; + int[] zArray = {z + 2, z + 3, z + 3}; + if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, true, 3, x + 3, z + 3, 2.5, x + 3, y + 1, + z + 1, typeVariant90Turn, idVariantSwitch)) + return false; + TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x + 1, y + 1, z + 2); + if (tcRailTurn != null) + tcRailTurn.hasModel = false; + world.setBlockMetadataWithNotify(x + 1, y + 1, z + 2, l, 2);//to force client update + + /** Switch rail 1 */ + putDownSingleRail(world, x, y + 1, z + 1, l, x + 3, y + 1, z + 1, 2.5, tempType.getLabel(), true, x + 1, y + 1, z + 2, true, false); + + /** Switch rail 2 **/ + putDownSingleRail(world, x, y + 1, z + 2, l, x + 3, y + 1, z + 1, 2.5, typeVariantStraight, false, x + 1, y + 1, z + 2, true, false); + + /** Put down straight exit **/ + putDownSingleRail(world, x, y + 1, z + 3, l, x, y + 1, z, 0, typeVariantStraight, true, x + 1, y + 1, z + 2, false, false); + + } + if (l == 1) { + /** Check if straight exit can be put down */ + if (!canPlaceTrack(player, world, x - 3, y + 1, z) || !canPlaceTrack(player, world, x - 2, y + 1, z) || !canPlaceTrack(player, world, x - 1, y + 1, z)) { + return false; + } + int[] xArray = {x - 2, x - 3, x - 3}; + int[] zArray = {z + 1, z + 1, z + 2}; + if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, true, 0, x - 3, z + 3, 2.5, x, y + 1, + z + 3, typeVariant90Turn, idVariantSwitch)) + return false; + + TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x - 2, y + 1, z + 1); + if (tcRailTurn != null) + tcRailTurn.hasModel = false; + world.setBlockMetadataWithNotify(x - 2, y + 1, z + 1, l, 2);//to force client update + + /** Switch rail 1 */ + putDownSingleRail(world, x - 1, y + 1, z, l, x, y + 1, z + 3, 2.5, tempType.getLabel(), true, x - 2, y + 1, z + 1, true, false); + + /** Switch rail 2 **/ + putDownSingleRail(world, x - 2, y + 1, z, l, x, y + 1, z + 3, 2.5, typeVariantStraight, false, x - 2, y + 1, z + 1, true, false); + + /** Put down straight exit **/ + putDownSingleRail(world, x - 3, y + 1, z, l, x, y + 1, z, 0, typeVariantStraight, true, x - 2, y + 1, z + 1, false, false); + + } + if (l == 3) { + /** Check if straight exit can be put down */ + if (!canPlaceTrack(player, world, x + 3, y + 1, z) || !canPlaceTrack(player, world, x + 2, y + 1, z) || !canPlaceTrack(player, world, x + 1, y + 1, z)) { + return false; + } + int[] xArray = {x + 2, x + 3, x + 3}; + int[] zArray = {z - 1, z - 1, z - 2}; + if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, true, 2, x + 3, z - 3, 2.5, x + 1, y + 1, + z - 2, typeVariant90Turn, idVariantSwitch)) + return false; + TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x + 2, y + 1, z - 1); + if (tcRailTurn != null) + tcRailTurn.hasModel = false; + world.setBlockMetadataWithNotify(x + 2, y + 1, z - 1, l, 2);//to force client update + + /** Switch rail 1 */ + putDownSingleRail(world, x + 1, y + 1, z, l, x + 1, y + 1, z - 2, 2.5, tempType.getLabel(), true, x + 2, y + 1, z - 1, true, false); + + /** Switch rail 2 **/ + putDownSingleRail(world, x + 2, y + 1, z, l, x + 1, y + 1, z - 2, 2.5, typeVariantStraight, false, x + 2, y + 1, z - 1, true, false); + + /** Put down straight exit **/ + putDownSingleRail(world, x + 3, y + 1, z, l, x, y + 1, z, 0, typeVariantStraight, true, x + 2, y + 1, z - 1, false, false); + + } + if (player == null || !player.capabilities.isCreativeMode) { + --itemstack.stackSize; + } + return true; + } else if (tempType == TrackTypes.LARGE_RIGHT_SWITCH || tempType == TrackTypes.EMBEDDED_LARGE_RIGHT_SWITCH) { + switch (tempType) { + case LARGE_RIGHT_SWITCH: + idVariantSwitch = ItemIDs.tcRailLargeSwitch.item; + typeVariant90Turn = TrackTypes.LARGE_RIGHT_TURN.getLabel(); + typeVariantStraight = TrackTypes.SMALL_STRAIGHT.getLabel(); + break; + case EMBEDDED_LARGE_RIGHT_SWITCH: + idVariantSwitch = ItemIDs.tcRailEmbeddedLargeSwitch.item; + typeVariant90Turn = TrackTypes.EMBEDDED_LARGE_RIGHT_TURN.getLabel(); + typeVariantStraight = TrackTypes.EMBEDDED_SMALL_STRAIGHT.getLabel(); + break; + } + if (l == 2) { + /** Check if straight exit can be put down */ + if (!canPlaceTrack(player, world, x, y + 1, z - 5) || !canPlaceTrack(player, world, x, y + 1, z - 4) || !canPlaceTrack(player, world, x, y + 1, z - 3) || !canPlaceTrack(player, world, x, y + 1, z - 2) || !canPlaceTrack(player, world, x, y + 1, z - 1)) { + return false; + } + int[] xArray = {x + 1, x + 1, x + 2, x + 1, x + 2, x + 3, x + 4, x + 3, x + 2}; + int[] zArray = {z - 2, z - 3, z - 3, z - 4, z - 4, z - 4, z - 5, z - 5, z - 5}; + if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, true, 1, x + 5, z - 5, 4.5, x + 5, y + 1, + z, typeVariant90Turn, idVariantSwitch)) + return false; + TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x + 1, y + 1, z - 2); + if (tcRailTurn != null) + tcRailTurn.hasModel = false; + world.setBlockMetadataWithNotify(x + 1, y + 1, z - 2, l, 2);//to force client update + /** Switch rail 1 */ + putDownSingleRail(world, x, y + 1, z - 1, l, x + 5, y + 1, z, 4.5, tempType.getLabel(), true, x + 1, y + 1, z - 2, true, false); + + /** Switch rail 2 **/ + putDownSingleRail(world, x, y + 1, z - 2, l, x + 5, y + 1, z, 4.5, typeVariantStraight, false, x + 1, y + 1, z - 2, true, false); + + /** Switch rail 3 **/ + putDownSingleRail(world, x, y + 1, z - 3, l, x + 5, y + 1, z, 4.5, typeVariantStraight, false, x + 1, y + 1, z - 2, true, false); + + /** Put down straight exit **/ + putDownSingleRail(world, x, y + 1, z - 4, l, x, y + 1, z, 0, typeVariantStraight, false, x + 1, y + 1, z - 2, false, false); + + /** Put down straight exit **/ + putDownSingleRail(world, x, y + 1, z - 5, l, x, y + 1, z, 0, typeVariantStraight, true, x + 1, y + 1, z - 2, false, false); + + } + if (l == 0) { + /** Check if straight exit can be put down */ + if (!canPlaceTrack(player, world, x, y + 1, z + 5) || !canPlaceTrack(player, world, x, y + 1, z + 4) || !canPlaceTrack(player, world, x, y + 1, z + 3) || !canPlaceTrack(player, world, x, y + 1, z + 2) || !canPlaceTrack(player, world, x, y + 1, z + 1)) { + return false; + } + + int[] xArray = {x - 1, x - 1, x - 2, x - 1, x - 2, x - 3, x - 2, x - 3, x - 4}; + int[] zArray = {z + 2, z + 3, z + 3, z + 4, z + 4, z + 4, z + 5, z + 5, z + 5}; + if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, true, 1, x - 5, z + 5, 4.5, x - 4, y + 1, + z + 1, typeVariant90Turn, idVariantSwitch)) + return false; + TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x - 1, y + 1, z + 2); + if (tcRailTurn != null) + tcRailTurn.hasModel = false; + world.setBlockMetadataWithNotify(x - 1, y + 1, z + 2, l, 2);//to force client update + + /** Switch rail 1 */ + putDownSingleRail(world, x, y + 1, z + 1, l, x - 4, y + 1, z + 1, 4.5, tempType.getLabel(), true, x - 1, y + 1, z + 2, true, false); + + /** Switch rail 2 **/ + putDownSingleRail(world, x, y + 1, z + 2, l, x - 4, y + 1, z + 1, 4.5, typeVariantStraight, false, x - 1, y + 1, z + 2, true, false); + + /** Switch rail 3 **/ + putDownSingleRail(world, x, y + 1, z + 3, l, x - 4, y + 1, z + 1, 4.5, typeVariantStraight, false, x - 1, y + 1, z + 2, true, false); + + /** Put down straight exit **/ + putDownSingleRail(world, x, y + 1, z + 4, l, x, y + 1, z, 0, typeVariantStraight, false, x - 1, y + 1, z + 2, false, false); + + /** Put down straight exit **/ + putDownSingleRail(world, x, y + 1, z + 5, l, x, y + 1, z, 0, typeVariantStraight, true, x - 1, y + 1, z + 2, false, false); + + } + if (l == 1) { + /** Check if straight exit can be put down */ + if (!canPlaceTrack(player, world, x - 5, y + 1, z) || !canPlaceTrack(player, world, x - 4, y + 1, z) || !canPlaceTrack(player, world, x - 3, y + 1, z) || !canPlaceTrack(player, world, x - 2, y + 1, z) || !canPlaceTrack(player, world, x - 1, y + 1, z)) { + return false; + } + int[] xArray = {x - 2, x - 3, x - 3, x - 4, x - 4, x - 4, x - 5, x - 5, x - 5}; + int[] zArray = {z - 1, z - 1, z - 2, z - 1, z - 2, z - 3, z - 2, z - 3, z - 4}; + if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, true, 2, x - 5, z - 5, 4.5, x, y + 1, + z - 4, typeVariant90Turn, idVariantSwitch)) + return false; + TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x - 2, y + 1, z - 1); + if (tcRailTurn != null) + tcRailTurn.hasModel = false; + world.setBlockMetadataWithNotify(x - 2, y + 1, z - 1, l, 2);//to force client update + + /** Switch rail 1 */ + putDownSingleRail(world, x - 1, y + 1, z, l, x, y + 1, z - 4, 4.5, tempType.getLabel(), true, x - 2, y + 1, z - 1, true, false); + + /** Switch rail 2 **/ + putDownSingleRail(world, x - 2, y + 1, z, l, x, y + 1, z - 4, 4.5, typeVariantStraight, false, x - 2, y + 1, z - 1, true, false); + + /** Switch rail 3 **/ + putDownSingleRail(world, x - 3, y + 1, z, l, x, y + 1, z - 4, 4.5, typeVariantStraight, false, x - 2, y + 1, z - 1, true, false); + + /** Put down straight exit **/ + putDownSingleRail(world, x - 4, y + 1, z, l, x, y + 1, z, 0, typeVariantStraight, false, x - 2, y + 1, z - 1, false, false); + + /** Put down straight exit **/ + putDownSingleRail(world, x - 5, y + 1, z, l, x, y + 1, z, 0, typeVariantStraight, true, x - 2, y + 1, z - 1, false, false); + + } + if (l == 3) { + /** Check if straight exit can be put down */ + if (!canPlaceTrack(player, world, x + 5, y + 1, z) || !canPlaceTrack(player, world, x + 4, y + 1, z) || !canPlaceTrack(player, world, x + 3, y + 1, z) || !canPlaceTrack(player, world, x + 2, y + 1, z) || !canPlaceTrack(player, world, x + 1, y + 1, z)) { + return false; + } + int[] xArray = {x + 2, x + 3, x + 3, x + 4, x + 4, x + 4, x + 5, x + 5, x + 5}; + int[] zArray = {z + 1, z + 1, z + 2, z + 1, z + 2, z + 3, z + 2, z + 3, z + 4}; + if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, true, 0, x + 5, z + 5, 4.5, x + 1, y + 1, + z + 5, typeVariant90Turn, idVariantSwitch)) + return false; + + TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x + 2, y + 1, z + 1); + if (tcRailTurn != null) + tcRailTurn.hasModel = false; + world.setBlockMetadataWithNotify(x + 2, y + 1, z + 1, l, 2);//to force client update + + /** Switch rail 1 */ + putDownSingleRail(world, x + 1, y + 1, z, l, x + 1, y + 1, z + 5, 4.5, tempType.getLabel(), true, x + 2, y + 1, z + 1, true, false); + + /** Switch rail 2 **/ + putDownSingleRail(world, x + 2, y + 1, z, l, x + 1, y + 1, z + 5, 4.5, typeVariantStraight, false, x + 2, y + 1, z + 1, true, false); + + /** Switch rail 3 **/ + putDownSingleRail(world, x + 3, y + 1, z, l, x + 1, y + 1, z + 5, 4.5, typeVariantStraight, false, x + 2, y + 1, z + 1, true, false); + + /** Put down straight exit **/ + putDownSingleRail(world, x + 4, y + 1, z, l, x, y + 1, z, 0, typeVariantStraight, false, x + 2, y + 1, z + 1, false, false); + + /** Put down straight exit **/ + putDownSingleRail(world, x + 5, y + 1, z, l, x, y + 1, z, 0, typeVariantStraight, true, x + 2, y + 1, z + 1, false, false); + + } + + if (player == null || !player.capabilities.isCreativeMode) { + --itemstack.stackSize; + } + return true; + } else if (tempType == TrackTypes.LARGE_LEFT_SWITCH || tempType == TrackTypes.EMBEDDED_LARGE_LEFT_SWITCH) { + switch (tempType) { + case LARGE_LEFT_SWITCH: + idVariantSwitch = ItemIDs.tcRailLargeSwitch.item; + typeVariant90Turn = TrackTypes.LARGE_LEFT_TURN.getLabel(); + typeVariantStraight = TrackTypes.SMALL_STRAIGHT.getLabel(); + break; + case EMBEDDED_LARGE_LEFT_SWITCH: + idVariantSwitch = ItemIDs.tcRailEmbeddedLargeSwitch.item; + typeVariant90Turn = TrackTypes.EMBEDDED_LARGE_LEFT_TURN.getLabel(); + typeVariantStraight = TrackTypes.EMBEDDED_SMALL_STRAIGHT.getLabel(); + break; + } + if (l == 2) { + /** Check if straight exit can be put down */ + if (!canPlaceTrack(player, world, x, y + 1, z - 5) || !canPlaceTrack(player, world, x, y + 1, z - 4) || !canPlaceTrack(player, world, x, y + 1, z - 3) || !canPlaceTrack(player, world, x, y + 1, z - 2) || !canPlaceTrack(player, world, x, y + 1, z - 1)) { + return false; + } + int[] xArray = {x - 1, x - 1, x - 2, x - 1, x - 2, x - 3, x - 4, x - 3, x - 2}; + int[] zArray = {z - 2, z - 3, z - 3, z - 4, z - 4, z - 4, z - 5, z - 5, z - 5}; + if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, true, 1, x - 5, z - 5, 4.5, x - 4, y + 1, + z, typeVariant90Turn, idVariantSwitch)) + return false; + TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x - 1, y + 1, z - 2); + if (tcRailTurn != null) + tcRailTurn.hasModel = false; + world.setBlockMetadataWithNotify(x - 1, y + 1, z - 2, l, 2);//to force client update + + /** Switch rail 1 */ + putDownSingleRail(world, x, y + 1, z - 1, l, x - 4, y + 1, z, 4.5, tempType.getLabel(), true, x - 1, y + 1, z - 2, true, false); + + /** Switch rail 2 **/ + putDownSingleRail(world, x, y + 1, z - 2, l, x - 4, y + 1, z, 4.5, typeVariantStraight, false, x - 1, y + 1, z - 2, true, false); + + /** Switch rail 3 **/ + putDownSingleRail(world, x, y + 1, z - 3, l, x - 4, y + 1, z, 4.5, typeVariantStraight, false, x - 1, y + 1, z - 2, true, false); + + /** Put down straight exit **/ + putDownSingleRail(world, x, y + 1, z - 4, l, x, y + 1, z, 0, typeVariantStraight, false, x - 1, y + 1, z - 2, false, false); + + /** Put down straight exit **/ + putDownSingleRail(world, x, y + 1, z - 5, l, x, y + 1, z, 0, typeVariantStraight, true, x - 1, y + 1, z - 2, false, false); + + } + if (l == 0) { + /** Check if straight exit can be put down */ + if (!canPlaceTrack(player, world, x, y + 1, z + 5) || !canPlaceTrack(player, world, x, y + 1, z + 4) || !canPlaceTrack(player, world, x, y + 1, z + 3) || !canPlaceTrack(player, world, x, y + 1, z + 2) || !canPlaceTrack(player, world, x, y + 1, z + 1)) { + return false; + } + int[] xArray = {x + 1, x + 1, x + 2, x + 1, x + 2, x + 3, x + 2, x + 3, x + 4}; + int[] zArray = {z + 2, z + 3, z + 3, z + 4, z + 4, z + 4, z + 5, z + 5, z + 5}; + if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, true, 1, x + 5, z + 5, 4.5, x + 5, y + 1, + z + 1, typeVariant90Turn, idVariantSwitch)) + return false; + + TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x + 1, y + 1, z + 2); + if (tcRailTurn != null) + tcRailTurn.hasModel = false; + world.setBlockMetadataWithNotify(x + 1, y + 1, z + 2, l, 2);//to force client update + + /** Switch rail 1 */ + putDownSingleRail(world, x, y + 1, z + 1, l, x + 5, y + 1, z + 1, 4.5, tempType.getLabel(), true, x + 1, y + 1, z + 2, true, false); + + /** Switch rail 2 **/ + putDownSingleRail(world, x, y + 1, z + 2, l, x + 5, y + 1, z + 1, 4.5, typeVariantStraight, false, x + 1, y + 1, z + 2, true, false); + + /** Switch rail 3 **/ + putDownSingleRail(world, x, y + 1, z + 3, l, x + 5, y + 1, z + 1, 4.5, typeVariantStraight, false, x + 1, y + 1, z + 2, true, false); + + /** Put down straight exit **/ + putDownSingleRail(world, x, y + 1, z + 4, l, x, y + 1, z, 0, typeVariantStraight, false, x + 1, y + 1, z + 2, false, false); + + /** Put down straight exit **/ + putDownSingleRail(world, x, y + 1, z + 5, l, x, y + 1, z, 0, typeVariantStraight, true, x + 1, y + 1, z + 2, false, false); + + } + if (l == 1) { + /** Check if straight exit can be put down */ + if (!canPlaceTrack(player, world, x - 5, y + 1, z) || !canPlaceTrack(player, world, x - 4, y + 1, z) || !canPlaceTrack(player, world, x - 3, y + 1, z) || !canPlaceTrack(player, world, x - 2, y + 1, z) || !canPlaceTrack(player, world, x - 1, y + 1, z)) { + return false; + } + int[] xArray = {x - 2, x - 3, x - 3, x - 4, x - 4, x - 4, x - 5, x - 5, x - 5}; + int[] zArray = {z + 1, z + 1, z + 2, z + 1, z + 2, z + 3, z + 2, z + 3, z + 4}; + if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, true, 2, x - 5, z + 5, 4.5, x, y + 1, + z + 5, typeVariant90Turn, idVariantSwitch)) + return false; + + TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x - 2, y + 1, z + 1); + if (tcRailTurn != null) + tcRailTurn.hasModel = false; + world.setBlockMetadataWithNotify(x - 2, y + 1, z + 1, l, 2);//to force client update + + /** Switch rail 1 */ + putDownSingleRail(world, x - 1, y + 1, z, l, x, y + 1, z + 5, 4.5, tempType.getLabel(), true, x - 2, y + 1, z + 1, true, false); + + /** Switch rail 2 **/ + putDownSingleRail(world, x - 2, y + 1, z, l, x, y + 1, z + 5, 4.5, typeVariantStraight, false, x - 2, y + 1, z + 1, true, false); + + /** Switch rail 3 **/ + putDownSingleRail(world, x - 3, y + 1, z, l, x, y + 1, z + 5, 4.5, typeVariantStraight, false, x - 2, y + 1, z + 1, true, false); + + /** Put down straight exit **/ + putDownSingleRail(world, x - 4, y + 1, z, l, x, y + 1, z, 0, typeVariantStraight, false, x - 2, y + 1, z + 1, false, false); + + /** Put down straight exit **/ + putDownSingleRail(world, x - 5, y + 1, z, l, x, y + 1, z, 0, typeVariantStraight, true, x - 2, y + 1, z + 1, false, false); + + } + if (l == 3) { + /** Check if straight exit can be put down */ + if (!canPlaceTrack(player, world, x + 5, y + 1, z) || !canPlaceTrack(player, world, x + 4, y + 1, z) || !canPlaceTrack(player, world, x + 3, y + 1, z) || !canPlaceTrack(player, world, x + 2, y + 1, z) || !canPlaceTrack(player, world, x + 1, y + 1, z)) { + return false; + } + int[] xArray = {x + 2, x + 3, x + 3, x + 4, x + 4, x + 4, x + 5, x + 5, x + 5}; + int[] zArray = {z - 1, z - 1, z - 2, z - 1, z - 2, z - 3, z - 2, z - 3, z - 4}; + if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, true, 0, x + 5, z - 5, 4.5, x + 1, y + 1, + z - 4, typeVariant90Turn, idVariantSwitch)) + return false; + + TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x + 2, y + 1, z - 1); + if (tcRailTurn != null) + tcRailTurn.hasModel = false; + world.setBlockMetadataWithNotify(x + 2, y + 1, z - 1, l, 2);//to force client update + + /** Switch rail 1 */ + putDownSingleRail(world, x + 1, y + 1, z, l, x + 1, y + 1, z - 4, 4.5, tempType.getLabel(), true, x + 2, y + 1, z - 1, true, false); + + /** Switch rail 2 **/ + putDownSingleRail(world, x + 2, y + 1, z, l, x + 1, y + 1, z - 4, 4.5, typeVariantStraight, false, x + 2, y + 1, z - 1, true, false); + + /** Switch rail 3 **/ + putDownSingleRail(world, x + 3, y + 1, z, l, x + 1, y + 1, z - 4, 4.5, typeVariantStraight, false, x + 2, y + 1, z - 1, true, false); + + /** Put down straight exit **/ + putDownSingleRail(world, x + 4, y + 1, z, l, x, y + 1, z, 0, typeVariantStraight, true, x + 2, y + 1, z - 1, false, false); + + /** Put down straight exit **/ + putDownSingleRail(world, x + 5, y + 1, z, l, x, y + 1, z, 0, typeVariantStraight, + true, x + 2, y + 1, z - 1, false, false); + + } + if (player == null || !player.capabilities.isCreativeMode) { + --itemstack.stackSize; + } + return true; + } else if (tempType == TrackTypes.MEDIUM_RIGHT_PARALLEL_SWITCH || tempType == TrackTypes.EMBEDDED_MEDIUM_RIGHT_PARALLEL_SWITCH) { + switch (tempType) { + case MEDIUM_RIGHT_PARALLEL_SWITCH: + typeVariantStraight = TrackTypes.SMALL_STRAIGHT.getLabel(); + idVariantSwitch = ItemIDs.tcRailMediumParallelSwitch.item; + break; + case EMBEDDED_MEDIUM_RIGHT_PARALLEL_SWITCH: + typeVariantStraight = TrackTypes.EMBEDDED_SMALL_STRAIGHT.getLabel(); + idVariantSwitch = ItemIDs.tcRailEmbeddedMediumParallelSwitch.item; + break; + } + + if (l == 2) { + if (!parallelRightSwitchNorth(player, world, x, y, z, l, tempType, typeVariantStraight, idVariantSwitch)) + return false; + } + if (l == 0) { + if (!parallelRightSwitchSouth(player, world, x, y, z, l, tempType, typeVariantStraight, idVariantSwitch)) + return false; + } + if (l == 1) { + if (!parallelRightSwitchWest(player, world, x, y, z, l, tempType, typeVariantStraight, idVariantSwitch)) + return false; + } + if (l == 3) { + if (!parallelRightSwitchEast(player, world, x, y, z, l, tempType, typeVariantStraight, idVariantSwitch)) + return false; + } + if (player == null || !player.capabilities.isCreativeMode) { + --itemstack.stackSize; + } + return true; + } else if (tempType == TrackTypes.MEDIUM_LEFT_PARALLEL_SWITCH || tempType == TrackTypes.EMBEDDED_MEDIUM_LEFT_PARALLEL_SWITCH) { + switch (tempType) { + case MEDIUM_LEFT_PARALLEL_SWITCH: + typeVariantStraight = TrackTypes.SMALL_STRAIGHT.getLabel(); + idVariantSwitch = ItemIDs.tcRailMediumParallelSwitch.item; + break; + case EMBEDDED_MEDIUM_LEFT_PARALLEL_SWITCH: + typeVariantStraight = TrackTypes.EMBEDDED_SMALL_STRAIGHT.getLabel(); + idVariantSwitch = ItemIDs.tcRailEmbeddedMediumParallelSwitch.item; + break; + } + if (l == 2) { + if (!parallelLeftSwitchNorth(player, world, x, y, z, l, tempType, typeVariantStraight, idVariantSwitch)) + return false; + } + if (l == 0) { + if (!parallelLeftSwitchSouth(player, world, x, y, z, l, tempType, typeVariantStraight, idVariantSwitch)) + return false; + } + if (l == 1) { + if (!parallelLeftSwitchWest(player, world, x, y, z, l, tempType, typeVariantStraight, idVariantSwitch)) + return false; + } + if (l == 3) { + if (!parallelLeftSwitchEast(player, world, x, y, z, l, tempType, typeVariantStraight, idVariantSwitch)) + return false; + } + if (player == null || !player.capabilities.isCreativeMode) { + --itemstack.stackSize; + } + return true; + } else if (tempType == TrackTypes.MEDIUM_RIGHT_TURN || tempType == TrackTypes.EMBEDDED_MEDIUM_RIGHT_TURN) { + + if (!mediumRightTurn(player, world, x, y, z, l, tempType)) { + return false; + } + + if (player == null || !player.capabilities.isCreativeMode) { + --itemstack.stackSize; + } + return true; + } else if (tempType == TrackTypes.MEDIUM_LEFT_TURN || tempType == TrackTypes.EMBEDDED_MEDIUM_LEFT_TURN) { + + if (!mediumLeftTurn(player, world, x, y, z, l, tempType)) { + return false; + } + + if (player == null || !player.capabilities.isCreativeMode) { + --itemstack.stackSize; + } + return true; + } else if (tempType == TrackTypes.LARGE_RIGHT_TURN || tempType == TrackTypes.EMBEDDED_LARGE_RIGHT_TURN) { + + if (!largeRightTurn(player, world, x, y, z, l, tempType)) { + return false; + } + if (player == null || !player.capabilities.isCreativeMode) { + --itemstack.stackSize; + } + return true; + } else if (tempType == TrackTypes.LARGE_LEFT_TURN || tempType == TrackTypes.EMBEDDED_LARGE_LEFT_TURN) { + + if (!largeLeftTurn(player, world, x, y, z, l, tempType)) { + return false; + } + + if (player == null || !player.capabilities.isCreativeMode) { + --itemstack.stackSize; + } + return true; + } else if (tempType == TrackTypes.VERY_LARGE_RIGHT_TURN || tempType == TrackTypes.EMBEDDED_VERY_LARGE_RIGHT_TURN) { + + if (!veryLargeRightTurn(player, world, x, y, z, l, tempType)) { + return false; + } + + if (player == null || !player.capabilities.isCreativeMode) { + --itemstack.stackSize; + } + return true; + } else if (tempType == TrackTypes.VERY_LARGE_LEFT_TURN || tempType == TrackTypes.EMBEDDED_VERY_LARGE_LEFT_TURN) { + + if (!veryLargeLeftTurn(player, world, x, y, z, l, tempType)) { + return false; + } + + if (player == null || !player.capabilities.isCreativeMode) { + --itemstack.stackSize; + } + return true; + } else if (tempType == TrackTypes.SUPER_LARGE_RIGHT_TURN || tempType == TrackTypes.EMBEDDED_SUPER_LARGE_RIGHT_TURN) { + + if (!superLargeRightTurn(player, world, x, y, z, l, tempType)) { + return false; + } + + if (player == null || !player.capabilities.isCreativeMode) { + --itemstack.stackSize; + } + return true; + } else if (tempType == TrackTypes.SUPER_LARGE_LEFT_TURN || tempType == TrackTypes.EMBEDDED_SUPER_LARGE_LEFT_TURN) { + + + if (!superLargeLeftTurn(player, world, x, y, z, l, tempType)) { + return false; + } + + if (player == null || !player.capabilities.isCreativeMode) { + --itemstack.stackSize; + } + return true; + } else if (type == TrackTypes.SLOPE_WOOD || type == TrackTypes.SLOPE_GRAVEL || type == TrackTypes.SLOPE_BALLAST + || type == TrackTypes.SLOPE_SNOW_GRAVEL || type == TrackTypes.SLOPE_DYNAMIC || type == TrackTypes.EMBEDDED_SLOPE_DYNAMIC + || type == TrackTypes.LARGE_SLOPE_WOOD || type == TrackTypes.LARGE_SLOPE_GRAVEL + || type == TrackTypes.LARGE_SLOPE_BALLAST || type == TrackTypes.LARGE_SLOPE_SNOW_GRAVEL + || type == TrackTypes.LARGE_SLOPE_DYNAMIC || type == TrackTypes.EMBEDDED_LARGE_SLOPE_DYNAMIC + || type == TrackTypes.VERY_LARGE_SLOPE_WOOD || type == TrackTypes.VERY_LARGE_SLOPE_GRAVEL + || type == TrackTypes.VERY_LARGE_SLOPE_BALLAST || type == TrackTypes.VERY_LARGE_SLOPE_SNOW_GRAVEL + || type == TrackTypes.VERY_LARGE_SLOPE_DYNAMIC || type == TrackTypes.EMBEDDED_VERY_LARGE_SLOPE_DYNAMIC + ) { + if (!canPlaceTrack(player, world, x, y + 1, z)) { + return false; + } + if (type.getLabel().contains("DYNAMIC") && world.getBlock(x, y, z) == BlockIDs.bridgePillar.block) { + return false; + } + + + int gagEnd = 0; + double slopeAngle = 0; + /** + * Explanation: normally you would devide 100 by (gagEnd+1) but this seems to be + * against TCs own brain. you need to devide 100 by (gagEnd+1) + **/ + if (type == TrackTypes.SLOPE_WOOD || type == TrackTypes.SLOPE_GRAVEL + || type == TrackTypes.SLOPE_BALLAST || type == TrackTypes.SLOPE_SNOW_GRAVEL + || type == TrackTypes.SLOPE_DYNAMIC || type == TrackTypes.EMBEDDED_SLOPE_DYNAMIC) { + gagEnd = 5; + slopeAngle = 0.13; + } + + if (type == TrackTypes.LARGE_SLOPE_WOOD || type == TrackTypes.LARGE_SLOPE_GRAVEL + || type == TrackTypes.LARGE_SLOPE_BALLAST || type == TrackTypes.LARGE_SLOPE_SNOW_GRAVEL + || type == TrackTypes.LARGE_SLOPE_DYNAMIC || type == TrackTypes.EMBEDDED_LARGE_SLOPE_DYNAMIC) { + gagEnd = 11; + slopeAngle = 0.0666; + } + + if (type == TrackTypes.VERY_LARGE_SLOPE_WOOD || type == TrackTypes.VERY_LARGE_SLOPE_GRAVEL + || type == TrackTypes.VERY_LARGE_SLOPE_BALLAST || type == TrackTypes.VERY_LARGE_SLOPE_SNOW_GRAVEL + || type == TrackTypes.VERY_LARGE_SLOPE_DYNAMIC || type == TrackTypes.EMBEDDED_VERY_LARGE_SLOPE_DYNAMIC) { + gagEnd = 17; + slopeAngle = 0.0444; + } + + + Item idDropped = this.type.getItem().item; + TileTCRailGag[] tileGag = new TileTCRailGag[gagEnd]; + + for (int i = 1; i <= gagEnd; i++) { + if (l == 2) { + if (!canPlaceTrack(player, world, x, y + 1, z - i)) { + return false; + } + } + if (l == 0) { + if (!canPlaceTrack(player, world, x, y + 1, z + i)) { + return false; + } + } + if (l == 1) { + if (!canPlaceTrack(player, world, x - i, y + 1, z)) { + return false; + } + } + if (l == 3) { + if (!canPlaceTrack(player, world, x + i, y + 1, z)) { + return false; + } + } + } + placeTrack(world, x, y + 1, z, BlockIDs.tcRail.block, l); + TileTCRail tcRail = (TileTCRail) world.getTileEntity(x, y + 1, z); + tcRail.setFacing(l); + tcRail.setType(type.getLabel()); + tcRail.idDrop = idDropped; + tcRail.slopeHeight = 1; + tcRail.slopeAngle = slopeAngle; + tcRail.slopeLength = gagEnd + 1; + + Block block = world.getBlock(x, y, z); + int blockID = Block.getIdFromBlock(block); + tcRail.setBallastMaterial(blockID); + tcRail.ballastMetadata = world.getBlockMetadata(x, y, z); + + + for (int i2 = 1; i2 <= gagEnd; i2++) { + if (l == 2) { + placeTrack(world, x, y + 1, z - i2, BlockIDs.tcRailGag.block, l); + tileGag[i2 - 1] = (TileTCRailGag) world.getTileEntity(x, y + 1, z - i2); + tileGag[i2 - 1].bbHeight = Math.max(0.125f, Math.min(1f, i2 / (float) gagEnd)); + } + if (l == 0) { + placeTrack(world, x, y + 1, z + i2, BlockIDs.tcRailGag.block, l); + tileGag[i2 - 1] = (TileTCRailGag) world.getTileEntity(x, y + 1, z + i2); + tileGag[i2 - 1].bbHeight = Math.max(0.125f, Math.min(1f, i2 / (float) gagEnd)); + } + if (l == 1) { + placeTrack(world, x - i2, y + 1, z, BlockIDs.tcRailGag.block, l); + tileGag[i2 - 1] = (TileTCRailGag) world.getTileEntity(x - i2, y + 1, z); + tileGag[i2 - 1].bbHeight = Math.max(0.125f, Math.min(1f, i2 / (float) gagEnd)); + } + if (l == 3) { + placeTrack(world, x + i2, y + 1, z, BlockIDs.tcRailGag.block, l); + tileGag[i2 - 1] = (TileTCRailGag) world.getTileEntity(x + i2, y + 1, z); + tileGag[i2 - 1].bbHeight = Math.max(0.125f, Math.min(1f, i2 / (float) gagEnd)); + } + } + for (int i = 0; i < tileGag.length; i++) { + if (player != null && tileGag[i] == null) { + player.addChatMessage(new ChatComponentText( + "There was a problem when placing the track. Possibly too many tracks around")); + return false; + } + tileGag[i].originX = x; + tileGag[i].originY = y + 1; + tileGag[i].originZ = z; + tileGag[i].type = type.getLabel(); + } + if (player == null || !player.capabilities.isCreativeMode) { + --itemstack.stackSize; + } + return true; + + + } else if (type == TrackTypes.TWO_WAYS_CROSSING || type == TrackTypes.EMBEDDED_TWO_WAYS_CROSSING) { + switch (type) { + case TWO_WAYS_CROSSING: + typeVariantStraight = TrackTypes.SMALL_STRAIGHT.getLabel(); + typeVariantCrossing = TrackTypes.TWO_WAYS_CROSSING.getLabel(); + break; + + case EMBEDDED_TWO_WAYS_CROSSING: + typeVariantStraight = TrackTypes.EMBEDDED_SMALL_STRAIGHT.getLabel(); + typeVariantCrossing = TrackTypes.EMBEDDED_TWO_WAYS_CROSSING.getLabel(); + break; + + + } + + + if (!canPlaceTrack(player, world, x, y + 1, z)) { + return false; + } + + int zDisplace = 0; + int xDisplace = 0; + int xSideDisplace = 0; + int zSideDisplace = 0; + int sideFacing = l; + + if (l == 2) { + zDisplace = -1; + xSideDisplace = 1; + sideFacing = 1; + } + if (l == 3) { + xDisplace = 1; + zSideDisplace = 1; + sideFacing = 2; + } + if (l == 0) { + zDisplace = 1; + xSideDisplace = 1; + sideFacing = 1; + } + if (l == 1) { + xDisplace = -1; + zSideDisplace = 1; + sideFacing = 2; + } + + if (!canPlaceTrack(player, world, x + xDisplace, y + 1, z + zDisplace) || !canPlaceTrack(player, world, x + (xDisplace * 2), y + 1, z + (zDisplace * 2))) { + return false; + } + if (!canPlaceTrack(player, world, x + (xDisplace) + (xSideDisplace), y + 1, + z + (zDisplace) + (zSideDisplace))) { + return false; + } + if (!canPlaceTrack(player, world, x + (xDisplace) - (xSideDisplace), y + 1, + z + (zDisplace) - (zSideDisplace))) { + return false; + } + + /* + * Top + */ + + putDownSingleRail(world, x + (xDisplace * 2), y + 1, z + (zDisplace * 2), l, x + (xDisplace * 2), y + 1, + z + (zDisplace * 2), 0, typeVariantStraight, true, x + (xDisplace), y + 1, + z + (zDisplace), false, false); + + // putDownSingleRail(world, x+(xDisplace*4), y + 1, z+(zDisplace*4), l, + // x+(xDisplace*4) , y + 1, z+(zDisplace*4), 0, + // TrackTypes.SMALL_STRAIGHT.getLabel(), true, x+(xDisplace*3), y + 1, + // z+(zDisplace*3), false, false); + + //Main + + placeTrack(world, x + (xDisplace), y + 1, z + (zDisplace), BlockIDs.tcRail.block, l); + TileTCRail tcRail2 = (TileTCRail) world.getTileEntity(x + (xDisplace), y + 1, z + (zDisplace)); + tcRail2.setFacing(l); + tcRail2.cx = x + (xDisplace); + tcRail2.cy = y + 1; + tcRail2.cz = z + (zDisplace); + tcRail2.setType(typeVariantCrossing); + tcRail2.idDrop = this.type.getItem().item; + + /* + * Bottom + */ + + // putDownSingleRail(world, x + (xDisplace), y + 1, z + (zDisplace), l, x + + // (xDisplace), y + 1, + // z + (zDisplace), 0, TrackTypes.SMALL_STRAIGHT.getLabel(), true, x + + // (xDisplace * 2), y + 1, + // z + (zDisplace * 2), false, false); + + putDownSingleRail(world, x, y + 1, z, l, x, y + 1, z, 0, typeVariantStraight, true, + x + (xDisplace), y + 1, z + (zDisplace), false, false); + + /* + * Right + */ + + putDownSingleRail(world, x + (xDisplace) + (xSideDisplace), y + 1, + z + (zDisplace) + (zSideDisplace), sideFacing, + x + (xDisplace) + (xSideDisplace), y + 1, z + (zDisplace) + (zSideDisplace), 0, + typeVariantStraight, true, x + (xDisplace), y + 1, z + (zDisplace), + false, false); + + // putDownSingleRail(world, x + (xDisplace * 2) + (xSideDisplace * 2), y + 1, + // z + (zDisplace * 2) + (zSideDisplace * 2), sideFacing, + // x + (xDisplace * 2) + (xSideDisplace * 2), y + 1, z + (zDisplace * 2) + + // (zSideDisplace * 2), 0, + // TrackTypes.SMALL_STRAIGHT.getLabel(), true, x + (xDisplace * 2) + (xSideDisplace + //), y + 1, + // z + (zDisplace * 2) + (zSideDisplace), false, false); + + /* + * Left + */ + + putDownSingleRail(world, x + (xDisplace) - (xSideDisplace), y + 1, + z + (zDisplace) - (zSideDisplace), sideFacing, + x + (xDisplace) - (xSideDisplace), y + 1, z + (zDisplace) - (zSideDisplace), 0, + typeVariantStraight, true, x + (xDisplace), y + 1, z + (zDisplace), + false, false); // putDownSingleRail(world, x+(xDisplace*2)-(xSideDisplace*2), y + 1, z+(zDisplace*2)-(zSideDisplace*2), sideFacing, x+(xDisplace*2)-(xSideDisplace*2) , y + 1, z+(zDisplace*2)-(zSideDisplace*2), 0, TrackTypes.SMALL_STRAIGHT.getLabel(), true, x+(xDisplace*2)-(xSideDisplace*1), y + 1, z+(zDisplace*2)-(zSideDisplace*1), false, false); - if (player ==null || !player.capabilities.isCreativeMode) { - --itemstack.stackSize; - } - return true; - - } - } - return false; - } - - - private TrackTypes getPlacementDirection(EntityPlayer player, World world, int l, float par10) { - if (!world.isRemote) { - - /** Determines if track is left or right*/ - float yaw = MathHelper.wrapAngleTo180_float(player!=null?player.rotationYaw:par10); - tempType = type; - - if (type == TrackTypes.MEDIUM_TURN) { - if (getTrackOrientation(l, yaw).equals("right")) { - tempType = TrackTypes.MEDIUM_RIGHT_TURN; - - } - if (getTrackOrientation(l, yaw).equals("left")) { - tempType = TrackTypes.MEDIUM_LEFT_TURN; - } - } - if (type == TrackTypes.LARGE_TURN) { - if (getTrackOrientation(l, yaw).equals("right")) { - tempType = TrackTypes.LARGE_RIGHT_TURN; - } - if (getTrackOrientation(l, yaw).equals("left")) { - tempType = TrackTypes.LARGE_LEFT_TURN; - } - } - if (type == TrackTypes.VERY_LARGE_TURN) { - if (getTrackOrientation(l, yaw).equals("right")) { - tempType = TrackTypes.VERY_LARGE_RIGHT_TURN; - } - if (getTrackOrientation(l, yaw).equals("left")) { - tempType = TrackTypes.VERY_LARGE_LEFT_TURN; - } - } - if (type == TrackTypes.SUPER_LARGE_TURN) { - if (getTrackOrientation(l, yaw).equals("right")) { - tempType = TrackTypes.SUPER_LARGE_RIGHT_TURN; - } - if (getTrackOrientation(l, yaw).equals("left")) { - tempType = TrackTypes.SUPER_LARGE_LEFT_TURN; - } - } - if (type == TrackTypes.MEDIUM_45DEGREE_TURN) { - if (getTrackOrientation(l, yaw).equals("right")) { - tempType = TrackTypes.MEDIUM_RIGHT_45DEGREE_TURN; - } - if (getTrackOrientation(l, yaw).equals("left")) { - tempType = TrackTypes.MEDIUM_LEFT_45DEGREE_TURN; - - } - } - if (type == TrackTypes.LARGE_45DEGREE_TURN) { - if (getTrackOrientation(l, yaw).equals("right")) { - tempType = TrackTypes.LARGE_RIGHT_45DEGREE_TURN; - } - if (getTrackOrientation(l, yaw).equals("left")) { - tempType = TrackTypes.LARGE_LEFT_45DEGREE_TURN; - - } - } - if (type == TrackTypes.VERY_LARGE_45DEGREE_TURN) { - if (getTrackOrientation(l, yaw).equals("right")) { - tempType = TrackTypes.VERY_LARGE_RIGHT_45DEGREE_TURN; - } - if (getTrackOrientation(l, yaw).equals("left")) { - tempType = TrackTypes.VERY_LARGE_LEFT_45DEGREE_TURN; - - } - } - if (type == TrackTypes.SUPER_LARGE_45DEGREE_TURN) { - if (getTrackOrientation(l, yaw).equals("right")) { - tempType = TrackTypes.SUPER_LARGE_RIGHT_45DEGREE_TURN; - } - if (getTrackOrientation(l, yaw).equals("left")) { - tempType = TrackTypes.SUPER_LARGE_LEFT_45DEGREE_TURN; - - } - } - if (type == TrackTypes.SMALL_PARALLEL_CURVE) { - if (getTrackOrientation(l, yaw).equals("right")) { - tempType = TrackTypes.SMALL_RIGHT_PARALLEL_CURVE; - } - if (getTrackOrientation(l, yaw).equals("left")) { - tempType = TrackTypes.SMALL_LEFT_PARALLEL_CURVE; - } - } - if (type == TrackTypes.MEDIUM_PARALLEL_CURVE) { - if (getTrackOrientation(l, yaw).equals("right")) { - tempType = TrackTypes.MEDIUM_RIGHT_PARALLEL_CURVE; - } - if (getTrackOrientation(l, yaw).equals("left")) { - tempType = TrackTypes.MEDIUM_LEFT_PARALLEL_CURVE; - } - } - if (type == TrackTypes.LARGE_PARALLEL_CURVE) { - if (getTrackOrientation(l, yaw).equals("right")) { - tempType = TrackTypes.LARGE_RIGHT_PARALLEL_CURVE; - } - if (getTrackOrientation(l, yaw).equals("left")) { - tempType = TrackTypes.LARGE_LEFT_PARALLEL_CURVE; - } - } - if (type == TrackTypes.MEDIUM_SWITCH) { - if (getTrackOrientation(l, yaw).equals("right")) { - tempType = TrackTypes.MEDIUM_RIGHT_SWITCH; - } - if (getTrackOrientation(l, yaw).equals("left")) { - tempType = TrackTypes.MEDIUM_LEFT_SWITCH; - } - } - if (type == TrackTypes.LARGE_SWITCH) { - if (getTrackOrientation(l, yaw).equals("right")) { - tempType = TrackTypes.LARGE_RIGHT_SWITCH; - } - if (getTrackOrientation(l, yaw).equals("left")) { - tempType = TrackTypes.LARGE_LEFT_SWITCH; - } - } - if (type == TrackTypes.MEDIUM_PARALLEL_SWITCH) { - if (getTrackOrientation(l, yaw).equals("right")) { - tempType = TrackTypes.MEDIUM_RIGHT_PARALLEL_SWITCH; - } - if (getTrackOrientation(l, yaw).equals("left")) { - tempType = TrackTypes.MEDIUM_LEFT_PARALLEL_SWITCH; - } - } - if (type == TrackTypes.MEDIUM_45DEGREE_SWITCH) { - if (getTrackOrientation(l, yaw).equals("right")) { - tempType = TrackTypes.MEDIUM_RIGHT_45DEGREE_SWITCH; - } - if (getTrackOrientation(l, yaw).equals("left")) { - tempType = TrackTypes.MEDIUM_LEFT_45DEGREE_SWITCH; - } - } - if (type == TrackTypes.EMBEDDED_MEDIUM_TURN) { - if (getTrackOrientation(l, yaw).equals("right")) { - tempType = TrackTypes.EMBEDDED_MEDIUM_RIGHT_TURN; - } - if (getTrackOrientation(l, yaw).equals("left")) { - tempType = TrackTypes.EMBEDDED_MEDIUM_LEFT_TURN; - } - } - if (type == TrackTypes.EMBEDDED_LARGE_TURN) { - if (getTrackOrientation(l, yaw).equals("right")) { - tempType = TrackTypes.EMBEDDED_LARGE_RIGHT_TURN; - } - if (getTrackOrientation(l, yaw).equals("left")) { - tempType = TrackTypes.EMBEDDED_LARGE_LEFT_TURN; - } - } - if (type == TrackTypes.EMBEDDED_VERY_LARGE_TURN) { - if (getTrackOrientation(l, yaw).equals("right")) { - tempType = TrackTypes.EMBEDDED_VERY_LARGE_RIGHT_TURN; - } - if (getTrackOrientation(l, yaw).equals("left")) { - tempType = TrackTypes.EMBEDDED_VERY_LARGE_LEFT_TURN; - } - } - if (type == TrackTypes.EMBEDDED_SUPER_LARGE_TURN) { - if (getTrackOrientation(l, yaw).equals("right")) { - tempType = TrackTypes.EMBEDDED_SUPER_LARGE_RIGHT_TURN; - } - if (getTrackOrientation(l, yaw).equals("left")) { - tempType = TrackTypes.EMBEDDED_SUPER_LARGE_LEFT_TURN; - } - } - if (type == TrackTypes.EMBEDDED_MEDIUM_45DEGREE_TURN) { - if (getTrackOrientation(l, yaw).equals("right")) { - tempType = TrackTypes.EMBEDDED_MEDIUM_RIGHT_45DEGREE_TURN; - } - if (getTrackOrientation(l, yaw).equals("left")) { - tempType = TrackTypes.EMBEDDED_MEDIUM_LEFT_45DEGREE_TURN; - - } - } - if (type == TrackTypes.EMBEDDED_LARGE_45DEGREE_TURN) { - if (getTrackOrientation(l, yaw).equals("right")) { - tempType = TrackTypes.EMBEDDED_LARGE_RIGHT_45DEGREE_TURN; - } - if (getTrackOrientation(l, yaw).equals("left")) { - tempType = TrackTypes.EMBEDDED_LARGE_LEFT_45DEGREE_TURN; - - } - } - if (type == TrackTypes.EMBEDDED_VERY_LARGE_45DEGREE_TURN) { - if (getTrackOrientation(l, yaw).equals("right")) { - tempType = TrackTypes.EMBEDDED_VERY_LARGE_RIGHT_45DEGREE_TURN; - } - if (getTrackOrientation(l, yaw).equals("left")) { - tempType = TrackTypes.EMBEDDED_VERY_LARGE_LEFT_45DEGREE_TURN; - - } - } - if (type == TrackTypes.EMBEDDED_SUPER_LARGE_45DEGREE_TURN) { - if (getTrackOrientation(l, yaw).equals("right")) { - tempType = TrackTypes.EMBEDDED_SUPER_LARGE_RIGHT_45DEGREE_TURN; - } - if (getTrackOrientation(l, yaw).equals("left")) { - tempType = TrackTypes.EMBEDDED_SUPER_LARGE_LEFT_45DEGREE_TURN; - - } - } - if (type == TrackTypes.EMBEDDED_SMALL_PARALLEL_CURVE) { - if (getTrackOrientation(l, yaw).equals("right")) { - tempType = TrackTypes.EMBEDDED_SMALL_RIGHT_PARALLEL_CURVE; - } - if (getTrackOrientation(l, yaw).equals("left")) { - tempType = TrackTypes.EMBEDDED_SMALL_LEFT_PARALLEL_CURVE; - } - } - if (type == TrackTypes.EMBEDDED_MEDIUM_PARALLEL_CURVE) { - if (getTrackOrientation(l, yaw).equals("right")) { - tempType = TrackTypes.EMBEDDED_MEDIUM_RIGHT_PARALLEL_CURVE; - } - if (getTrackOrientation(l, yaw).equals("left")) { - tempType = TrackTypes.EMBEDDED_MEDIUM_LEFT_PARALLEL_CURVE; - } - } - if (type == TrackTypes.EMBEDDED_LARGE_PARALLEL_CURVE) { - if (getTrackOrientation(l, yaw).equals("right")) { - tempType = TrackTypes.EMBEDDED_LARGE_RIGHT_PARALLEL_CURVE; - } - if (getTrackOrientation(l, yaw).equals("left")) { - tempType = TrackTypes.EMBEDDED_LARGE_LEFT_PARALLEL_CURVE; - } - } - if (type == TrackTypes.EMBEDDED_MEDIUM_SWITCH) { - if (getTrackOrientation(l, yaw).equals("right")) { - tempType = TrackTypes.EMBEDDED_MEDIUM_RIGHT_SWITCH; - } - if (getTrackOrientation(l, yaw).equals("left")) { - tempType = TrackTypes.EMBEDDED_MEDIUM_LEFT_SWITCH; - } - } - if (type == TrackTypes.EMBEDDED_LARGE_SWITCH) { - if (getTrackOrientation(l, yaw).equals("right")) { - tempType = TrackTypes.EMBEDDED_LARGE_RIGHT_SWITCH; - } - if (getTrackOrientation(l, yaw).equals("left")) { - tempType = TrackTypes.EMBEDDED_LARGE_LEFT_SWITCH; - } - } - if (type == TrackTypes.EMBEDDED_MEDIUM_PARALLEL_SWITCH) { - if (getTrackOrientation(l, yaw).equals("right")) { - tempType = TrackTypes.EMBEDDED_MEDIUM_RIGHT_PARALLEL_SWITCH; - } - if (getTrackOrientation(l, yaw).equals("left")) { - tempType = TrackTypes.EMBEDDED_MEDIUM_LEFT_PARALLEL_SWITCH; - } - } - if (type == TrackTypes.EMBEDDED_MEDIUM_45DEGREE_SWITCH) { - if (getTrackOrientation(l, yaw).equals("right")) { - tempType = TrackTypes.EMBEDDED_MEDIUM_RIGHT_45DEGREE_SWITCH; - } - if (getTrackOrientation(l, yaw).equals("left")) { - tempType = TrackTypes.EMBEDDED_MEDIUM_LEFT_45DEGREE_SWITCH; - } - } - if (type == TrackTypes.LARGE_CURVED_SLOPE_DYNAMIC) { - if (getTrackOrientation(l, yaw).equals("right")) { - tempType = TrackTypes.LARGE_RIGHT_CURVED_SLOPE_DYNAMIC; - } - if (getTrackOrientation(l, yaw).equals("left")) { - tempType = TrackTypes.LARGE_LEFT_CURVED_SLOPE_DYNAMIC; - } - } - - if (type == TrackTypes.EMBEDDED_LARGE_CURVED_SLOPE_DYNAMIC) { - if (getTrackOrientation(l, yaw).equals("right")) { - tempType = TrackTypes.EMBEDDED_LARGE_RIGHT_CURVED_SLOPE_DYNAMIC; - } - if (getTrackOrientation(l, yaw).equals("left")) { - tempType = TrackTypes.EMBEDDED_LARGE_LEFT_CURVED_SLOPE_DYNAMIC; - } - } - if (type == TrackTypes.VERY_LARGE_CURVED_SLOPE_DYNAMIC) { - if (getTrackOrientation(l, yaw).equals("right")) { - tempType = TrackTypes.VERY_LARGE_RIGHT_CURVED_SLOPE_DYNAMIC; - } - if (getTrackOrientation(l, yaw).equals("left")) { - tempType = TrackTypes.VERY_LARGE_LEFT_CURVED_SLOPE_DYNAMIC; - } - } - - if (type == TrackTypes.EMBEDDED_VERY_LARGE_CURVED_SLOPE_DYNAMIC) { - if (getTrackOrientation(l, yaw).equals("right")) { - tempType = TrackTypes.EMBEDDED_VERY_LARGE_RIGHT_CURVED_SLOPE_DYNAMIC; - } - if (getTrackOrientation(l, yaw).equals("left")) { - tempType = TrackTypes.EMBEDDED_VERY_LARGE_LEFT_CURVED_SLOPE_DYNAMIC; - } - } - if (type == TrackTypes.SUPER_LARGE_CURVED_SLOPE_DYNAMIC) { - if (getTrackOrientation(l, yaw).equals("right")) { - tempType = TrackTypes.SUPER_LARGE_RIGHT_CURVED_SLOPE_DYNAMIC; - } - if (getTrackOrientation(l, yaw).equals("left")) { - tempType = TrackTypes.SUPER_LARGE_LEFT_CURVED_SLOPE_DYNAMIC; - } - } - - if (type == TrackTypes.EMBEDDED_SUPER_LARGE_CURVED_SLOPE_DYNAMIC) { - if (getTrackOrientation(l, yaw).equals("right")) { - tempType = TrackTypes.EMBEDDED_SUPER_LARGE_RIGHT_CURVED_SLOPE_DYNAMIC; - } - if (getTrackOrientation(l, yaw).equals("left")) { - tempType = TrackTypes.EMBEDDED_SUPER_LARGE_LEFT_CURVED_SLOPE_DYNAMIC; - } - } - if (type == TrackTypes.DIAMOND_CROSSING) { - if (getTrackOrientation(l, yaw).equals("right")) { - tempType = TrackTypes.RIGHT_DIAMOND_CROSSING; - } - if (getTrackOrientation(l, yaw).equals("left")) { - tempType = TrackTypes.LEFT_DIAMOND_CROSSING; - } - } - if (type == TrackTypes.EMBEDDED_DIAMOND_CROSSING) { - if (getTrackOrientation(l, yaw).equals("right")) { - tempType = TrackTypes.EMBEDDED_RIGHT_DIAMOND_CROSSING; - } - if (getTrackOrientation(l, yaw).equals("left")) { - tempType = TrackTypes.EMBEDDED_LEFT_DIAMOND_CROSSING; - } - } - - } - return tempType; - } - - /** Track Placement (because onItemUse is getting too big)*/ - - private boolean smallStraight(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes type) { - if (!canPlaceTrack(player, world, x, y + 1, z)) { - return false; - } - placeTrack(world,x, y + 1, z, BlockIDs.tcRail.block, l); - TileTCRail tcRail = (TileTCRail) world.getTileEntity(x, y + 1, z); - tcRail.setFacing(l); - tcRail.cx = x; - tcRail.cy = y + 1; - tcRail.cz = z; - tcRail.setType(type.getLabel()); - tcRail.idDrop = this.type.getItem().item; - return true; - } - private boolean straight(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes type) { - /** check if first rail can be placed */ - if (!canPlaceTrack(player, world, x, y + 1, z)) { - return false; - } - - TileTCRailGag[] tileGag = new TileTCRailGag[2]; /** makes it so only 2 gags are placed */ - if (type == TrackTypes.LONG_STRAIGHT || type == TrackTypes.EMBEDDED_LONG_STRAIGHT) { - tileGag = new TileTCRailGag[4]; - } - - if (type == TrackTypes.VERY_LONG_STRAIGHT || type == TrackTypes.EMBEDDED_VERY_LONG_STRAIGHT){ - tileGag = new TileTCRailGag[8]; - } - if (l == 2) { - - if (!canPlaceTrack(player, world, x, y + 1, z - 1) || !canPlaceTrack(player, world, x, y + 1, z - 2)) { - return false; - } - if (type == TrackTypes.LONG_STRAIGHT || type == TrackTypes.EMBEDDED_LONG_STRAIGHT){ - if (!canPlaceTrack(player, world, x, y + 1, z - 3) || !canPlaceTrack(player, world, x, y + 1, z - 4) - || !canPlaceTrack(player, world, x, y + 1, z - 5)) { - return false; - } - } - if (type == TrackTypes.VERY_LONG_STRAIGHT || type == TrackTypes.EMBEDDED_VERY_LONG_STRAIGHT){ - if (!canPlaceTrack(player, world, x, y + 1, z - 3) || !canPlaceTrack(player, world, x, y + 1, z - 4) - || !canPlaceTrack(player, world, x, y + 1, z - 5) || !canPlaceTrack(player, world, x, y+1, z - 6) || !canPlaceTrack(player, world, x, y+1, z - 7) || !canPlaceTrack(player, world, x, y+1, z - 8) || - !canPlaceTrack(player, world, x, y+1, z - 9) || !canPlaceTrack(player, world,x, y+1, z - 10) || !canPlaceTrack(player, world, x, y+1, z - 11)) { - return false; - } - } - placeTrack(world,x, y + 1, z, BlockIDs.tcRail.block, l); - TileTCRail tcRail = (TileTCRail) world.getTileEntity(x, y + 1, z); - tcRail.setFacing(l); - tcRail.setType(type.getLabel()); - - placeTrack(world,x, y + 1, z - 1, BlockIDs.tcRailGag.block, l); - tileGag[0] = (TileTCRailGag) world.getTileEntity(x, y + 1, z - 1); - - placeTrack(world,x, y + 1, z - 2, BlockIDs.tcRailGag.block, l); - tileGag[1] = (TileTCRailGag) world.getTileEntity(x, y + 1, z - 2); - - if (type == TrackTypes.LONG_STRAIGHT || type == TrackTypes.EMBEDDED_LONG_STRAIGHT) { - tcRail.idDrop = this.type.getItem().item; - } else { - tcRail.idDrop = this.type.getItem().item; - } - - if (type == TrackTypes.LONG_STRAIGHT || type == TrackTypes.EMBEDDED_LONG_STRAIGHT || type == TrackTypes.VERY_LONG_STRAIGHT || type == TrackTypes.EMBEDDED_VERY_LONG_STRAIGHT) { - placeTrack(world,x, y + 1, z - 3, BlockIDs.tcRail.block, l); - TileTCRail tcRail2 = (TileTCRail) world.getTileEntity(x, y + 1, z - 3); - tcRail2.setFacing(l); - tcRail2.setType(type.getLabel()); - tcRail2.isLinkedToRail = true; - tcRail2.linkedX = x; - tcRail2.linkedY = y + 1; - tcRail2.linkedZ = z - 1; - - placeTrack(world,x, y + 1, z - 4, BlockIDs.tcRailGag.block, l); - tileGag[2] = (TileTCRailGag) world.getTileEntity(x, y + 1, z - 4); - - placeTrack(world,x, y + 1, z - 5, BlockIDs.tcRailGag.block, l); - tileGag[3] = (TileTCRailGag) world.getTileEntity(x, y + 1, z - 5); - - if (type == TrackTypes.VERY_LONG_STRAIGHT || type == TrackTypes.EMBEDDED_VERY_LONG_STRAIGHT) { - tcRail.idDrop = this.type.getItem().item; - } else { - tcRail.idDrop = this.type.getItem().item; - } - } - if (type == TrackTypes.VERY_LONG_STRAIGHT || type == TrackTypes.EMBEDDED_VERY_LONG_STRAIGHT) { - - placeTrack(world,x, y+1, z - 6, BlockIDs.tcRail.block, l); - TileTCRail tcRail3 = (TileTCRail) world.getTileEntity(x, y + 1, z - 6); - tcRail3.setFacing(l); - tcRail3.setType(type.getLabel()); - tcRail3.isLinkedToRail = true; - tcRail3.linkedX = x; - tcRail3.linkedY = y + 1; - tcRail3.linkedZ = z - 1; - - placeTrack(world,x, y + 1, z - 7, BlockIDs.tcRailGag.block, l); - tileGag[4] = (TileTCRailGag) world.getTileEntity(x, y + 1, z - 7); - - placeTrack(world,x, y + 1, z - 8, BlockIDs.tcRailGag.block, l); - tileGag[5] = (TileTCRailGag) world.getTileEntity(x, y + 1, z - 8); - - placeTrack(world,x, y+1, z - 9, BlockIDs.tcRail.block, l); - TileTCRail tcRail4 = (TileTCRail) world.getTileEntity(x, y + 1, z - 9); - tcRail4.setFacing(l); - tcRail4.setType(type.getLabel()); - tcRail4.isLinkedToRail = true; - tcRail4.linkedX = x; - tcRail4.linkedY = y + 1; - tcRail4.linkedZ = z - 1; - - placeTrack(world,x, y + 1, z - 10, BlockIDs.tcRailGag.block, l); - tileGag[6] = (TileTCRailGag) world.getTileEntity(x, y + 1, z - 10); - - placeTrack(world,x, y + 1, z - 11, BlockIDs.tcRailGag.block, l); - tileGag[7] = (TileTCRailGag) world.getTileEntity(x, y + 1, z - 11); - - - } - - } - if (l == 0) { - if (!canPlaceTrack(player, world, x, y + 1, z + 1) || !canPlaceTrack(player, world, x, y + 1, z + 2)) { - return false; - } - if (type == TrackTypes.LONG_STRAIGHT || type == TrackTypes.EMBEDDED_LONG_STRAIGHT){ - if (!canPlaceTrack(player, world, x, y + 1, z + 3) || !canPlaceTrack(player, world, x, y + 1, z + 4) - || !canPlaceTrack(player, world, x, y + 1, z + 5)) { - return false; - } - } - if (type == TrackTypes.VERY_LONG_STRAIGHT || type == TrackTypes.EMBEDDED_VERY_LONG_STRAIGHT){ - if (!canPlaceTrack(player, world, x, y + 1, z + 3) || !canPlaceTrack(player, world, x, y + 1, z + 4) - || !canPlaceTrack(player, world, x, y + 1, z + 5) || !canPlaceTrack(player, world, x, y+1, z + 6) || !canPlaceTrack(player, world, x, y+1, z + 7) || - !canPlaceTrack(player, world, x, y+1, z + 8) || !canPlaceTrack(player, world, x, y+1, z + 9) || !canPlaceTrack(player, world, x, y+1, z + 10) || !canPlaceTrack(player, world, x, y+1, z + 11)) { - return false; - } - } - placeTrack(world,x, y + 1, z, BlockIDs.tcRail.block, l); - TileTCRail tcRail = (TileTCRail) world.getTileEntity(x, y + 1, z); - tcRail.setFacing(l); - tcRail.setType(type.getLabel()); - - placeTrack(world,x, y + 1, z + 1, BlockIDs.tcRailGag.block, l); - tileGag[0] = (TileTCRailGag) world.getTileEntity(x, y + 1, z + 1); - - placeTrack(world,x, y + 1, z + 2, BlockIDs.tcRailGag.block, l); - tileGag[1] = (TileTCRailGag) world.getTileEntity(x, y + 1, z + 2); - - if (type == TrackTypes.LONG_STRAIGHT || type == TrackTypes.EMBEDDED_LONG_STRAIGHT) { - tcRail.idDrop = this.type.getItem().item; - } else { - tcRail.idDrop = this.type.getItem().item; - } - - if (type == TrackTypes.LONG_STRAIGHT || type == TrackTypes.EMBEDDED_LONG_STRAIGHT - || type == TrackTypes.VERY_LONG_STRAIGHT || type == TrackTypes.EMBEDDED_VERY_LONG_STRAIGHT) { - placeTrack(world,x, y + 1, z + 3, BlockIDs.tcRail.block, l); - TileTCRail tcRail2 = (TileTCRail) world.getTileEntity(x, y + 1, z + 3); - tcRail2.setFacing(l); - tcRail2.setType(type.getLabel()); - tcRail2.isLinkedToRail = true; - tcRail2.linkedX = x; - tcRail2.linkedY = y + 1; - tcRail2.linkedZ = z + 1; - - placeTrack(world,x, y + 1, z + 4, BlockIDs.tcRailGag.block, l); - tileGag[2] = (TileTCRailGag) world.getTileEntity(x, y + 1, z + 4); - - placeTrack(world,x, y + 1, z + 5, BlockIDs.tcRailGag.block, l); - tileGag[3] = (TileTCRailGag) world.getTileEntity(x, y + 1, z + 5); - - if (type == TrackTypes.VERY_LONG_STRAIGHT || type == TrackTypes.EMBEDDED_VERY_LONG_STRAIGHT) { - tcRail.idDrop = this.type.getItem().item; - } else { - tcRail.idDrop = this.type.getItem().item; - } - } - if (type == TrackTypes.VERY_LONG_STRAIGHT || type == TrackTypes.EMBEDDED_VERY_LONG_STRAIGHT) { - - placeTrack(world,x, y+1, z + 6, BlockIDs.tcRail.block, l); - TileTCRail tcRail3 = (TileTCRail) world.getTileEntity(x, y + 1, z + 6); - tcRail3.setFacing(l); - tcRail3.setType(type.getLabel()); - tcRail3.isLinkedToRail = true; - tcRail3.linkedX = x; - tcRail3.linkedY = y + 1; - tcRail3.linkedZ = z + 1; - - placeTrack(world,x, y + 1, z + 7, BlockIDs.tcRailGag.block, l); - tileGag[4] = (TileTCRailGag) world.getTileEntity(x, y + 1, z + 7); - - placeTrack(world,x, y + 1, z + 8, BlockIDs.tcRailGag.block, l); - tileGag[5] = (TileTCRailGag) world.getTileEntity(x, y + 1, z + 8); - - placeTrack(world,x, y+1, z + 9, BlockIDs.tcRail.block, l); - TileTCRail tcRail4 = (TileTCRail) world.getTileEntity(x, y + 1, z + 9); - tcRail4.setFacing(l); - tcRail4.setType(type.getLabel()); - tcRail4.isLinkedToRail = true; - tcRail4.linkedX = x; - tcRail4.linkedY = y + 1; - tcRail4.linkedZ = z + 1; - - placeTrack(world,x, y + 1, z + 10, BlockIDs.tcRailGag.block, l); - tileGag[6] = (TileTCRailGag) world.getTileEntity(x, y + 1, z + 10); - - placeTrack(world,x, y + 1, z + 11, BlockIDs.tcRailGag.block, l); - tileGag[7] = (TileTCRailGag) world.getTileEntity(x, y + 1, z + 11); - - - } - - } - if (l == 1) { - if (!canPlaceTrack(player, world, x - 1, y + 1, z) || !canPlaceTrack(player, world, x - 2, y + 1, z)) { - return false; - } - if (type == TrackTypes.LONG_STRAIGHT || type == TrackTypes.EMBEDDED_LONG_STRAIGHT){ - if (!canPlaceTrack(player, world, x - 3, y + 1, z) || !canPlaceTrack(player, world, x - 4, y + 1, z) - || !canPlaceTrack(player, world, x - 5, y + 1, z)) { - return false; - } - } - if (type == TrackTypes.VERY_LONG_STRAIGHT || type == TrackTypes.EMBEDDED_VERY_LONG_STRAIGHT){ - if ( !canPlaceTrack(player, world, x - 3, y + 1, z) || !canPlaceTrack(player, world, x - 4, y + 1, z) - || !canPlaceTrack(player, world, x - 5, y + 1, z) || !canPlaceTrack(player, world, x - 6, y+1, z ) || !canPlaceTrack(player, world, x - 7, y+1, z ) || - !canPlaceTrack(player, world, x - 8, y+1, z) || !canPlaceTrack(player, world, x - 9, y+1, z) || !canPlaceTrack(player, world, x - 10, y+1, z ) || !canPlaceTrack(player, world, x - 11, y+1, z)) { - return false; - } - } - placeTrack(world,x, y + 1, z, BlockIDs.tcRail.block, l); - TileTCRail tcRail = (TileTCRail) world.getTileEntity(x, y + 1, z); - tcRail.setFacing(l); - tcRail.setType(type.getLabel()); - - placeTrack(world,x - 1, y + 1, z , BlockIDs.tcRailGag.block, l); - tileGag[0] = (TileTCRailGag) world.getTileEntity(x - 1, y + 1, z); - - placeTrack(world,x - 2, y + 1, z, BlockIDs.tcRailGag.block, l); - tileGag[1] = (TileTCRailGag) world.getTileEntity(x - 2, y + 1, z ); - - if (type == TrackTypes.LONG_STRAIGHT || type == TrackTypes.EMBEDDED_LONG_STRAIGHT) { - tcRail.idDrop = this.type.getItem().item; - } else { - tcRail.idDrop = this.type.getItem().item; - } - - if (type == TrackTypes.LONG_STRAIGHT || type == TrackTypes.EMBEDDED_LONG_STRAIGHT - || type == TrackTypes.VERY_LONG_STRAIGHT || type == TrackTypes.EMBEDDED_VERY_LONG_STRAIGHT) { - placeTrack(world,x - 3, y + 1, z, BlockIDs.tcRail.block, l); - TileTCRail tcRail2 = (TileTCRail) world.getTileEntity(x - 3, y + 1, z); - tcRail2.setFacing(l); - tcRail2.setType(type.getLabel()); - tcRail2.isLinkedToRail = true; - tcRail2.linkedX = x - 1; - tcRail2.linkedY = y + 1; - tcRail2.linkedZ = z ; - - placeTrack(world,x - 4, y + 1, z , BlockIDs.tcRailGag.block, l); - tileGag[2] = (TileTCRailGag) world.getTileEntity(x - 4, y + 1, z); - - placeTrack(world,x - 5, y + 1, z, BlockIDs.tcRailGag.block, l); - tileGag[3] = (TileTCRailGag) world.getTileEntity(x - 5, y + 1, z); - - if (type == TrackTypes.VERY_LONG_STRAIGHT || type == TrackTypes.EMBEDDED_VERY_LONG_STRAIGHT) { - tcRail.idDrop = this.type.getItem().item; - } else { - tcRail.idDrop = this.type.getItem().item; - } - } - if (type == TrackTypes.VERY_LONG_STRAIGHT || type == TrackTypes.EMBEDDED_VERY_LONG_STRAIGHT) { - - placeTrack(world,x - 6, y+1, z, BlockIDs.tcRail.block, l); - TileTCRail tcRail3 = (TileTCRail) world.getTileEntity(x - 6, y + 1, z); - tcRail3.setType(type.getLabel()); - tcRail3.isLinkedToRail = true; - tcRail3.linkedX = x - 1; - tcRail3.linkedY = y + 1; - tcRail3.linkedZ = z ; - - placeTrack(world,x - 7, y + 1, z, BlockIDs.tcRailGag.block, l); - tileGag[4] = (TileTCRailGag) world.getTileEntity(x - 7, y + 1, z); - - placeTrack(world,x - 8, y + 1, z, BlockIDs.tcRailGag.block, l); - tileGag[5] = (TileTCRailGag) world.getTileEntity(x - 8, y + 1, z); - - placeTrack(world,x - 9, y+1, z, BlockIDs.tcRail.block, l); - TileTCRail tcRail4 = (TileTCRail) world.getTileEntity(x - 9, y + 1, z); - tcRail4.setFacing(l); - tcRail4.setType(type.getLabel()); - tcRail4.isLinkedToRail = true; - tcRail4.linkedX = x - 1; - tcRail4.linkedY = y + 1; - tcRail4.linkedZ = z; - - placeTrack(world,x - 10, y + 1, z, BlockIDs.tcRailGag.block, l); - tileGag[6] = (TileTCRailGag) world.getTileEntity(x - 10, y + 1, z); - - placeTrack(world,x - 11, y + 1, z, BlockIDs.tcRailGag.block, l); - tileGag[7] = (TileTCRailGag) world.getTileEntity(x - 11, y + 1, z); - - - } - - } - if (l == 3) { - if (!canPlaceTrack(player, world, x + 1, y + 1, z) || !canPlaceTrack(player, world, x + 2, y + 1, z)) { - return false; - } - if (type == TrackTypes.LONG_STRAIGHT || type == TrackTypes.EMBEDDED_LONG_STRAIGHT){ - if (!canPlaceTrack(player, world, x + 3, y + 1, z) || !canPlaceTrack(player, world, x + 4, y + 1, z) - || !canPlaceTrack(player, world, x + 5, y + 1, z)) { - return false; - } - } - if (type == TrackTypes.VERY_LONG_STRAIGHT || type == TrackTypes.EMBEDDED_VERY_LONG_STRAIGHT){ - if ( !canPlaceTrack(player, world, x + 3, y + 1, z) || !canPlaceTrack(player, world, x + 4, y + 1, z) - || !canPlaceTrack(player, world, x + 5, y + 1, z) || !canPlaceTrack(player, world, x + 6, y+1, z ) || !canPlaceTrack(player, world, x + 7, y+1, z ) || - !canPlaceTrack(player, world, x + 8, y+1, z) || !canPlaceTrack(player, world, x + 9, y+1, z) || !canPlaceTrack(player, world, x + 10, y+1, z ) || !canPlaceTrack(player, world, x + 11, y+1, z)) { - return false; - } - } - placeTrack(world,x, y + 1, z, BlockIDs.tcRail.block, l); - TileTCRail tcRail = (TileTCRail) world.getTileEntity(x, y + 1, z); - tcRail.setFacing(l); - tcRail.setType(type.getLabel()); - - placeTrack(world,x + 1, y + 1, z , BlockIDs.tcRailGag.block, l); - tileGag[0] = (TileTCRailGag) world.getTileEntity(x + 1, y + 1, z); - - placeTrack(world,x + 2, y + 1, z, BlockIDs.tcRailGag.block, l); - tileGag[1] = (TileTCRailGag) world.getTileEntity(x + 2, y + 1, z ); - - if (type == TrackTypes.LONG_STRAIGHT || type == TrackTypes.EMBEDDED_LONG_STRAIGHT) { - tcRail.idDrop = this.type.getItem().item; - } else { - tcRail.idDrop = this.type.getItem().item; - } - - if (type == TrackTypes.LONG_STRAIGHT || type == TrackTypes.EMBEDDED_LONG_STRAIGHT - || type == TrackTypes.VERY_LONG_STRAIGHT || type == TrackTypes.EMBEDDED_VERY_LONG_STRAIGHT) { - placeTrack(world,x + 3, y + 1, z, BlockIDs.tcRail.block, l); - TileTCRail tcRail2 = (TileTCRail) world.getTileEntity(x + 3, y + 1, z); - tcRail2.setFacing(l); - tcRail2.setType(type.getLabel()); - tcRail2.isLinkedToRail = true; - tcRail2.linkedX = x + 1; - tcRail2.linkedY = y + 1; - tcRail2.linkedZ = z ; - - placeTrack(world,x + 4, y + 1, z , BlockIDs.tcRailGag.block, l); - tileGag[2] = (TileTCRailGag) world.getTileEntity(x + 4, y + 1, z); - - placeTrack(world,x + 5, y + 1, z, BlockIDs.tcRailGag.block, l); - tileGag[3] = (TileTCRailGag) world.getTileEntity(x + 5, y + 1, z); - - if (type == TrackTypes.VERY_LONG_STRAIGHT || type == TrackTypes.EMBEDDED_VERY_LONG_STRAIGHT) { - tcRail.idDrop = this.type.getItem().item; - } else { - tcRail.idDrop = this.type.getItem().item; - } - } - if (type == TrackTypes.VERY_LONG_STRAIGHT || type == TrackTypes.EMBEDDED_VERY_LONG_STRAIGHT) { - - placeTrack(world,x + 6, y+1, z, BlockIDs.tcRail.block, l); - TileTCRail tcRail3 = (TileTCRail) world.getTileEntity(x + 6, y + 1, z); - tcRail3.setFacing(l); - tcRail3.setType(type.getLabel()); - tcRail3.isLinkedToRail = true; - tcRail3.linkedX = x + 1; - tcRail3.linkedY = y + 1; - tcRail3.linkedZ = z ; - - placeTrack(world,x + 7, y + 1, z, BlockIDs.tcRailGag.block, l); - tileGag[4] = (TileTCRailGag) world.getTileEntity(x + 7, y + 1, z); - - placeTrack(world,x + 8, y + 1, z, BlockIDs.tcRailGag.block, l); - tileGag[5] = (TileTCRailGag) world.getTileEntity(x + 8, y + 1, z); - - placeTrack(world,x + 9, y+1, z, BlockIDs.tcRail.block, l); - TileTCRail tcRail4 = (TileTCRail) world.getTileEntity(x + 9, y + 1, z); - tcRail4.setFacing(l); - tcRail4.setType(type.getLabel()); - tcRail4.isLinkedToRail = true; - tcRail4.linkedX = x + 1; - tcRail4.linkedY = y + 1; - tcRail4.linkedZ = z; - - placeTrack(world,x + 10, y + 1, z, BlockIDs.tcRailGag.block, l); - tileGag[6] = (TileTCRailGag) world.getTileEntity(x + 10, y + 1, z); - - placeTrack(world,x + 11, y + 1, z, BlockIDs.tcRailGag.block, l); - tileGag[7] = (TileTCRailGag) world.getTileEntity(x + 11, y + 1, z); - - - } - - } - for (TileTCRailGag tileTCRailGag : tileGag) { - if (player != null && tileTCRailGag == null) { - player.addChatMessage(new ChatComponentText("There was a problem when placing the track. Possibly too many tracks around")); - return false; - } - tileTCRailGag.originX = x; - tileTCRailGag.originY = y + 1; - tileTCRailGag.originZ = z; - tileTCRailGag.type = TrackTypes.MEDIUM_STRAIGHT.getLabel(); - } - return true; - } - private boolean rightDiamondCrossing(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes tempType) { - - - if (tempType.getLabel().contains("EMBEDDED")) { - typeVariantStraight = TrackTypes.EMBEDDED_SMALL_STRAIGHT.getLabel(); - typeVariantDiagonal = TrackTypes.EMBEDDED_SMALL_DIAGONAL_STRAIGHT.getLabel(); - } - - - if (!canPlaceTrack(player, world, x, y + 1, z)) { - return false; - } - - int zDisplace = 0; - int xDisplace = 0; - int xSideDisplace = 0; - int zSideDisplace = 0; - int sideFacing = l; - - if (l == 2){ - zDisplace = -1; - xSideDisplace = 1; - sideFacing = 6; - } - if (l == 0) { - zDisplace = 1; - xSideDisplace = -1; - sideFacing = 4; - } - if (l == 1) { - xDisplace = -1; - zSideDisplace= -1; - sideFacing = 5; - } - if (l == 3) { - xDisplace = 1; - zSideDisplace=1; - sideFacing = 7; - } - - if (!canPlaceTrack(player, world, x + xDisplace, y + 1, z + zDisplace) || !canPlaceTrack(player, world, x + (xDisplace * 2), y + 1, z + (zDisplace * 2))) { - return false; - } - if (!canPlaceTrack(player, world, x + (xDisplace * 2) + xSideDisplace, y + 1, z + (zDisplace * 2) + zSideDisplace) ) { - return false; - } - if (!canPlaceTrack(player, world, x - (xSideDisplace), y + 1, z - zSideDisplace)) { - return false; - } - - //Top - - putDownSingleRail(world, x + (xDisplace * 2), y + 1, z + (zDisplace * 2), l, x + (xDisplace * 2), y + 1, - z + (zDisplace * 2), 0, typeVariantStraight, false, x + (xDisplace), y + 1, - z + (zDisplace), false, false); - - //Main - - placeTrack(world,x + (xDisplace), y + 1, z + (zDisplace), BlockIDs.tcRail.block, l); - TileTCRail tcRail2 = (TileTCRail) world.getTileEntity(x + (xDisplace), y + 1, z + (zDisplace)); - tcRail2.setFacing(l); - tcRail2.cx = x + (xDisplace); - tcRail2.cy = y + 1; - tcRail2.cz = z + (zDisplace); - tcRail2.setType(tempType.getLabel()); - tcRail2.idDrop = this.type.getItem().item; - - //Bottom - - - putDownSingleRail(world, x, y + 1, z, l, x, y + 1, z, 0, typeVariantStraight, false, - x + (xDisplace), y + 1, z + (zDisplace), false, false); - - //Right - - putDownSingleRail(world, x + (xDisplace * 2) + (xSideDisplace), y + 1, - z + (zDisplace * 2) + (zSideDisplace), sideFacing, - x + (xDisplace) + (xSideDisplace), y + 1, z + (zDisplace * 2) + (zSideDisplace), 0, - typeVariantDiagonal, false, x + (xDisplace), y + 1, z + (zDisplace), - false, false); - - //Left - - putDownSingleRail(world, x - (xSideDisplace), y + 1, - z - (zSideDisplace), sideFacing, - x - (xSideDisplace), y + 1, z - (zSideDisplace), 0, - typeVariantDiagonal, false, x + (xDisplace), y + 1, z + (zDisplace), - false, false); - - - return true; - } - private boolean leftDiamondCrossing(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes tempType) { - - if (tempType.getLabel().contains("EMBEDDED")) { - typeVariantStraight = TrackTypes.EMBEDDED_SMALL_STRAIGHT.getLabel(); - typeVariantDiagonal = TrackTypes.EMBEDDED_SMALL_DIAGONAL_STRAIGHT.getLabel(); - } - - - if (!canPlaceTrack(player, world, x, y + 1, z)) { - return false; - } - - int zDisplace = 0; - int xDisplace = 0; - int xSideDisplace = 0; - int zSideDisplace = 0; - int sideFacing = l; - - if (l == 2){ - zDisplace = -1; - xSideDisplace = 1; - sideFacing = 5; - } - if (l == 0) { - zDisplace = 1; - xSideDisplace = -1; - sideFacing = 7; - } - if (l == 1) { - xDisplace = -1; - zSideDisplace= -1; - sideFacing = 4; - } - if (l == 3) { - xDisplace = 1; - zSideDisplace=1; - sideFacing = 6; - } - - - if (!canPlaceTrack(player, world, x + xDisplace, y + 1, z + zDisplace) || !canPlaceTrack(player, world, x + (xDisplace * 2), y + 1, z + (zDisplace * 2))) { - return false; - } - if (!canPlaceTrack(player, world, x + (xDisplace * 2) - xSideDisplace, y + 1, z + (zDisplace * 2) - zSideDisplace) ) { - return false; - } - if (!canPlaceTrack(player, world, x + (xSideDisplace), y + 1, z + zSideDisplace)) { - return false; - } - - //Top - - putDownSingleRail(world, x + (xDisplace * 2), y + 1, z + (zDisplace * 2), l, x + (xDisplace * 2), y + 1, - z + (zDisplace * 2), 0, typeVariantStraight, false, x + (xDisplace), y + 1, - z + (zDisplace), false, false); - - //Main - - placeTrack(world,x + (xDisplace), y + 1, z + (zDisplace), BlockIDs.tcRail.block, l); - TileTCRail tcRail2 = (TileTCRail) world.getTileEntity(x + (xDisplace), y + 1, z + (zDisplace)); - tcRail2.setFacing(l); - tcRail2.cx = x + (xDisplace); - tcRail2.cy = y + 1; - tcRail2.cz = z + (zDisplace); - tcRail2.setType(tempType.getLabel()); - tcRail2.idDrop = this.type.getItem().item; - - //Bottom - - - putDownSingleRail(world, x, y + 1, z, l, x, y + 1, z, 0, typeVariantStraight, false, - x + (xDisplace), y + 1, z + (zDisplace), false, false); - - //Left - - putDownSingleRail(world, x + (xDisplace * 2) - (xSideDisplace), y + 1, - z + (zDisplace * 2) - (zSideDisplace), sideFacing, - x - (xDisplace) - (xSideDisplace), y + 1, z + (zDisplace * 2) - (zSideDisplace), 0, - typeVariantDiagonal, false, x + (xDisplace), y + 1, z + (zDisplace), - false, false); - - //Right - - putDownSingleRail(world, x + (xSideDisplace), y + 1, - z + (zSideDisplace), sideFacing, - x + (xSideDisplace), y + 1, z + (zSideDisplace), 0, - typeVariantDiagonal, false, x + (xDisplace), y + 1, z + (zDisplace), - false, false); - - - return true; - } - private boolean doubleDiamondCrossing(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes type){ - - if (type.getLabel().contains("EMBEDDED")) { - typeVariantStraight = TrackTypes.EMBEDDED_SMALL_STRAIGHT.getLabel(); - typeVariantDiagonal = TrackTypes.EMBEDDED_SMALL_DIAGONAL_STRAIGHT.getLabel(); - } - - - if (!canPlaceTrack(player, world, x, y + 1, z)) { - return false; - } - - int zDisplace = 0; - int xDisplace = 0; - int xSideDisplace = 0; - int zSideDisplace = 0; - int sideFacing = l; - int sideFacing2 = l; - - if (l == 2){ - zDisplace = -1; - xSideDisplace = 1; - sideFacing = 6; - sideFacing2 = 5; - } - if (l == 0) { - zDisplace = 1; - xSideDisplace = -1; - sideFacing = 4; - sideFacing2 = 7; - } - if (l == 1) { - xDisplace = -1; - zSideDisplace= -1; - sideFacing = 5; - sideFacing2 = 4; - } - if (l == 3) { - xDisplace = 1; - zSideDisplace=1; - sideFacing = 7; - sideFacing2 = 6; - } - - if (!canPlaceTrack(player, world, x + xDisplace, y + 1, z + zDisplace) || !canPlaceTrack(player, world, x + (xDisplace * 2), y + 1, z + (zDisplace * 2))) { - return false; - } - if (!canPlaceTrack(player, world, x + (xDisplace * 2) - xSideDisplace, y + 1, z + (zDisplace * 2) - zSideDisplace) ) { - return false; - } - if (!canPlaceTrack(player, world, x + (xSideDisplace), y + 1, z + zSideDisplace)) { - return false; - } - if (!canPlaceTrack(player, world, x + (xDisplace * 2) + xSideDisplace, y + 1, z + (zDisplace * 2) + zSideDisplace) ) { - return false; - } - if (!canPlaceTrack(player, world, x - (xSideDisplace), y + 1, z - zSideDisplace)) { - return false; - } - - //Top - - putDownSingleRail(world, x + (xDisplace * 2), y + 1, z + (zDisplace * 2), l, x + (xDisplace * 2), y + 1, - z + (zDisplace * 2), 0, typeVariantStraight, false, x + (xDisplace), y + 1, - z + (zDisplace), false, false); - - //Main - - placeTrack(world,x + (xDisplace), y + 1, z + (zDisplace), BlockIDs.tcRail.block, l); - TileTCRail tcRail2 = (TileTCRail) world.getTileEntity(x + (xDisplace), y + 1, z + (zDisplace)); - tcRail2.setFacing(l); - tcRail2.cx = x + (xDisplace); - tcRail2.cy = y + 1; - tcRail2.cz = z + (zDisplace); - tcRail2.setType(type.getLabel()); - tcRail2.idDrop = this.type.getItem().item; - - //Bottom - - - putDownSingleRail(world, x, y + 1, z, l, x, y + 1, z, 0, typeVariantStraight, false, - x + (xDisplace), y + 1, z + (zDisplace), false, false); - //RIGHT - putDownSingleRail(world, x + (xDisplace * 2) + (xSideDisplace), y + 1, - z + (zDisplace * 2) + (zSideDisplace), sideFacing, - x + (xDisplace) + (xSideDisplace), y + 1, z + (zDisplace * 2) + (zSideDisplace), 0, - typeVariantDiagonal, false,x + (xDisplace), y + 1, z + (zDisplace), - false, false); - - //Left - - putDownSingleRail(world, x - (xSideDisplace), y + 1, - z - (zSideDisplace), sideFacing, - x - (xSideDisplace), y + 1, z - (zSideDisplace), 0, - typeVariantDiagonal, false, x + (xDisplace), y + 1, z + (zDisplace), - false, false); - //Left2 - - putDownSingleRail(world, x + (xDisplace * 2) - (xSideDisplace), y + 1, - z + (zDisplace * 2) - (zSideDisplace), sideFacing2, - x - (xDisplace) - (xSideDisplace), y + 1, z + (zDisplace * 2) - (zSideDisplace), 0, - typeVariantDiagonal, false, x + (xDisplace), y + 1, z + (zDisplace), - false, false); - - //Right2 - - putDownSingleRail(world, x + (xSideDisplace), y + 1, - z + (zSideDisplace), sideFacing2, - x + (xSideDisplace), y + 1, z + (zSideDisplace), 0, - typeVariantDiagonal, false, x + (xDisplace), y + 1, z + (zDisplace), - false, false); - - return true; - } - private boolean diagonalTwoWaysCrossing(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes type){ - if (type.getLabel().contains("EMBEDDED")) { - typeVariantDiagonal = TrackTypes.EMBEDDED_SMALL_DIAGONAL_STRAIGHT.getLabel(); - } - - - if (!canPlaceTrack(player, world, x, y + 1, z)) { - return false; - } - - int zDisplace = 0; - int xDisplace = 0; - int xSideDisplace = 0; - int zSideDisplace = 0; - int sideFacing = l; - int sideFacing2 = l; - - if (l == 2){ - zDisplace = -1; - xSideDisplace = 1; - sideFacing = 6; - sideFacing2 = 5; - } - if (l == 0) { - zDisplace = 1; - xSideDisplace = -1; - sideFacing = 4; - sideFacing2 = 7; - } - if (l == 1) { - xDisplace = -1; - zSideDisplace= -1; - sideFacing = 5; - sideFacing2 = 4; - } - if (l == 3) { - xDisplace = 1; - zSideDisplace=1; - sideFacing = 7; - sideFacing2 = 6; - } - - if (!canPlaceTrack(player, world, x + xDisplace + xSideDisplace, y + 1, z + zDisplace + zSideDisplace) ) { - return false; - } - if (!canPlaceTrack(player, world, x - xDisplace - (xSideDisplace), y + 1, z - zDisplace - zSideDisplace)) { - return false; - } - if (!canPlaceTrack(player, world, x + xDisplace - xSideDisplace, y + 1, z + zDisplace - zSideDisplace) ) { - return false; - } - if (!canPlaceTrack(player, world, x - xDisplace + (xSideDisplace), y + 1, z - zDisplace + zSideDisplace)) { - return false; - } - - - //Main - placeTrack(world,x , y + 1, z , BlockIDs.tcRail.block, l); - TileTCRail tcRail2 = (TileTCRail) world.getTileEntity(x , y + 1, z); - tcRail2.setFacing(l); - tcRail2.cx = x + (xDisplace); - tcRail2.cy = y + 1; - tcRail2.cz = z + (zDisplace); - tcRail2.setType(type.getLabel()); - tcRail2.idDrop = this.type.getItem().item; - - //RIGHT - putDownSingleRail(world, x + xDisplace + (xSideDisplace), y + 1, - z + zDisplace + (zSideDisplace), sideFacing, - x + (xDisplace) + (xSideDisplace), y + 1, z + zDisplace + (zSideDisplace), 0, - typeVariantDiagonal, false,x , y + 1, z, - false, false); - - //Left - - putDownSingleRail(world, x - xDisplace - (xSideDisplace), y + 1, - z - zDisplace - (zSideDisplace), sideFacing, - x - xDisplace - (xSideDisplace), y + 1, z - zDisplace - (zSideDisplace), 0, - typeVariantDiagonal, false, x , y + 1, z, - false, false); - //Left2 - - putDownSingleRail(world, x + xDisplace - (xSideDisplace), y + 1, - z + zDisplace - (zSideDisplace), sideFacing2, - x + (xDisplace) - (xSideDisplace), y + 1, z + zDisplace - (zSideDisplace), 0, - typeVariantDiagonal, false, x , y + 1, z , - false, false); - - //Right2 - - putDownSingleRail(world, x - xDisplace + (xSideDisplace), y + 1, - z - zDisplace + (zSideDisplace), sideFacing2, - x - xDisplace + (xSideDisplace), y + 1, z - zDisplace + (zSideDisplace), 0, - typeVariantDiagonal, false, x, y + 1, z , - false, false); - - - return true; - } - private boolean fourWaysCrossing(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes type){ - - if (type.getLabel().contains("EMBEDDED")) { - typeVariantDiagonal = TrackTypes.EMBEDDED_SMALL_DIAGONAL_STRAIGHT.getLabel(); - } - - - if (!canPlaceTrack(player, world, x, y + 1, z)) { - return false; - } - - int zDisplace = 0; - int xDisplace = 0; - int xSideDisplace = 0; - int zSideDisplace = 0; - int sideFacing = l; - int sideFacing2 = l; - int facing = l; - - if (l == 2){ - zDisplace = -1; - xSideDisplace = 1; - sideFacing = 6; - sideFacing2 = 5; - facing = 1; - } - if (l == 0) { - zDisplace = 1; - xSideDisplace = -1; - sideFacing = 4; - sideFacing2 = 7; - facing = 1; - } - if (l == 1) { - xDisplace = -1; - zSideDisplace= -1; - sideFacing = 5; - sideFacing2 = 4; - facing = 2; - } - if (l == 3) { - xDisplace = 1; - zSideDisplace=1; - sideFacing = 7; - sideFacing2 = 6; - facing = 2; - } - - if (!canPlaceTrack(player, world, x + xDisplace + xSideDisplace, y + 1, z + zDisplace + zSideDisplace) ) { - return false; - } - if (!canPlaceTrack(player, world, x - xDisplace - (xSideDisplace), y + 1, z - zDisplace - zSideDisplace)) { - return false; - } - if (!canPlaceTrack(player, world, x + xDisplace - xSideDisplace, y + 1, z + zDisplace - zSideDisplace) ) { - return false; - } - if (!canPlaceTrack(player, world, x - xDisplace + (xSideDisplace), y + 1, z - zDisplace + zSideDisplace)) { - return false; - } - if (!canPlaceTrack(player, world, x + xDisplace, y + 1, z + zDisplace) ) { - return false; - } - if (!canPlaceTrack(player, world, x - xDisplace , y + 1, z - zDisplace) ) { - return false; - } - if (!canPlaceTrack(player, world, x + xSideDisplace, y + 1, z + zSideDisplace) ) { - return false; - } - if (!canPlaceTrack(player, world, x - xSideDisplace, y + 1, z - zSideDisplace) ) { - return false; - } - - - //Main - placeTrack(world,x , y + 1, z , BlockIDs.tcRail.block, l); - TileTCRail tcRail2 = (TileTCRail) world.getTileEntity(x , y + 1, z); - tcRail2.setFacing(l); - tcRail2.cx = x + (xDisplace); - tcRail2.cy = y + 1; - tcRail2.cz = z + (zDisplace); - tcRail2.setType(type.getLabel()); - tcRail2.idDrop = this.type.getItem().item; - - - //T - putDownSingleRail(world, x + xDisplace , y + 1, - z + zDisplace , l, - x + (xDisplace) , y + 1, z + zDisplace , 0, - typeVariantStraight, false,x , y + 1, z, - false, false); - //B - putDownSingleRail(world, x - xDisplace , y + 1, - z - zDisplace , l, - x - (xDisplace) , y + 1, z - zDisplace , 0, - typeVariantStraight, false,x , y + 1, z, - false, false); - //L - putDownSingleRail(world, x + xSideDisplace , y + 1, - z + zSideDisplace , facing, - x + (xSideDisplace) , y + 1, z + zSideDisplace , 0, - typeVariantStraight, false,x , y + 1, z, - false, false); - //R - putDownSingleRail(world, x - xSideDisplace , y + 1, - z - zSideDisplace , facing, - x - (xSideDisplace) , y + 1, z - zSideDisplace , 0, - typeVariantStraight, false,x , y + 1, z, - false, false); - - - //BR - putDownSingleRail(world, x + xDisplace + (xSideDisplace), y + 1, - z + zDisplace + (zSideDisplace), sideFacing, - x + (xDisplace) + (xSideDisplace), y + 1, z + zDisplace + (zSideDisplace), 0, - typeVariantDiagonal, false,x , y + 1, z, - false, false); - - //TL - - putDownSingleRail(world, x - xDisplace - (xSideDisplace), y + 1, - z - zDisplace - (zSideDisplace), sideFacing, - x - xDisplace - (xSideDisplace), y + 1, z - zDisplace - (zSideDisplace), 0, - typeVariantDiagonal, false, x , y + 1, z, - false, false); - //TR - - putDownSingleRail(world, x + xDisplace - (xSideDisplace), y + 1, - z + zDisplace - (zSideDisplace), sideFacing2, - x + (xDisplace) - (xSideDisplace), y + 1, z + zDisplace - (zSideDisplace), 0, - typeVariantDiagonal, false, x , y + 1, z , - false, false); - - //BL - - putDownSingleRail(world, x - xDisplace + (xSideDisplace), y + 1, - z - zDisplace + (zSideDisplace), sideFacing2, - x - xDisplace + (xSideDisplace), y + 1, z - zDisplace + (zSideDisplace), 0, - typeVariantDiagonal, false, x, y + 1, z , - false, false); - - - - return true; - } - private boolean smallDiagonalStraight(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes type) { - - - TileTCRailGag[] tileGag = new TileTCRailGag[2]; - - if (l == 6) { - - if (!canPlaceTrack(player, world, x, y + 1, z) || !canPlaceTrack(player, world, x, y + 1, z - 1) || !canPlaceTrack(player, world, x + 1, y + 1, z) ) { - return false; - } - - placeTrack(world, x, y + 1, z, BlockIDs.tcRail.block, l); - TileTCRail tcRail = (TileTCRail) world.getTileEntity(x, y + 1, z); - - placeTrack(world, x , y + 1, z - 1, BlockIDs.tcRailGag.block, l); - tileGag[0] = (TileTCRailGag) world.getTileEntity(x , y+1, z - 1); - tileGag[0].canPlaceRollingstock = false; - - placeTrack(world, x + 1 , y + 1, z , BlockIDs.tcRailGag.block, l); - tileGag[1] = (TileTCRailGag) world.getTileEntity(x + 1 , y+1, z ); - tileGag[1].canPlaceRollingstock = false; - tcRail.setFacing(l); - tcRail.setType(type.getLabel()); - tcRail.setRailLength(1D); - tcRail.idDrop = this.type.getItem().item; - } - if (l == 4) { - - if (!canPlaceTrack(player, world, x, y + 1, z) || !canPlaceTrack(player, world, x, y + 1, z + 1) || !canPlaceTrack(player, world, x - 1, y + 1, z) ) { - return false; - } - - placeTrack(world, x, y + 1, z, BlockIDs.tcRail.block, l); - TileTCRail tcRail = (TileTCRail) world.getTileEntity(x, y + 1, z); - placeTrack(world, x , y + 1, z + 1, BlockIDs.tcRailGag.block, l); - tileGag[0] = (TileTCRailGag) world.getTileEntity(x , y+1, z + 1); - - placeTrack(world, x - 1 , y + 1, z , BlockIDs.tcRailGag.block, l); - tileGag[1] = (TileTCRailGag) world.getTileEntity(x - 1 , y+1, z ); - - tcRail.setFacing(l); - tcRail.setType(type.getLabel()); - tcRail.setRailLength(1D); - tcRail.idDrop = this.type.getItem().item; - } - if (l == 5) { - - if (!canPlaceTrack(player, world, x, y + 1, z) || !canPlaceTrack(player, world, x - 1, y + 1, z) || !canPlaceTrack(player, world, x - 1, y + 1, z) ) { - return false; - } - - placeTrack(world, x, y + 1, z, BlockIDs.tcRail.block, l); - TileTCRail tcRail = (TileTCRail) world.getTileEntity(x, y + 1, z); - - placeTrack(world, x , y + 1, z - 1, BlockIDs.tcRailGag.block, l); - tileGag[0] = (TileTCRailGag) world.getTileEntity(x , y+1, z - 1); - - placeTrack(world, x - 1 , y + 1, z , BlockIDs.tcRailGag.block, l); - tileGag[1] = (TileTCRailGag) world.getTileEntity(x - 1 , y+1, z ); - tcRail.setFacing(l); - tcRail.setType(type.getLabel()); - tcRail.setRailLength(1D); - tcRail.idDrop = this.type.getItem().item; - } - if (l == 7) { - - if (!canPlaceTrack(player, world, x, y + 1, z) || !canPlaceTrack(player, world, x, y + 1, z + 1) || !canPlaceTrack(player, world, x + 1, y + 1, z) ) { - return false; - } - - placeTrack(world, x, y + 1, z, BlockIDs.tcRail.block, l); - TileTCRail tcRail = (TileTCRail) world.getTileEntity(x, y + 1, z); - placeTrack(world, x , y + 1, z + 1, BlockIDs.tcRailGag.block, l); - tileGag[0] = (TileTCRailGag) world.getTileEntity(x , y+1, z + 1); - - placeTrack(world, x + 1 , y + 1, z , BlockIDs.tcRailGag.block, l); - tileGag[1] = (TileTCRailGag) world.getTileEntity(x + 1 , y+1, z ); - tcRail.setFacing(l); - tcRail.setType(type.getLabel()); - tcRail.setRailLength(1D); - tcRail.idDrop = this.type.getItem().item; - } - - for (TileTCRailGag tileTCRailGag : tileGag) { - if (player != null && tileTCRailGag == null) { - player.addChatMessage(new ChatComponentText("There was a problem when placing the track. Possibly too many tracks around")); - return false; - } - tileTCRailGag.originX = x; - tileTCRailGag.originY = y + 1; - tileTCRailGag.originZ = z; - tileTCRailGag.type = TrackTypes.SMALL_DIAGONAL_STRAIGHT.getLabel(); - tileTCRailGag.canPlaceRollingstock = false; - } - return true; - } - private boolean diagonalStraight(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes type) { - /** check if first rail can be placed */ - if (!canPlaceTrack(player, world, x, y + 1, z)) { - return false; - } - TileTCRailGag[] tileGag = new TileTCRailGag[8]; - if (type == TrackTypes.LONG_DIAGONAL_STRAIGHT || type == TrackTypes.EMBEDDED_LONG_DIAGONAL_STRAIGHT) { - tileGag = new TileTCRailGag[16]; - } - - if (type == TrackTypes.VERY_LONG_DIAGONAL_STRAIGHT || type == TrackTypes.EMBEDDED_VERY_LONG_DIAGONAL_STRAIGHT){ - tileGag = new TileTCRailGag[32]; - } - if (l == 6) { - - if ( !canPlaceTrack(player, world, x , y + 1, z - 1) || !canPlaceTrack(player, world, x + 1, y + 1, z) - || !canPlaceTrack(player, world, x + 1 , y + 1, z - 1)|| !canPlaceTrack(player, world, x + 1, y + 1, z - 2) || !canPlaceTrack(player, world, x + 2, y + 1, z - 1) - || !canPlaceTrack(player, world, x + 2, y + 1, z - 2) || !canPlaceTrack(player, world, x + 2, y + 1, z - 3) || !canPlaceTrack(player, world, x + 3, y + 1, z - 2)) { - return false; - } - if (type == TrackTypes.LONG_DIAGONAL_STRAIGHT || type == TrackTypes.EMBEDDED_LONG_DIAGONAL_STRAIGHT){ - if ( !canPlaceTrack(player, world, x + 3, y + 1, z - 3) || !canPlaceTrack(player, world, x + 3, y + 1, z - 4) || !canPlaceTrack(player, world, x + 4, y + 1, z - 3) - || !canPlaceTrack(player, world, x + 4, y + 1, z - 4) || !canPlaceTrack(player, world, x + 4, y + 1, z - 5) || !canPlaceTrack(player, world, x + 5, y + 1, z - 4) - || !canPlaceTrack(player, world, x + 5, y + 1, z - 5) || !canPlaceTrack(player, world, x + 5, y + 1, z - 6) || !canPlaceTrack(player, world, x + 6, y + 1, z - 5)) { - return false; - } - } - if (type == TrackTypes.VERY_LONG_DIAGONAL_STRAIGHT || type == TrackTypes.EMBEDDED_VERY_LONG_DIAGONAL_STRAIGHT){ - if ( !canPlaceTrack(player, world, x + 3, y + 1, z - 3) || !canPlaceTrack(player, world, x + 3, y + 1, z - 4) || !canPlaceTrack(player, world, x + 4, y + 1, z - 3) - || !canPlaceTrack(player, world, x + 4, y + 1, z - 4) || !canPlaceTrack(player, world, x + 4, y + 1, z - 5) || !canPlaceTrack(player, world, x + 5, y + 1, z - 4) - || !canPlaceTrack(player, world, x + 5, y + 1, z - 5) || !canPlaceTrack(player, world, x + 5, y + 1, z - 6) || !canPlaceTrack(player, world, x + 6, y + 1, z - 5) - || !canPlaceTrack(player, world, x + 6, y+1, z - 6) || !canPlaceTrack(player, world, x + 6, y+1, z - 7) || !canPlaceTrack(player, world, x + 7, y+1, z - 6) - || !canPlaceTrack(player, world, x + 7, y+1, z - 7) || !canPlaceTrack(player, world, x + 7, y+1, z - 8) || !canPlaceTrack(player, world, x + 8, y+1, z - 7) - || !canPlaceTrack(player, world, x + 8, y+1, z - 8) || !canPlaceTrack(player, world, x + 8, y+1, z - 9) || !canPlaceTrack(player, world, x + 9, y+1, z - 8) - || !canPlaceTrack(player, world, x + 9, y+1, z - 9) || !canPlaceTrack(player, world, x + 9, y+1, z - 10) || !canPlaceTrack(player, world, x + 10, y+1, z - 9) - || !canPlaceTrack(player, world,x + 10, y+1, z - 10) || !canPlaceTrack(player, world,x + 10, y+1, z - 11) || !canPlaceTrack(player, world,x + 11, y+1, z - 10) - || !canPlaceTrack(player, world, x + 11, y+1, z - 11)|| !canPlaceTrack(player, world, x + 11, y+1, z - 12)|| !canPlaceTrack(player, world, x + 12, y+1, z - 11)) { - return false; - } - } - placeTrack(world,x, y + 1, z, BlockIDs.tcRail.block, l); - TileTCRail tcRail = (TileTCRail) world.getTileEntity(x, y + 1, z); - tcRail.setFacing(l); - tcRail.setType(type.getLabel()); - tcRail.setRailLength(3D); - - placeTrack(world,x + 1, y + 1, z - 1, BlockIDs.tcRailGag.block, l); - tileGag[0] = (TileTCRailGag) world.getTileEntity(x + 1, y + 1, z - 1); - - placeTrack(world,x + 2, y + 1, z - 2, BlockIDs.tcRailGag.block, l); - tileGag[1] = (TileTCRailGag) world.getTileEntity(x + 2, y + 1, z - 2); - - placeTrack(world,x , y + 1, z - 1, BlockIDs.tcRailGag.block, l); - tileGag[2] = (TileTCRailGag) world.getTileEntity(x, y + 1, z - 1); - tileGag[2].canPlaceRollingstock = false; - placeTrack(world,x + 1, y + 1, z , BlockIDs.tcRailGag.block, l); - tileGag[3] = (TileTCRailGag) world.getTileEntity(x + 1, y + 1, z ); - tileGag[3].canPlaceRollingstock = false; - placeTrack(world,x + 1, y + 1, z - 2, BlockIDs.tcRailGag.block, l); - tileGag[4] = (TileTCRailGag) world.getTileEntity(x + 1, y + 1, z - 2); - tileGag[4].canPlaceRollingstock = false; - placeTrack(world,x + 2, y + 1, z - 1, BlockIDs.tcRailGag.block, l); - tileGag[5] = (TileTCRailGag) world.getTileEntity(x + 2, y + 1, z - 1); - tileGag[5].canPlaceRollingstock = false; - placeTrack(world,x + 2, y + 1, z - 3, BlockIDs.tcRailGag.block, l); - tileGag[6] = (TileTCRailGag) world.getTileEntity(x + 2, y + 1, z - 3); - tileGag[6].canPlaceRollingstock = false; - placeTrack(world,x + 3, y + 1, z - 2, BlockIDs.tcRailGag.block, l); - tileGag[7] = (TileTCRailGag) world.getTileEntity(x + 3, y + 1, z - 2); - tileGag[7].canPlaceRollingstock = false; - if (type == TrackTypes.LONG_DIAGONAL_STRAIGHT || type == TrackTypes.EMBEDDED_LONG_DIAGONAL_STRAIGHT) { - tcRail.idDrop = this.type.getItem().item; - } else { - tcRail.idDrop = this.type.getItem().item; - } - - - - if (type == TrackTypes.LONG_DIAGONAL_STRAIGHT || type == TrackTypes.VERY_LONG_DIAGONAL_STRAIGHT || type == TrackTypes.EMBEDDED_LONG_DIAGONAL_STRAIGHT || type == TrackTypes.EMBEDDED_VERY_LONG_DIAGONAL_STRAIGHT) { - placeTrack(world,x + 3, y + 1, z - 3, BlockIDs.tcRail.block, l); - TileTCRail tcRail2 = (TileTCRail) world.getTileEntity(x + 3, y + 1, z - 3); - tcRail2.setFacing(l); - tcRail2.setType(type.getLabel()); - tcRail2.isLinkedToRail = true; - tcRail2.linkedX = x + 1; - tcRail2.linkedY = y + 1; - tcRail2.linkedZ = z - 1; - tcRail.setRailLength(6D); - tcRail2.setRailLength(3D); - - placeTrack(world,x + 4, y + 1, z - 4, BlockIDs.tcRailGag.block, l); - tileGag[8] = (TileTCRailGag) world.getTileEntity(x + 4, y + 1, z - 4); - - placeTrack(world,x + 5, y + 1, z - 5, BlockIDs.tcRailGag.block, l); - tileGag[9] = (TileTCRailGag) world.getTileEntity(x + 5, y + 1, z - 5); - - placeTrack(world,x + 3 , y + 1, z - 4, BlockIDs.tcRailGag.block, l); - tileGag[10] = (TileTCRailGag) world.getTileEntity(x + 3, y + 1, z - 4); - tileGag[10].canPlaceRollingstock = false; - placeTrack(world,x + 4, y + 1, z - 3, BlockIDs.tcRailGag.block, l); - tileGag[11] = (TileTCRailGag) world.getTileEntity(x + 4, y + 1, z - 3); - tileGag[11].canPlaceRollingstock = false; - placeTrack(world,x + 5, y + 1, z - 4, BlockIDs.tcRailGag.block, l); - tileGag[12] = (TileTCRailGag) world.getTileEntity(x + 5, y + 1, z - 4); - tileGag[12].canPlaceRollingstock = false; - placeTrack(world,x + 4, y + 1, z - 5, BlockIDs.tcRailGag.block, l); - tileGag[13] = (TileTCRailGag) world.getTileEntity(x + 4, y + 1, z - 5); - tileGag[13].canPlaceRollingstock = false; - placeTrack(world,x + 6, y + 1, z - 5, BlockIDs.tcRailGag.block, l); - tileGag[14] = (TileTCRailGag) world.getTileEntity(x + 6, y + 1, z - 5); - tileGag[14].canPlaceRollingstock = false; - placeTrack(world,x + 5, y + 1, z - 6, BlockIDs.tcRailGag.block, l); - tileGag[15] = (TileTCRailGag) world.getTileEntity(x + 5, y + 1, z - 6); - tileGag[15].canPlaceRollingstock = false; - if (type == TrackTypes.VERY_LONG_DIAGONAL_STRAIGHT) { - tcRail.idDrop = this.type.getItem().item; - } else { - tcRail.idDrop = this.type.getItem().item; - } - } - if (type == TrackTypes.VERY_LONG_DIAGONAL_STRAIGHT || type == TrackTypes.EMBEDDED_VERY_LONG_DIAGONAL_STRAIGHT) { - - placeTrack(world,x + 6, y + 1, z - 6, BlockIDs.tcRail.block, l); - TileTCRail tcRail3 = (TileTCRail) world.getTileEntity(x + 6, y + 1, z - 6); - tcRail3.setFacing(l); - tcRail3.setType(type.getLabel()); - tcRail3.isLinkedToRail = true; - tcRail3.linkedX = x + 1; - tcRail3.linkedY = y + 1; - tcRail3.linkedZ = z - 1; - tcRail.setRailLength(12D); - tcRail3.setRailLength(3D); - - placeTrack(world,x + 7, y + 1, z - 7, BlockIDs.tcRailGag.block, l); - tileGag[16] = (TileTCRailGag) world.getTileEntity(x + 7, y + 1, z - 7); - - placeTrack(world,x + 8, y + 1, z - 8, BlockIDs.tcRailGag.block, l); - tileGag[17] = (TileTCRailGag) world.getTileEntity(x + 8, y + 1, z - 8); - - placeTrack(world,x + 6 , y + 1, z - 7, BlockIDs.tcRailGag.block, l); - tileGag[18] = (TileTCRailGag) world.getTileEntity(x + 6, y + 1, z - 7); - tileGag[18].canPlaceRollingstock = false; - placeTrack(world,x + 7, y + 1, z - 6, BlockIDs.tcRailGag.block, l); - tileGag[19] = (TileTCRailGag) world.getTileEntity(x + 7, y + 1, z - 6); - tileGag[19].canPlaceRollingstock = false; - placeTrack(world,x + 7, y + 1, z - 8, BlockIDs.tcRailGag.block, l); - tileGag[20] = (TileTCRailGag) world.getTileEntity(x + 7, y + 1, z - 8); - tileGag[20].canPlaceRollingstock = false; - placeTrack(world,x + 8, y + 1, z - 7, BlockIDs.tcRailGag.block, l); - tileGag[21] = (TileTCRailGag) world.getTileEntity(x + 8, y + 1, z - 7); - tileGag[21].canPlaceRollingstock = false; - placeTrack(world,x + 8, y + 1, z - 9, BlockIDs.tcRailGag.block, l); - tileGag[22] = (TileTCRailGag) world.getTileEntity(x + 8, y + 1, z - 9); - tileGag[22].canPlaceRollingstock = false; - placeTrack(world,x + 9, y + 1, z - 8, BlockIDs.tcRailGag.block, l); - tileGag[23] = (TileTCRailGag) world.getTileEntity(x + 9, y + 1, z - 8); - tileGag[23].canPlaceRollingstock = false; - - placeTrack(world,x + 9, y+1, z - 9, BlockIDs.tcRail.block, l); - TileTCRail tcRail4 = (TileTCRail) world.getTileEntity(x + 9, y + 1, z - 9); - tcRail4.setFacing(l); - tcRail4.setType(type.getLabel()); - tcRail4.isLinkedToRail = true; - tcRail4.linkedX = x + 1; - tcRail4.linkedY = y + 1; - tcRail4.linkedZ = z - 1; - tcRail4.setRailLength(3D); - - - - placeTrack(world,x + 10, y + 1, z - 10, BlockIDs.tcRailGag.block, l); - tileGag[24] = (TileTCRailGag) world.getTileEntity(x + 10, y + 1, z - 10); - - placeTrack(world,x + 11, y + 1, z - 11, BlockIDs.tcRailGag.block, l); - tileGag[25] = (TileTCRailGag) world.getTileEntity(x + 11, y + 1, z - 11); - - placeTrack(world,x + 9 , y + 1, z - 10, BlockIDs.tcRailGag.block, l); - tileGag[26] = (TileTCRailGag) world.getTileEntity(x + 9, y + 1, z - 10); - tileGag[26].canPlaceRollingstock = false; - placeTrack(world,x + 10, y + 1, z - 9, BlockIDs.tcRailGag.block, l); - tileGag[27] = (TileTCRailGag) world.getTileEntity(x + 10, y + 1, z - 9); - tileGag[27].canPlaceRollingstock = false; - placeTrack(world,x + 10, y + 1, z - 11, BlockIDs.tcRailGag.block, l); - tileGag[28] = (TileTCRailGag) world.getTileEntity(x + 10, y + 1, z - 11); - tileGag[28].canPlaceRollingstock = false; - placeTrack(world,x + 11, y + 1, z - 10, BlockIDs.tcRailGag.block, l); - tileGag[29] = (TileTCRailGag) world.getTileEntity(x + 11, y + 1, z - 10); - tileGag[29].canPlaceRollingstock = false; - placeTrack(world,x + 11, y + 1, z - 12, BlockIDs.tcRailGag.block, l); - tileGag[30] = (TileTCRailGag) world.getTileEntity(x + 11, y + 1, z - 12); - tileGag[30].canPlaceRollingstock = false; - placeTrack(world,x + 12, y + 1, z - 11, BlockIDs.tcRailGag.block, l); - tileGag[31] = (TileTCRailGag) world.getTileEntity(x + 12, y + 1, z - 11); - tileGag[31].canPlaceRollingstock = false; - - } - - } - - if (l == 4) { - - if ( !canPlaceTrack(player, world, x , y + 1, z + 1) || !canPlaceTrack(player, world, x - 1, y + 1, z) - || !canPlaceTrack(player, world, x - 1 , y + 1, z + 1) || !canPlaceTrack(player, world, x - 1, y + 1, z + 2) || !canPlaceTrack(player, world, x - 2, y + 1, z + 1) - || !canPlaceTrack(player, world, x - 2, y + 1, z + 2) || !canPlaceTrack(player, world, x - 2, y + 1, z + 3) || !canPlaceTrack(player, world, x - 3, y + 1, z + 2)) { - return false; - } - if (type == TrackTypes.LONG_DIAGONAL_STRAIGHT || type == TrackTypes.EMBEDDED_LONG_DIAGONAL_STRAIGHT){ - if ( !canPlaceTrack(player, world, x - 3, y + 1, z + 3) || !canPlaceTrack(player, world, x - 3, y + 1, z + 4) || !canPlaceTrack(player, world, x - 4, y + 1, z + 3) - || !canPlaceTrack(player, world, x - 4, y + 1, z + 4) || !canPlaceTrack(player, world, x - 4, y + 1, z + 5) || !canPlaceTrack(player, world, x - 5, y + 1, z + 4) - || !canPlaceTrack(player, world, x - 5, y + 1, z + 5) || !canPlaceTrack(player, world, x - 5, y + 1, z + 6) || !canPlaceTrack(player, world, x - 6, y + 1, z + 5)) { - return false; - } - } - if (type == TrackTypes.VERY_LONG_DIAGONAL_STRAIGHT || type == TrackTypes.EMBEDDED_VERY_LONG_DIAGONAL_STRAIGHT){ - if ( !canPlaceTrack(player, world, x - 3, y + 1, z + 3) || !canPlaceTrack(player, world, x - 3, y + 1, z + 4) || !canPlaceTrack(player, world, x - 4, y + 1, z + 3) - || !canPlaceTrack(player, world, x - 4, y + 1, z + 4) || !canPlaceTrack(player, world, x - 4, y + 1, z + 5) || !canPlaceTrack(player, world, x - 5, y + 1, z + 4) - || !canPlaceTrack(player, world, x - 5, y + 1, z + 5) || !canPlaceTrack(player, world, x - 5, y + 1, z + 6) || !canPlaceTrack(player, world, x - 6, y + 1, z + 5) - || !canPlaceTrack(player, world, x - 6, y+1, z + 6) || !canPlaceTrack(player, world, x - 6, y+1, z + 7) || !canPlaceTrack(player, world, x - 7, y+1, z + 6) - || !canPlaceTrack(player, world, x - 7, y+1, z + 7) || !canPlaceTrack(player, world, x - 7, y+1, z + 8) || !canPlaceTrack(player, world, x - 8, y+1, z + 7) - || !canPlaceTrack(player, world, x - 8, y+1, z + 8) || !canPlaceTrack(player, world, x - 8, y+1, z + 9) || !canPlaceTrack(player, world, x - 9, y+1, z + 8) - || !canPlaceTrack(player, world, x - 9, y+1, z + 9) || !canPlaceTrack(player, world, x - 9, y+1, z + 10) || !canPlaceTrack(player, world, x - 10, y+1, z + 9) - || !canPlaceTrack(player, world,x - 10, y+1, z + 10) || !canPlaceTrack(player, world,x - 10, y+1, z + 11) || !canPlaceTrack(player, world,x - 11, y+1, z + 10) - || !canPlaceTrack(player, world, x - 11, y+1, z + 11)|| !canPlaceTrack(player, world, x - 11, y+1, z + 12)|| !canPlaceTrack(player, world, x - 12, y+1, z + 11)) { - return false; - } - } - placeTrack(world,x, y + 1, z, BlockIDs.tcRail.block, l); - TileTCRail tcRail = (TileTCRail) world.getTileEntity(x, y + 1, z); - tcRail.setFacing(l); - tcRail.setType(type.getLabel()); - tcRail.setRailLength(3D); - - placeTrack(world,x - 1, y + 1, z + 1, BlockIDs.tcRailGag.block, l); - tileGag[0] = (TileTCRailGag) world.getTileEntity(x - 1, y + 1, z + 1); - - placeTrack(world,x - 2, y + 1, z + 2, BlockIDs.tcRailGag.block, l); - tileGag[1] = (TileTCRailGag) world.getTileEntity(x - 2, y + 1, z + 2); - - placeTrack(world,x , y + 1, z + 1, BlockIDs.tcRailGag.block, l); - tileGag[2] = (TileTCRailGag) world.getTileEntity(x, y + 1, z + 1); - tileGag[2].canPlaceRollingstock = false; - placeTrack(world,x - 1, y + 1, z , BlockIDs.tcRailGag.block, l); - tileGag[3] = (TileTCRailGag) world.getTileEntity(x - 1, y + 1, z ); - tileGag[3].canPlaceRollingstock = false; - placeTrack(world,x - 1, y + 1, z + 2, BlockIDs.tcRailGag.block, l); - tileGag[4] = (TileTCRailGag) world.getTileEntity(x - 1, y + 1, z + 2); - tileGag[4].canPlaceRollingstock = false; - placeTrack(world,x - 2, y + 1, z + 1, BlockIDs.tcRailGag.block, l); - tileGag[5] = (TileTCRailGag) world.getTileEntity(x - 2, y + 1, z + 1); - tileGag[5].canPlaceRollingstock = false; - placeTrack(world,x - 2, y + 1, z + 3, BlockIDs.tcRailGag.block, l); - tileGag[6] = (TileTCRailGag) world.getTileEntity(x - 2, y + 1, z + 3); - tileGag[6].canPlaceRollingstock = false; - placeTrack(world,x - 3, y + 1, z + 2, BlockIDs.tcRailGag.block, l); - tileGag[7] = (TileTCRailGag) world.getTileEntity(x - 3, y + 1, z + 2); - tileGag[7].canPlaceRollingstock = false; - if (type == TrackTypes.LONG_DIAGONAL_STRAIGHT || type == TrackTypes.EMBEDDED_LONG_DIAGONAL_STRAIGHT) { - tcRail.idDrop = this.type.getItem().item; - } else { - tcRail.idDrop = this.type.getItem().item; - } - - - - if (type == TrackTypes.LONG_DIAGONAL_STRAIGHT || type == TrackTypes.VERY_LONG_DIAGONAL_STRAIGHT || type == TrackTypes.EMBEDDED_LONG_DIAGONAL_STRAIGHT || type == TrackTypes.EMBEDDED_VERY_LONG_DIAGONAL_STRAIGHT) { - placeTrack(world,x - 3, y + 1, z + 3, BlockIDs.tcRail.block, l); - TileTCRail tcRail2 = (TileTCRail) world.getTileEntity(x - 3, y + 1, z + 3); - tcRail2.setFacing(l); - tcRail2.setType(type.getLabel()); - tcRail2.isLinkedToRail = true; - tcRail2.linkedX = x - 1; - tcRail2.linkedY = y + 1; - tcRail2.linkedZ = z + 1; - tcRail.setRailLength(6D); - tcRail2.setRailLength(3D); - - placeTrack(world,x - 4, y + 1, z + 4, BlockIDs.tcRailGag.block, l); - tileGag[8] = (TileTCRailGag) world.getTileEntity(x - 4, y + 1, z + 4); - - placeTrack(world,x - 5, y + 1, z + 5, BlockIDs.tcRailGag.block, l); - tileGag[9] = (TileTCRailGag) world.getTileEntity(x - 5, y + 1, z + 5); - - placeTrack(world,x - 3 , y + 1, z + 4, BlockIDs.tcRailGag.block, l); - tileGag[10] = (TileTCRailGag) world.getTileEntity(x - 3, y + 1, z + 4); - tileGag[10].canPlaceRollingstock = false; - placeTrack(world,x - 4, y + 1, z + 3, BlockIDs.tcRailGag.block, l); - tileGag[11] = (TileTCRailGag) world.getTileEntity(x - 4, y + 1, z + 3); - tileGag[11].canPlaceRollingstock = false; - placeTrack(world,x - 5, y + 1, z + 4, BlockIDs.tcRailGag.block, l); - tileGag[12] = (TileTCRailGag) world.getTileEntity(x - 5, y + 1, z + 4); - tileGag[12].canPlaceRollingstock = false; - placeTrack(world,x - 4, y + 1, z + 5, BlockIDs.tcRailGag.block, l); - tileGag[13] = (TileTCRailGag) world.getTileEntity(x - 4, y + 1, z + 5); - tileGag[13].canPlaceRollingstock = false; - placeTrack(world,x - 6, y + 1, z + 5, BlockIDs.tcRailGag.block, l); - tileGag[14] = (TileTCRailGag) world.getTileEntity(x - 6, y + 1, z + 5); - tileGag[14].canPlaceRollingstock = false; - placeTrack(world,x - 5, y + 1, z + 6, BlockIDs.tcRailGag.block, l); - tileGag[15] = (TileTCRailGag) world.getTileEntity(x - 5, y + 1, z + 6); - tileGag[15].canPlaceRollingstock = false; - if (type == TrackTypes.VERY_LONG_DIAGONAL_STRAIGHT) { - tcRail.idDrop = this.type.getItem().item; - } else { - tcRail.idDrop = this.type.getItem().item; - } - } - if (type == TrackTypes.VERY_LONG_DIAGONAL_STRAIGHT || type == TrackTypes.EMBEDDED_VERY_LONG_DIAGONAL_STRAIGHT) { - - placeTrack(world,x - 6, y + 1, z + 6, BlockIDs.tcRail.block, l); - TileTCRail tcRail3 = (TileTCRail) world.getTileEntity(x - 6, y + 1, z + 6); - tcRail3.setFacing(l); - tcRail3.setType(type.getLabel()); - tcRail3.isLinkedToRail = true; - tcRail3.linkedX = x - 1; - tcRail3.linkedY = y + 1; - tcRail3.linkedZ = z + 1; - tcRail.setRailLength(12D); - tcRail3.setRailLength(3D); - - placeTrack(world,x - 7, y + 1, z + 7, BlockIDs.tcRailGag.block, l); - tileGag[16] = (TileTCRailGag) world.getTileEntity(x - 7, y + 1, z + 7); - - placeTrack(world,x - 8, y + 1, z + 8, BlockIDs.tcRailGag.block, l); - tileGag[17] = (TileTCRailGag) world.getTileEntity(x - 8, y + 1, z + 8); - - placeTrack(world,x - 6 , y + 1, z + 7, BlockIDs.tcRailGag.block, l); - tileGag[18] = (TileTCRailGag) world.getTileEntity(x - 6, y + 1, z + 7); - tileGag[18].canPlaceRollingstock = false; - placeTrack(world,x - 7, y + 1, z + 6, BlockIDs.tcRailGag.block, l); - tileGag[19] = (TileTCRailGag) world.getTileEntity(x - 7, y + 1, z + 6); - tileGag[19].canPlaceRollingstock = false; - placeTrack(world,x - 7, y + 1, z + 8, BlockIDs.tcRailGag.block, l); - tileGag[20] = (TileTCRailGag) world.getTileEntity(x - 7, y + 1, z + 8); - tileGag[20].canPlaceRollingstock = false; - placeTrack(world,x - 8, y + 1, z + 7, BlockIDs.tcRailGag.block, l); - tileGag[21] = (TileTCRailGag) world.getTileEntity(x - 8, y + 1, z + 7); - tileGag[21].canPlaceRollingstock = false; - placeTrack(world,x - 8, y + 1, z + 9, BlockIDs.tcRailGag.block, l); - tileGag[22] = (TileTCRailGag) world.getTileEntity(x - 8, y + 1, z + 9); - tileGag[22].canPlaceRollingstock = false; - placeTrack(world,x - 9, y + 1, z + 8, BlockIDs.tcRailGag.block, l); - tileGag[23] = (TileTCRailGag) world.getTileEntity(x - 9, y + 1, z + 8); - tileGag[23].canPlaceRollingstock = false; - placeTrack(world,x - 9, y+1, z + 9, BlockIDs.tcRail.block, l); - TileTCRail tcRail4 = (TileTCRail) world.getTileEntity(x - 9, y + 1, z + 9); - tcRail4.setFacing(l); - tcRail4.setType(type.getLabel()); - tcRail4.isLinkedToRail = true; - tcRail4.linkedX = x - 1; - tcRail4.linkedY = y + 1; - tcRail4.linkedZ = z + 1; - tcRail4.setRailLength(3D); - - - placeTrack(world,x - 10, y + 1, z + 10, BlockIDs.tcRailGag.block, l); - tileGag[24] = (TileTCRailGag) world.getTileEntity(x - 10, y + 1, z + 10); - - placeTrack(world,x - 11, y + 1, z + 11, BlockIDs.tcRailGag.block, l); - tileGag[25] = (TileTCRailGag) world.getTileEntity(x - 11, y + 1, z + 11); - - placeTrack(world,x - 9 , y + 1, z + 10, BlockIDs.tcRailGag.block, l); - tileGag[26] = (TileTCRailGag) world.getTileEntity(x - 9, y + 1, z + 10); - tileGag[26].canPlaceRollingstock = false; - placeTrack(world,x - 10, y + 1, z + 9, BlockIDs.tcRailGag.block, l); - tileGag[27] = (TileTCRailGag) world.getTileEntity(x - 10, y + 1, z + 9); - tileGag[27].canPlaceRollingstock = false; - placeTrack(world,x - 10, y + 1, z + 11, BlockIDs.tcRailGag.block, l); - tileGag[28] = (TileTCRailGag) world.getTileEntity(x - 10, y + 1, z + 11); - tileGag[28].canPlaceRollingstock = false; - placeTrack(world,x - 11, y + 1, z + 10, BlockIDs.tcRailGag.block, l); - tileGag[29] = (TileTCRailGag) world.getTileEntity(x - 11, y + 1, z + 10); - tileGag[29].canPlaceRollingstock = false; - placeTrack(world,x - 11, y + 1, z + 12, BlockIDs.tcRailGag.block, l); - tileGag[30] = (TileTCRailGag) world.getTileEntity(x - 11, y + 1, z + 12); - tileGag[30].canPlaceRollingstock = false; - placeTrack(world,x - 12, y + 1, z + 11, BlockIDs.tcRailGag.block, l); - tileGag[31] = (TileTCRailGag) world.getTileEntity(x - 12, y + 1, z + 11); - tileGag[31].canPlaceRollingstock = false; - - } - - } - - if (l == 7) { - - if ( !canPlaceTrack(player, world, x , y + 1, z + 1) || !canPlaceTrack(player, world, x + 1, y + 1, z) - || !canPlaceTrack(player, world, x + 1 , y + 1, z + 1) || !canPlaceTrack(player, world, x + 1, y + 1, z + 2) || !canPlaceTrack(player, world, x + 2, y + 1, z + 1) - || !canPlaceTrack(player, world, x + 2, y + 1, z + 2) || !canPlaceTrack(player, world, x + 2, y + 1, z + 3) || !canPlaceTrack(player, world, x + 3, y + 1, z + 2)) { - return false; - } - if (type == TrackTypes.LONG_DIAGONAL_STRAIGHT || type == TrackTypes.EMBEDDED_LONG_DIAGONAL_STRAIGHT){ - if ( !canPlaceTrack(player, world, x + 3, y + 1, z + 3) || !canPlaceTrack(player, world, x + 3, y + 1, z + 4) || !canPlaceTrack(player, world, x + 4, y + 1, z + 3) - || !canPlaceTrack(player, world, x + 4, y + 1, z + 4) || !canPlaceTrack(player, world, x + 4, y + 1, z + 5) || !canPlaceTrack(player, world, x + 5, y + 1, z + 4) - || !canPlaceTrack(player, world, x + 5, y + 1, z + 5) || !canPlaceTrack(player, world, x + 5, y + 1, z + 6) || !canPlaceTrack(player, world, x + 6, y + 1, z + 5)) { - return false; - } - } - if (type == TrackTypes.VERY_LONG_DIAGONAL_STRAIGHT || type == TrackTypes.EMBEDDED_VERY_LONG_DIAGONAL_STRAIGHT){ - if ( !canPlaceTrack(player, world, x + 3, y + 1, z + 3) || !canPlaceTrack(player, world, x + 3, y + 1, z + 4) || !canPlaceTrack(player, world, x + 4, y + 1, z + 3) - || !canPlaceTrack(player, world, x + 4, y + 1, z + 4) || !canPlaceTrack(player, world, x + 4, y + 1, z + 5) || !canPlaceTrack(player, world, x + 5, y + 1, z + 4) - || !canPlaceTrack(player, world, x + 5, y + 1, z + 5) || !canPlaceTrack(player, world, x + 5, y + 1, z + 6) || !canPlaceTrack(player, world, x + 6, y + 1, z + 5) - || !canPlaceTrack(player, world, x + 6, y+1, z + 6) || !canPlaceTrack(player, world, x + 6, y+1, z + 7) || !canPlaceTrack(player, world, x + 7, y+1, z + 6) - || !canPlaceTrack(player, world, x + 7, y+1, z + 7) || !canPlaceTrack(player, world, x + 7, y+1, z + 8) || !canPlaceTrack(player, world, x + 8, y+1, z + 7) - || !canPlaceTrack(player, world, x + 8, y+1, z + 8) || !canPlaceTrack(player, world, x + 8, y+1, z + 9) || !canPlaceTrack(player, world, x + 9, y+1, z + 8) - || !canPlaceTrack(player, world, x + 9, y+1, z + 9) || !canPlaceTrack(player, world, x + 9, y+1, z + 10) || !canPlaceTrack(player, world, x + 10, y+1, z + 9) - || !canPlaceTrack(player, world,x + 10, y+1, z + 10) || !canPlaceTrack(player, world,x + 10, y+1, z + 11) || !canPlaceTrack(player, world,x + 11, y+1, z + 10) - || !canPlaceTrack(player, world, x + 11, y+1, z + 11)|| !canPlaceTrack(player, world, x + 11, y+1, z + 12)|| !canPlaceTrack(player, world, x + 12, y+1, z + 11)) { - return false; - } - } - placeTrack(world,x, y + 1, z, BlockIDs.tcRail.block, l); - TileTCRail tcRail = (TileTCRail) world.getTileEntity(x, y + 1, z); - tcRail.setFacing(l); - tcRail.setType(type.getLabel()); - tcRail.setRailLength(3D); - - placeTrack(world,x + 1, y + 1, z + 1, BlockIDs.tcRailGag.block, l); - tileGag[0] = (TileTCRailGag) world.getTileEntity(x + 1, y + 1, z + 1); - - placeTrack(world,x + 2, y + 1, z + 2, BlockIDs.tcRailGag.block, l); - tileGag[1] = (TileTCRailGag) world.getTileEntity(x + 2, y + 1, z + 2); - - placeTrack(world,x , y + 1, z + 1, BlockIDs.tcRailGag.block, l); - tileGag[2] = (TileTCRailGag) world.getTileEntity(x, y + 1, z + 1); - tileGag[2].canPlaceRollingstock = false; - placeTrack(world,x + 1, y + 1, z , BlockIDs.tcRailGag.block, l); - tileGag[3] = (TileTCRailGag) world.getTileEntity(x + 1, y + 1, z ); - tileGag[3].canPlaceRollingstock = false; - placeTrack(world,x + 1, y + 1, z + 2, BlockIDs.tcRailGag.block, l); - tileGag[4] = (TileTCRailGag) world.getTileEntity(x + 1, y + 1, z + 2); - tileGag[4].canPlaceRollingstock = false; - placeTrack(world,x + 2, y + 1, z + 1, BlockIDs.tcRailGag.block, l); - tileGag[5] = (TileTCRailGag) world.getTileEntity(x + 2, y + 1, z + 1); - tileGag[5].canPlaceRollingstock = false; - placeTrack(world,x + 2, y + 1, z + 3, BlockIDs.tcRailGag.block, l); - tileGag[6] = (TileTCRailGag) world.getTileEntity(x + 2, y + 1, z + 3); - tileGag[6].canPlaceRollingstock = false; - placeTrack(world,x + 3, y + 1, z + 2, BlockIDs.tcRailGag.block, l); - tileGag[7] = (TileTCRailGag) world.getTileEntity(x + 3, y + 1, z + 2); - tileGag[7].canPlaceRollingstock = false; - if (type == TrackTypes.LONG_DIAGONAL_STRAIGHT || type == TrackTypes.EMBEDDED_LONG_DIAGONAL_STRAIGHT) { - tcRail.idDrop = this.type.getItem().item; - } else { - tcRail.idDrop = this.type.getItem().item; - } - - - - if (type == TrackTypes.LONG_DIAGONAL_STRAIGHT || type == TrackTypes.VERY_LONG_DIAGONAL_STRAIGHT || type == TrackTypes.EMBEDDED_LONG_DIAGONAL_STRAIGHT || type == TrackTypes.EMBEDDED_VERY_LONG_DIAGONAL_STRAIGHT) { - placeTrack(world,x + 3, y + 1, z + 3, BlockIDs.tcRail.block, l); - TileTCRail tcRail2 = (TileTCRail) world.getTileEntity(x + 3, y + 1, z + 3); - tcRail2.setFacing(l); - tcRail2.setType(type.getLabel()); - tcRail2.isLinkedToRail = true; - tcRail2.linkedX = x + 1; - tcRail2.linkedY = y + 1; - tcRail2.linkedZ = z + 1; - tcRail.setRailLength(6D); - tcRail2.setRailLength(3D); - - placeTrack(world,x + 4, y + 1, z + 4, BlockIDs.tcRailGag.block, l); - tileGag[8] = (TileTCRailGag) world.getTileEntity(x + 4, y + 1, z + 4); - - placeTrack(world,x + 5, y + 1, z + 5, BlockIDs.tcRailGag.block, l); - tileGag[9] = (TileTCRailGag) world.getTileEntity(x + 5, y + 1, z + 5); - - placeTrack(world,x + 3 , y + 1, z + 4, BlockIDs.tcRailGag.block, l); - tileGag[10] = (TileTCRailGag) world.getTileEntity(x + 3, y + 1, z + 4); - tileGag[10].canPlaceRollingstock = false; - placeTrack(world,x + 4, y + 1, z + 3, BlockIDs.tcRailGag.block, l); - tileGag[11] = (TileTCRailGag) world.getTileEntity(x + 4, y + 1, z + 3); - tileGag[11].canPlaceRollingstock = false; - placeTrack(world,x + 5, y + 1, z + 4, BlockIDs.tcRailGag.block, l); - tileGag[12] = (TileTCRailGag) world.getTileEntity(x + 5, y + 1, z + 4); - tileGag[12].canPlaceRollingstock = false; - placeTrack(world,x + 4, y + 1, z + 5, BlockIDs.tcRailGag.block, l); - tileGag[13] = (TileTCRailGag) world.getTileEntity(x + 4, y + 1, z + 5); - tileGag[13].canPlaceRollingstock = false; - placeTrack(world,x + 6, y + 1, z + 5, BlockIDs.tcRailGag.block, l); - tileGag[14] = (TileTCRailGag) world.getTileEntity(x + 6, y + 1, z + 5); - tileGag[14].canPlaceRollingstock = false; - placeTrack(world,x + 5, y + 1, z + 6, BlockIDs.tcRailGag.block, l); - tileGag[15] = (TileTCRailGag) world.getTileEntity(x + 5, y + 1, z + 6); - tileGag[15].canPlaceRollingstock = false; - if (type == TrackTypes.VERY_LONG_DIAGONAL_STRAIGHT) { - tcRail.idDrop = this.type.getItem().item; - } else { - tcRail.idDrop = this.type.getItem().item; - } - } - if (type == TrackTypes.VERY_LONG_DIAGONAL_STRAIGHT || type == TrackTypes.EMBEDDED_VERY_LONG_DIAGONAL_STRAIGHT) { - - placeTrack(world,x + 6, y + 1, z + 6, BlockIDs.tcRail.block, l); - TileTCRail tcRail3 = (TileTCRail) world.getTileEntity(x + 6, y + 1, z + 6); - tcRail3.setFacing(l); - tcRail3.setType(type.getLabel()); - tcRail3.isLinkedToRail = true; - tcRail3.linkedX = x + 1; - tcRail3.linkedY = y + 1; - tcRail3.linkedZ = z + 1; - tcRail.setRailLength(12D); - tcRail3.setRailLength(3D); - - placeTrack(world,x + 7, y + 1, z + 7, BlockIDs.tcRailGag.block, l); - tileGag[16] = (TileTCRailGag) world.getTileEntity(x + 7, y + 1, z + 7); - - placeTrack(world,x + 8, y + 1, z + 8, BlockIDs.tcRailGag.block, l); - tileGag[17] = (TileTCRailGag) world.getTileEntity(x + 8, y + 1, z + 8); - - placeTrack(world,x + 6 , y + 1, z + 7, BlockIDs.tcRailGag.block, l); - tileGag[18] = (TileTCRailGag) world.getTileEntity(x + 6, y + 1, z + 7); - tileGag[18].canPlaceRollingstock = false; - placeTrack(world,x + 7, y + 1, z + 6, BlockIDs.tcRailGag.block, l); - tileGag[19] = (TileTCRailGag) world.getTileEntity(x + 7, y + 1, z + 6); - tileGag[19].canPlaceRollingstock = false; - placeTrack(world,x + 7, y + 1, z + 8, BlockIDs.tcRailGag.block, l); - tileGag[20] = (TileTCRailGag) world.getTileEntity(x + 7, y + 1, z + 8); - tileGag[20].canPlaceRollingstock = false; - placeTrack(world,x + 8, y + 1, z + 7, BlockIDs.tcRailGag.block, l); - tileGag[21] = (TileTCRailGag) world.getTileEntity(x + 8, y + 1, z + 7); - tileGag[21].canPlaceRollingstock = false; - placeTrack(world,x + 8, y + 1, z + 9, BlockIDs.tcRailGag.block, l); - tileGag[22] = (TileTCRailGag) world.getTileEntity(x + 8, y + 1, z + 9); - tileGag[22].canPlaceRollingstock = false; - placeTrack(world,x + 9, y + 1, z + 8, BlockIDs.tcRailGag.block, l); - tileGag[23] = (TileTCRailGag) world.getTileEntity(x + 9, y + 1, z + 8); - tileGag[23].canPlaceRollingstock = false; - placeTrack(world,x + 9, y+1, z + 9, BlockIDs.tcRail.block, l); - TileTCRail tcRail4 = (TileTCRail) world.getTileEntity(x + 9, y + 1, z + 9); - tcRail4.setFacing(l); - tcRail4.setType(type.getLabel()); - tcRail4.isLinkedToRail = true; - tcRail4.linkedX = x + 1; - tcRail4.linkedY = y + 1; - tcRail4.linkedZ = z + 1; - tcRail4.setRailLength(3D); - - - placeTrack(world,x + 10, y + 1, z + 10, BlockIDs.tcRailGag.block, l); - tileGag[24] = (TileTCRailGag) world.getTileEntity(x + 10, y + 1, z + 10); - - placeTrack(world,x + 11, y + 1, z + 11, BlockIDs.tcRailGag.block, l); - tileGag[25] = (TileTCRailGag) world.getTileEntity(x + 11, y + 1, z + 11); - - placeTrack(world,x + 9 , y + 1, z + 10, BlockIDs.tcRailGag.block, l); - tileGag[26] = (TileTCRailGag) world.getTileEntity(x + 9, y + 1, z + 10); - tileGag[26].canPlaceRollingstock = false; - placeTrack(world,x + 10, y + 1, z + 9, BlockIDs.tcRailGag.block, l); - tileGag[27] = (TileTCRailGag) world.getTileEntity(x + 10, y + 1, z + 9); - tileGag[27].canPlaceRollingstock = false; - placeTrack(world,x + 10, y + 1, z + 11, BlockIDs.tcRailGag.block, l); - tileGag[28] = (TileTCRailGag) world.getTileEntity(x + 10, y + 1, z + 11); - tileGag[28].canPlaceRollingstock = false; - placeTrack(world,x + 11, y + 1, z + 10, BlockIDs.tcRailGag.block, l); - tileGag[29] = (TileTCRailGag) world.getTileEntity(x + 11, y + 1, z + 10); - tileGag[29].canPlaceRollingstock = false; - placeTrack(world,x + 11, y + 1, z + 12, BlockIDs.tcRailGag.block, l); - tileGag[30] = (TileTCRailGag) world.getTileEntity(x + 11, y + 1, z + 12); - tileGag[30].canPlaceRollingstock = false; - placeTrack(world,x + 12, y + 1, z + 11, BlockIDs.tcRailGag.block, l); - tileGag[31] = (TileTCRailGag) world.getTileEntity(x + 12, y + 1, z + 11); - tileGag[31].canPlaceRollingstock = false; - } - - } - - if (l == 5) { - - if ( !canPlaceTrack(player, world, x , y + 1, z - 1) || !canPlaceTrack(player, world, x - 1, y + 1, z) - || !canPlaceTrack(player, world, x - 1 , y + 1, z - 1) || !canPlaceTrack(player, world, x - 1, y + 1, z - 2) || !canPlaceTrack(player, world, x - 2, y + 1, z - 1) - || !canPlaceTrack(player, world, x - 2, y + 1, z - 2) || !canPlaceTrack(player, world, x - 2, y + 1, z - 3) || !canPlaceTrack(player, world, x - 3, y + 1, z - 2)) { - return false; - } - if (type == TrackTypes.LONG_DIAGONAL_STRAIGHT || type == TrackTypes.EMBEDDED_LONG_DIAGONAL_STRAIGHT){ - if ( !canPlaceTrack(player, world, x - 3, y + 1, z - 3) || !canPlaceTrack(player, world, x - 3, y + 1, z - 4) || !canPlaceTrack(player, world, x - 4, y + 1, z - 3) - || !canPlaceTrack(player, world, x - 4, y + 1, z - 4) || !canPlaceTrack(player, world, x - 4, y + 1, z - 5) || !canPlaceTrack(player, world, x - 5, y + 1, z - 4) - || !canPlaceTrack(player, world, x - 5, y + 1, z - 5) || !canPlaceTrack(player, world, x - 5, y + 1, z - 6) || !canPlaceTrack(player, world, x - 6, y + 1, z - 5)) { - return false; - } - } - if (type == TrackTypes.VERY_LONG_DIAGONAL_STRAIGHT || type == TrackTypes.EMBEDDED_VERY_LONG_DIAGONAL_STRAIGHT){ - if ( !canPlaceTrack(player, world, x - 3, y + 1, z - 3) || !canPlaceTrack(player, world, x - 3, y + 1, z - 4) || !canPlaceTrack(player, world, x - 4, y + 1, z - 3) - || !canPlaceTrack(player, world, x - 4, y + 1, z - 4) || !canPlaceTrack(player, world, x - 4, y + 1, z - 5) || !canPlaceTrack(player, world, x - 5, y + 1, z - 4) - || !canPlaceTrack(player, world, x - 5, y + 1, z - 5) || !canPlaceTrack(player, world, x - 5, y + 1, z - 6) || !canPlaceTrack(player, world, x - 6, y + 1, z - 5) - || !canPlaceTrack(player, world, x - 6, y+1, z - 6) || !canPlaceTrack(player, world, x - 6, y+1, z - 7) || !canPlaceTrack(player, world, x - 7, y+1, z - 6) - || !canPlaceTrack(player, world, x - 7, y+1, z - 7) || !canPlaceTrack(player, world, x - 7, y+1, z - 8) || !canPlaceTrack(player, world, x - 8, y+1, z - 7) - || !canPlaceTrack(player, world, x - 8, y+1, z - 8) || !canPlaceTrack(player, world, x - 8, y+1, z - 9) || !canPlaceTrack(player, world, x - 9, y+1, z - 8) - || !canPlaceTrack(player, world, x - 9, y+1, z - 9) || !canPlaceTrack(player, world, x - 9, y+1, z - 10) || !canPlaceTrack(player, world, x - 10, y+1, z - 9) - || !canPlaceTrack(player, world,x - 10, y+1, z - 10) || !canPlaceTrack(player, world,x - 10, y+1, z - 11) || !canPlaceTrack(player, world,x - 11, y+1, z - 10) - || !canPlaceTrack(player, world, x - 11, y+1, z - 11)|| !canPlaceTrack(player, world, x - 11, y+1, z - 12)|| !canPlaceTrack(player, world, x - 12, y+1, z - 11)) { - return false; - } - } - placeTrack(world,x, y + 1, z, BlockIDs.tcRail.block, l); - TileTCRail tcRail = (TileTCRail) world.getTileEntity(x, y + 1, z); - tcRail.setFacing(l); - tcRail.setType(type.getLabel()); - tcRail.setRailLength(3D); - - placeTrack(world,x - 1, y + 1, z - 1, BlockIDs.tcRailGag.block, l); - tileGag[0] = (TileTCRailGag) world.getTileEntity(x - 1, y + 1, z - 1); - - placeTrack(world,x - 2, y + 1, z - 2, BlockIDs.tcRailGag.block, l); - tileGag[1] = (TileTCRailGag) world.getTileEntity(x - 2, y + 1, z - 2); - - placeTrack(world,x , y + 1, z - 1, BlockIDs.tcRailGag.block, l); - tileGag[2] = (TileTCRailGag) world.getTileEntity(x, y + 1, z - 1); - tileGag[2].canPlaceRollingstock = false; - placeTrack(world,x - 1, y + 1, z , BlockIDs.tcRailGag.block, l); - tileGag[3] = (TileTCRailGag) world.getTileEntity(x - 1, y + 1, z ); - tileGag[3].canPlaceRollingstock = false; - placeTrack(world,x - 1, y + 1, z - 2, BlockIDs.tcRailGag.block, l); - tileGag[4] = (TileTCRailGag) world.getTileEntity(x - 1, y + 1, z - 2); - tileGag[4].canPlaceRollingstock = false; - placeTrack(world,x - 2, y + 1, z - 1, BlockIDs.tcRailGag.block, l); - tileGag[5] = (TileTCRailGag) world.getTileEntity(x - 2, y + 1, z - 1); - tileGag[5].canPlaceRollingstock = false; - placeTrack(world,x - 2, y + 1, z - 3, BlockIDs.tcRailGag.block, l); - tileGag[6] = (TileTCRailGag) world.getTileEntity(x - 2, y + 1, z - 3); - tileGag[6].canPlaceRollingstock = false; - placeTrack(world,x - 3, y + 1, z - 2, BlockIDs.tcRailGag.block, l); - tileGag[7] = (TileTCRailGag) world.getTileEntity(x - 3, y + 1, z - 2); - tileGag[7].canPlaceRollingstock = false; - if (type == TrackTypes.LONG_DIAGONAL_STRAIGHT || type == TrackTypes.EMBEDDED_LONG_DIAGONAL_STRAIGHT) { - tcRail.idDrop = this.type.getItem().item; - } else { - tcRail.idDrop = this.type.getItem().item; - } - - - - if (type == TrackTypes.LONG_DIAGONAL_STRAIGHT || type == TrackTypes.VERY_LONG_DIAGONAL_STRAIGHT || type == TrackTypes.EMBEDDED_LONG_DIAGONAL_STRAIGHT || type == TrackTypes.EMBEDDED_VERY_LONG_DIAGONAL_STRAIGHT) { - placeTrack(world,x - 3, y + 1, z - 3, BlockIDs.tcRail.block, l); - TileTCRail tcRail2 = (TileTCRail) world.getTileEntity(x - 3, y + 1, z - 3); - tcRail2.setFacing(l); - tcRail2.setType(type.getLabel()); - tcRail2.isLinkedToRail = true; - tcRail2.linkedX = x - 1; - tcRail2.linkedY = y + 1; - tcRail2.linkedZ = z - 1; - tcRail.setRailLength(6D); - tcRail2.setRailLength(3D); - - placeTrack(world,x - 4, y + 1, z - 4, BlockIDs.tcRailGag.block, l); - tileGag[8] = (TileTCRailGag) world.getTileEntity(x - 4, y + 1, z - 4); - - placeTrack(world,x - 5, y + 1, z - 5, BlockIDs.tcRailGag.block, l); - tileGag[9] = (TileTCRailGag) world.getTileEntity(x - 5, y + 1, z - 5); - - placeTrack(world,x - 3 , y + 1, z - 4, BlockIDs.tcRailGag.block, l); - tileGag[10] = (TileTCRailGag) world.getTileEntity(x - 3, y + 1, z - 4); - tileGag[10].canPlaceRollingstock = false; - placeTrack(world,x - 4, y + 1, z - 3, BlockIDs.tcRailGag.block, l); - tileGag[11] = (TileTCRailGag) world.getTileEntity(x - 4, y + 1, z - 3); - tileGag[11].canPlaceRollingstock = false; - placeTrack(world,x - 5, y + 1, z - 4, BlockIDs.tcRailGag.block, l); - tileGag[12] = (TileTCRailGag) world.getTileEntity(x - 5, y + 1, z - 4); - tileGag[12].canPlaceRollingstock = false; - placeTrack(world,x - 4, y + 1, z - 5, BlockIDs.tcRailGag.block, l); - tileGag[13] = (TileTCRailGag) world.getTileEntity(x - 4, y + 1, z - 5); - tileGag[13].canPlaceRollingstock = false; - placeTrack(world,x - 6, y + 1, z - 5, BlockIDs.tcRailGag.block, l); - tileGag[14] = (TileTCRailGag) world.getTileEntity(x - 6, y + 1, z - 5); - tileGag[14].canPlaceRollingstock = false; - placeTrack(world,x - 5, y + 1, z - 6, BlockIDs.tcRailGag.block, l); - tileGag[15] = (TileTCRailGag) world.getTileEntity(x - 5, y + 1, z - 6); - tileGag[15].canPlaceRollingstock = false; - if (type == TrackTypes.VERY_LONG_DIAGONAL_STRAIGHT) { - tcRail.idDrop = this.type.getItem().item; - } else { - tcRail.idDrop = this.type.getItem().item; - } - } - if (type == TrackTypes.VERY_LONG_DIAGONAL_STRAIGHT || type == TrackTypes.EMBEDDED_VERY_LONG_DIAGONAL_STRAIGHT) { - - placeTrack(world,x - 6, y + 1, z - 6, BlockIDs.tcRail.block, l); - TileTCRail tcRail3 = (TileTCRail) world.getTileEntity(x - 6, y + 1, z - 6); - tcRail3.setFacing(l); - tcRail3.setType(type.getLabel()); - tcRail3.isLinkedToRail = true; - tcRail3.linkedX = x - 1; - tcRail3.linkedY = y + 1; - tcRail3.linkedZ = z - 1; - tcRail.setRailLength(12D); - tcRail3.setRailLength(3D); - - placeTrack(world,x - 7, y + 1, z - 7, BlockIDs.tcRailGag.block, l); - tileGag[16] = (TileTCRailGag) world.getTileEntity(x - 7, y + 1, z - 7); - - placeTrack(world,x - 8, y + 1, z - 8, BlockIDs.tcRailGag.block, l); - tileGag[17] = (TileTCRailGag) world.getTileEntity(x - 8, y + 1, z - 8); - - placeTrack(world,x - 6 , y + 1, z - 7, BlockIDs.tcRailGag.block, l); - tileGag[18] = (TileTCRailGag) world.getTileEntity(x - 6, y + 1, z - 7); - tileGag[18].canPlaceRollingstock = false; - placeTrack(world,x - 7, y + 1, z - 6, BlockIDs.tcRailGag.block, l); - tileGag[19] = (TileTCRailGag) world.getTileEntity(x - 7, y + 1, z - 6); - tileGag[19].canPlaceRollingstock = false; - placeTrack(world,x - 7, y + 1, z - 8, BlockIDs.tcRailGag.block, l); - tileGag[20] = (TileTCRailGag) world.getTileEntity(x - 7, y + 1, z - 8); - tileGag[20].canPlaceRollingstock = false; - placeTrack(world,x - 8, y + 1, z - 7, BlockIDs.tcRailGag.block, l); - tileGag[21] = (TileTCRailGag) world.getTileEntity(x - 8, y + 1, z - 7); - tileGag[21].canPlaceRollingstock = false; - placeTrack(world,x - 8, y + 1, z - 9, BlockIDs.tcRailGag.block, l); - tileGag[22] = (TileTCRailGag) world.getTileEntity(x - 8, y + 1, z - 9); - tileGag[22].canPlaceRollingstock = false; - placeTrack(world,x - 9, y + 1, z - 8, BlockIDs.tcRailGag.block, l); - tileGag[23] = (TileTCRailGag) world.getTileEntity(x - 9, y + 1, z - 8); - tileGag[23].canPlaceRollingstock = false; - placeTrack(world,x - 9, y+1, z - 9, BlockIDs.tcRail.block, l); - TileTCRail tcRail4 = (TileTCRail) world.getTileEntity(x - 9, y + 1, z - 9); - tcRail4.setFacing(l); - tcRail4.setType(type.getLabel()); - tcRail4.isLinkedToRail = true; - tcRail4.linkedX = x - 1; - tcRail4.linkedY = y + 1; - tcRail4.linkedZ = z - 1; - tcRail4.setRailLength(3D); - - - placeTrack(world,x - 10, y + 1, z - 10, BlockIDs.tcRailGag.block, l); - tileGag[24] = (TileTCRailGag) world.getTileEntity(x - 10, y + 1, z - 10); - - placeTrack(world,x - 11, y + 1, z - 11, BlockIDs.tcRailGag.block, l); - tileGag[25] = (TileTCRailGag) world.getTileEntity(x - 11, y + 1, z - 11); - - placeTrack(world,x - 9 , y + 1, z - 10, BlockIDs.tcRailGag.block, l); - tileGag[26] = (TileTCRailGag) world.getTileEntity(x - 9, y + 1, z - 10); - tileGag[26].canPlaceRollingstock = false; - placeTrack(world,x - 10, y + 1, z - 9, BlockIDs.tcRailGag.block, l); - tileGag[27] = (TileTCRailGag) world.getTileEntity(x - 10, y + 1, z - 9); - tileGag[27].canPlaceRollingstock = false; - placeTrack(world,x - 10, y + 1, z - 11, BlockIDs.tcRailGag.block, l); - tileGag[28] = (TileTCRailGag) world.getTileEntity(x - 10, y + 1, z - 11); - tileGag[28].canPlaceRollingstock = false; - placeTrack(world,x - 11, y + 1, z - 10, BlockIDs.tcRailGag.block, l); - tileGag[29] = (TileTCRailGag) world.getTileEntity(x - 11, y + 1, z - 10); - tileGag[29].canPlaceRollingstock = false; - placeTrack(world,x - 11, y + 1, z - 12, BlockIDs.tcRailGag.block, l); - tileGag[30] = (TileTCRailGag) world.getTileEntity(x - 11, y + 1, z - 12); - tileGag[30].canPlaceRollingstock = false; - placeTrack(world,x - 12, y + 1, z - 11, BlockIDs.tcRailGag.block, l); - tileGag[31] = (TileTCRailGag) world.getTileEntity(x - 12, y + 1, z - 11); - tileGag[31].canPlaceRollingstock = false; - - } - - } - - for (TileTCRailGag tileTCRailGag : tileGag) { - if (player != null && tileTCRailGag == null) { - player.addChatMessage(new ChatComponentText("There was a problem when placing the track. Possibly too many tracks around")); - return false; - } - tileTCRailGag.originX = x; - tileTCRailGag.originY = y + 1; - tileTCRailGag.originZ = z; - tileTCRailGag.type = type.getLabel(); - - } - - return true; - } - private boolean mediumRightTurn(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes tempType){ - - int[] xArray = {0, 0, 1, 1, 2}; - int[] zArray = {0, 1, 1, 2, 2}; - - if (l == 2) { - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, false), flipArraySign(zArray, z, true), l, false, 1, x + 3, z - 3, 2.5, x + 3, - y + 1, z + 1, tempType.getLabel(), tempType.getItem().item)) - return false; - } - if (l == 0) { - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, true), flipArraySign(zArray, z, false), l, false, 1, x - 3, z + 3, 2.5, x - 2, - y + 1, z, tempType.getLabel(), tempType.getItem().item)) - return false; - } - if (l == 1) { - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, true), flipArraySign(xArray, z, true), l, false, 2, x - 3, z - 3, 2.5, x + 1, - y + 1, z - 2, tempType.getLabel(), tempType.getItem().item)) - return false; - } - if (l == 3) { - return putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, false), flipArraySign(xArray, z, false), l, false, 0, x + 3, z + 3, 2.5, x, y + 1, - z + 3, tempType.getLabel(), tempType.getItem().item); - } - return true; - } - private boolean mediumLeftTurn(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes tempType) { - - int[] xArray = { 0, 0, 1, 1, 2 }; - int[] zArray = { 0, 1, 1, 2, 2 }; - - if (l == 2) { - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, true), flipArraySign(zArray, z, true), l, false, 1, x - 3, z - 3, 2.5, x - 2, - y + 1, z + 1, tempType.getLabel(), tempType.getItem().item)) - return false; - } - if (l == 0) { - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, false), flipArraySign(zArray, z, false), l, false, 3, x + 3, z + 3, 2.5, x + 3, - y + 1, z, tempType.getLabel(), tempType.getItem().item)) - return false; - } - if (l == 1) { - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, true), flipArraySign(xArray, z, false), l, false, 0, x - 3, z + 3, 2.5, x + 1, - y + 1, z + 3, tempType.getLabel(), tempType.getItem().item)) - return false; - } - if (l == 3) { - return putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, false), flipArraySign(xArray, z, true), l, false, 2, x + 3, z - 3, 2.5, x, y + 1, - z - 2, tempType.getLabel(), tempType.getItem().item); - } - return true; - } - private boolean largeRightTurn(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes tempType) { - - int[] xArray = { 0, 0, 1, 1, 2, 0, 1, 2, 3, 4, 3, 2}; - int[] zArray = { 0, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4}; - - if (l == 2) { - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, false), flipArraySign(zArray, z, true), l, false, 1, x + 5, z - 5, 4.5, x + 5, - y + 1, z + 1, tempType.getLabel(), tempType.getItem().item)) - return false; - } - if (l == 0) { - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, true), flipArraySign(zArray, z, false), l, false, 1, x - 5, z + 5, 4.5, x - 4, - y + 1, z, tempType.getLabel(), tempType.getItem().item)) - return false; - } - if (l == 1) { - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, true), flipArraySign(xArray, z, true), l, false, 2, x - 5, z - 5, 4.5, x + 1, - y + 1, z - 4, tempType.getLabel(), tempType.getItem().item)) - return false; - } - if (l == 3) { - return putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, false), flipArraySign(xArray, z, false), l, false, 0, x + 5, z + 5, 4.5, x, y + 1, - z + 5, tempType.getLabel(), tempType.getItem().item); - } - return true; - } - private boolean largeLeftTurn(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes tempType) { - int[] xArray = { 0, 0, 1, 1, 2, 0, 1, 2, 3, 4, 3, 2}; - int[] zArray = { 0, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4}; - if (l == 2) { - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, true), flipArraySign(zArray, z, true), l, false, 1, x - 5, z - 5, 4.5, x - 4, - y + 1, z + 1, tempType.getLabel(), tempType.getItem().item)) - return false; - } - if (l == 0) { - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, false), flipArraySign(zArray, z, false), l, false, 1, x + 5, z + 5, 4.5, x + 5, - y + 1, z, tempType.getLabel(), tempType.getItem().item)) - return false; - } - if (l == 1) { - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, true), flipArraySign(xArray, z, false), l, false, 2, x - 5, z + 5, 4.5, x + 1, - y + 1, z + 5, tempType.getLabel(), tempType.getItem().item)) - return false; - } - if (l == 3) { - return putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, false), flipArraySign(xArray, z, true), l, false, 0, x + 5, z - 5, 4.5, x, y + 1, - z - 4, tempType.getLabel(), tempType.getItem().item); - } - return true; - } - private boolean veryLargeRightTurn(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes tempType) { - int[] xArray = { 0, 0, 0, 1, 0, 1, 0, 1, 1, 2, 2, 2, 3, 3, 4, 4, 5, 5, 5, 6, 6, 7, 7, 8, 9}; - int[] zArray = { 0, 1, 2, 2, 3, 3, 4, 4, 5, 4, 5, 6, 6, 7, 7, 8, 7, 8, 9, 8, 9, 8, 9, 9, 9}; - - if (l == 2) { - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, false), flipArraySign(zArray, z, true), l, false, 1, x + 10, z - 10, 9.5, x + 10, - y + 1, z + 1, tempType.getLabel(), tempType.getItem().item)) - return false; - } - if (l == 0) { - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, true), flipArraySign(zArray, z, false), l, false, 1, x - 10, z + 10, 9.5, x - 9, - y + 1, z, tempType.getLabel(), tempType.getItem().item)) - return false; - } - if (l == 1) { - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, true), flipArraySign(xArray, z, true), l, false, 2, x - 10, z - 10, 9.5, x + 1, - y + 1, z - 9, tempType.getLabel(), tempType.getItem().item)) - return false; - } - if (l == 3) { - return putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, false), flipArraySign(xArray, z, false), l, false, 0, x + 10, z + 10, 9.5, x, y + 1, - z + 10, tempType.getLabel(), tempType.getItem().item); - } - return true; - } - private boolean veryLargeLeftTurn(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes tempType) { - int[] xArray = { 0, 0, 0, 1, 0, 1, 0, 1, 1, 2, 2, 2, 3, 3, 4, 4, 5, 5, 5, 6, 6, 7, 7, 8, 9}; - int[] zArray = { 0, 1, 2, 2, 3, 3, 4, 4, 5, 4, 5, 6, 6, 7, 7, 8, 7, 8, 9, 8, 9, 8, 9, 9, 9}; - - if (l == 2) { - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, true), flipArraySign(zArray, z, true), l, false, 1, x - 10, z - 10, 9.5, x - 9, - y + 1, z + 1, tempType.getLabel(), tempType.getItem().item)) - return false; - } - if (l == 0) { - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, false), flipArraySign(zArray, z, false), l, false, 1, x + 10, z + 10, 9.5, x + 10, - y + 1, z, tempType.getLabel(), tempType.getItem().item)) - return false; - } - if (l == 1) { - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, true), flipArraySign(xArray, z, false), l, false, 2, x - 10, z + 10, 9.5, x + 1, - y + 1, z + 10, tempType.getLabel(), tempType.getItem().item)) - return false; - } - if (l == 3) { - return putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, false), flipArraySign(xArray, z, true), l, false, 0, x + 10, z - 10, 9.5, x, y + 1, - z - 9, tempType.getLabel(), tempType.getItem().item); - } - return true; - } - private boolean superLargeRightTurn(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes tempType) { - int[] xArray = {0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 4 , 5 , 5 , 6 , 6 , 7 , 7 , 8 , 9 , 9 , 10, 11, 11, 12, 12, 13, 14, 15}; - int[] zArray = {0, 1, 2, 3, 4, 3, 4, 5, 6, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 13, 14, 14, 14, 15, 14, 15, 15, 15, 15}; - - if (l == 2) { - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, false), flipArraySign(zArray, z, true), l, false, 1, x + 16, z - 16, 15.5, x + 16, - y + 1, z + 1, tempType.getLabel(), tempType.getItem().item)) - return false; - } - if (l == 0) { - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, true), flipArraySign(zArray, z, false), l, false, 1, x - 15, z + 15, 15.5, x - 15, - y + 1, z, tempType.getLabel(), tempType.getItem().item)) - return false; - } - if (l == 1) { - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, true), flipArraySign(xArray, z, true), l, false, 2, x - 15, z - 15, 15.5, x +1 , - y + 1, z - 15 , tempType.getLabel(), tempType.getItem().item)) - return false; - } - if (l == 3) { - return putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, false), flipArraySign(xArray, z, false), l, false, 2, x + 15, z + 15, 15.5, x, y + 1, - z + 16, tempType.getLabel(), tempType.getItem().item); - } - return true; - } - private boolean superLargeLeftTurn(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes tempType) { - int[] xArray = {0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 4 , 5 , 5 , 6 , 6 , 7 , 7 , 8 , 9 , 9 , 10, 11, 11, 12, 12, 13, 14, 15}; - int[] zArray = {0, 1, 2, 3, 4, 3, 4, 5, 6, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 13, 14, 14, 14, 15, 14, 15, 15, 15, 15}; - if (l == 2) { - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, true), flipArraySign(zArray, z, true), l, false, 1, x - 15, z + 15, 15.5, x - 15, - y + 1, z+1, tempType.getLabel(), tempType.getItem().item)) - return false; - } - if (l == 0) { - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, false), flipArraySign(zArray, z, false), l, false, 1, x + 15, z + 15, 15.5, x + 16, - y + 1, z , tempType.getLabel(), tempType.getItem().item)) - return false; - } - if (l == 1) { - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, true), flipArraySign(xArray, z, false), l, false, 2, x - 15, z + 15, 15.5, x + 1 , - y + 1, z + 16, tempType.getLabel(), tempType.getItem().item)) - return false; - } - if (l == 3) { - return putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, false), flipArraySign(xArray, z, true), l, false, 0, x + 15, z - 15, 15.5, x, y + 1, - z - 15, tempType.getLabel(), tempType.getItem().item); - } - return true; - } - private boolean mediumRight45DegreeTurn(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes tempType){ - - int[] xArray; - int[] zArray; - if (player.isSneaking()) { - xArray = new int[]{0, 0, 0, 1, 1}; - zArray = new int[]{0, 1, 2, 1, 2}; - } - else { - xArray = new int[]{0, 0, 0, 1, 1, 1, 2}; - zArray = new int[]{0, 1, 2, 1, 2, 3, 2}; - } - if (l == 2) { - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, false), flipArraySign(zArray, z, true), l, false, 3, x + 1, z - 2, 3.75, x + 4.25, - y + 1, z + 1, tempType.getLabel(), tempType.getItem().item)) - return false; - } - if (l == 0) { - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, true), flipArraySign(zArray, z, false), l, false, 1, x - 1, z + 2, 3.75, x - 3.25, - y + 1, z, tempType.getLabel(), tempType.getItem().item)) - return false; - } - if (l == 1) { - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, true), flipArraySign(xArray, z, true), l, false, 2, x - 2, z - 1, 3.75, x + 1 , - y + 1, z - 3.25, tempType.getLabel(), tempType.getItem().item)) - return false; - } - if (l == 3) { - return putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, false), flipArraySign(xArray, z, false), l, false, 0, x + 2, z + 1, 3.75, x, y + 1, - z + 4.25, tempType.getLabel(), tempType.getItem().item); - } - return true; - } - private boolean mediumLeft45DegreeTurn(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes tempType) { - - int[] xArray; - int[] zArray; - if (player.isSneaking()) { - xArray = new int[]{0, 0, 0, 1, 1}; - zArray = new int[]{0, 1, 2, 1, 2}; - } - else { - xArray = new int[]{0, 0, 0, 1, 1, 1, 2}; - zArray = new int[]{0, 1, 2, 1, 2, 3, 2}; - } - - if (l == 2) { - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, true), flipArraySign(zArray, z, true), l, false, 1, x - 1, z - 2, 3.75, x - 3.25, - y + 1, z + 1, tempType.getLabel(), tempType.getItem().item)) - return false; - } - if (l == 0) { - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, false), flipArraySign(zArray, z, false), l, false, 3, x + 1, z + 2, 3.75, x + 4.25, - y + 1, z, tempType.getLabel(), tempType.getItem().item)) - return false; - } - if (l == 1) { - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, true), flipArraySign(xArray, z, false), l, false, 0, x - 2, z + 1, 3.75, x + 1 , - y + 1, z + 4.25, tempType.getLabel(), tempType.getItem().item)) - return false; - } - if (l == 3) { - return putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, false), flipArraySign(xArray, z, true), l, false, 2, x + 2, z - 1, 3.75, x, y + 1, - z - 3.25, tempType.getLabel(), tempType.getItem().item); - } - return true; - } - private boolean largeRight45DegreeTurn(EntityPlayer player, World world, int x, int y ,int z, int l, TrackTypes tempType){ - int[] xArray; - int[]zArray; - if (player.isSneaking()) { - xArray = new int[]{0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2 }; - zArray = new int[]{0, 1, 2, 3, 1, 2, 3, 4, 5, 4, 5 }; - } else { - xArray = new int[]{0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 3}; - zArray = new int[]{0, 1, 2, 3, 1, 2, 3, 4, 5, 4, 5, 6, 5}; - } - if (l == 2) { - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, false), flipArraySign(zArray, z, true), l, false, 3, x + 2, z - 5, 8.49, x + 8.99, - y + 1, z + 1, tempType.getLabel(), tempType.getItem().item)) - return false; - } - if (l == 0) { - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, true), flipArraySign(zArray, z, false), l, false, 1, x - 2, z + 5, 8.49, x - 7.99, - y + 1, z, tempType.getLabel(), tempType.getItem().item)) - return false; - } - if (l == 1) { - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, true), flipArraySign(xArray, z, true), l, false, 2, x - 5, z - 2, 8.49, x + 1, - y + 1, z - 7.99, tempType.getLabel(), tempType.getItem().item)) - return false; - } - if (l == 3) { - return putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, false), flipArraySign(xArray, z, false), l, false, 0, x + 5, z + 2, 8.49, x, - y + 1, z + 8.99, tempType.getLabel(), tempType.getItem().item); - } - return true; - } - private boolean largeLeft45DegreeTurn(EntityPlayer player, World world, int x, int y ,int z, int l, TrackTypes tempType) { - int[] xArray; - int[] zArray; - if (player.isSneaking()) { - xArray = new int[]{0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2 }; - zArray = new int[]{0, 1, 2, 3, 1, 2, 3, 4, 5, 4, 5 }; - } else { - xArray = new int[]{0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 3}; - zArray = new int[]{0, 1, 2, 3, 1, 2, 3, 4, 5, 4, 5, 6, 5}; - } - if (l == 2) { - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, true), flipArraySign(zArray, z, true), l, false, 1, x - 2, z - 5, 8.49, x - 7.99, - y + 1, z + 1, tempType.getLabel(), tempType.getItem().item)) - return false; - } - if (l == 0) { - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, false), flipArraySign(zArray, z, false), l, false, 3, x + 2, z + 5, 8.49, x + 8.99, - y + 1, z, tempType.getLabel(), tempType.getItem().item)) - return false; - } - if (l == 1) { - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, true), flipArraySign(xArray, z, false), l, false, 0, x - 5, z + 2, 8.49, x + 1, - y + 1, z + 8.99, tempType.getLabel(), tempType.getItem().item)) - return false; - } - if (l == 3) { - return putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, false), flipArraySign(xArray, z, true), l, false, 2, x + 5, z - 2, 8.49, x, - y + 1, z - 7.99, tempType.getLabel(), tempType.getItem().item); - } - return true; - } - public boolean veryLargeRight45DegreeTurn(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes tempType){ - int[] xArray; - int[] zArray; - if (player.isSneaking()) { - xArray = new int[]{0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3}; - zArray = new int[]{0, 1, 2, 3, 4, 1, 2, 3, 4, 5, 6, 4, 5, 6, 7, 6, 7}; - } - else { - xArray = new int[]{0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 4}; - zArray = new int[]{0, 1, 2, 3, 4, 1, 2, 3, 4, 5, 6, 4, 5, 6, 7, 6, 7, 8, 7}; - - } - if (l == 2) { - - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, false), flipArraySign(zArray, z, true), l, false, 3, x + 3, z - 7, 10.89, x + 11.39, - y + 1, z + 1, tempType.getLabel(), tempType.getItem().item)) - return false; - } - - if (l == 0) { - - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, true), flipArraySign(zArray, z, false), l, false, 1, x - 3, z + 7, 10.89, x - 10.39, - y + 1, z , tempType.getLabel(), tempType.getItem().item)) - return false; - } - if (l == 1) { - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, true), flipArraySign(xArray, z, true), l, false, 2, x - 7, z - 3, 10.89, x + 1, - y + 1, z - 10.39, tempType.getLabel(), tempType.getItem().item)) - return false; - } - - if (l == 3) { - return putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, false), flipArraySign(xArray, z, false), l, false, 0, x + 7, z + 3, 10.89, x, - y + 1, z + 11.39, tempType.getLabel(), tempType.getItem().item); - } - return true; - } - public boolean veryLargeLeft45DegreeTurn(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes tempType){ - int[] xArray; - int[] zArray; - if (player.isSneaking()) { - xArray = new int[]{0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3}; - zArray = new int[]{0, 1, 2, 3, 4, 1, 2, 3, 4, 5, 6, 4, 5, 6, 7, 6, 7}; - } - else { - xArray = new int[]{0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 4}; - zArray = new int[]{0, 1, 2, 3, 4, 1, 2, 3, 4, 5, 6, 4, 5, 6, 7, 6, 7, 8, 7}; - } - if (l == 2) { - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, true), flipArraySign(zArray, z, true), l, false, 3, x + 3, z - 7, 10.89, x - 10.39, - y + 1, z + 1, tempType.getLabel(), tempType.getItem().item)) - return false; - } - if (l == 0) { - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, false), flipArraySign(zArray, z, false), l, false, 1, x - 3, z + 7, 10.89, x + 11.39, - y + 1, z , tempType.getLabel(), tempType.getItem().item)) - return false; - } - if (l == 1) { - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, true), flipArraySign(xArray, z, false), l, false, 2, x - 7, z - 3, 10.89, x + 1, - y + 1, z + 11.39, tempType.getLabel(), tempType.getItem().item)) - return false; - } - if (l == 3) { - return putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, false), flipArraySign(xArray, z, true), l, false, 0, x + 7, z + 3, 10.89, x, - y + 1, z - 10.39, tempType.getLabel(), tempType.getItem().item); - } - return true; - } - public boolean superLargeRight45DegreeTurn(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes tempType){ - - int[] xArray; - int[] zArray; - if (player.isSneaking()) { - xArray = new int[] {0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3 , 4, 4 }; - zArray = new int[] {0, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, 7, 5, 6, 7, 8, 9, 7, 8, 9, 10, 9, 10}; - } - else { - xArray = new int[] {0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3 , 4, 4 , 4 , 5 }; - zArray = new int[] {0, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, 7, 5, 6, 7, 8, 9, 7, 8, 9, 10, 9, 10, 11, 10}; - } - - if (l == 2) { - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, false), flipArraySign(zArray, z, true), l, false, 3, x + 4, z - 11 , 15.69, x + 16.19, - y + 1, z + 1, tempType.getLabel(), tempType.getItem().item)) - return false; - } - if (l == 0) { - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, true), flipArraySign(zArray, z, false), l, false, 1, x - 4, z + 11 , 15.69, x - 15.19, - y + 1, z , tempType.getLabel(), tempType.getItem().item)) - return false; - } - if (l == 1) { - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, true), flipArraySign(xArray, z, true), l, false, 2, x - 11, z - 4 , 15.69, x + 1, - y + 1, z - 15.19, tempType.getLabel(), tempType.getItem().item)) - return false; - } - if (l == 3) { - return putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, false), flipArraySign(xArray, z, false), l, false, 0, x + 11, z + 4, 15.69, x, - y + 1, z + 16.19, tempType.getLabel(), tempType.getItem().item); - } - return true; - } - public boolean superLargeLeft45DegreeTurn(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes tempType){ - - int[] xArray; - int[] zArray; - if (player.isSneaking()) { - xArray = new int[] {0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3 , 4, 4 }; - zArray = new int[] {0, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, 7, 5, 6, 7, 8, 9, 7, 8, 9, 10, 9, 10}; - } - else { - xArray = new int[] {0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3 , 4, 4 , 4 , 5 }; - zArray = new int[] {0, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, 7, 5, 6, 7, 8, 9, 7, 8, 9, 10, 9, 10, 11, 10}; - } - if (l == 2) { - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, true), flipArraySign(zArray, z, true), l, false, 1, x - 4, z - 11 , 15.69, x - 15.19, - y + 1, z + 1, tempType.getLabel(), tempType.getItem().item)) - return false; - } - - if (l == 0) { - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, false), flipArraySign(zArray, z, false), l, false, 3, x + 4, z + 11 , 15.69, x + 16.19, - y + 1, z , tempType.getLabel(), tempType.getItem().item)) - return false; - } - if (l == 1) { - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, true), flipArraySign(xArray, z, false), l, false, 0, x - 11, z + 4 , 15.69, x + 1, - y + 1, z + 16.19, tempType.getLabel(), tempType.getItem().item)) - return false; - } - - if (l == 3) { - return putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, false), flipArraySign(xArray, z, true), l, false, 2, x + 11, z - 4, 15.69, x, - y + 1, z - 15.19, tempType.getLabel(), tempType.getItem().item); - } - return true; - } - public boolean largeRightCurvedSlope(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes tempType){ - - int[] xArray = {0, 0, 1, 0, 1, 1, 2, 2, 2, 3, 3, 4}; - int[] zArray = {0, 1, 1, 2, 2, 3, 2, 3, 4, 3, 4, 4}; - - if (l == 2 ) { - return putDownSlopedTurn(player, world, x, y, z, flipArraySign(xArray,x, false), flipArraySign(zArray, z, true), l, 4.5, x+5, - y + 1, z + 1, 0.1558f, 6.3639, tempType.getLabel(), tempType.getItem().item) -; } - if (l == 0 ) { - return putDownSlopedTurn(player, world, x, y, z, flipArraySign(xArray,x, true), flipArraySign(zArray, z, false), l, 4.5, x- 4, - y + 1, z , 0.1558f, 6.3639, tempType.getLabel(), tempType.getItem().item); - } - if (l == 1 ) { - return putDownSlopedTurn(player, world, x, y, z, flipArraySign(zArray,x, true), flipArraySign(xArray, z, true), l, 4.5, x + 1, - y + 1, z - 4, 0.1558f, 6.3639, tempType.getLabel(), tempType.getItem().item); - } - if (l == 3 ) { - return putDownSlopedTurn(player, world, x, y, z, flipArraySign(zArray,x, false), flipArraySign(xArray, z, false), l, 4.5, x, - y + 1, z + 5, 0.1558f, 6.3639, tempType.getLabel(), tempType.getItem().item); - } - return true; - } - public boolean largeLeftCurvedSlope(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes tempType){ - - int[] xArray = {0, 0, 1, 0, 1, 1, 2, 2, 2, 3, 3, 4}; - int[] zArray = {0, 1, 1, 2, 2, 3, 2, 3, 4, 3, 4, 4}; - - if (l == 2 ) { - return putDownSlopedTurn(player, world, x, y, z, flipArraySign(xArray,x, true), flipArraySign(zArray, z, true), l, 4.5, x - 4, - y + 1, z + 1, 0.1558f, 6.3639, tempType.getLabel(), tempType.getItem().item) - ; } - if (l == 0 ) { - return putDownSlopedTurn(player, world, x, y, z, flipArraySign(xArray,x, false), flipArraySign(zArray, z, false), l, 4.5, x + 5, - y + 1, z , 0.1558f, 6.3639, tempType.getLabel(), tempType.getItem().item); - } - if (l == 1 ) { - return putDownSlopedTurn(player, world, x, y, z, flipArraySign(zArray,x, true), flipArraySign(xArray, z, false), l, 4.5, x + 1, - y + 1, z + 5, 0.1558f, 6.3639, tempType.getLabel(), tempType.getItem().item); - } - if (l == 3 ) { - return putDownSlopedTurn(player, world, x, y, z, flipArraySign(zArray,x, false), flipArraySign(xArray, z, true), l, 4.5, x, - y + 1, z - 4 , 0.1558f, 6.3639, tempType.getLabel(), tempType.getItem().item); - } - return true; - } - public boolean veryLargeRightCurvedSlope(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes tempType) { - int[] xArray = {0,0,0,0,0,1,1,1,1,2,2,2,3,3,3,4,4,5,5,6,6,7,8}; - int[] zArray = {0,1,2,3,4,2,3,4,5,4,5,6,5,6,7,6,7,7,8,7,8,8,8}; - - if (l == 2 ) { - return putDownSlopedTurn(player, world, x, y, z, flipArraySign(xArray,x, false), flipArraySign(zArray, z, true), l, 8.5, x + 9, - y + 1, z + 1, 0.083003f, 12.0208, tempType.getLabel(), tempType.getItem().item) - ; } - if (l == 0 ) { - return putDownSlopedTurn(player, world, x, y, z, flipArraySign(xArray,x, true), flipArraySign(zArray, z, false), l, 8.5, x - 8, - y + 1, z , 0.083003f, 12.0208, tempType.getLabel(), tempType.getItem().item); - } - if (l == 1 ) { - return putDownSlopedTurn(player, world, x, y, z, flipArraySign(zArray,x, true), flipArraySign(xArray, z, true), l, 8.5, x + 1, - y + 1, z - 8, 0.083003f, 12.0208, tempType.getLabel(), tempType.getItem().item); - } - if (l == 3 ) { - return putDownSlopedTurn(player, world, x, y, z, flipArraySign(zArray,x, false), flipArraySign(xArray, z, false), l, 8.5, x, - y + 1, z + 9, 0.083003f, 12.0208, tempType.getLabel(), tempType.getItem().item); - } - return true; - } - public boolean veryLargeLeftCurvedSlope(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes tempType){ - - int[] xArray = {0,0,0,0,0,1,1,1,1,2,2,2,3,3,3,4,4,5,5,6,6,7,8}; - int[] zArray = {0,1,2,3,4,2,3,4,5,4,5,6,5,6,7,6,7,7,8,7,8,8,8}; - - if (l == 2 ) { - return putDownSlopedTurn(player, world, x, y, z, flipArraySign(xArray,x, true), flipArraySign(zArray, z, true), l, 8.5, x - 8, - y + 1, z + 1, 0.083003f, 12.0208, tempType.getLabel(), tempType.getItem().item) - ; } - if (l == 0 ) { - return putDownSlopedTurn(player, world, x, y, z, flipArraySign(xArray,x, false), flipArraySign(zArray, z, false), l, 8.5, x + 9, - y + 1, z , 0.083003f, 12.0208, tempType.getLabel(), tempType.getItem().item); - } - if (l == 1 ) { - return putDownSlopedTurn(player, world, x, y, z, flipArraySign(zArray,x, true), flipArraySign(xArray, z, false), l, 8.5, x + 1, - y + 1, z + 9, 0.083003f, 12.0208, tempType.getLabel(), tempType.getItem().item); - } - if (l == 3 ) { - return putDownSlopedTurn(player, world, x, y, z, flipArraySign(zArray,x, false), flipArraySign(xArray, z, true), l, 8.5, x, - y + 1, z - 8 , 0.083003f, 12.0208, tempType.getLabel(), tempType.getItem().item); - } - return true; - } - public boolean superLargeRightCurvedSlope(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes tempType) { - int[] xArray = {0,0,0,0,0,0,1,1,1,1,1,1,2,2,2,2,2,3,3,3 ,4,4 ,4 ,5 ,5 ,5 ,6 ,6 ,6 ,7 ,7 ,8 ,8 ,8 ,9 ,9 ,10,10,10,11,11,12,12,13,13,14,15}; - int[] zArray = {0,1,2,3,4,5,2,3,4,5,6,7,5,6,7,8,9,8,9,10,9,10,11,10,11,12,11,12,13,12,13,12,13,14,13,14,13,14,15,14,15,14,15,14,15,15,15}; - - if (l == 2 ) { - return putDownSlopedTurn(player, world, x, y, z, flipArraySign(xArray,x, false), flipArraySign(zArray, z, true), l, 15.5, x+16, - y + 1, z + 1, 0.045589f, 21.9203, tempType.getLabel(), tempType.getItem().item) - ; } - if (l == 0 ) { - return putDownSlopedTurn(player, world, x, y, z, flipArraySign(xArray,x, true), flipArraySign(zArray, z, false), l, 15.5, x- 15, - y + 1, z , 0.045589f, 21.9203, tempType.getLabel(), tempType.getItem().item); - } - if (l == 1 ) { - return putDownSlopedTurn(player, world, x, y, z, flipArraySign(zArray,x, true), flipArraySign(xArray, z, true), l, 15.5, x + 1, - y + 1, z - 15, 0.045589f, 21.9203, tempType.getLabel(), tempType.getItem().item); - } - if (l == 3 ) { - return putDownSlopedTurn(player, world, x, y, z, flipArraySign(zArray,x, false), flipArraySign(xArray, z, false), l, 15.5, x, - y + 1, z + 16, 0.045589f, 21.9203, tempType.getLabel(), tempType.getItem().item); - } - return true; - } - public boolean superLargeLeftCurvedSlope(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes tempType){ - - int[] xArray = {0,0,0,0,0,0,1,1,1,1,1,1,2,2,2,2,2,3,3,3 ,4,4 ,4 ,5 ,5 ,5 ,6 ,6 ,6 ,7 ,7 ,8 ,8 ,8 ,9 ,9 ,10,10,10,11,11,12,12,13,13,14,15}; - int[] zArray = {0,1,2,3,4,5,2,3,4,5,6,7,5,6,7,8,9,8,9,10,9,10,11,10,11,12,11,12,13,12,13,12,13,14,13,14,13,14,15,14,15,14,15,14,15,15,15}; - - if (l == 2 ) { - return putDownSlopedTurn(player, world, x, y, z, flipArraySign(xArray,x, true), flipArraySign(zArray, z, true), l, 15.5, x - 15, - y + 1, z + 1, 0.045589f, 21.9203, tempType.getLabel(), tempType.getItem().item); } - if (l == 0 ) { - return putDownSlopedTurn(player, world, x, y, z, flipArraySign(xArray,x, false), flipArraySign(zArray, z, false), l, 15.5, x + 16, - y + 1, z , 0.045589f, 21.9203, tempType.getLabel(), tempType.getItem().item); - } - if (l == 1 ) { - return putDownSlopedTurn(player, world, x, y, z, flipArraySign(zArray,x, true), flipArraySign(xArray, z, false), l, 15.5, x + 1, - y + 1, z + 16, 0.045589f, 21.9203, tempType.getLabel(), tempType.getItem().item); - } - if (l == 3 ) { - return putDownSlopedTurn(player, world, x, y, z, flipArraySign(zArray,x, false), flipArraySign(xArray, z, true), l, 15.5, x, - y + 1, z - 15 , 0.045589f, 21.9203, tempType.getLabel(), tempType.getItem().item); - } - return true; - } - public boolean smallRightParallelCurve(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes tempType) { - - int[] xArray = {0, 0, 0, 0, 0, 0}; - int[] zArray = {0, 1, 2, 3, 4, 5}; - int[] xArray2 = {1, 1, 1, 1, 1, 1}; - int[] zArray2 = {7, 3, 4, 2, 6, 5}; - - - if (l == 2) { - - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, false), flipArraySign(zArray, z, true), l, false, 2, x + 1, z - 7, 16.25, x + 16.75, - y + 1, z + 1, tempType.getLabel(), tempType.getItem().item)) - return false; - TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x, y + 1, z); - - if (tcRailTurn != null) { - tcRailTurn.hasModel = true; - if (!putDownTurn(player, world, false, x, y, z,flipArraySign(xArray2, x, false), flipArraySign(zArray2, z, true), 3, false, 2, x + 1, z - 7, 16.25, x - 14.75, - y + 1, z - 7, TrackTypes.MEDIUM_LEFT_TURN.getLabel(), null)) - return false; - - TileTCRail tcRailTurn2 = (TileTCRail) world.getTileEntity(x + 1, y + 1, z - 7); - - if (tcRailTurn2 != null) { - tcRailTurn2.hasModel = false; - tcRailTurn2.isLinkedToRail = true; - tcRailTurn2.linkedX = x; - tcRailTurn2.linkedY = y + 1; - tcRailTurn2.linkedZ = z; - } - tcRailTurn.isLinkedToRail = true; - tcRailTurn.linkedX = x + 1; - tcRailTurn.linkedY = y + 1; - tcRailTurn.linkedZ = z - 7; - } - return true; - } - if (l == 0) { - if (!putDownTurn(player, world, false, x, y, z,flipArraySign(xArray, x, true), flipArraySign(zArray, z, false), l, false, 0, x - 1, z + 8, 16.25, x - 15.75, - y + 1, z, tempType.getLabel(), tempType.getItem().item)) - return false; - TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x, y + 1, z); - if (tcRailTurn != null) { - tcRailTurn.hasModel = true; - - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray2, x, true), flipArraySign(zArray2, z, false), 1, false, 0, x - 1, z + 8, 16.25, x + 15.75, - y + 1, z + 8, TrackTypes.MEDIUM_LEFT_TURN.getLabel(), null)) - return false; - TileTCRail tcRailTurn2 = (TileTCRail) world.getTileEntity(x - 1, y + 1, z + 7); - - if (tcRailTurn2 != null) { - tcRailTurn2.hasModel = false; - tcRailTurn2.isLinkedToRail = true; - tcRailTurn2.linkedX = x; - tcRailTurn2.linkedY = y + 1; - tcRailTurn2.linkedZ = z; - } - tcRailTurn.isLinkedToRail = true; - tcRailTurn.linkedX = x - 1; - tcRailTurn.linkedY = y + 1; - tcRailTurn.linkedZ = z + 7; - } - return true; - } - - if (l == 1) { - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, true), flipArraySign(xArray, z, true), l, false, 1, x - 7, z - 1, 16.25, x + 1, - y + 1, z - 15.75, tempType.getLabel(), tempType.getItem().item)) - return false; - TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x, y + 1, z); - - if (tcRailTurn != null) { - tcRailTurn.hasModel = true; - - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray2, x, true), flipArraySign(xArray2, z, true), 2, false, 1, x - 7, z - 1, 16.25, x - 7, - y + 1, z + 15.75, TrackTypes.MEDIUM_LEFT_TURN.getLabel(), null)) - return false; - - TileTCRail tcRailTurn2 = (TileTCRail) world.getTileEntity(x - 7, y + 1, z - 1); - - if (tcRailTurn2 != null) { - tcRailTurn2.hasModel = false; - tcRailTurn2.isLinkedToRail = true; - tcRailTurn2.linkedX = x; - tcRailTurn2.linkedY = y + 1; - tcRailTurn2.linkedZ = z; - } - tcRailTurn.isLinkedToRail = true; - tcRailTurn.linkedX = x - 7; - tcRailTurn.linkedY = y + 1; - tcRailTurn.linkedZ = z - 1; - } - return true; - } - - if (l == 3) { - - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, false), flipArraySign(xArray, z, false), l, false, 3, x + 7, z + 1, 16.25, x, - y + 1, z + 16.75, tempType.getLabel(), tempType.getItem().item)) - return false; - TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x, y + 1, z); - - if (tcRailTurn != null) { - tcRailTurn.hasModel = true; - - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray2, x, false), flipArraySign(xArray2, z, false), 0, false, 3, x + 7, z + 1, 16.25, x + 8, - y + 1, z - 14.75, TrackTypes.MEDIUM_LEFT_TURN.getLabel(), null)) - return false; - - TileTCRail tcRailTurn2 = (TileTCRail) world.getTileEntity(x + 7, y + 1, z + 1); - - if (tcRailTurn2 != null) { - tcRailTurn2.hasModel = false; - tcRailTurn2.isLinkedToRail = true; - tcRailTurn2.linkedX = x; - tcRailTurn2.linkedY = y + 1; - tcRailTurn2.linkedZ = z; - } - tcRailTurn.isLinkedToRail = true; - tcRailTurn.linkedX = x + 7; - tcRailTurn.linkedY = y + 1; - tcRailTurn.linkedZ = z + 1; - } - return true; - } - return true; - } - public boolean smallLeftParallelCurve(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes tempType) { - - int[] xArray = {0, 0, 0, 0, 0, 0}; - int[] zArray = {0, 1, 2, 3, 4, 5}; - int[] xArray2 = {1, 1, 1, 1, 1, 1}; - int[] zArray2 = {7, 3, 4, 2, 6, 5}; - - if (l == 2) { - - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, true), flipArraySign(zArray, z, true), l, false, 2, x - 1, z - 7, 16.25, x - 15.75, - y + 1, z + 1, tempType.getLabel(), tempType.getItem().item)) - return false; - TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x, y + 1, z); - - if (tcRailTurn != null) { - tcRailTurn.hasModel = true; - - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray2, x, true), flipArraySign(zArray2, z, true), 1, false, 2, x - 1, z - 7, 16.25, x + 15.75, - y + 1, z - 7, TrackTypes.MEDIUM_LEFT_TURN.getLabel(), null)) - return false; - - TileTCRail tcRailTurn2 = (TileTCRail) world.getTileEntity(x - 1, y + 1, z - 7); - - if (tcRailTurn2 != null) { - tcRailTurn2.hasModel = false; - tcRailTurn2.isLinkedToRail = true; - tcRailTurn2.linkedX = x; - tcRailTurn2.linkedY = y + 1; - tcRailTurn2.linkedZ = z; - } - tcRailTurn.isLinkedToRail = true; - tcRailTurn.linkedX = x - 1; - tcRailTurn.linkedY = y + 1; - tcRailTurn.linkedZ = z - 7; - } - return true; - } - - if (l == 0) { - - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, false), flipArraySign(zArray, z, false), l, false, 0, x + 1, z + 8, 16.25, x + 16.75, - y + 1, z, tempType.getLabel(), tempType.getItem().item)) - return false; - TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x, y + 1, z); - - if (tcRailTurn != null) { - tcRailTurn.hasModel = true; - - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray2, x, false), flipArraySign(zArray2, z, false), 3, false, 0, x + 1, z + 8, 16.25, x - 14.75, - y + 1, z + 8, TrackTypes.MEDIUM_LEFT_TURN.getLabel(), null)) - return false; - - TileTCRail tcRailTurn2 = (TileTCRail) world.getTileEntity(x + 1, y + 1, z + 7); - - if (tcRailTurn2 != null) { - tcRailTurn2.hasModel = false; - tcRailTurn2.isLinkedToRail = true; - tcRailTurn2.linkedX = x; - tcRailTurn2.linkedY = y + 1; - tcRailTurn2.linkedZ = z; - } - tcRailTurn.isLinkedToRail = true; - tcRailTurn.linkedX = x + 1; - tcRailTurn.linkedY = y + 1; - tcRailTurn.linkedZ = z + 7; - } - return true; - } - - if (l == 1) { - - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, true), flipArraySign(xArray, z, false), l, false, 1, x - 7, z + 1, 16.25, x + 1, - y + 1, z + 16.75, tempType.getLabel(), tempType.getItem().item)) - return false; - TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x, y + 1, z); - - if (tcRailTurn != null) { - tcRailTurn.hasModel = true; - - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray2, x, true), flipArraySign(xArray2, z, false), 0, false, 1, x - 7, z + 1, 16.25, x - 7, - y + 1, z - 14.75, TrackTypes.MEDIUM_LEFT_TURN.getLabel(), null)) - return false; - - TileTCRail tcRailTurn2 = (TileTCRail) world.getTileEntity(x - 7, y + 1, z + 1); - - if (tcRailTurn2 != null) { - tcRailTurn2.hasModel = false; - tcRailTurn2.isLinkedToRail = true; - tcRailTurn2.linkedX = x; - tcRailTurn2.linkedY = y + 1; - tcRailTurn2.linkedZ = z; - } - tcRailTurn.isLinkedToRail = true; - tcRailTurn.linkedX = x - 7; - tcRailTurn.linkedY = y + 1; - tcRailTurn.linkedZ = z + 1; - } - return true; - } - - if (l == 3) { - - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, false), flipArraySign(xArray, z, true), l, false, 3, x + 7, z - 1, 16.25, x, - y + 1, z - 15.75, tempType.getLabel(), tempType.getItem().item)) - return false; - TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x, y + 1, z); - - if (tcRailTurn != null) { - tcRailTurn.hasModel = true; - - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray2, x, false), flipArraySign(xArray2, z, true), 0, false, 3, x + 7, z - 1, 16.25, x + 8, - y + 1, z + 15.75, TrackTypes.MEDIUM_LEFT_TURN.getLabel(), null)) - return false; - - TileTCRail tcRailTurn2 = (TileTCRail) world.getTileEntity(x + 7, y + 1, z - 1); - - if (tcRailTurn2 != null) { - tcRailTurn2.hasModel = false; - tcRailTurn2.isLinkedToRail = true; - tcRailTurn2.linkedX = x; - tcRailTurn2.linkedY = y + 1; - tcRailTurn2.linkedZ = z; - } - tcRailTurn.isLinkedToRail = true; - tcRailTurn.linkedX = x + 7; - tcRailTurn.linkedY = y + 1; - tcRailTurn.linkedZ = z - 1; - } - return true; - } - - return true; - } - private boolean parallelRightSwitchEast(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes tempType, String typeVariantStraight, Item idVariantSwitch) { - for (int check = 1; check < 10; check++) { - if (!canPlaceTrack(player, world, x + check, y + 1, z)) - return false; - } - if (!canPlaceTrack(player, world, x + 3, y + 1, z + 1) || !canPlaceTrack(player, world, x + 4, y + 1, z + 1) || !canPlaceTrack(player, world, x + 5, y + 1, z + 1) || !canPlaceTrack(player, world, x + 4, y + 1, z + 2) || !canPlaceTrack(player, world, x + 5, y + 1, z + 2) || !canPlaceTrack(player, world, x + 6, y + 1, z + 2) || !canPlaceTrack(player, world, x + 7, y + 1, z + 2) || !canPlaceTrack(player, world, x + 8, y + 1, z + 2) || !canPlaceTrack(player, world, x + 6, y + 1, z + 3) || !canPlaceTrack(player, world, x + 7, y + 1, z + 3) || !canPlaceTrack(player, world, x + 8, y + 1, z + 3) || !canPlaceTrack(player, world, x + 9, y + 1, z + 3) || !canPlaceTrack(player, world, x + 10, y + 1, z + 3) || !canPlaceTrack(player, world, x, y + 1, z)) { - return false; - } - int[] xArray = { x + 3, x + 2, x + 4, x + 5 }; - int[] zArray = { z + 1, z + 1, z + 1, z + 1 }; - if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, true, 3, x + 10, z, 8.5, x + 0.5, y + 1, z + 9, - TrackTypes.MEDIUM_RIGHT_TURN.getLabel(), idVariantSwitch)) - return false; - TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x + 3, y + 1, z + 1); - if (tcRailTurn != null) { - tcRailTurn.hasModel = false; - - /** Switch rail 1 */ - putDownSingleRail(world, x + 1, y + 1, z, l, x + 0.5, y + 1, z + 9, 8.5, tempType.getLabel(), true, x + 3, y + 1, z + 1, true, false); - - /** Switch rail 2 **/ - putDownSingleRail(world, x + 2, y + 1, z, l, x + 0.5, y + 1, z + 9, 8.5, typeVariantStraight, false, x + 3, y + 1, z + 1, true, false); - /** Switch rail 3 **/ - putDownSingleRail(world, x + 3, y + 1, z, l, x + 0.5, y + 1, z + 9, 8.5, typeVariantStraight, false, x + 3, y + 1, z + 1, true, false); - - int[] xArray2 = {x + 4, x + 5, x + 6, x + 7, x + 8, x + 6, x + 7, x + 8, x + 9}; - int[] zArray2 = {z + 2, z + 2, z + 2, z + 2, z + 2, z + 3, z + 3, z + 3, z + 3}; - if (!putDownTurn(player, world, false, x, y, z, xArray2, zArray2, 0, true, 3, x + 10, z + 3, 8.5, x + 10, y + 1, z - 5, - TrackTypes.MEDIUM_LEFT_TURN.getLabel(), null)) - return false; - TileTCRail tcRailTurn2 = (TileTCRail) world.getTileEntity(x + 4, y + 1, z + 2); - if (tcRailTurn2 != null) { - tcRailTurn2.hasModel = false; - tcRailTurn2.isLinkedToRail = true; - tcRailTurn2.linkedX = x + 3; - tcRailTurn2.linkedY = y + 1; - tcRailTurn2.linkedZ = z + 1; - } - tcRailTurn.isLinkedToRail = true; - tcRailTurn.linkedX = x + 4; - tcRailTurn.linkedY = y + 1; - tcRailTurn.linkedZ = z + 2; - } - /** Put down straight **/ - putDownSingleRail(world, x + 4, y + 1, z, l, x, y + 1, z, 0, typeVariantStraight, false, x + 3, y + 1, z + 1, false, false); - for (int straight = 5; straight < 10; straight++) { - putDownSingleRail(world, x + straight, y + 1, z, l, x, y + 1, z, 0, typeVariantStraight, true, x + 3, y + 1, z + 1, false, false); - } - return true; - } - private boolean parallelRightSwitchWest(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes tempType, String typeVariantStraight, Item idVariantSwitch) { - for (int check = 1; check < 10; check++) { - if (!canPlaceTrack(player, world, x - check, y + 1, z)) - return false; - } - if (!canPlaceTrack(player, world, x - 3, y + 1, z - 1) || !canPlaceTrack(player, world, x - 4, y + 1, z - 1) || !canPlaceTrack(player, world, x - 5, y + 1, z - 1) || !canPlaceTrack(player, world, x - 4, y + 1, z - 2) || !canPlaceTrack(player, world, x - 5, y + 1, z - 2) || !canPlaceTrack(player, world, x - 6, y + 1, z - 2) || !canPlaceTrack(player, world, x - 7, y + 1, z - 2) || !canPlaceTrack(player, world, x - 8, y + 1, z - 2) || !canPlaceTrack(player, world, x - 6, y + 1, z - 3) || !canPlaceTrack(player, world, x - 7, y + 1, z - 3) || !canPlaceTrack(player, world, x - 8, y + 1, z - 3) || !canPlaceTrack(player, world, x - 9, y + 1, z - 3) || !canPlaceTrack(player, world, x - 10, y + 1, z - 3) || !canPlaceTrack(player, world, x, y + 1, z)) { - return false; - } - int[] xArray = { x - 3, x - 2, x - 4, x - 5 }; - int[] zArray = { z - 1, z - 1, z - 1, z - 1 }; - if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, true, 1, x - 10, z, 8.5, x + 0.5, y + 1, z - 8, - TrackTypes.MEDIUM_RIGHT_TURN.getLabel(), idVariantSwitch)) - return false; - TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x - 3, y + 1, z - 1); - if (tcRailTurn != null) { - tcRailTurn.hasModel = false; - - /** Switch rail 1 */ - putDownSingleRail(world, x - 1, y + 1, z, l, x + 0.5, y + 1, z - 8, 8.5, tempType.getLabel(), true, x - 3, y + 1, z - 1, true, false); - - /** Switch rail 2 **/ - putDownSingleRail(world, x - 2, y + 1, z, l, x + 0.5, y + 1, z - 8, 8.5, typeVariantStraight, false, x - 3, y + 1, z - 1, true, false); - /** Switch rail 3 **/ - putDownSingleRail(world, x - 3, y + 1, z, l, x + 0.5, y + 1, z - 8, 8.5, typeVariantStraight, false, x - 3, y + 1, z - 1, true, false); - - int[] xArray2 = {x - 4, x - 5, x - 6, x - 7, x - 8, x - 6, x - 7, x - 8, x - 9}; - int[] zArray2 = {z - 2, z - 2, z - 2, z - 2, z - 2, z - 3, z - 3, z - 3, z - 3}; - if (!putDownTurn(player, world, false, x, y, z, xArray2, zArray2, 2, true, 1, x - 10, z - 3, 8.5, x - 9, y + 1, z + 6, - TrackTypes.MEDIUM_LEFT_TURN.getLabel(), null)) - return false; - TileTCRail tcRailTurn2 = (TileTCRail) world.getTileEntity(x - 4, y + 1, z - 2); - if (tcRailTurn2 != null) { - tcRailTurn2.hasModel = false; - tcRailTurn2.isLinkedToRail = true; - tcRailTurn2.linkedX = x - 3; - tcRailTurn2.linkedY = y + 1; - tcRailTurn2.linkedZ = z - 1; - } - tcRailTurn.isLinkedToRail = true; - tcRailTurn.linkedX = x - 4; - tcRailTurn.linkedY = y + 1; - tcRailTurn.linkedZ = z - 2; - } - - /** Put down straight **/ - putDownSingleRail(world, x - 4, y + 1, z, l, x, y + 1, z, 0, typeVariantStraight, false, x - 3, y + 1, z - 1, false, false); - for (int straight = 5; straight < 10; straight++) { - putDownSingleRail(world, x - straight, y + 1, z, l, x, y + 1, z, 0, typeVariantStraight, true, x - 3, y + 1, z - 1, false, false); - } - return true; - } - private boolean parallelRightSwitchSouth(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes tempType, String typeVariantStraight, Item idVariantSwitch) { - for (int check = 1; check < 10; check++) { - if (!canPlaceTrack(player, world, x, y + 1, z + check)) - return false; - } - if (!canPlaceTrack(player, world, x - 1, y + 1, z + 3) || !canPlaceTrack(player, world, x - 1, y + 1, z + 4) || !canPlaceTrack(player, world, x - 1, y + 1, z + 5) || !canPlaceTrack(player, world, x - 2, y + 1, z + 4) || !canPlaceTrack(player, world, x - 2, y + 1, z + 5) || !canPlaceTrack(player, world, x - 2, y + 1, z + 6) || !canPlaceTrack(player, world, x - 2, y + 1, z + 7) || !canPlaceTrack(player, world, x - 2, y + 1, z + 8) || !canPlaceTrack(player, world, x - 3, y + 1, z + 6) || !canPlaceTrack(player, world, x - 3, y + 1, z + 7) || !canPlaceTrack(player, world, x - 3, y + 1, z + 8) || !canPlaceTrack(player, world, x - 3, y + 1, z + 9) || !canPlaceTrack(player, world, x - 3, y + 1, z + 10) || !canPlaceTrack(player, world, x, y + 1, z)) { - return false; - } - int[] xArray = { x - 1, x - 1, x - 1, x - 1 }; - int[] zArray = { z + 3, z + 2, z + 4, z + 5 }; - if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, true, 0, x, z + 10, 8.5, x - 8, y + 1, z + 0.5, - TrackTypes.MEDIUM_RIGHT_TURN.getLabel(), idVariantSwitch)) - return false; - TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x - 1, y + 1, z + 3); - if (tcRailTurn != null) { - tcRailTurn.hasModel = false; - - /** Switch rail 1 */ - putDownSingleRail(world, x, y + 1, z + 1, l, x - 8, y + 1, z + 0.5, 8.5, tempType.getLabel(), true, x - 1, y + 1, z + 3, true, false); - - /** Switch rail 2 **/ - putDownSingleRail(world, x, y + 1, z + 2, l, x - 8, y + 1, z + 0.5, 8.5, typeVariantStraight, false, x - 1, y + 1, z + 3, true, false); - /** Switch rail 3 **/ - putDownSingleRail(world, x, y + 1, z + 3, l, x - 8, y + 1, z + 0.5, 8.5, typeVariantStraight, false, x - 1, y + 1, z + 3, true, false); - - int[] xArray2 = {x - 2, x - 2, x - 2, x - 2, x - 2, x - 3, x - 3, x - 3, x - 3}; - int[] zArray2 = {z + 4, z + 5, z + 6, z + 7, z + 8, z + 6, z + 7, z + 8, z + 9}; - if (!putDownTurn(player, world, false, x, y, z, xArray2, zArray2, 1, true, 0, x - 3, z + 10, 8.5, x + 6, y + 1, z + 10, - TrackTypes.MEDIUM_LEFT_TURN.getLabel(), null)) - return false; - TileTCRail tcRailTurn2 = (TileTCRail) world.getTileEntity(x - 2, y + 1, z + 4); - if (tcRailTurn2 != null) { - tcRailTurn2.hasModel = false; - tcRailTurn2.isLinkedToRail = true; - tcRailTurn2.linkedX = x - 1; - tcRailTurn2.linkedY = y + 1; - tcRailTurn2.linkedZ = z + 3; - } - tcRailTurn.isLinkedToRail = true; - tcRailTurn.linkedX = x - 2; - tcRailTurn.linkedY = y + 1; - tcRailTurn.linkedZ = z + 4; - } - /** Put down straight **/ - putDownSingleRail(world, x, y + 1, z + 4, l, x, y + 1, z, 0, typeVariantStraight, false, x - 1, y + 1, z + 3, false, false); - for (int straight = 5; straight < 10; straight++) { - putDownSingleRail(world, x, y + 1, z + straight, l, x, y + 1, z, 0, typeVariantStraight, true, x - 1, y + 1, z + 3, false, false); - } - return true; - } - private boolean parallelRightSwitchNorth(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes tempType, String typeVariantStraight, Item idVariantSwitch) { - for (int check = 1; check < 10; check++) { - if (!canPlaceTrack(player, world, x, y + 1, z - check)) - return false; /** checks if the next 11 blocks can be placed */ - } - if (!canPlaceTrack(player, world, x + 1, y + 1, z - 3) || !canPlaceTrack(player, world, x + 1, y + 1, z - 4) || !canPlaceTrack(player, world, x + 1, y + 1, z - 5) || !canPlaceTrack(player, world, x + 2, y + 1, z - 4) || !canPlaceTrack(player, world, x + 2, y + 1, z - 5) || !canPlaceTrack(player, world, x + 2, y + 1, z - 6) || !canPlaceTrack(player, world, x + 2, y + 1, z - 7) || !canPlaceTrack(player, world, x + 2, y + 1, z - 8) || !canPlaceTrack(player, world, x + 3, y + 1, z - 6) || !canPlaceTrack(player, world, x + 3, y + 1, z - 7) || !canPlaceTrack(player, world, x + 3, y + 1, z - 8) || !canPlaceTrack(player, world, x + 3, y + 1, z - 9) || !canPlaceTrack(player, world, x + 3, y + 1, z - 10) || !canPlaceTrack(player, world, x, y + 1, z)) { - return false; - } - int[] xArray = { x + 1, x + 1, x + 1, x + 1 }; - int[] zArray = { z - 3, z - 2, z - 4, z - 5 }; - if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, true, 2, x, z - 10, 8.5, x + 9, y + 1, z + 0.5, - TrackTypes.MEDIUM_RIGHT_TURN.getLabel(), idVariantSwitch)) - return false; - TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x + 1, y + 1, z - 3); - if (tcRailTurn != null) { - tcRailTurn.hasModel = false; - - /** Switch rail 1 */ - putDownSingleRail(world, x, y + 1, z - 1, l, x + 9, y + 1, z + 0.5, 8.5, tempType.getLabel(), true, x + 1, y + 1, z - 3, true, false); - - /** Switch rail 2 **/ - putDownSingleRail(world, x, y + 1, z - 2, l, x + 9, y + 1, z + 0.5, 8.5, typeVariantStraight, false, x + 1, y + 1, z - 3, true, false); - /** Switch rail 3 **/ - putDownSingleRail(world, x, y + 1, z - 3, l, x + 9, y + 1, z + 0.5, 8.5, typeVariantStraight, false, x + 1, y + 1, z - 3, true, false); - - int[] xArray2 = {x + 2, x + 2, x + 2, x + 2, x + 2, x + 3, x + 3, x + 3, x + 3}; - int[] zArray2 = {z - 4, z - 5, z - 6, z - 7, z - 8, z - 6, z - 7, z - 8, z - 9}; - if (!putDownTurn(player, world, false, x, y, z, xArray2, zArray2, 3, true, 2, x + 3, z - 10, 8.5, x - 5, y + 1, z - 9, - TrackTypes.MEDIUM_LEFT_TURN.getLabel(), null)) - return false; - TileTCRail tcRailTurn2 = (TileTCRail) world.getTileEntity(x + 2, y + 1, z - 4); - if (tcRailTurn2 != null) { - tcRailTurn2.hasModel = false; - tcRailTurn2.isLinkedToRail = true; - tcRailTurn2.linkedX = x + 1; - tcRailTurn2.linkedY = y + 1; - tcRailTurn2.linkedZ = z - 3; - } - tcRailTurn.isLinkedToRail = true; - tcRailTurn.linkedX = x + 2; - tcRailTurn.linkedY = y + 1; - tcRailTurn.linkedZ = z - 4; - } - /** Put down straight **/ - putDownSingleRail(world, x, y + 1, z - 4, l, x, y + 1, z, 0, typeVariantStraight, false, x + 1, y + 1, z - 3, false, false); - for (int straight = 5; straight < 10; straight++) { - putDownSingleRail(world, x, y + 1, z - straight, l, x, y + 1, z, 0, typeVariantStraight, true, x + 1, y + 1, z - 3, false, false); - } - - return true; - } - private boolean parallelLeftSwitchNorth(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes tempType, String variantStraight, Item idVariantSwitch) { - for (int check = 1; check < 10; check++) { - if (!canPlaceTrack(player, world, x, y + 1, z - check)) - return false; - } - if (!canPlaceTrack(player, world, x - 1, y + 1, z - 3) || !canPlaceTrack(player, world, x - 1, y + 1, z - 4) || !canPlaceTrack(player, world, x - 1, y + 1, z - 5) || !canPlaceTrack(player, world, x - 2, y + 1, z - 4) || !canPlaceTrack(player, world, x - 2, y + 1, z - 5) || !canPlaceTrack(player, world, x - 2, y + 1, z - 6) || !canPlaceTrack(player, world, x - 2, y + 1, z - 7) || !canPlaceTrack(player, world, x - 2, y + 1, z - 8) || !canPlaceTrack(player, world, x - 3, y + 1, z - 6) || !canPlaceTrack(player, world, x - 3, y + 1, z - 7) || !canPlaceTrack(player, world, x - 3, y + 1, z - 8) || !canPlaceTrack(player, world, x - 3, y + 1, z - 9) || !canPlaceTrack(player, world, x - 3, y + 1, z - 10) || !canPlaceTrack(player, world, x, y + 1, z)) { - return false; - } - int[] xArray = { x - 1, x - 1, x - 1, x - 1 }; - int[] zArray = { z - 3, z - 2, z - 4, z - 5 }; - if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, true, 2, x, z - 10, 8.5, x - 8, y + 1, z + 0.5, - TrackTypes.MEDIUM_LEFT_TURN.getLabel(), idVariantSwitch)) - return false; - TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x - 1, y + 1, z - 3); - if (tcRailTurn != null) { - tcRailTurn.hasModel = false; - - /** Switch rail 1 */ - putDownSingleRail(world, x, y + 1, z - 1, l, x - 8, y + 1, z + 0.5, 8.5, tempType.getLabel(), true, x - 1, y + 1, z - 3, true, false); - - /** Switch rail 2 **/ - putDownSingleRail(world, x, y + 1, z - 2, l, x - 8, y + 1, z + 0.5, 8.5, typeVariantStraight, false, x - 1, y + 1, z - 3, true, false); - /** Switch rail 3 **/ - putDownSingleRail(world, x, y + 1, z - 3, l, x - 8, y + 1, z + 0.5, 8.5, typeVariantStraight, false, x - 1, y + 1, z - 3, true, false); - - int[] xArray2 = {x - 2, x - 2, x - 2, x - 2, x - 2, x - 3, x - 3, x - 3, x - 3}; - int[] zArray2 = {z - 4, z - 5, z - 6, z - 7, z - 8, z - 6, z - 7, z - 8, z - 9}; - if (!putDownTurn(player, world, false, x, y, z, xArray2, zArray2, 1, true, 2, x - 3, z - 10, 8.5, x + 6, y + 1, z - 9, - TrackTypes.MEDIUM_RIGHT_TURN.getLabel(), null)) - return false; - TileTCRail tcRailTurn2 = (TileTCRail) world.getTileEntity(x - 2, y + 1, z - 4); - if (tcRailTurn2 != null) { - tcRailTurn2.hasModel = false; - tcRailTurn2.isLinkedToRail = true; - tcRailTurn2.linkedX = x - 1; - tcRailTurn2.linkedY = y + 1; - tcRailTurn2.linkedZ = z - 3; - } - tcRailTurn.isLinkedToRail = true; - tcRailTurn.linkedX = x - 2; - tcRailTurn.linkedY = y + 1; - tcRailTurn.linkedZ = z - 4; - } - /** Put down straight **/ - putDownSingleRail(world, x, y + 1, z - 4, l, x, y + 1, z, 0, typeVariantStraight, false, x - 1, y + 1, z - 3, false, false); - for (int straight = 5; straight < 10; straight++) { - putDownSingleRail(world, x, y + 1, z - straight, l, x, y + 1, z, 0, typeVariantStraight, true, x - 1, y + 1, z - 3, false, false); - } - return true; - } - private boolean parallelLeftSwitchSouth(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes tempType, String typeVariantStraight, Item idVariantSwitch) { - for (int check = 1; check < 10; check++) { - if (!canPlaceTrack(player, world, x, y + 1, z + check)) - return false; - } - if (!canPlaceTrack(player, world, x + 1, y + 1, z + 3) || !canPlaceTrack(player, world, x + 1, y + 1, z + 4) || !canPlaceTrack(player, world, x + 1, y + 1, z + 5) || !canPlaceTrack(player, world, x + 2, y + 1, z + 4) || !canPlaceTrack(player, world, x + 2, y + 1, z + 5) || !canPlaceTrack(player, world, x + 2, y + 1, z + 6) || !canPlaceTrack(player, world, x + 2, y + 1, z + 7) || !canPlaceTrack(player, world, x + 2, y + 1, z + 8) || !canPlaceTrack(player, world, x + 3, y + 1, z + 6) || !canPlaceTrack(player, world, x + 3, y + 1, z + 7) || !canPlaceTrack(player, world, x + 3, y + 1, z + 8) || !canPlaceTrack(player, world, x + 3, y + 1, z + 9) || !canPlaceTrack(player, world, x + 3, y + 1, z + 10) || !canPlaceTrack(player, world, x, y + 1, z)) { - return false; - } - int[] xArray = { x + 1, x + 1, x + 1, x + 1 }; - int[] zArray = { z + 3, z + 2, z + 4, z + 5 }; - if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, true, 0, x, z + 10, 8.5, x + 9, y + 1, z + 0.5, - TrackTypes.MEDIUM_LEFT_TURN.getLabel(), idVariantSwitch)) - return false; - TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x + 1, y + 1, z + 3); - if (tcRailTurn != null) { - tcRailTurn.hasModel = false; - - /** Switch rail 1 */ - putDownSingleRail(world, x, y + 1, z + 1, l, x + 9, y + 1, z + 0.5, 8.5, tempType.getLabel(), true, x + 1, y + 1, z + 3, true, false); - - /** Switch rail 2 **/ - putDownSingleRail(world, x, y + 1, z + 2, l, x + 9, y + 1, z + 0.5, 8.5, typeVariantStraight, false, x + 1, y + 1, z + 3, true, false); - /** Switch rail 3 **/ - putDownSingleRail(world, x, y + 1, z + 3, l, x + 9, y + 1, z + 0.5, 8.5, typeVariantStraight, false, x + 1, y + 1, z + 3, true, false); - - int[] xArray2 = {x + 2, x + 2, x + 2, x + 2, x + 2, x + 3, x + 3, x + 3, x + 3}; - int[] zArray2 = {z + 4, z + 5, z + 6, z + 7, z + 8, z + 6, z + 7, z + 8, z + 9}; - if (!putDownTurn(player, world, false, x, y, z, xArray2, zArray2, 3, true, 0, x + 3, z + 10, 8.5, x - 5, y + 1, z + 10, - TrackTypes.MEDIUM_RIGHT_TURN.getLabel(), null)) - return false; - TileTCRail tcRailTurn2 = (TileTCRail) world.getTileEntity(x + 2, y + 1, z + 4); - if (tcRailTurn2 != null) { - tcRailTurn2.hasModel = false; - tcRailTurn2.isLinkedToRail = true; - tcRailTurn2.linkedX = x + 1; - tcRailTurn2.linkedY = y + 1; - tcRailTurn2.linkedZ = z + 3; - } - tcRailTurn.isLinkedToRail = true; - tcRailTurn.linkedX = x + 2; - tcRailTurn.linkedY = y + 1; - tcRailTurn.linkedZ = z + 4; - } - /** Put down straight **/ - putDownSingleRail(world, x, y + 1, z + 4, l, x, y + 1, z, 0, typeVariantStraight, false, x + 1, y + 1, z + 3, false, false); - for (int straight = 5; straight < 10; straight++) { - putDownSingleRail(world, x, y + 1, z + straight, l, x, y + 1, z, 0, typeVariantStraight, true, x + 1, y + 1, z + 3, false, false); - } - return true; - } - private boolean parallelLeftSwitchEast(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes tempType, String typeVariantStraight, Item idVariantSwitch) { - for (int check = 1; check < 10; check++) { - if (!canPlaceTrack(player, world, x + check, y + 1, z)) - return false; - } - if (!canPlaceTrack(player, world, x + 3, y + 1, z - 1) || !canPlaceTrack(player, world, x + 4, y + 1, z - 1) || !canPlaceTrack(player, world, x + 5, y + 1, z - 1) || !canPlaceTrack(player, world, x + 4, y + 1, z - 2) || !canPlaceTrack(player, world, x + 5, y + 1, z - 2) || !canPlaceTrack(player, world, x + 6, y + 1, z - 2) || !canPlaceTrack(player, world, x + 7, y + 1, z - 2) || !canPlaceTrack(player, world, x + 8, y + 1, z - 2) || !canPlaceTrack(player, world, x + 6, y + 1, z - 3) || !canPlaceTrack(player, world, x + 7, y + 1, z - 3) || !canPlaceTrack(player, world, x + 8, y + 1, z - 3) || !canPlaceTrack(player, world, x + 9, y + 1, z - 3) || !canPlaceTrack(player, world, x + 10, y + 1, z - 3) || !canPlaceTrack(player, world, x, y + 1, z)) { - return false; - } - int[] xArray = { x + 3, x + 2, x + 4, x + 5 }; - int[] zArray = { z - 1, z - 1, z - 1, z - 1 }; - if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, true, 3, x + 10, z, 8.5, x + 0.5, y + 1, z - 8, - TrackTypes.MEDIUM_LEFT_TURN.getLabel(), idVariantSwitch)) - return false; - TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x + 3, y + 1, z - 1); - if (tcRailTurn != null) { - tcRailTurn.hasModel = false; - - /** Switch rail 1 */ - putDownSingleRail(world, x + 1, y + 1, z, l, x + 0.5, y + 1, z - 8, 8.5, tempType.getLabel(), true, x + 3, y + 1, z - 1, true, false); - - /** Switch rail 2 **/ - putDownSingleRail(world, x + 2, y + 1, z, l, x + 0.5, y + 1, z - 8, 8.5, typeVariantStraight, false, x + 3, y + 1, z - 1, true, false); - /** Switch rail 3 **/ - putDownSingleRail(world, x + 3, y + 1, z, l, x + 0.5, y + 1, z - 8, 8.5, typeVariantStraight, false, x + 3, y + 1, z - 1, true, false); - - int[] xArray2 = {x + 4, x + 5, x + 6, x + 7, x + 8, x + 6, x + 7, x + 8, x + 9}; - int[] zArray2 = {z - 2, z - 2, z - 2, z - 2, z - 2, z - 3, z - 3, z - 3, z - 3}; - if (!putDownTurn(player, world, false, x, y, z, xArray2, zArray2, 2, true, 3, x + 10, z - 3, 8.5, x + 10, y + 1, z + 6, - TrackTypes.MEDIUM_RIGHT_TURN.getLabel(), null)) - return false; - TileTCRail tcRailTurn2 = (TileTCRail) world.getTileEntity(x + 4, y + 1, z - 2); - if (tcRailTurn2 != null) { - tcRailTurn2.hasModel = false; - - tcRailTurn2.isLinkedToRail = true; - tcRailTurn2.linkedX = x + 3; - tcRailTurn2.linkedY = y + 1; - tcRailTurn2.linkedZ = z - 1; - } - tcRailTurn.isLinkedToRail = true; - tcRailTurn.linkedX = x + 4; - tcRailTurn.linkedY = y + 1; - tcRailTurn.linkedZ = z - 2; - } - /** Put down straight **/ - putDownSingleRail(world, x + 4, y + 1, z, l, x, y + 1, z, 0, typeVariantStraight, false, x + 3, y + 1, z - 1, false, false); - for (int straight = 5; straight < 10; straight++) { - putDownSingleRail(world, x + straight, y + 1, z, l, x, y + 1, z, 0, typeVariantStraight, true, x + 3, y + 1, z - 1, false, false); - } - return true; - } - private boolean parallelLeftSwitchWest(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes tempType, String typeVariantStraight, Item idVariantSwitch) { - for (int check = 1; check < 10; check++) { - if (!canPlaceTrack(player, world, x - check, y + 1, z)) - return false; - } - if (!canPlaceTrack(player, world, x - 3, y + 1, z + 1) || !canPlaceTrack(player, world, x - 4, y + 1, z + 1) || !canPlaceTrack(player, world, x - 5, y + 1, z + 1) || !canPlaceTrack(player, world, x - 4, y + 1, z + 2) || !canPlaceTrack(player, world, x - 5, y + 1, z + 2) || !canPlaceTrack(player, world, x - 6, y + 1, z + 2) || !canPlaceTrack(player, world, x - 7, y + 1, z + 2) || !canPlaceTrack(player, world, x - 8, y + 1, z + 2) || !canPlaceTrack(player, world, x - 6, y + 1, z + 3) || !canPlaceTrack(player, world, x - 7, y + 1, z + 3) || !canPlaceTrack(player, world, x - 8, y + 1, z + 3) || !canPlaceTrack(player, world, x - 9, y + 1, z + 3) || !canPlaceTrack(player, world, x - 10, y + 1, z + 3) || !canPlaceTrack(player, world, x, y + 1, z)) { - return false; - } - int[] xArray = { x - 3, x - 2, x - 4, x - 5 }; - int[] zArray = { z + 1, z + 1, z + 1, z + 1 }; - if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, true, 1, x - 10, z, 8.5, x + 0.5, y + 1, z + 9, - TrackTypes.MEDIUM_LEFT_TURN.getLabel(), idVariantSwitch)) - return false; - TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x - 3, y + 1, z + 1); - if (tcRailTurn != null) { - tcRailTurn.hasModel = false; - - /** Switch rail 1 */ - putDownSingleRail(world, x - 1, y + 1, z, l, x + 0.5, y + 1, z + 9, 8.5, tempType.getLabel(), true, x - 3, y + 1, z + 1, true, false); - - /** Switch rail 2 **/ - putDownSingleRail(world, x - 2, y + 1, z, l, x + 0.5, y + 1, z + 9, 8.5, typeVariantStraight, false, x - 3, y + 1, z + 1, true, false); - /** Switch rail 3 **/ - putDownSingleRail(world, x - 3, y + 1, z, l, x + 0.5, y + 1, z + 9, 8.5, typeVariantStraight, false, x - 3, y + 1, z + 1, true, false); - - int[] xArray2 = {x - 4, x - 5, x - 6, x - 7, x - 8, x - 6, x - 7, x - 8, x - 9}; - int[] zArray2 = {z + 2, z + 2, z + 2, z + 2, z + 2, z + 3, z + 3, z + 3, z + 3}; - if (!putDownTurn(player, world, false, x, y, z, xArray2, zArray2, 0, true, 1, x - 10, z + 3, 8.5, x - 9, y + 1, z - 5, - TrackTypes.MEDIUM_RIGHT_TURN.getLabel(), null)) - return false; - TileTCRail tcRailTurn2 = (TileTCRail) world.getTileEntity(x - 4, y + 1, z + 2); - if (tcRailTurn2 != null) { - tcRailTurn2.hasModel = false; - tcRailTurn2.isLinkedToRail = true; - tcRailTurn2.linkedX = x - 3; - tcRailTurn2.linkedY = y + 1; - tcRailTurn2.linkedZ = z + 1; - } - tcRailTurn.isLinkedToRail = true; - tcRailTurn.linkedX = x - 4; - tcRailTurn.linkedY = y + 1; - tcRailTurn.linkedZ = z + 2; - } - /** Put down straight **/ - putDownSingleRail(world, x - 4, y + 1, z, l, x, y + 1, z, 0, typeVariantStraight, false, x - 3, y + 1, z + 1, false, false); - for (int straight = 5; straight < 10; straight++) { - putDownSingleRail(world, x - straight, y + 1, z, l, x, y + 1, z, 0, typeVariantStraight, true, x - 3, y + 1, z + 1, false, false); - } - return true; - } - private boolean mediumRightParallelCurve(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes tempType){ - - int[] xArray = {0, 0 , 0 , 0 , 0 ,1,1,1}; - int[] zArray = {0,1,2,3,4,3,4,5}; - - int[] xArray2 = {2,1,1,1,2,2,2,2}; - int[] zArray2 = {11,6,7,8,7,8,9,10}; - - if (l == 2) { - - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, false), flipArraySign(zArray, z, true), l, false, 2, x + 2, z - 11, 18.5, x + 19, - y + 1, z + 1, tempType.getLabel(), tempType.getItem().item)) - return false; - TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x , y + 1, z ); - - if (tcRailTurn != null) { - tcRailTurn.hasModel = true; - - - - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray2, x, false), flipArraySign(zArray2, z, true), 3, false, 2, x + 2, z - 11, 18.5, x - 16, - y + 1, z - 11, TrackTypes.MEDIUM_LEFT_TURN.getLabel(), null)) - return false; - - TileTCRail tcRailTurn2 = (TileTCRail) world.getTileEntity(x + 2, y + 1, z - 11); - - if (tcRailTurn2 != null) { - tcRailTurn2.hasModel = false; - tcRailTurn2.isLinkedToRail = true; - tcRailTurn2.linkedX = x; - tcRailTurn2.linkedY = y + 1; - tcRailTurn2.linkedZ = z ; - - } - tcRailTurn.isLinkedToRail = true; - tcRailTurn.linkedX = x + 2; - tcRailTurn.linkedY = y + 1; - tcRailTurn.linkedZ = z - 11; - } - return true; - } - - if (l == 0) { - - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, true), flipArraySign(zArray, z, false), l, false, 0, x - 2, z + 11, 18.5, x -18, - y + 1, z , tempType.getLabel(), tempType.getItem().item)) - return false; - TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x , y + 1, z ); - - if (tcRailTurn != null) { - tcRailTurn.hasModel = true; - - - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray2, x, true), flipArraySign(zArray2, z, false), 3, false, 0, x - 2, z + 11, 18.5, x + 17, - y + 1, z + 12, TrackTypes.MEDIUM_LEFT_TURN.getLabel(), null)) - return false; - - TileTCRail tcRailTurn2 = (TileTCRail) world.getTileEntity(x - 2, y + 1, z + 11); - - if (tcRailTurn2 != null) { - tcRailTurn2.hasModel = false; - tcRailTurn2.isLinkedToRail = true; - tcRailTurn2.linkedX = x; - tcRailTurn2.linkedY = y + 1; - tcRailTurn2.linkedZ = z ; - - } - tcRailTurn.isLinkedToRail = true; - tcRailTurn.linkedX = x - 2; - tcRailTurn.linkedY = y + 1; - tcRailTurn.linkedZ = z + 11; - } - return true; - } - - if (l == 1) { - - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, true), flipArraySign(xArray, z, true), l, false, 1, x - 11, z - 2, 18.5, x + 1, - y + 1, z - 18 , tempType.getLabel(), tempType.getItem().item)) - return false; - TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x , y + 1, z ); - - if (tcRailTurn != null) { - tcRailTurn.hasModel = true; - - - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray2, x, true), flipArraySign(xArray2, z, true), 2, false, 1, x - 11, z - 2, 18.5, x - 11, - y + 1, z + 17, TrackTypes.MEDIUM_LEFT_TURN.getLabel(), null)) - return false; - - TileTCRail tcRailTurn2 = (TileTCRail) world.getTileEntity(x - 11, y + 1, z - 2); - - if (tcRailTurn2 != null) { - tcRailTurn2.hasModel = false; - tcRailTurn2.isLinkedToRail = true; - tcRailTurn2.linkedX = x; - tcRailTurn2.linkedY = y + 1; - tcRailTurn2.linkedZ = z ; - - } - tcRailTurn.isLinkedToRail = true; - tcRailTurn.linkedX = x - 11; - tcRailTurn.linkedY = y + 1; - tcRailTurn.linkedZ = z - 2; - } - return true; - } - - if (l == 3) { - - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, false), flipArraySign(xArray, z, false), l, false, 3, x + 11, z + 2, 18.5, x, - y + 1, z + 19 , tempType.getLabel(), tempType.getItem().item)) - return false; - TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x , y + 1, z ); - - if (tcRailTurn != null) { - tcRailTurn.hasModel = true; - - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray2, x, false), flipArraySign(xArray2, z, false), 0, false, 3, x + 11, z + 2, 18.5, x + 12, - y + 1, z - 16, TrackTypes.MEDIUM_LEFT_TURN.getLabel(), null)) - return false; - - TileTCRail tcRailTurn2 = (TileTCRail) world.getTileEntity(x + 11, y + 1, z + 2); - - if (tcRailTurn2 != null) { - tcRailTurn2.hasModel = false; - tcRailTurn2.isLinkedToRail = true; - tcRailTurn2.linkedX = x; - tcRailTurn2.linkedY = y + 1; - tcRailTurn2.linkedZ = z ; - - } - tcRailTurn.isLinkedToRail = true; - tcRailTurn.linkedX = x + 11; - tcRailTurn.linkedY = y + 1; - tcRailTurn.linkedZ = z + 2; - } - return true; - } + if (player == null || !player.capabilities.isCreativeMode) { + --itemstack.stackSize; + } + return true; + + } + } + return false; + } + + + private TrackTypes getPlacementDirection(EntityPlayer player, World world, int l, float par10) { + if (!world.isRemote) { + + /** Determines if track is left or right*/ + float yaw = MathHelper.wrapAngleTo180_float(player != null ? player.rotationYaw : par10); + tempType = type; + + if (type == TrackTypes.MEDIUM_TURN) { + if (getTrackOrientation(l, yaw).equals("right")) { + tempType = TrackTypes.MEDIUM_RIGHT_TURN; + + } + if (getTrackOrientation(l, yaw).equals("left")) { + tempType = TrackTypes.MEDIUM_LEFT_TURN; + } + } + if (type == TrackTypes.LARGE_TURN) { + if (getTrackOrientation(l, yaw).equals("right")) { + tempType = TrackTypes.LARGE_RIGHT_TURN; + } + if (getTrackOrientation(l, yaw).equals("left")) { + tempType = TrackTypes.LARGE_LEFT_TURN; + } + } + if (type == TrackTypes.VERY_LARGE_TURN) { + if (getTrackOrientation(l, yaw).equals("right")) { + tempType = TrackTypes.VERY_LARGE_RIGHT_TURN; + } + if (getTrackOrientation(l, yaw).equals("left")) { + tempType = TrackTypes.VERY_LARGE_LEFT_TURN; + } + } + if (type == TrackTypes.SUPER_LARGE_TURN) { + if (getTrackOrientation(l, yaw).equals("right")) { + tempType = TrackTypes.SUPER_LARGE_RIGHT_TURN; + } + if (getTrackOrientation(l, yaw).equals("left")) { + tempType = TrackTypes.SUPER_LARGE_LEFT_TURN; + } + } + if (type == TrackTypes.MEDIUM_45DEGREE_TURN) { + if (getTrackOrientation(l, yaw).equals("right")) { + tempType = TrackTypes.MEDIUM_RIGHT_45DEGREE_TURN; + } + if (getTrackOrientation(l, yaw).equals("left")) { + tempType = TrackTypes.MEDIUM_LEFT_45DEGREE_TURN; + + } + } + if (type == TrackTypes.LARGE_45DEGREE_TURN) { + if (getTrackOrientation(l, yaw).equals("right")) { + tempType = TrackTypes.LARGE_RIGHT_45DEGREE_TURN; + } + if (getTrackOrientation(l, yaw).equals("left")) { + tempType = TrackTypes.LARGE_LEFT_45DEGREE_TURN; + + } + } + if (type == TrackTypes.VERY_LARGE_45DEGREE_TURN) { + if (getTrackOrientation(l, yaw).equals("right")) { + tempType = TrackTypes.VERY_LARGE_RIGHT_45DEGREE_TURN; + } + if (getTrackOrientation(l, yaw).equals("left")) { + tempType = TrackTypes.VERY_LARGE_LEFT_45DEGREE_TURN; + + } + } + if (type == TrackTypes.SUPER_LARGE_45DEGREE_TURN) { + if (getTrackOrientation(l, yaw).equals("right")) { + tempType = TrackTypes.SUPER_LARGE_RIGHT_45DEGREE_TURN; + } + if (getTrackOrientation(l, yaw).equals("left")) { + tempType = TrackTypes.SUPER_LARGE_LEFT_45DEGREE_TURN; + + } + } + if (type == TrackTypes.SMALL_PARALLEL_CURVE) { + if (getTrackOrientation(l, yaw).equals("right")) { + tempType = TrackTypes.SMALL_RIGHT_PARALLEL_CURVE; + } + if (getTrackOrientation(l, yaw).equals("left")) { + tempType = TrackTypes.SMALL_LEFT_PARALLEL_CURVE; + } + } + if (type == TrackTypes.MEDIUM_PARALLEL_CURVE) { + if (getTrackOrientation(l, yaw).equals("right")) { + tempType = TrackTypes.MEDIUM_RIGHT_PARALLEL_CURVE; + } + if (getTrackOrientation(l, yaw).equals("left")) { + tempType = TrackTypes.MEDIUM_LEFT_PARALLEL_CURVE; + } + } + if (type == TrackTypes.LARGE_PARALLEL_CURVE) { + if (getTrackOrientation(l, yaw).equals("right")) { + tempType = TrackTypes.LARGE_RIGHT_PARALLEL_CURVE; + } + if (getTrackOrientation(l, yaw).equals("left")) { + tempType = TrackTypes.LARGE_LEFT_PARALLEL_CURVE; + } + } + if (type == TrackTypes.MEDIUM_SWITCH) { + if (getTrackOrientation(l, yaw).equals("right")) { + tempType = TrackTypes.MEDIUM_RIGHT_SWITCH; + } + if (getTrackOrientation(l, yaw).equals("left")) { + tempType = TrackTypes.MEDIUM_LEFT_SWITCH; + } + } + if (type == TrackTypes.LARGE_SWITCH) { + if (getTrackOrientation(l, yaw).equals("right")) { + tempType = TrackTypes.LARGE_RIGHT_SWITCH; + } + if (getTrackOrientation(l, yaw).equals("left")) { + tempType = TrackTypes.LARGE_LEFT_SWITCH; + } + } + if (type == TrackTypes.MEDIUM_PARALLEL_SWITCH) { + if (getTrackOrientation(l, yaw).equals("right")) { + tempType = TrackTypes.MEDIUM_RIGHT_PARALLEL_SWITCH; + } + if (getTrackOrientation(l, yaw).equals("left")) { + tempType = TrackTypes.MEDIUM_LEFT_PARALLEL_SWITCH; + } + } + if (type == TrackTypes.MEDIUM_45DEGREE_SWITCH) { + if (getTrackOrientation(l, yaw).equals("right")) { + tempType = TrackTypes.MEDIUM_RIGHT_45DEGREE_SWITCH; + } + if (getTrackOrientation(l, yaw).equals("left")) { + tempType = TrackTypes.MEDIUM_LEFT_45DEGREE_SWITCH; + } + } + if (type == TrackTypes.EMBEDDED_MEDIUM_TURN) { + if (getTrackOrientation(l, yaw).equals("right")) { + tempType = TrackTypes.EMBEDDED_MEDIUM_RIGHT_TURN; + } + if (getTrackOrientation(l, yaw).equals("left")) { + tempType = TrackTypes.EMBEDDED_MEDIUM_LEFT_TURN; + } + } + if (type == TrackTypes.EMBEDDED_LARGE_TURN) { + if (getTrackOrientation(l, yaw).equals("right")) { + tempType = TrackTypes.EMBEDDED_LARGE_RIGHT_TURN; + } + if (getTrackOrientation(l, yaw).equals("left")) { + tempType = TrackTypes.EMBEDDED_LARGE_LEFT_TURN; + } + } + if (type == TrackTypes.EMBEDDED_VERY_LARGE_TURN) { + if (getTrackOrientation(l, yaw).equals("right")) { + tempType = TrackTypes.EMBEDDED_VERY_LARGE_RIGHT_TURN; + } + if (getTrackOrientation(l, yaw).equals("left")) { + tempType = TrackTypes.EMBEDDED_VERY_LARGE_LEFT_TURN; + } + } + if (type == TrackTypes.EMBEDDED_SUPER_LARGE_TURN) { + if (getTrackOrientation(l, yaw).equals("right")) { + tempType = TrackTypes.EMBEDDED_SUPER_LARGE_RIGHT_TURN; + } + if (getTrackOrientation(l, yaw).equals("left")) { + tempType = TrackTypes.EMBEDDED_SUPER_LARGE_LEFT_TURN; + } + } + if (type == TrackTypes.EMBEDDED_MEDIUM_45DEGREE_TURN) { + if (getTrackOrientation(l, yaw).equals("right")) { + tempType = TrackTypes.EMBEDDED_MEDIUM_RIGHT_45DEGREE_TURN; + } + if (getTrackOrientation(l, yaw).equals("left")) { + tempType = TrackTypes.EMBEDDED_MEDIUM_LEFT_45DEGREE_TURN; + + } + } + if (type == TrackTypes.EMBEDDED_LARGE_45DEGREE_TURN) { + if (getTrackOrientation(l, yaw).equals("right")) { + tempType = TrackTypes.EMBEDDED_LARGE_RIGHT_45DEGREE_TURN; + } + if (getTrackOrientation(l, yaw).equals("left")) { + tempType = TrackTypes.EMBEDDED_LARGE_LEFT_45DEGREE_TURN; + + } + } + if (type == TrackTypes.EMBEDDED_VERY_LARGE_45DEGREE_TURN) { + if (getTrackOrientation(l, yaw).equals("right")) { + tempType = TrackTypes.EMBEDDED_VERY_LARGE_RIGHT_45DEGREE_TURN; + } + if (getTrackOrientation(l, yaw).equals("left")) { + tempType = TrackTypes.EMBEDDED_VERY_LARGE_LEFT_45DEGREE_TURN; + + } + } + if (type == TrackTypes.EMBEDDED_SUPER_LARGE_45DEGREE_TURN) { + if (getTrackOrientation(l, yaw).equals("right")) { + tempType = TrackTypes.EMBEDDED_SUPER_LARGE_RIGHT_45DEGREE_TURN; + } + if (getTrackOrientation(l, yaw).equals("left")) { + tempType = TrackTypes.EMBEDDED_SUPER_LARGE_LEFT_45DEGREE_TURN; + + } + } + if (type == TrackTypes.EMBEDDED_SMALL_PARALLEL_CURVE) { + if (getTrackOrientation(l, yaw).equals("right")) { + tempType = TrackTypes.EMBEDDED_SMALL_RIGHT_PARALLEL_CURVE; + } + if (getTrackOrientation(l, yaw).equals("left")) { + tempType = TrackTypes.EMBEDDED_SMALL_LEFT_PARALLEL_CURVE; + } + } + if (type == TrackTypes.EMBEDDED_MEDIUM_PARALLEL_CURVE) { + if (getTrackOrientation(l, yaw).equals("right")) { + tempType = TrackTypes.EMBEDDED_MEDIUM_RIGHT_PARALLEL_CURVE; + } + if (getTrackOrientation(l, yaw).equals("left")) { + tempType = TrackTypes.EMBEDDED_MEDIUM_LEFT_PARALLEL_CURVE; + } + } + if (type == TrackTypes.EMBEDDED_LARGE_PARALLEL_CURVE) { + if (getTrackOrientation(l, yaw).equals("right")) { + tempType = TrackTypes.EMBEDDED_LARGE_RIGHT_PARALLEL_CURVE; + } + if (getTrackOrientation(l, yaw).equals("left")) { + tempType = TrackTypes.EMBEDDED_LARGE_LEFT_PARALLEL_CURVE; + } + } + if (type == TrackTypes.EMBEDDED_MEDIUM_SWITCH) { + if (getTrackOrientation(l, yaw).equals("right")) { + tempType = TrackTypes.EMBEDDED_MEDIUM_RIGHT_SWITCH; + } + if (getTrackOrientation(l, yaw).equals("left")) { + tempType = TrackTypes.EMBEDDED_MEDIUM_LEFT_SWITCH; + } + } + if (type == TrackTypes.EMBEDDED_LARGE_SWITCH) { + if (getTrackOrientation(l, yaw).equals("right")) { + tempType = TrackTypes.EMBEDDED_LARGE_RIGHT_SWITCH; + } + if (getTrackOrientation(l, yaw).equals("left")) { + tempType = TrackTypes.EMBEDDED_LARGE_LEFT_SWITCH; + } + } + if (type == TrackTypes.EMBEDDED_MEDIUM_PARALLEL_SWITCH) { + if (getTrackOrientation(l, yaw).equals("right")) { + tempType = TrackTypes.EMBEDDED_MEDIUM_RIGHT_PARALLEL_SWITCH; + } + if (getTrackOrientation(l, yaw).equals("left")) { + tempType = TrackTypes.EMBEDDED_MEDIUM_LEFT_PARALLEL_SWITCH; + } + } + if (type == TrackTypes.EMBEDDED_MEDIUM_45DEGREE_SWITCH) { + if (getTrackOrientation(l, yaw).equals("right")) { + tempType = TrackTypes.EMBEDDED_MEDIUM_RIGHT_45DEGREE_SWITCH; + } + if (getTrackOrientation(l, yaw).equals("left")) { + tempType = TrackTypes.EMBEDDED_MEDIUM_LEFT_45DEGREE_SWITCH; + } + } + if (type == TrackTypes.LARGE_CURVED_SLOPE_DYNAMIC) { + if (getTrackOrientation(l, yaw).equals("right")) { + tempType = TrackTypes.LARGE_RIGHT_CURVED_SLOPE_DYNAMIC; + } + if (getTrackOrientation(l, yaw).equals("left")) { + tempType = TrackTypes.LARGE_LEFT_CURVED_SLOPE_DYNAMIC; + } + } + + if (type == TrackTypes.EMBEDDED_LARGE_CURVED_SLOPE_DYNAMIC) { + if (getTrackOrientation(l, yaw).equals("right")) { + tempType = TrackTypes.EMBEDDED_LARGE_RIGHT_CURVED_SLOPE_DYNAMIC; + } + if (getTrackOrientation(l, yaw).equals("left")) { + tempType = TrackTypes.EMBEDDED_LARGE_LEFT_CURVED_SLOPE_DYNAMIC; + } + } + if (type == TrackTypes.VERY_LARGE_CURVED_SLOPE_DYNAMIC) { + if (getTrackOrientation(l, yaw).equals("right")) { + tempType = TrackTypes.VERY_LARGE_RIGHT_CURVED_SLOPE_DYNAMIC; + } + if (getTrackOrientation(l, yaw).equals("left")) { + tempType = TrackTypes.VERY_LARGE_LEFT_CURVED_SLOPE_DYNAMIC; + } + } + + if (type == TrackTypes.EMBEDDED_VERY_LARGE_CURVED_SLOPE_DYNAMIC) { + if (getTrackOrientation(l, yaw).equals("right")) { + tempType = TrackTypes.EMBEDDED_VERY_LARGE_RIGHT_CURVED_SLOPE_DYNAMIC; + } + if (getTrackOrientation(l, yaw).equals("left")) { + tempType = TrackTypes.EMBEDDED_VERY_LARGE_LEFT_CURVED_SLOPE_DYNAMIC; + } + } + if (type == TrackTypes.SUPER_LARGE_CURVED_SLOPE_DYNAMIC) { + if (getTrackOrientation(l, yaw).equals("right")) { + tempType = TrackTypes.SUPER_LARGE_RIGHT_CURVED_SLOPE_DYNAMIC; + } + if (getTrackOrientation(l, yaw).equals("left")) { + tempType = TrackTypes.SUPER_LARGE_LEFT_CURVED_SLOPE_DYNAMIC; + } + } + + if (type == TrackTypes.EMBEDDED_SUPER_LARGE_CURVED_SLOPE_DYNAMIC) { + if (getTrackOrientation(l, yaw).equals("right")) { + tempType = TrackTypes.EMBEDDED_SUPER_LARGE_RIGHT_CURVED_SLOPE_DYNAMIC; + } + if (getTrackOrientation(l, yaw).equals("left")) { + tempType = TrackTypes.EMBEDDED_SUPER_LARGE_LEFT_CURVED_SLOPE_DYNAMIC; + } + } + if (type == TrackTypes.DIAMOND_CROSSING) { + if (getTrackOrientation(l, yaw).equals("right")) { + tempType = TrackTypes.RIGHT_DIAMOND_CROSSING; + } + if (getTrackOrientation(l, yaw).equals("left")) { + tempType = TrackTypes.LEFT_DIAMOND_CROSSING; + } + } + if (type == TrackTypes.EMBEDDED_DIAMOND_CROSSING) { + if (getTrackOrientation(l, yaw).equals("right")) { + tempType = TrackTypes.EMBEDDED_RIGHT_DIAMOND_CROSSING; + } + if (getTrackOrientation(l, yaw).equals("left")) { + tempType = TrackTypes.EMBEDDED_LEFT_DIAMOND_CROSSING; + } + } + + } + return tempType; + } + + /** + * Track Placement (because onItemUse is getting too big) + */ + + private boolean smallStraight(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes type) { + if (!canPlaceTrack(player, world, x, y + 1, z)) { + return false; + } + placeTrack(world, x, y + 1, z, BlockIDs.tcRail.block, l); + TileTCRail tcRail = (TileTCRail) world.getTileEntity(x, y + 1, z); + tcRail.setFacing(l); + tcRail.cx = x; + tcRail.cy = y + 1; + tcRail.cz = z; + tcRail.setType(type.getLabel()); + tcRail.idDrop = this.type.getItem().item; + return true; + } + + private boolean straight(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes type) { + /** check if first rail can be placed */ + if (!canPlaceTrack(player, world, x, y + 1, z)) { + return false; + } + + TileTCRailGag[] tileGag = new TileTCRailGag[2]; /** makes it so only 2 gags are placed */ + if (type == TrackTypes.LONG_STRAIGHT || type == TrackTypes.EMBEDDED_LONG_STRAIGHT) { + tileGag = new TileTCRailGag[4]; + } + + if (type == TrackTypes.VERY_LONG_STRAIGHT || type == TrackTypes.EMBEDDED_VERY_LONG_STRAIGHT) { + tileGag = new TileTCRailGag[8]; + } + if (l == 2) { + + if (!canPlaceTrack(player, world, x, y + 1, z - 1) || !canPlaceTrack(player, world, x, y + 1, z - 2)) { + return false; + } + if (type == TrackTypes.LONG_STRAIGHT || type == TrackTypes.EMBEDDED_LONG_STRAIGHT) { + if (!canPlaceTrack(player, world, x, y + 1, z - 3) || !canPlaceTrack(player, world, x, y + 1, z - 4) + || !canPlaceTrack(player, world, x, y + 1, z - 5)) { + return false; + } + } + if (type == TrackTypes.VERY_LONG_STRAIGHT || type == TrackTypes.EMBEDDED_VERY_LONG_STRAIGHT) { + if (!canPlaceTrack(player, world, x, y + 1, z - 3) || !canPlaceTrack(player, world, x, y + 1, z - 4) + || !canPlaceTrack(player, world, x, y + 1, z - 5) || !canPlaceTrack(player, world, x, y + 1, z - 6) || !canPlaceTrack(player, world, x, y + 1, z - 7) || !canPlaceTrack(player, world, x, y + 1, z - 8) || + !canPlaceTrack(player, world, x, y + 1, z - 9) || !canPlaceTrack(player, world, x, y + 1, z - 10) || !canPlaceTrack(player, world, x, y + 1, z - 11)) { + return false; + } + } + placeTrack(world, x, y + 1, z, BlockIDs.tcRail.block, l); + TileTCRail tcRail = (TileTCRail) world.getTileEntity(x, y + 1, z); + tcRail.setFacing(l); + tcRail.setType(type.getLabel()); + + placeTrack(world, x, y + 1, z - 1, BlockIDs.tcRailGag.block, l); + tileGag[0] = (TileTCRailGag) world.getTileEntity(x, y + 1, z - 1); + + placeTrack(world, x, y + 1, z - 2, BlockIDs.tcRailGag.block, l); + tileGag[1] = (TileTCRailGag) world.getTileEntity(x, y + 1, z - 2); + + if (type == TrackTypes.LONG_STRAIGHT || type == TrackTypes.EMBEDDED_LONG_STRAIGHT) { + tcRail.idDrop = this.type.getItem().item; + } else { + tcRail.idDrop = this.type.getItem().item; + } + + if (type == TrackTypes.LONG_STRAIGHT || type == TrackTypes.EMBEDDED_LONG_STRAIGHT || type == TrackTypes.VERY_LONG_STRAIGHT || type == TrackTypes.EMBEDDED_VERY_LONG_STRAIGHT) { + placeTrack(world, x, y + 1, z - 3, BlockIDs.tcRail.block, l); + TileTCRail tcRail2 = (TileTCRail) world.getTileEntity(x, y + 1, z - 3); + tcRail2.setFacing(l); + tcRail2.setType(type.getLabel()); + tcRail2.isLinkedToRail = true; + tcRail2.linkedX = x; + tcRail2.linkedY = y + 1; + tcRail2.linkedZ = z - 1; + + placeTrack(world, x, y + 1, z - 4, BlockIDs.tcRailGag.block, l); + tileGag[2] = (TileTCRailGag) world.getTileEntity(x, y + 1, z - 4); + + placeTrack(world, x, y + 1, z - 5, BlockIDs.tcRailGag.block, l); + tileGag[3] = (TileTCRailGag) world.getTileEntity(x, y + 1, z - 5); + + if (type == TrackTypes.VERY_LONG_STRAIGHT || type == TrackTypes.EMBEDDED_VERY_LONG_STRAIGHT) { + tcRail.idDrop = this.type.getItem().item; + } else { + tcRail.idDrop = this.type.getItem().item; + } + } + if (type == TrackTypes.VERY_LONG_STRAIGHT || type == TrackTypes.EMBEDDED_VERY_LONG_STRAIGHT) { + + placeTrack(world, x, y + 1, z - 6, BlockIDs.tcRail.block, l); + TileTCRail tcRail3 = (TileTCRail) world.getTileEntity(x, y + 1, z - 6); + tcRail3.setFacing(l); + tcRail3.setType(type.getLabel()); + tcRail3.isLinkedToRail = true; + tcRail3.linkedX = x; + tcRail3.linkedY = y + 1; + tcRail3.linkedZ = z - 1; + + placeTrack(world, x, y + 1, z - 7, BlockIDs.tcRailGag.block, l); + tileGag[4] = (TileTCRailGag) world.getTileEntity(x, y + 1, z - 7); + + placeTrack(world, x, y + 1, z - 8, BlockIDs.tcRailGag.block, l); + tileGag[5] = (TileTCRailGag) world.getTileEntity(x, y + 1, z - 8); + + placeTrack(world, x, y + 1, z - 9, BlockIDs.tcRail.block, l); + TileTCRail tcRail4 = (TileTCRail) world.getTileEntity(x, y + 1, z - 9); + tcRail4.setFacing(l); + tcRail4.setType(type.getLabel()); + tcRail4.isLinkedToRail = true; + tcRail4.linkedX = x; + tcRail4.linkedY = y + 1; + tcRail4.linkedZ = z - 1; + + placeTrack(world, x, y + 1, z - 10, BlockIDs.tcRailGag.block, l); + tileGag[6] = (TileTCRailGag) world.getTileEntity(x, y + 1, z - 10); + + placeTrack(world, x, y + 1, z - 11, BlockIDs.tcRailGag.block, l); + tileGag[7] = (TileTCRailGag) world.getTileEntity(x, y + 1, z - 11); + + + } + + } + if (l == 0) { + if (!canPlaceTrack(player, world, x, y + 1, z + 1) || !canPlaceTrack(player, world, x, y + 1, z + 2)) { + return false; + } + if (type == TrackTypes.LONG_STRAIGHT || type == TrackTypes.EMBEDDED_LONG_STRAIGHT) { + if (!canPlaceTrack(player, world, x, y + 1, z + 3) || !canPlaceTrack(player, world, x, y + 1, z + 4) + || !canPlaceTrack(player, world, x, y + 1, z + 5)) { + return false; + } + } + if (type == TrackTypes.VERY_LONG_STRAIGHT || type == TrackTypes.EMBEDDED_VERY_LONG_STRAIGHT) { + if (!canPlaceTrack(player, world, x, y + 1, z + 3) || !canPlaceTrack(player, world, x, y + 1, z + 4) + || !canPlaceTrack(player, world, x, y + 1, z + 5) || !canPlaceTrack(player, world, x, y + 1, z + 6) || !canPlaceTrack(player, world, x, y + 1, z + 7) || + !canPlaceTrack(player, world, x, y + 1, z + 8) || !canPlaceTrack(player, world, x, y + 1, z + 9) || !canPlaceTrack(player, world, x, y + 1, z + 10) || !canPlaceTrack(player, world, x, y + 1, z + 11)) { + return false; + } + } + placeTrack(world, x, y + 1, z, BlockIDs.tcRail.block, l); + TileTCRail tcRail = (TileTCRail) world.getTileEntity(x, y + 1, z); + tcRail.setFacing(l); + tcRail.setType(type.getLabel()); + + placeTrack(world, x, y + 1, z + 1, BlockIDs.tcRailGag.block, l); + tileGag[0] = (TileTCRailGag) world.getTileEntity(x, y + 1, z + 1); + + placeTrack(world, x, y + 1, z + 2, BlockIDs.tcRailGag.block, l); + tileGag[1] = (TileTCRailGag) world.getTileEntity(x, y + 1, z + 2); + + if (type == TrackTypes.LONG_STRAIGHT || type == TrackTypes.EMBEDDED_LONG_STRAIGHT) { + tcRail.idDrop = this.type.getItem().item; + } else { + tcRail.idDrop = this.type.getItem().item; + } + + if (type == TrackTypes.LONG_STRAIGHT || type == TrackTypes.EMBEDDED_LONG_STRAIGHT + || type == TrackTypes.VERY_LONG_STRAIGHT || type == TrackTypes.EMBEDDED_VERY_LONG_STRAIGHT) { + placeTrack(world, x, y + 1, z + 3, BlockIDs.tcRail.block, l); + TileTCRail tcRail2 = (TileTCRail) world.getTileEntity(x, y + 1, z + 3); + tcRail2.setFacing(l); + tcRail2.setType(type.getLabel()); + tcRail2.isLinkedToRail = true; + tcRail2.linkedX = x; + tcRail2.linkedY = y + 1; + tcRail2.linkedZ = z + 1; + + placeTrack(world, x, y + 1, z + 4, BlockIDs.tcRailGag.block, l); + tileGag[2] = (TileTCRailGag) world.getTileEntity(x, y + 1, z + 4); + + placeTrack(world, x, y + 1, z + 5, BlockIDs.tcRailGag.block, l); + tileGag[3] = (TileTCRailGag) world.getTileEntity(x, y + 1, z + 5); + + if (type == TrackTypes.VERY_LONG_STRAIGHT || type == TrackTypes.EMBEDDED_VERY_LONG_STRAIGHT) { + tcRail.idDrop = this.type.getItem().item; + } else { + tcRail.idDrop = this.type.getItem().item; + } + } + if (type == TrackTypes.VERY_LONG_STRAIGHT || type == TrackTypes.EMBEDDED_VERY_LONG_STRAIGHT) { + + placeTrack(world, x, y + 1, z + 6, BlockIDs.tcRail.block, l); + TileTCRail tcRail3 = (TileTCRail) world.getTileEntity(x, y + 1, z + 6); + tcRail3.setFacing(l); + tcRail3.setType(type.getLabel()); + tcRail3.isLinkedToRail = true; + tcRail3.linkedX = x; + tcRail3.linkedY = y + 1; + tcRail3.linkedZ = z + 1; + + placeTrack(world, x, y + 1, z + 7, BlockIDs.tcRailGag.block, l); + tileGag[4] = (TileTCRailGag) world.getTileEntity(x, y + 1, z + 7); + + placeTrack(world, x, y + 1, z + 8, BlockIDs.tcRailGag.block, l); + tileGag[5] = (TileTCRailGag) world.getTileEntity(x, y + 1, z + 8); + + placeTrack(world, x, y + 1, z + 9, BlockIDs.tcRail.block, l); + TileTCRail tcRail4 = (TileTCRail) world.getTileEntity(x, y + 1, z + 9); + tcRail4.setFacing(l); + tcRail4.setType(type.getLabel()); + tcRail4.isLinkedToRail = true; + tcRail4.linkedX = x; + tcRail4.linkedY = y + 1; + tcRail4.linkedZ = z + 1; + + placeTrack(world, x, y + 1, z + 10, BlockIDs.tcRailGag.block, l); + tileGag[6] = (TileTCRailGag) world.getTileEntity(x, y + 1, z + 10); + + placeTrack(world, x, y + 1, z + 11, BlockIDs.tcRailGag.block, l); + tileGag[7] = (TileTCRailGag) world.getTileEntity(x, y + 1, z + 11); + + + } + + } + if (l == 1) { + if (!canPlaceTrack(player, world, x - 1, y + 1, z) || !canPlaceTrack(player, world, x - 2, y + 1, z)) { + return false; + } + if (type == TrackTypes.LONG_STRAIGHT || type == TrackTypes.EMBEDDED_LONG_STRAIGHT) { + if (!canPlaceTrack(player, world, x - 3, y + 1, z) || !canPlaceTrack(player, world, x - 4, y + 1, z) + || !canPlaceTrack(player, world, x - 5, y + 1, z)) { + return false; + } + } + if (type == TrackTypes.VERY_LONG_STRAIGHT || type == TrackTypes.EMBEDDED_VERY_LONG_STRAIGHT) { + if (!canPlaceTrack(player, world, x - 3, y + 1, z) || !canPlaceTrack(player, world, x - 4, y + 1, z) + || !canPlaceTrack(player, world, x - 5, y + 1, z) || !canPlaceTrack(player, world, x - 6, y + 1, z) || !canPlaceTrack(player, world, x - 7, y + 1, z) || + !canPlaceTrack(player, world, x - 8, y + 1, z) || !canPlaceTrack(player, world, x - 9, y + 1, z) || !canPlaceTrack(player, world, x - 10, y + 1, z) || !canPlaceTrack(player, world, x - 11, y + 1, z)) { + return false; + } + } + placeTrack(world, x, y + 1, z, BlockIDs.tcRail.block, l); + TileTCRail tcRail = (TileTCRail) world.getTileEntity(x, y + 1, z); + tcRail.setFacing(l); + tcRail.setType(type.getLabel()); + + placeTrack(world, x - 1, y + 1, z, BlockIDs.tcRailGag.block, l); + tileGag[0] = (TileTCRailGag) world.getTileEntity(x - 1, y + 1, z); + + placeTrack(world, x - 2, y + 1, z, BlockIDs.tcRailGag.block, l); + tileGag[1] = (TileTCRailGag) world.getTileEntity(x - 2, y + 1, z); + + if (type == TrackTypes.LONG_STRAIGHT || type == TrackTypes.EMBEDDED_LONG_STRAIGHT) { + tcRail.idDrop = this.type.getItem().item; + } else { + tcRail.idDrop = this.type.getItem().item; + } + + if (type == TrackTypes.LONG_STRAIGHT || type == TrackTypes.EMBEDDED_LONG_STRAIGHT + || type == TrackTypes.VERY_LONG_STRAIGHT || type == TrackTypes.EMBEDDED_VERY_LONG_STRAIGHT) { + placeTrack(world, x - 3, y + 1, z, BlockIDs.tcRail.block, l); + TileTCRail tcRail2 = (TileTCRail) world.getTileEntity(x - 3, y + 1, z); + tcRail2.setFacing(l); + tcRail2.setType(type.getLabel()); + tcRail2.isLinkedToRail = true; + tcRail2.linkedX = x - 1; + tcRail2.linkedY = y + 1; + tcRail2.linkedZ = z; + + placeTrack(world, x - 4, y + 1, z, BlockIDs.tcRailGag.block, l); + tileGag[2] = (TileTCRailGag) world.getTileEntity(x - 4, y + 1, z); + + placeTrack(world, x - 5, y + 1, z, BlockIDs.tcRailGag.block, l); + tileGag[3] = (TileTCRailGag) world.getTileEntity(x - 5, y + 1, z); + + if (type == TrackTypes.VERY_LONG_STRAIGHT || type == TrackTypes.EMBEDDED_VERY_LONG_STRAIGHT) { + tcRail.idDrop = this.type.getItem().item; + } else { + tcRail.idDrop = this.type.getItem().item; + } + } + if (type == TrackTypes.VERY_LONG_STRAIGHT || type == TrackTypes.EMBEDDED_VERY_LONG_STRAIGHT) { + + placeTrack(world, x - 6, y + 1, z, BlockIDs.tcRail.block, l); + TileTCRail tcRail3 = (TileTCRail) world.getTileEntity(x - 6, y + 1, z); + tcRail3.setType(type.getLabel()); + tcRail3.isLinkedToRail = true; + tcRail3.linkedX = x - 1; + tcRail3.linkedY = y + 1; + tcRail3.linkedZ = z; + + placeTrack(world, x - 7, y + 1, z, BlockIDs.tcRailGag.block, l); + tileGag[4] = (TileTCRailGag) world.getTileEntity(x - 7, y + 1, z); + + placeTrack(world, x - 8, y + 1, z, BlockIDs.tcRailGag.block, l); + tileGag[5] = (TileTCRailGag) world.getTileEntity(x - 8, y + 1, z); + + placeTrack(world, x - 9, y + 1, z, BlockIDs.tcRail.block, l); + TileTCRail tcRail4 = (TileTCRail) world.getTileEntity(x - 9, y + 1, z); + tcRail4.setFacing(l); + tcRail4.setType(type.getLabel()); + tcRail4.isLinkedToRail = true; + tcRail4.linkedX = x - 1; + tcRail4.linkedY = y + 1; + tcRail4.linkedZ = z; + + placeTrack(world, x - 10, y + 1, z, BlockIDs.tcRailGag.block, l); + tileGag[6] = (TileTCRailGag) world.getTileEntity(x - 10, y + 1, z); + + placeTrack(world, x - 11, y + 1, z, BlockIDs.tcRailGag.block, l); + tileGag[7] = (TileTCRailGag) world.getTileEntity(x - 11, y + 1, z); + + + } + + } + if (l == 3) { + if (!canPlaceTrack(player, world, x + 1, y + 1, z) || !canPlaceTrack(player, world, x + 2, y + 1, z)) { + return false; + } + if (type == TrackTypes.LONG_STRAIGHT || type == TrackTypes.EMBEDDED_LONG_STRAIGHT) { + if (!canPlaceTrack(player, world, x + 3, y + 1, z) || !canPlaceTrack(player, world, x + 4, y + 1, z) + || !canPlaceTrack(player, world, x + 5, y + 1, z)) { + return false; + } + } + if (type == TrackTypes.VERY_LONG_STRAIGHT || type == TrackTypes.EMBEDDED_VERY_LONG_STRAIGHT) { + if (!canPlaceTrack(player, world, x + 3, y + 1, z) || !canPlaceTrack(player, world, x + 4, y + 1, z) + || !canPlaceTrack(player, world, x + 5, y + 1, z) || !canPlaceTrack(player, world, x + 6, y + 1, z) || !canPlaceTrack(player, world, x + 7, y + 1, z) || + !canPlaceTrack(player, world, x + 8, y + 1, z) || !canPlaceTrack(player, world, x + 9, y + 1, z) || !canPlaceTrack(player, world, x + 10, y + 1, z) || !canPlaceTrack(player, world, x + 11, y + 1, z)) { + return false; + } + } + placeTrack(world, x, y + 1, z, BlockIDs.tcRail.block, l); + TileTCRail tcRail = (TileTCRail) world.getTileEntity(x, y + 1, z); + tcRail.setFacing(l); + tcRail.setType(type.getLabel()); + + placeTrack(world, x + 1, y + 1, z, BlockIDs.tcRailGag.block, l); + tileGag[0] = (TileTCRailGag) world.getTileEntity(x + 1, y + 1, z); + + placeTrack(world, x + 2, y + 1, z, BlockIDs.tcRailGag.block, l); + tileGag[1] = (TileTCRailGag) world.getTileEntity(x + 2, y + 1, z); + + if (type == TrackTypes.LONG_STRAIGHT || type == TrackTypes.EMBEDDED_LONG_STRAIGHT) { + tcRail.idDrop = this.type.getItem().item; + } else { + tcRail.idDrop = this.type.getItem().item; + } + + if (type == TrackTypes.LONG_STRAIGHT || type == TrackTypes.EMBEDDED_LONG_STRAIGHT + || type == TrackTypes.VERY_LONG_STRAIGHT || type == TrackTypes.EMBEDDED_VERY_LONG_STRAIGHT) { + placeTrack(world, x + 3, y + 1, z, BlockIDs.tcRail.block, l); + TileTCRail tcRail2 = (TileTCRail) world.getTileEntity(x + 3, y + 1, z); + tcRail2.setFacing(l); + tcRail2.setType(type.getLabel()); + tcRail2.isLinkedToRail = true; + tcRail2.linkedX = x + 1; + tcRail2.linkedY = y + 1; + tcRail2.linkedZ = z; + + placeTrack(world, x + 4, y + 1, z, BlockIDs.tcRailGag.block, l); + tileGag[2] = (TileTCRailGag) world.getTileEntity(x + 4, y + 1, z); + + placeTrack(world, x + 5, y + 1, z, BlockIDs.tcRailGag.block, l); + tileGag[3] = (TileTCRailGag) world.getTileEntity(x + 5, y + 1, z); + + if (type == TrackTypes.VERY_LONG_STRAIGHT || type == TrackTypes.EMBEDDED_VERY_LONG_STRAIGHT) { + tcRail.idDrop = this.type.getItem().item; + } else { + tcRail.idDrop = this.type.getItem().item; + } + } + if (type == TrackTypes.VERY_LONG_STRAIGHT || type == TrackTypes.EMBEDDED_VERY_LONG_STRAIGHT) { + + placeTrack(world, x + 6, y + 1, z, BlockIDs.tcRail.block, l); + TileTCRail tcRail3 = (TileTCRail) world.getTileEntity(x + 6, y + 1, z); + tcRail3.setFacing(l); + tcRail3.setType(type.getLabel()); + tcRail3.isLinkedToRail = true; + tcRail3.linkedX = x + 1; + tcRail3.linkedY = y + 1; + tcRail3.linkedZ = z; + + placeTrack(world, x + 7, y + 1, z, BlockIDs.tcRailGag.block, l); + tileGag[4] = (TileTCRailGag) world.getTileEntity(x + 7, y + 1, z); + + placeTrack(world, x + 8, y + 1, z, BlockIDs.tcRailGag.block, l); + tileGag[5] = (TileTCRailGag) world.getTileEntity(x + 8, y + 1, z); + + placeTrack(world, x + 9, y + 1, z, BlockIDs.tcRail.block, l); + TileTCRail tcRail4 = (TileTCRail) world.getTileEntity(x + 9, y + 1, z); + tcRail4.setFacing(l); + tcRail4.setType(type.getLabel()); + tcRail4.isLinkedToRail = true; + tcRail4.linkedX = x + 1; + tcRail4.linkedY = y + 1; + tcRail4.linkedZ = z; + + placeTrack(world, x + 10, y + 1, z, BlockIDs.tcRailGag.block, l); + tileGag[6] = (TileTCRailGag) world.getTileEntity(x + 10, y + 1, z); + + placeTrack(world, x + 11, y + 1, z, BlockIDs.tcRailGag.block, l); + tileGag[7] = (TileTCRailGag) world.getTileEntity(x + 11, y + 1, z); + + + } + + } + for (TileTCRailGag tileTCRailGag : tileGag) { + if (player != null && tileTCRailGag == null) { + player.addChatMessage(new ChatComponentText("There was a problem when placing the track. Possibly too many tracks around")); + return false; + } + tileTCRailGag.originX = x; + tileTCRailGag.originY = y + 1; + tileTCRailGag.originZ = z; + tileTCRailGag.type = TrackTypes.MEDIUM_STRAIGHT.getLabel(); + } + return true; + } + + private boolean rightDiamondCrossing(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes tempType) { + + + if (tempType.getLabel().contains("EMBEDDED")) { + typeVariantStraight = TrackTypes.EMBEDDED_SMALL_STRAIGHT.getLabel(); + typeVariantDiagonal = TrackTypes.EMBEDDED_SMALL_DIAGONAL_STRAIGHT.getLabel(); + } + + + if (!canPlaceTrack(player, world, x, y + 1, z)) { + return false; + } + + int zDisplace = 0; + int xDisplace = 0; + int xSideDisplace = 0; + int zSideDisplace = 0; + int sideFacing = l; + + if (l == 2) { + zDisplace = -1; + xSideDisplace = 1; + sideFacing = 6; + } + if (l == 0) { + zDisplace = 1; + xSideDisplace = -1; + sideFacing = 4; + } + if (l == 1) { + xDisplace = -1; + zSideDisplace = -1; + sideFacing = 5; + } + if (l == 3) { + xDisplace = 1; + zSideDisplace = 1; + sideFacing = 7; + } + + if (!canPlaceTrack(player, world, x + xDisplace, y + 1, z + zDisplace) || !canPlaceTrack(player, world, x + (xDisplace * 2), y + 1, z + (zDisplace * 2))) { + return false; + } + if (!canPlaceTrack(player, world, x + (xDisplace * 2) + xSideDisplace, y + 1, z + (zDisplace * 2) + zSideDisplace)) { + return false; + } + if (!canPlaceTrack(player, world, x - (xSideDisplace), y + 1, z - zSideDisplace)) { + return false; + } + + //Top + + putDownSingleRail(world, x + (xDisplace * 2), y + 1, z + (zDisplace * 2), l, x + (xDisplace * 2), y + 1, + z + (zDisplace * 2), 0, typeVariantStraight, false, x + (xDisplace), y + 1, + z + (zDisplace), false, false); + + //Main + + placeTrack(world, x + (xDisplace), y + 1, z + (zDisplace), BlockIDs.tcRail.block, l); + TileTCRail tcRail2 = (TileTCRail) world.getTileEntity(x + (xDisplace), y + 1, z + (zDisplace)); + tcRail2.setFacing(l); + tcRail2.cx = x + (xDisplace); + tcRail2.cy = y + 1; + tcRail2.cz = z + (zDisplace); + tcRail2.setType(tempType.getLabel()); + tcRail2.idDrop = this.type.getItem().item; + + //Bottom + + + putDownSingleRail(world, x, y + 1, z, l, x, y + 1, z, 0, typeVariantStraight, false, + x + (xDisplace), y + 1, z + (zDisplace), false, false); + + //Right + + putDownSingleRail(world, x + (xDisplace * 2) + (xSideDisplace), y + 1, + z + (zDisplace * 2) + (zSideDisplace), sideFacing, + x + (xDisplace) + (xSideDisplace), y + 1, z + (zDisplace * 2) + (zSideDisplace), 0, + typeVariantDiagonal, false, x + (xDisplace), y + 1, z + (zDisplace), + false, false); + + //Left + + putDownSingleRail(world, x - (xSideDisplace), y + 1, + z - (zSideDisplace), sideFacing, + x - (xSideDisplace), y + 1, z - (zSideDisplace), 0, + typeVariantDiagonal, false, x + (xDisplace), y + 1, z + (zDisplace), + false, false); + + + return true; + } + + private boolean leftDiamondCrossing(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes tempType) { + + if (tempType.getLabel().contains("EMBEDDED")) { + typeVariantStraight = TrackTypes.EMBEDDED_SMALL_STRAIGHT.getLabel(); + typeVariantDiagonal = TrackTypes.EMBEDDED_SMALL_DIAGONAL_STRAIGHT.getLabel(); + } + + + if (!canPlaceTrack(player, world, x, y + 1, z)) { + return false; + } + + int zDisplace = 0; + int xDisplace = 0; + int xSideDisplace = 0; + int zSideDisplace = 0; + int sideFacing = l; + + if (l == 2) { + zDisplace = -1; + xSideDisplace = 1; + sideFacing = 5; + } + if (l == 0) { + zDisplace = 1; + xSideDisplace = -1; + sideFacing = 7; + } + if (l == 1) { + xDisplace = -1; + zSideDisplace = -1; + sideFacing = 4; + } + if (l == 3) { + xDisplace = 1; + zSideDisplace = 1; + sideFacing = 6; + } + + + if (!canPlaceTrack(player, world, x + xDisplace, y + 1, z + zDisplace) || !canPlaceTrack(player, world, x + (xDisplace * 2), y + 1, z + (zDisplace * 2))) { + return false; + } + if (!canPlaceTrack(player, world, x + (xDisplace * 2) - xSideDisplace, y + 1, z + (zDisplace * 2) - zSideDisplace)) { + return false; + } + if (!canPlaceTrack(player, world, x + (xSideDisplace), y + 1, z + zSideDisplace)) { + return false; + } + + //Top + + putDownSingleRail(world, x + (xDisplace * 2), y + 1, z + (zDisplace * 2), l, x + (xDisplace * 2), y + 1, + z + (zDisplace * 2), 0, typeVariantStraight, false, x + (xDisplace), y + 1, + z + (zDisplace), false, false); + + //Main + + placeTrack(world, x + (xDisplace), y + 1, z + (zDisplace), BlockIDs.tcRail.block, l); + TileTCRail tcRail2 = (TileTCRail) world.getTileEntity(x + (xDisplace), y + 1, z + (zDisplace)); + tcRail2.setFacing(l); + tcRail2.cx = x + (xDisplace); + tcRail2.cy = y + 1; + tcRail2.cz = z + (zDisplace); + tcRail2.setType(tempType.getLabel()); + tcRail2.idDrop = this.type.getItem().item; + + //Bottom + + + putDownSingleRail(world, x, y + 1, z, l, x, y + 1, z, 0, typeVariantStraight, false, + x + (xDisplace), y + 1, z + (zDisplace), false, false); + + //Left + + putDownSingleRail(world, x + (xDisplace * 2) - (xSideDisplace), y + 1, + z + (zDisplace * 2) - (zSideDisplace), sideFacing, + x - (xDisplace) - (xSideDisplace), y + 1, z + (zDisplace * 2) - (zSideDisplace), 0, + typeVariantDiagonal, false, x + (xDisplace), y + 1, z + (zDisplace), + false, false); + + //Right + + putDownSingleRail(world, x + (xSideDisplace), y + 1, + z + (zSideDisplace), sideFacing, + x + (xSideDisplace), y + 1, z + (zSideDisplace), 0, + typeVariantDiagonal, false, x + (xDisplace), y + 1, z + (zDisplace), + false, false); + + + return true; + } + + private boolean doubleDiamondCrossing(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes type) { + + if (type.getLabel().contains("EMBEDDED")) { + typeVariantStraight = TrackTypes.EMBEDDED_SMALL_STRAIGHT.getLabel(); + typeVariantDiagonal = TrackTypes.EMBEDDED_SMALL_DIAGONAL_STRAIGHT.getLabel(); + } + + + if (!canPlaceTrack(player, world, x, y + 1, z)) { + return false; + } + + int zDisplace = 0; + int xDisplace = 0; + int xSideDisplace = 0; + int zSideDisplace = 0; + int sideFacing = l; + int sideFacing2 = l; + + if (l == 2) { + zDisplace = -1; + xSideDisplace = 1; + sideFacing = 6; + sideFacing2 = 5; + } + if (l == 0) { + zDisplace = 1; + xSideDisplace = -1; + sideFacing = 4; + sideFacing2 = 7; + } + if (l == 1) { + xDisplace = -1; + zSideDisplace = -1; + sideFacing = 5; + sideFacing2 = 4; + } + if (l == 3) { + xDisplace = 1; + zSideDisplace = 1; + sideFacing = 7; + sideFacing2 = 6; + } + + if (!canPlaceTrack(player, world, x + xDisplace, y + 1, z + zDisplace) || !canPlaceTrack(player, world, x + (xDisplace * 2), y + 1, z + (zDisplace * 2))) { + return false; + } + if (!canPlaceTrack(player, world, x + (xDisplace * 2) - xSideDisplace, y + 1, z + (zDisplace * 2) - zSideDisplace)) { + return false; + } + if (!canPlaceTrack(player, world, x + (xSideDisplace), y + 1, z + zSideDisplace)) { + return false; + } + if (!canPlaceTrack(player, world, x + (xDisplace * 2) + xSideDisplace, y + 1, z + (zDisplace * 2) + zSideDisplace)) { + return false; + } + if (!canPlaceTrack(player, world, x - (xSideDisplace), y + 1, z - zSideDisplace)) { + return false; + } + + //Top + + putDownSingleRail(world, x + (xDisplace * 2), y + 1, z + (zDisplace * 2), l, x + (xDisplace * 2), y + 1, + z + (zDisplace * 2), 0, typeVariantStraight, false, x + (xDisplace), y + 1, + z + (zDisplace), false, false); + + //Main + + placeTrack(world, x + (xDisplace), y + 1, z + (zDisplace), BlockIDs.tcRail.block, l); + TileTCRail tcRail2 = (TileTCRail) world.getTileEntity(x + (xDisplace), y + 1, z + (zDisplace)); + tcRail2.setFacing(l); + tcRail2.cx = x + (xDisplace); + tcRail2.cy = y + 1; + tcRail2.cz = z + (zDisplace); + tcRail2.setType(type.getLabel()); + tcRail2.idDrop = this.type.getItem().item; + + //Bottom + + + putDownSingleRail(world, x, y + 1, z, l, x, y + 1, z, 0, typeVariantStraight, false, + x + (xDisplace), y + 1, z + (zDisplace), false, false); + //RIGHT + putDownSingleRail(world, x + (xDisplace * 2) + (xSideDisplace), y + 1, + z + (zDisplace * 2) + (zSideDisplace), sideFacing, + x + (xDisplace) + (xSideDisplace), y + 1, z + (zDisplace * 2) + (zSideDisplace), 0, + typeVariantDiagonal, false, x + (xDisplace), y + 1, z + (zDisplace), + false, false); + + //Left + + putDownSingleRail(world, x - (xSideDisplace), y + 1, + z - (zSideDisplace), sideFacing, + x - (xSideDisplace), y + 1, z - (zSideDisplace), 0, + typeVariantDiagonal, false, x + (xDisplace), y + 1, z + (zDisplace), + false, false); + //Left2 + + putDownSingleRail(world, x + (xDisplace * 2) - (xSideDisplace), y + 1, + z + (zDisplace * 2) - (zSideDisplace), sideFacing2, + x - (xDisplace) - (xSideDisplace), y + 1, z + (zDisplace * 2) - (zSideDisplace), 0, + typeVariantDiagonal, false, x + (xDisplace), y + 1, z + (zDisplace), + false, false); + + //Right2 + + putDownSingleRail(world, x + (xSideDisplace), y + 1, + z + (zSideDisplace), sideFacing2, + x + (xSideDisplace), y + 1, z + (zSideDisplace), 0, + typeVariantDiagonal, false, x + (xDisplace), y + 1, z + (zDisplace), + false, false); + + return true; + } + + private boolean diagonalTwoWaysCrossing(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes type) { + if (type.getLabel().contains("EMBEDDED")) { + typeVariantDiagonal = TrackTypes.EMBEDDED_SMALL_DIAGONAL_STRAIGHT.getLabel(); + } + + + if (!canPlaceTrack(player, world, x, y + 1, z)) { + return false; + } + + int zDisplace = 0; + int xDisplace = 0; + int xSideDisplace = 0; + int zSideDisplace = 0; + int sideFacing = l; + int sideFacing2 = l; + + if (l == 2) { + zDisplace = -1; + xSideDisplace = 1; + sideFacing = 6; + sideFacing2 = 5; + } + if (l == 0) { + zDisplace = 1; + xSideDisplace = -1; + sideFacing = 4; + sideFacing2 = 7; + } + if (l == 1) { + xDisplace = -1; + zSideDisplace = -1; + sideFacing = 5; + sideFacing2 = 4; + } + if (l == 3) { + xDisplace = 1; + zSideDisplace = 1; + sideFacing = 7; + sideFacing2 = 6; + } + + if (!canPlaceTrack(player, world, x + xDisplace + xSideDisplace, y + 1, z + zDisplace + zSideDisplace)) { + return false; + } + if (!canPlaceTrack(player, world, x - xDisplace - (xSideDisplace), y + 1, z - zDisplace - zSideDisplace)) { + return false; + } + if (!canPlaceTrack(player, world, x + xDisplace - xSideDisplace, y + 1, z + zDisplace - zSideDisplace)) { + return false; + } + if (!canPlaceTrack(player, world, x - xDisplace + (xSideDisplace), y + 1, z - zDisplace + zSideDisplace)) { + return false; + } + + + //Main + placeTrack(world, x, y + 1, z, BlockIDs.tcRail.block, l); + TileTCRail tcRail2 = (TileTCRail) world.getTileEntity(x, y + 1, z); + tcRail2.setFacing(l); + tcRail2.cx = x + (xDisplace); + tcRail2.cy = y + 1; + tcRail2.cz = z + (zDisplace); + tcRail2.setType(type.getLabel()); + tcRail2.idDrop = this.type.getItem().item; + + //RIGHT + putDownSingleRail(world, x + xDisplace + (xSideDisplace), y + 1, + z + zDisplace + (zSideDisplace), sideFacing, + x + (xDisplace) + (xSideDisplace), y + 1, z + zDisplace + (zSideDisplace), 0, + typeVariantDiagonal, false, x, y + 1, z, + false, false); + + //Left + + putDownSingleRail(world, x - xDisplace - (xSideDisplace), y + 1, + z - zDisplace - (zSideDisplace), sideFacing, + x - xDisplace - (xSideDisplace), y + 1, z - zDisplace - (zSideDisplace), 0, + typeVariantDiagonal, false, x, y + 1, z, + false, false); + //Left2 + + putDownSingleRail(world, x + xDisplace - (xSideDisplace), y + 1, + z + zDisplace - (zSideDisplace), sideFacing2, + x + (xDisplace) - (xSideDisplace), y + 1, z + zDisplace - (zSideDisplace), 0, + typeVariantDiagonal, false, x, y + 1, z, + false, false); + + //Right2 + + putDownSingleRail(world, x - xDisplace + (xSideDisplace), y + 1, + z - zDisplace + (zSideDisplace), sideFacing2, + x - xDisplace + (xSideDisplace), y + 1, z - zDisplace + (zSideDisplace), 0, + typeVariantDiagonal, false, x, y + 1, z, + false, false); + + + return true; + } + + private boolean fourWaysCrossing(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes type) { + + if (type.getLabel().contains("EMBEDDED")) { + typeVariantDiagonal = TrackTypes.EMBEDDED_SMALL_DIAGONAL_STRAIGHT.getLabel(); + } + + + if (!canPlaceTrack(player, world, x, y + 1, z)) { + return false; + } + + int zDisplace = 0; + int xDisplace = 0; + int xSideDisplace = 0; + int zSideDisplace = 0; + int sideFacing = l; + int sideFacing2 = l; + int facing = l; + + if (l == 2) { + zDisplace = -1; + xSideDisplace = 1; + sideFacing = 6; + sideFacing2 = 5; + facing = 1; + } + if (l == 0) { + zDisplace = 1; + xSideDisplace = -1; + sideFacing = 4; + sideFacing2 = 7; + facing = 1; + } + if (l == 1) { + xDisplace = -1; + zSideDisplace = -1; + sideFacing = 5; + sideFacing2 = 4; + facing = 2; + } + if (l == 3) { + xDisplace = 1; + zSideDisplace = 1; + sideFacing = 7; + sideFacing2 = 6; + facing = 2; + } + + if (!canPlaceTrack(player, world, x + xDisplace + xSideDisplace, y + 1, z + zDisplace + zSideDisplace)) { + return false; + } + if (!canPlaceTrack(player, world, x - xDisplace - (xSideDisplace), y + 1, z - zDisplace - zSideDisplace)) { + return false; + } + if (!canPlaceTrack(player, world, x + xDisplace - xSideDisplace, y + 1, z + zDisplace - zSideDisplace)) { + return false; + } + if (!canPlaceTrack(player, world, x - xDisplace + (xSideDisplace), y + 1, z - zDisplace + zSideDisplace)) { + return false; + } + if (!canPlaceTrack(player, world, x + xDisplace, y + 1, z + zDisplace)) { + return false; + } + if (!canPlaceTrack(player, world, x - xDisplace, y + 1, z - zDisplace)) { + return false; + } + if (!canPlaceTrack(player, world, x + xSideDisplace, y + 1, z + zSideDisplace)) { + return false; + } + if (!canPlaceTrack(player, world, x - xSideDisplace, y + 1, z - zSideDisplace)) { + return false; + } + + + //Main + placeTrack(world, x, y + 1, z, BlockIDs.tcRail.block, l); + TileTCRail tcRail2 = (TileTCRail) world.getTileEntity(x, y + 1, z); + tcRail2.setFacing(l); + tcRail2.cx = x + (xDisplace); + tcRail2.cy = y + 1; + tcRail2.cz = z + (zDisplace); + tcRail2.setType(type.getLabel()); + tcRail2.idDrop = this.type.getItem().item; + + + //T + putDownSingleRail(world, x + xDisplace, y + 1, + z + zDisplace, l, + x + (xDisplace), y + 1, z + zDisplace, 0, + typeVariantStraight, false, x, y + 1, z, + false, false); + //B + putDownSingleRail(world, x - xDisplace, y + 1, + z - zDisplace, l, + x - (xDisplace), y + 1, z - zDisplace, 0, + typeVariantStraight, false, x, y + 1, z, + false, false); + //L + putDownSingleRail(world, x + xSideDisplace, y + 1, + z + zSideDisplace, facing, + x + (xSideDisplace), y + 1, z + zSideDisplace, 0, + typeVariantStraight, false, x, y + 1, z, + false, false); + //R + putDownSingleRail(world, x - xSideDisplace, y + 1, + z - zSideDisplace, facing, + x - (xSideDisplace), y + 1, z - zSideDisplace, 0, + typeVariantStraight, false, x, y + 1, z, + false, false); + + + //BR + putDownSingleRail(world, x + xDisplace + (xSideDisplace), y + 1, + z + zDisplace + (zSideDisplace), sideFacing, + x + (xDisplace) + (xSideDisplace), y + 1, z + zDisplace + (zSideDisplace), 0, + typeVariantDiagonal, false, x, y + 1, z, + false, false); + + //TL + + putDownSingleRail(world, x - xDisplace - (xSideDisplace), y + 1, + z - zDisplace - (zSideDisplace), sideFacing, + x - xDisplace - (xSideDisplace), y + 1, z - zDisplace - (zSideDisplace), 0, + typeVariantDiagonal, false, x, y + 1, z, + false, false); + //TR + + putDownSingleRail(world, x + xDisplace - (xSideDisplace), y + 1, + z + zDisplace - (zSideDisplace), sideFacing2, + x + (xDisplace) - (xSideDisplace), y + 1, z + zDisplace - (zSideDisplace), 0, + typeVariantDiagonal, false, x, y + 1, z, + false, false); + + //BL + + putDownSingleRail(world, x - xDisplace + (xSideDisplace), y + 1, + z - zDisplace + (zSideDisplace), sideFacing2, + x - xDisplace + (xSideDisplace), y + 1, z - zDisplace + (zSideDisplace), 0, + typeVariantDiagonal, false, x, y + 1, z, + false, false); + + + return true; + } + + private boolean smallDiagonalStraight(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes type) { + + + TileTCRailGag[] tileGag = new TileTCRailGag[2]; + + if (l == 6) { + + if (!canPlaceTrack(player, world, x, y + 1, z) || !canPlaceTrack(player, world, x, y + 1, z - 1) || !canPlaceTrack(player, world, x + 1, y + 1, z)) { + return false; + } + + placeTrack(world, x, y + 1, z, BlockIDs.tcRail.block, l); + TileTCRail tcRail = (TileTCRail) world.getTileEntity(x, y + 1, z); + + placeTrack(world, x, y + 1, z - 1, BlockIDs.tcRailGag.block, l); + tileGag[0] = (TileTCRailGag) world.getTileEntity(x, y + 1, z - 1); + tileGag[0].canPlaceRollingstock = false; + + placeTrack(world, x + 1, y + 1, z, BlockIDs.tcRailGag.block, l); + tileGag[1] = (TileTCRailGag) world.getTileEntity(x + 1, y + 1, z); + tileGag[1].canPlaceRollingstock = false; + tcRail.setFacing(l); + tcRail.setType(type.getLabel()); + tcRail.setRailLength(1D); + tcRail.idDrop = this.type.getItem().item; + } + if (l == 4) { + + if (!canPlaceTrack(player, world, x, y + 1, z) || !canPlaceTrack(player, world, x, y + 1, z + 1) || !canPlaceTrack(player, world, x - 1, y + 1, z)) { + return false; + } + + placeTrack(world, x, y + 1, z, BlockIDs.tcRail.block, l); + TileTCRail tcRail = (TileTCRail) world.getTileEntity(x, y + 1, z); + placeTrack(world, x, y + 1, z + 1, BlockIDs.tcRailGag.block, l); + tileGag[0] = (TileTCRailGag) world.getTileEntity(x, y + 1, z + 1); + + placeTrack(world, x - 1, y + 1, z, BlockIDs.tcRailGag.block, l); + tileGag[1] = (TileTCRailGag) world.getTileEntity(x - 1, y + 1, z); + + tcRail.setFacing(l); + tcRail.setType(type.getLabel()); + tcRail.setRailLength(1D); + tcRail.idDrop = this.type.getItem().item; + } + if (l == 5) { + + if (!canPlaceTrack(player, world, x, y + 1, z) || !canPlaceTrack(player, world, x - 1, y + 1, z) || !canPlaceTrack(player, world, x - 1, y + 1, z)) { + return false; + } + + placeTrack(world, x, y + 1, z, BlockIDs.tcRail.block, l); + TileTCRail tcRail = (TileTCRail) world.getTileEntity(x, y + 1, z); + + placeTrack(world, x, y + 1, z - 1, BlockIDs.tcRailGag.block, l); + tileGag[0] = (TileTCRailGag) world.getTileEntity(x, y + 1, z - 1); + + placeTrack(world, x - 1, y + 1, z, BlockIDs.tcRailGag.block, l); + tileGag[1] = (TileTCRailGag) world.getTileEntity(x - 1, y + 1, z); + tcRail.setFacing(l); + tcRail.setType(type.getLabel()); + tcRail.setRailLength(1D); + tcRail.idDrop = this.type.getItem().item; + } + if (l == 7) { + + if (!canPlaceTrack(player, world, x, y + 1, z) || !canPlaceTrack(player, world, x, y + 1, z + 1) || !canPlaceTrack(player, world, x + 1, y + 1, z)) { + return false; + } + + placeTrack(world, x, y + 1, z, BlockIDs.tcRail.block, l); + TileTCRail tcRail = (TileTCRail) world.getTileEntity(x, y + 1, z); + placeTrack(world, x, y + 1, z + 1, BlockIDs.tcRailGag.block, l); + tileGag[0] = (TileTCRailGag) world.getTileEntity(x, y + 1, z + 1); + + placeTrack(world, x + 1, y + 1, z, BlockIDs.tcRailGag.block, l); + tileGag[1] = (TileTCRailGag) world.getTileEntity(x + 1, y + 1, z); + tcRail.setFacing(l); + tcRail.setType(type.getLabel()); + tcRail.setRailLength(1D); + tcRail.idDrop = this.type.getItem().item; + } + + for (TileTCRailGag tileTCRailGag : tileGag) { + if (player != null && tileTCRailGag == null) { + player.addChatMessage(new ChatComponentText("There was a problem when placing the track. Possibly too many tracks around")); + return false; + } + tileTCRailGag.originX = x; + tileTCRailGag.originY = y + 1; + tileTCRailGag.originZ = z; + tileTCRailGag.type = TrackTypes.SMALL_DIAGONAL_STRAIGHT.getLabel(); + tileTCRailGag.canPlaceRollingstock = false; + } + return true; + } + + private boolean diagonalStraight(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes type) { + /** check if first rail can be placed */ + if (!canPlaceTrack(player, world, x, y + 1, z)) { + return false; + } + TileTCRailGag[] tileGag = new TileTCRailGag[8]; + if (type == TrackTypes.LONG_DIAGONAL_STRAIGHT || type == TrackTypes.EMBEDDED_LONG_DIAGONAL_STRAIGHT) { + tileGag = new TileTCRailGag[16]; + } + + if (type == TrackTypes.VERY_LONG_DIAGONAL_STRAIGHT || type == TrackTypes.EMBEDDED_VERY_LONG_DIAGONAL_STRAIGHT) { + tileGag = new TileTCRailGag[32]; + } + if (l == 6) { + + if (!canPlaceTrack(player, world, x, y + 1, z - 1) || !canPlaceTrack(player, world, x + 1, y + 1, z) + || !canPlaceTrack(player, world, x + 1, y + 1, z - 1) || !canPlaceTrack(player, world, x + 1, y + 1, z - 2) || !canPlaceTrack(player, world, x + 2, y + 1, z - 1) + || !canPlaceTrack(player, world, x + 2, y + 1, z - 2) || !canPlaceTrack(player, world, x + 2, y + 1, z - 3) || !canPlaceTrack(player, world, x + 3, y + 1, z - 2)) { + return false; + } + if (type == TrackTypes.LONG_DIAGONAL_STRAIGHT || type == TrackTypes.EMBEDDED_LONG_DIAGONAL_STRAIGHT) { + if (!canPlaceTrack(player, world, x + 3, y + 1, z - 3) || !canPlaceTrack(player, world, x + 3, y + 1, z - 4) || !canPlaceTrack(player, world, x + 4, y + 1, z - 3) + || !canPlaceTrack(player, world, x + 4, y + 1, z - 4) || !canPlaceTrack(player, world, x + 4, y + 1, z - 5) || !canPlaceTrack(player, world, x + 5, y + 1, z - 4) + || !canPlaceTrack(player, world, x + 5, y + 1, z - 5) || !canPlaceTrack(player, world, x + 5, y + 1, z - 6) || !canPlaceTrack(player, world, x + 6, y + 1, z - 5)) { + return false; + } + } + if (type == TrackTypes.VERY_LONG_DIAGONAL_STRAIGHT || type == TrackTypes.EMBEDDED_VERY_LONG_DIAGONAL_STRAIGHT) { + if (!canPlaceTrack(player, world, x + 3, y + 1, z - 3) || !canPlaceTrack(player, world, x + 3, y + 1, z - 4) || !canPlaceTrack(player, world, x + 4, y + 1, z - 3) + || !canPlaceTrack(player, world, x + 4, y + 1, z - 4) || !canPlaceTrack(player, world, x + 4, y + 1, z - 5) || !canPlaceTrack(player, world, x + 5, y + 1, z - 4) + || !canPlaceTrack(player, world, x + 5, y + 1, z - 5) || !canPlaceTrack(player, world, x + 5, y + 1, z - 6) || !canPlaceTrack(player, world, x + 6, y + 1, z - 5) + || !canPlaceTrack(player, world, x + 6, y + 1, z - 6) || !canPlaceTrack(player, world, x + 6, y + 1, z - 7) || !canPlaceTrack(player, world, x + 7, y + 1, z - 6) + || !canPlaceTrack(player, world, x + 7, y + 1, z - 7) || !canPlaceTrack(player, world, x + 7, y + 1, z - 8) || !canPlaceTrack(player, world, x + 8, y + 1, z - 7) + || !canPlaceTrack(player, world, x + 8, y + 1, z - 8) || !canPlaceTrack(player, world, x + 8, y + 1, z - 9) || !canPlaceTrack(player, world, x + 9, y + 1, z - 8) + || !canPlaceTrack(player, world, x + 9, y + 1, z - 9) || !canPlaceTrack(player, world, x + 9, y + 1, z - 10) || !canPlaceTrack(player, world, x + 10, y + 1, z - 9) + || !canPlaceTrack(player, world, x + 10, y + 1, z - 10) || !canPlaceTrack(player, world, x + 10, y + 1, z - 11) || !canPlaceTrack(player, world, x + 11, y + 1, z - 10) + || !canPlaceTrack(player, world, x + 11, y + 1, z - 11) || !canPlaceTrack(player, world, x + 11, y + 1, z - 12) || !canPlaceTrack(player, world, x + 12, y + 1, z - 11)) { + return false; + } + } + placeTrack(world, x, y + 1, z, BlockIDs.tcRail.block, l); + TileTCRail tcRail = (TileTCRail) world.getTileEntity(x, y + 1, z); + tcRail.setFacing(l); + tcRail.setType(type.getLabel()); + tcRail.setRailLength(3D); + + placeTrack(world, x + 1, y + 1, z - 1, BlockIDs.tcRailGag.block, l); + tileGag[0] = (TileTCRailGag) world.getTileEntity(x + 1, y + 1, z - 1); + + placeTrack(world, x + 2, y + 1, z - 2, BlockIDs.tcRailGag.block, l); + tileGag[1] = (TileTCRailGag) world.getTileEntity(x + 2, y + 1, z - 2); + + placeTrack(world, x, y + 1, z - 1, BlockIDs.tcRailGag.block, l); + tileGag[2] = (TileTCRailGag) world.getTileEntity(x, y + 1, z - 1); + tileGag[2].canPlaceRollingstock = false; + placeTrack(world, x + 1, y + 1, z, BlockIDs.tcRailGag.block, l); + tileGag[3] = (TileTCRailGag) world.getTileEntity(x + 1, y + 1, z); + tileGag[3].canPlaceRollingstock = false; + placeTrack(world, x + 1, y + 1, z - 2, BlockIDs.tcRailGag.block, l); + tileGag[4] = (TileTCRailGag) world.getTileEntity(x + 1, y + 1, z - 2); + tileGag[4].canPlaceRollingstock = false; + placeTrack(world, x + 2, y + 1, z - 1, BlockIDs.tcRailGag.block, l); + tileGag[5] = (TileTCRailGag) world.getTileEntity(x + 2, y + 1, z - 1); + tileGag[5].canPlaceRollingstock = false; + placeTrack(world, x + 2, y + 1, z - 3, BlockIDs.tcRailGag.block, l); + tileGag[6] = (TileTCRailGag) world.getTileEntity(x + 2, y + 1, z - 3); + tileGag[6].canPlaceRollingstock = false; + placeTrack(world, x + 3, y + 1, z - 2, BlockIDs.tcRailGag.block, l); + tileGag[7] = (TileTCRailGag) world.getTileEntity(x + 3, y + 1, z - 2); + tileGag[7].canPlaceRollingstock = false; + if (type == TrackTypes.LONG_DIAGONAL_STRAIGHT || type == TrackTypes.EMBEDDED_LONG_DIAGONAL_STRAIGHT) { + tcRail.idDrop = this.type.getItem().item; + } else { + tcRail.idDrop = this.type.getItem().item; + } + + + if (type == TrackTypes.LONG_DIAGONAL_STRAIGHT || type == TrackTypes.VERY_LONG_DIAGONAL_STRAIGHT || type == TrackTypes.EMBEDDED_LONG_DIAGONAL_STRAIGHT || type == TrackTypes.EMBEDDED_VERY_LONG_DIAGONAL_STRAIGHT) { + placeTrack(world, x + 3, y + 1, z - 3, BlockIDs.tcRail.block, l); + TileTCRail tcRail2 = (TileTCRail) world.getTileEntity(x + 3, y + 1, z - 3); + tcRail2.setFacing(l); + tcRail2.setType(type.getLabel()); + tcRail2.isLinkedToRail = true; + tcRail2.linkedX = x + 1; + tcRail2.linkedY = y + 1; + tcRail2.linkedZ = z - 1; + tcRail.setRailLength(6D); + tcRail2.setRailLength(3D); + + placeTrack(world, x + 4, y + 1, z - 4, BlockIDs.tcRailGag.block, l); + tileGag[8] = (TileTCRailGag) world.getTileEntity(x + 4, y + 1, z - 4); + + placeTrack(world, x + 5, y + 1, z - 5, BlockIDs.tcRailGag.block, l); + tileGag[9] = (TileTCRailGag) world.getTileEntity(x + 5, y + 1, z - 5); + + placeTrack(world, x + 3, y + 1, z - 4, BlockIDs.tcRailGag.block, l); + tileGag[10] = (TileTCRailGag) world.getTileEntity(x + 3, y + 1, z - 4); + tileGag[10].canPlaceRollingstock = false; + placeTrack(world, x + 4, y + 1, z - 3, BlockIDs.tcRailGag.block, l); + tileGag[11] = (TileTCRailGag) world.getTileEntity(x + 4, y + 1, z - 3); + tileGag[11].canPlaceRollingstock = false; + placeTrack(world, x + 5, y + 1, z - 4, BlockIDs.tcRailGag.block, l); + tileGag[12] = (TileTCRailGag) world.getTileEntity(x + 5, y + 1, z - 4); + tileGag[12].canPlaceRollingstock = false; + placeTrack(world, x + 4, y + 1, z - 5, BlockIDs.tcRailGag.block, l); + tileGag[13] = (TileTCRailGag) world.getTileEntity(x + 4, y + 1, z - 5); + tileGag[13].canPlaceRollingstock = false; + placeTrack(world, x + 6, y + 1, z - 5, BlockIDs.tcRailGag.block, l); + tileGag[14] = (TileTCRailGag) world.getTileEntity(x + 6, y + 1, z - 5); + tileGag[14].canPlaceRollingstock = false; + placeTrack(world, x + 5, y + 1, z - 6, BlockIDs.tcRailGag.block, l); + tileGag[15] = (TileTCRailGag) world.getTileEntity(x + 5, y + 1, z - 6); + tileGag[15].canPlaceRollingstock = false; + if (type == TrackTypes.VERY_LONG_DIAGONAL_STRAIGHT) { + tcRail.idDrop = this.type.getItem().item; + } else { + tcRail.idDrop = this.type.getItem().item; + } + } + if (type == TrackTypes.VERY_LONG_DIAGONAL_STRAIGHT || type == TrackTypes.EMBEDDED_VERY_LONG_DIAGONAL_STRAIGHT) { + + placeTrack(world, x + 6, y + 1, z - 6, BlockIDs.tcRail.block, l); + TileTCRail tcRail3 = (TileTCRail) world.getTileEntity(x + 6, y + 1, z - 6); + tcRail3.setFacing(l); + tcRail3.setType(type.getLabel()); + tcRail3.isLinkedToRail = true; + tcRail3.linkedX = x + 1; + tcRail3.linkedY = y + 1; + tcRail3.linkedZ = z - 1; + tcRail.setRailLength(12D); + tcRail3.setRailLength(3D); + + placeTrack(world, x + 7, y + 1, z - 7, BlockIDs.tcRailGag.block, l); + tileGag[16] = (TileTCRailGag) world.getTileEntity(x + 7, y + 1, z - 7); + + placeTrack(world, x + 8, y + 1, z - 8, BlockIDs.tcRailGag.block, l); + tileGag[17] = (TileTCRailGag) world.getTileEntity(x + 8, y + 1, z - 8); + + placeTrack(world, x + 6, y + 1, z - 7, BlockIDs.tcRailGag.block, l); + tileGag[18] = (TileTCRailGag) world.getTileEntity(x + 6, y + 1, z - 7); + tileGag[18].canPlaceRollingstock = false; + placeTrack(world, x + 7, y + 1, z - 6, BlockIDs.tcRailGag.block, l); + tileGag[19] = (TileTCRailGag) world.getTileEntity(x + 7, y + 1, z - 6); + tileGag[19].canPlaceRollingstock = false; + placeTrack(world, x + 7, y + 1, z - 8, BlockIDs.tcRailGag.block, l); + tileGag[20] = (TileTCRailGag) world.getTileEntity(x + 7, y + 1, z - 8); + tileGag[20].canPlaceRollingstock = false; + placeTrack(world, x + 8, y + 1, z - 7, BlockIDs.tcRailGag.block, l); + tileGag[21] = (TileTCRailGag) world.getTileEntity(x + 8, y + 1, z - 7); + tileGag[21].canPlaceRollingstock = false; + placeTrack(world, x + 8, y + 1, z - 9, BlockIDs.tcRailGag.block, l); + tileGag[22] = (TileTCRailGag) world.getTileEntity(x + 8, y + 1, z - 9); + tileGag[22].canPlaceRollingstock = false; + placeTrack(world, x + 9, y + 1, z - 8, BlockIDs.tcRailGag.block, l); + tileGag[23] = (TileTCRailGag) world.getTileEntity(x + 9, y + 1, z - 8); + tileGag[23].canPlaceRollingstock = false; + + placeTrack(world, x + 9, y + 1, z - 9, BlockIDs.tcRail.block, l); + TileTCRail tcRail4 = (TileTCRail) world.getTileEntity(x + 9, y + 1, z - 9); + tcRail4.setFacing(l); + tcRail4.setType(type.getLabel()); + tcRail4.isLinkedToRail = true; + tcRail4.linkedX = x + 1; + tcRail4.linkedY = y + 1; + tcRail4.linkedZ = z - 1; + tcRail4.setRailLength(3D); + + + placeTrack(world, x + 10, y + 1, z - 10, BlockIDs.tcRailGag.block, l); + tileGag[24] = (TileTCRailGag) world.getTileEntity(x + 10, y + 1, z - 10); + + placeTrack(world, x + 11, y + 1, z - 11, BlockIDs.tcRailGag.block, l); + tileGag[25] = (TileTCRailGag) world.getTileEntity(x + 11, y + 1, z - 11); + + placeTrack(world, x + 9, y + 1, z - 10, BlockIDs.tcRailGag.block, l); + tileGag[26] = (TileTCRailGag) world.getTileEntity(x + 9, y + 1, z - 10); + tileGag[26].canPlaceRollingstock = false; + placeTrack(world, x + 10, y + 1, z - 9, BlockIDs.tcRailGag.block, l); + tileGag[27] = (TileTCRailGag) world.getTileEntity(x + 10, y + 1, z - 9); + tileGag[27].canPlaceRollingstock = false; + placeTrack(world, x + 10, y + 1, z - 11, BlockIDs.tcRailGag.block, l); + tileGag[28] = (TileTCRailGag) world.getTileEntity(x + 10, y + 1, z - 11); + tileGag[28].canPlaceRollingstock = false; + placeTrack(world, x + 11, y + 1, z - 10, BlockIDs.tcRailGag.block, l); + tileGag[29] = (TileTCRailGag) world.getTileEntity(x + 11, y + 1, z - 10); + tileGag[29].canPlaceRollingstock = false; + placeTrack(world, x + 11, y + 1, z - 12, BlockIDs.tcRailGag.block, l); + tileGag[30] = (TileTCRailGag) world.getTileEntity(x + 11, y + 1, z - 12); + tileGag[30].canPlaceRollingstock = false; + placeTrack(world, x + 12, y + 1, z - 11, BlockIDs.tcRailGag.block, l); + tileGag[31] = (TileTCRailGag) world.getTileEntity(x + 12, y + 1, z - 11); + tileGag[31].canPlaceRollingstock = false; + + } + + } + + if (l == 4) { + + if (!canPlaceTrack(player, world, x, y + 1, z + 1) || !canPlaceTrack(player, world, x - 1, y + 1, z) + || !canPlaceTrack(player, world, x - 1, y + 1, z + 1) || !canPlaceTrack(player, world, x - 1, y + 1, z + 2) || !canPlaceTrack(player, world, x - 2, y + 1, z + 1) + || !canPlaceTrack(player, world, x - 2, y + 1, z + 2) || !canPlaceTrack(player, world, x - 2, y + 1, z + 3) || !canPlaceTrack(player, world, x - 3, y + 1, z + 2)) { + return false; + } + if (type == TrackTypes.LONG_DIAGONAL_STRAIGHT || type == TrackTypes.EMBEDDED_LONG_DIAGONAL_STRAIGHT) { + if (!canPlaceTrack(player, world, x - 3, y + 1, z + 3) || !canPlaceTrack(player, world, x - 3, y + 1, z + 4) || !canPlaceTrack(player, world, x - 4, y + 1, z + 3) + || !canPlaceTrack(player, world, x - 4, y + 1, z + 4) || !canPlaceTrack(player, world, x - 4, y + 1, z + 5) || !canPlaceTrack(player, world, x - 5, y + 1, z + 4) + || !canPlaceTrack(player, world, x - 5, y + 1, z + 5) || !canPlaceTrack(player, world, x - 5, y + 1, z + 6) || !canPlaceTrack(player, world, x - 6, y + 1, z + 5)) { + return false; + } + } + if (type == TrackTypes.VERY_LONG_DIAGONAL_STRAIGHT || type == TrackTypes.EMBEDDED_VERY_LONG_DIAGONAL_STRAIGHT) { + if (!canPlaceTrack(player, world, x - 3, y + 1, z + 3) || !canPlaceTrack(player, world, x - 3, y + 1, z + 4) || !canPlaceTrack(player, world, x - 4, y + 1, z + 3) + || !canPlaceTrack(player, world, x - 4, y + 1, z + 4) || !canPlaceTrack(player, world, x - 4, y + 1, z + 5) || !canPlaceTrack(player, world, x - 5, y + 1, z + 4) + || !canPlaceTrack(player, world, x - 5, y + 1, z + 5) || !canPlaceTrack(player, world, x - 5, y + 1, z + 6) || !canPlaceTrack(player, world, x - 6, y + 1, z + 5) + || !canPlaceTrack(player, world, x - 6, y + 1, z + 6) || !canPlaceTrack(player, world, x - 6, y + 1, z + 7) || !canPlaceTrack(player, world, x - 7, y + 1, z + 6) + || !canPlaceTrack(player, world, x - 7, y + 1, z + 7) || !canPlaceTrack(player, world, x - 7, y + 1, z + 8) || !canPlaceTrack(player, world, x - 8, y + 1, z + 7) + || !canPlaceTrack(player, world, x - 8, y + 1, z + 8) || !canPlaceTrack(player, world, x - 8, y + 1, z + 9) || !canPlaceTrack(player, world, x - 9, y + 1, z + 8) + || !canPlaceTrack(player, world, x - 9, y + 1, z + 9) || !canPlaceTrack(player, world, x - 9, y + 1, z + 10) || !canPlaceTrack(player, world, x - 10, y + 1, z + 9) + || !canPlaceTrack(player, world, x - 10, y + 1, z + 10) || !canPlaceTrack(player, world, x - 10, y + 1, z + 11) || !canPlaceTrack(player, world, x - 11, y + 1, z + 10) + || !canPlaceTrack(player, world, x - 11, y + 1, z + 11) || !canPlaceTrack(player, world, x - 11, y + 1, z + 12) || !canPlaceTrack(player, world, x - 12, y + 1, z + 11)) { + return false; + } + } + placeTrack(world, x, y + 1, z, BlockIDs.tcRail.block, l); + TileTCRail tcRail = (TileTCRail) world.getTileEntity(x, y + 1, z); + tcRail.setFacing(l); + tcRail.setType(type.getLabel()); + tcRail.setRailLength(3D); + + placeTrack(world, x - 1, y + 1, z + 1, BlockIDs.tcRailGag.block, l); + tileGag[0] = (TileTCRailGag) world.getTileEntity(x - 1, y + 1, z + 1); + + placeTrack(world, x - 2, y + 1, z + 2, BlockIDs.tcRailGag.block, l); + tileGag[1] = (TileTCRailGag) world.getTileEntity(x - 2, y + 1, z + 2); + + placeTrack(world, x, y + 1, z + 1, BlockIDs.tcRailGag.block, l); + tileGag[2] = (TileTCRailGag) world.getTileEntity(x, y + 1, z + 1); + tileGag[2].canPlaceRollingstock = false; + placeTrack(world, x - 1, y + 1, z, BlockIDs.tcRailGag.block, l); + tileGag[3] = (TileTCRailGag) world.getTileEntity(x - 1, y + 1, z); + tileGag[3].canPlaceRollingstock = false; + placeTrack(world, x - 1, y + 1, z + 2, BlockIDs.tcRailGag.block, l); + tileGag[4] = (TileTCRailGag) world.getTileEntity(x - 1, y + 1, z + 2); + tileGag[4].canPlaceRollingstock = false; + placeTrack(world, x - 2, y + 1, z + 1, BlockIDs.tcRailGag.block, l); + tileGag[5] = (TileTCRailGag) world.getTileEntity(x - 2, y + 1, z + 1); + tileGag[5].canPlaceRollingstock = false; + placeTrack(world, x - 2, y + 1, z + 3, BlockIDs.tcRailGag.block, l); + tileGag[6] = (TileTCRailGag) world.getTileEntity(x - 2, y + 1, z + 3); + tileGag[6].canPlaceRollingstock = false; + placeTrack(world, x - 3, y + 1, z + 2, BlockIDs.tcRailGag.block, l); + tileGag[7] = (TileTCRailGag) world.getTileEntity(x - 3, y + 1, z + 2); + tileGag[7].canPlaceRollingstock = false; + if (type == TrackTypes.LONG_DIAGONAL_STRAIGHT || type == TrackTypes.EMBEDDED_LONG_DIAGONAL_STRAIGHT) { + tcRail.idDrop = this.type.getItem().item; + } else { + tcRail.idDrop = this.type.getItem().item; + } + + + if (type == TrackTypes.LONG_DIAGONAL_STRAIGHT || type == TrackTypes.VERY_LONG_DIAGONAL_STRAIGHT || type == TrackTypes.EMBEDDED_LONG_DIAGONAL_STRAIGHT || type == TrackTypes.EMBEDDED_VERY_LONG_DIAGONAL_STRAIGHT) { + placeTrack(world, x - 3, y + 1, z + 3, BlockIDs.tcRail.block, l); + TileTCRail tcRail2 = (TileTCRail) world.getTileEntity(x - 3, y + 1, z + 3); + tcRail2.setFacing(l); + tcRail2.setType(type.getLabel()); + tcRail2.isLinkedToRail = true; + tcRail2.linkedX = x - 1; + tcRail2.linkedY = y + 1; + tcRail2.linkedZ = z + 1; + tcRail.setRailLength(6D); + tcRail2.setRailLength(3D); + + placeTrack(world, x - 4, y + 1, z + 4, BlockIDs.tcRailGag.block, l); + tileGag[8] = (TileTCRailGag) world.getTileEntity(x - 4, y + 1, z + 4); + + placeTrack(world, x - 5, y + 1, z + 5, BlockIDs.tcRailGag.block, l); + tileGag[9] = (TileTCRailGag) world.getTileEntity(x - 5, y + 1, z + 5); + + placeTrack(world, x - 3, y + 1, z + 4, BlockIDs.tcRailGag.block, l); + tileGag[10] = (TileTCRailGag) world.getTileEntity(x - 3, y + 1, z + 4); + tileGag[10].canPlaceRollingstock = false; + placeTrack(world, x - 4, y + 1, z + 3, BlockIDs.tcRailGag.block, l); + tileGag[11] = (TileTCRailGag) world.getTileEntity(x - 4, y + 1, z + 3); + tileGag[11].canPlaceRollingstock = false; + placeTrack(world, x - 5, y + 1, z + 4, BlockIDs.tcRailGag.block, l); + tileGag[12] = (TileTCRailGag) world.getTileEntity(x - 5, y + 1, z + 4); + tileGag[12].canPlaceRollingstock = false; + placeTrack(world, x - 4, y + 1, z + 5, BlockIDs.tcRailGag.block, l); + tileGag[13] = (TileTCRailGag) world.getTileEntity(x - 4, y + 1, z + 5); + tileGag[13].canPlaceRollingstock = false; + placeTrack(world, x - 6, y + 1, z + 5, BlockIDs.tcRailGag.block, l); + tileGag[14] = (TileTCRailGag) world.getTileEntity(x - 6, y + 1, z + 5); + tileGag[14].canPlaceRollingstock = false; + placeTrack(world, x - 5, y + 1, z + 6, BlockIDs.tcRailGag.block, l); + tileGag[15] = (TileTCRailGag) world.getTileEntity(x - 5, y + 1, z + 6); + tileGag[15].canPlaceRollingstock = false; + if (type == TrackTypes.VERY_LONG_DIAGONAL_STRAIGHT) { + tcRail.idDrop = this.type.getItem().item; + } else { + tcRail.idDrop = this.type.getItem().item; + } + } + if (type == TrackTypes.VERY_LONG_DIAGONAL_STRAIGHT || type == TrackTypes.EMBEDDED_VERY_LONG_DIAGONAL_STRAIGHT) { + + placeTrack(world, x - 6, y + 1, z + 6, BlockIDs.tcRail.block, l); + TileTCRail tcRail3 = (TileTCRail) world.getTileEntity(x - 6, y + 1, z + 6); + tcRail3.setFacing(l); + tcRail3.setType(type.getLabel()); + tcRail3.isLinkedToRail = true; + tcRail3.linkedX = x - 1; + tcRail3.linkedY = y + 1; + tcRail3.linkedZ = z + 1; + tcRail.setRailLength(12D); + tcRail3.setRailLength(3D); + + placeTrack(world, x - 7, y + 1, z + 7, BlockIDs.tcRailGag.block, l); + tileGag[16] = (TileTCRailGag) world.getTileEntity(x - 7, y + 1, z + 7); + + placeTrack(world, x - 8, y + 1, z + 8, BlockIDs.tcRailGag.block, l); + tileGag[17] = (TileTCRailGag) world.getTileEntity(x - 8, y + 1, z + 8); + + placeTrack(world, x - 6, y + 1, z + 7, BlockIDs.tcRailGag.block, l); + tileGag[18] = (TileTCRailGag) world.getTileEntity(x - 6, y + 1, z + 7); + tileGag[18].canPlaceRollingstock = false; + placeTrack(world, x - 7, y + 1, z + 6, BlockIDs.tcRailGag.block, l); + tileGag[19] = (TileTCRailGag) world.getTileEntity(x - 7, y + 1, z + 6); + tileGag[19].canPlaceRollingstock = false; + placeTrack(world, x - 7, y + 1, z + 8, BlockIDs.tcRailGag.block, l); + tileGag[20] = (TileTCRailGag) world.getTileEntity(x - 7, y + 1, z + 8); + tileGag[20].canPlaceRollingstock = false; + placeTrack(world, x - 8, y + 1, z + 7, BlockIDs.tcRailGag.block, l); + tileGag[21] = (TileTCRailGag) world.getTileEntity(x - 8, y + 1, z + 7); + tileGag[21].canPlaceRollingstock = false; + placeTrack(world, x - 8, y + 1, z + 9, BlockIDs.tcRailGag.block, l); + tileGag[22] = (TileTCRailGag) world.getTileEntity(x - 8, y + 1, z + 9); + tileGag[22].canPlaceRollingstock = false; + placeTrack(world, x - 9, y + 1, z + 8, BlockIDs.tcRailGag.block, l); + tileGag[23] = (TileTCRailGag) world.getTileEntity(x - 9, y + 1, z + 8); + tileGag[23].canPlaceRollingstock = false; + placeTrack(world, x - 9, y + 1, z + 9, BlockIDs.tcRail.block, l); + TileTCRail tcRail4 = (TileTCRail) world.getTileEntity(x - 9, y + 1, z + 9); + tcRail4.setFacing(l); + tcRail4.setType(type.getLabel()); + tcRail4.isLinkedToRail = true; + tcRail4.linkedX = x - 1; + tcRail4.linkedY = y + 1; + tcRail4.linkedZ = z + 1; + tcRail4.setRailLength(3D); + + + placeTrack(world, x - 10, y + 1, z + 10, BlockIDs.tcRailGag.block, l); + tileGag[24] = (TileTCRailGag) world.getTileEntity(x - 10, y + 1, z + 10); + + placeTrack(world, x - 11, y + 1, z + 11, BlockIDs.tcRailGag.block, l); + tileGag[25] = (TileTCRailGag) world.getTileEntity(x - 11, y + 1, z + 11); + + placeTrack(world, x - 9, y + 1, z + 10, BlockIDs.tcRailGag.block, l); + tileGag[26] = (TileTCRailGag) world.getTileEntity(x - 9, y + 1, z + 10); + tileGag[26].canPlaceRollingstock = false; + placeTrack(world, x - 10, y + 1, z + 9, BlockIDs.tcRailGag.block, l); + tileGag[27] = (TileTCRailGag) world.getTileEntity(x - 10, y + 1, z + 9); + tileGag[27].canPlaceRollingstock = false; + placeTrack(world, x - 10, y + 1, z + 11, BlockIDs.tcRailGag.block, l); + tileGag[28] = (TileTCRailGag) world.getTileEntity(x - 10, y + 1, z + 11); + tileGag[28].canPlaceRollingstock = false; + placeTrack(world, x - 11, y + 1, z + 10, BlockIDs.tcRailGag.block, l); + tileGag[29] = (TileTCRailGag) world.getTileEntity(x - 11, y + 1, z + 10); + tileGag[29].canPlaceRollingstock = false; + placeTrack(world, x - 11, y + 1, z + 12, BlockIDs.tcRailGag.block, l); + tileGag[30] = (TileTCRailGag) world.getTileEntity(x - 11, y + 1, z + 12); + tileGag[30].canPlaceRollingstock = false; + placeTrack(world, x - 12, y + 1, z + 11, BlockIDs.tcRailGag.block, l); + tileGag[31] = (TileTCRailGag) world.getTileEntity(x - 12, y + 1, z + 11); + tileGag[31].canPlaceRollingstock = false; + + } + + } + + if (l == 7) { + + if (!canPlaceTrack(player, world, x, y + 1, z + 1) || !canPlaceTrack(player, world, x + 1, y + 1, z) + || !canPlaceTrack(player, world, x + 1, y + 1, z + 1) || !canPlaceTrack(player, world, x + 1, y + 1, z + 2) || !canPlaceTrack(player, world, x + 2, y + 1, z + 1) + || !canPlaceTrack(player, world, x + 2, y + 1, z + 2) || !canPlaceTrack(player, world, x + 2, y + 1, z + 3) || !canPlaceTrack(player, world, x + 3, y + 1, z + 2)) { + return false; + } + if (type == TrackTypes.LONG_DIAGONAL_STRAIGHT || type == TrackTypes.EMBEDDED_LONG_DIAGONAL_STRAIGHT) { + if (!canPlaceTrack(player, world, x + 3, y + 1, z + 3) || !canPlaceTrack(player, world, x + 3, y + 1, z + 4) || !canPlaceTrack(player, world, x + 4, y + 1, z + 3) + || !canPlaceTrack(player, world, x + 4, y + 1, z + 4) || !canPlaceTrack(player, world, x + 4, y + 1, z + 5) || !canPlaceTrack(player, world, x + 5, y + 1, z + 4) + || !canPlaceTrack(player, world, x + 5, y + 1, z + 5) || !canPlaceTrack(player, world, x + 5, y + 1, z + 6) || !canPlaceTrack(player, world, x + 6, y + 1, z + 5)) { + return false; + } + } + if (type == TrackTypes.VERY_LONG_DIAGONAL_STRAIGHT || type == TrackTypes.EMBEDDED_VERY_LONG_DIAGONAL_STRAIGHT) { + if (!canPlaceTrack(player, world, x + 3, y + 1, z + 3) || !canPlaceTrack(player, world, x + 3, y + 1, z + 4) || !canPlaceTrack(player, world, x + 4, y + 1, z + 3) + || !canPlaceTrack(player, world, x + 4, y + 1, z + 4) || !canPlaceTrack(player, world, x + 4, y + 1, z + 5) || !canPlaceTrack(player, world, x + 5, y + 1, z + 4) + || !canPlaceTrack(player, world, x + 5, y + 1, z + 5) || !canPlaceTrack(player, world, x + 5, y + 1, z + 6) || !canPlaceTrack(player, world, x + 6, y + 1, z + 5) + || !canPlaceTrack(player, world, x + 6, y + 1, z + 6) || !canPlaceTrack(player, world, x + 6, y + 1, z + 7) || !canPlaceTrack(player, world, x + 7, y + 1, z + 6) + || !canPlaceTrack(player, world, x + 7, y + 1, z + 7) || !canPlaceTrack(player, world, x + 7, y + 1, z + 8) || !canPlaceTrack(player, world, x + 8, y + 1, z + 7) + || !canPlaceTrack(player, world, x + 8, y + 1, z + 8) || !canPlaceTrack(player, world, x + 8, y + 1, z + 9) || !canPlaceTrack(player, world, x + 9, y + 1, z + 8) + || !canPlaceTrack(player, world, x + 9, y + 1, z + 9) || !canPlaceTrack(player, world, x + 9, y + 1, z + 10) || !canPlaceTrack(player, world, x + 10, y + 1, z + 9) + || !canPlaceTrack(player, world, x + 10, y + 1, z + 10) || !canPlaceTrack(player, world, x + 10, y + 1, z + 11) || !canPlaceTrack(player, world, x + 11, y + 1, z + 10) + || !canPlaceTrack(player, world, x + 11, y + 1, z + 11) || !canPlaceTrack(player, world, x + 11, y + 1, z + 12) || !canPlaceTrack(player, world, x + 12, y + 1, z + 11)) { + return false; + } + } + placeTrack(world, x, y + 1, z, BlockIDs.tcRail.block, l); + TileTCRail tcRail = (TileTCRail) world.getTileEntity(x, y + 1, z); + tcRail.setFacing(l); + tcRail.setType(type.getLabel()); + tcRail.setRailLength(3D); + + placeTrack(world, x + 1, y + 1, z + 1, BlockIDs.tcRailGag.block, l); + tileGag[0] = (TileTCRailGag) world.getTileEntity(x + 1, y + 1, z + 1); + + placeTrack(world, x + 2, y + 1, z + 2, BlockIDs.tcRailGag.block, l); + tileGag[1] = (TileTCRailGag) world.getTileEntity(x + 2, y + 1, z + 2); + + placeTrack(world, x, y + 1, z + 1, BlockIDs.tcRailGag.block, l); + tileGag[2] = (TileTCRailGag) world.getTileEntity(x, y + 1, z + 1); + tileGag[2].canPlaceRollingstock = false; + placeTrack(world, x + 1, y + 1, z, BlockIDs.tcRailGag.block, l); + tileGag[3] = (TileTCRailGag) world.getTileEntity(x + 1, y + 1, z); + tileGag[3].canPlaceRollingstock = false; + placeTrack(world, x + 1, y + 1, z + 2, BlockIDs.tcRailGag.block, l); + tileGag[4] = (TileTCRailGag) world.getTileEntity(x + 1, y + 1, z + 2); + tileGag[4].canPlaceRollingstock = false; + placeTrack(world, x + 2, y + 1, z + 1, BlockIDs.tcRailGag.block, l); + tileGag[5] = (TileTCRailGag) world.getTileEntity(x + 2, y + 1, z + 1); + tileGag[5].canPlaceRollingstock = false; + placeTrack(world, x + 2, y + 1, z + 3, BlockIDs.tcRailGag.block, l); + tileGag[6] = (TileTCRailGag) world.getTileEntity(x + 2, y + 1, z + 3); + tileGag[6].canPlaceRollingstock = false; + placeTrack(world, x + 3, y + 1, z + 2, BlockIDs.tcRailGag.block, l); + tileGag[7] = (TileTCRailGag) world.getTileEntity(x + 3, y + 1, z + 2); + tileGag[7].canPlaceRollingstock = false; + if (type == TrackTypes.LONG_DIAGONAL_STRAIGHT || type == TrackTypes.EMBEDDED_LONG_DIAGONAL_STRAIGHT) { + tcRail.idDrop = this.type.getItem().item; + } else { + tcRail.idDrop = this.type.getItem().item; + } + + + if (type == TrackTypes.LONG_DIAGONAL_STRAIGHT || type == TrackTypes.VERY_LONG_DIAGONAL_STRAIGHT || type == TrackTypes.EMBEDDED_LONG_DIAGONAL_STRAIGHT || type == TrackTypes.EMBEDDED_VERY_LONG_DIAGONAL_STRAIGHT) { + placeTrack(world, x + 3, y + 1, z + 3, BlockIDs.tcRail.block, l); + TileTCRail tcRail2 = (TileTCRail) world.getTileEntity(x + 3, y + 1, z + 3); + tcRail2.setFacing(l); + tcRail2.setType(type.getLabel()); + tcRail2.isLinkedToRail = true; + tcRail2.linkedX = x + 1; + tcRail2.linkedY = y + 1; + tcRail2.linkedZ = z + 1; + tcRail.setRailLength(6D); + tcRail2.setRailLength(3D); + + placeTrack(world, x + 4, y + 1, z + 4, BlockIDs.tcRailGag.block, l); + tileGag[8] = (TileTCRailGag) world.getTileEntity(x + 4, y + 1, z + 4); + + placeTrack(world, x + 5, y + 1, z + 5, BlockIDs.tcRailGag.block, l); + tileGag[9] = (TileTCRailGag) world.getTileEntity(x + 5, y + 1, z + 5); + + placeTrack(world, x + 3, y + 1, z + 4, BlockIDs.tcRailGag.block, l); + tileGag[10] = (TileTCRailGag) world.getTileEntity(x + 3, y + 1, z + 4); + tileGag[10].canPlaceRollingstock = false; + placeTrack(world, x + 4, y + 1, z + 3, BlockIDs.tcRailGag.block, l); + tileGag[11] = (TileTCRailGag) world.getTileEntity(x + 4, y + 1, z + 3); + tileGag[11].canPlaceRollingstock = false; + placeTrack(world, x + 5, y + 1, z + 4, BlockIDs.tcRailGag.block, l); + tileGag[12] = (TileTCRailGag) world.getTileEntity(x + 5, y + 1, z + 4); + tileGag[12].canPlaceRollingstock = false; + placeTrack(world, x + 4, y + 1, z + 5, BlockIDs.tcRailGag.block, l); + tileGag[13] = (TileTCRailGag) world.getTileEntity(x + 4, y + 1, z + 5); + tileGag[13].canPlaceRollingstock = false; + placeTrack(world, x + 6, y + 1, z + 5, BlockIDs.tcRailGag.block, l); + tileGag[14] = (TileTCRailGag) world.getTileEntity(x + 6, y + 1, z + 5); + tileGag[14].canPlaceRollingstock = false; + placeTrack(world, x + 5, y + 1, z + 6, BlockIDs.tcRailGag.block, l); + tileGag[15] = (TileTCRailGag) world.getTileEntity(x + 5, y + 1, z + 6); + tileGag[15].canPlaceRollingstock = false; + if (type == TrackTypes.VERY_LONG_DIAGONAL_STRAIGHT) { + tcRail.idDrop = this.type.getItem().item; + } else { + tcRail.idDrop = this.type.getItem().item; + } + } + if (type == TrackTypes.VERY_LONG_DIAGONAL_STRAIGHT || type == TrackTypes.EMBEDDED_VERY_LONG_DIAGONAL_STRAIGHT) { + + placeTrack(world, x + 6, y + 1, z + 6, BlockIDs.tcRail.block, l); + TileTCRail tcRail3 = (TileTCRail) world.getTileEntity(x + 6, y + 1, z + 6); + tcRail3.setFacing(l); + tcRail3.setType(type.getLabel()); + tcRail3.isLinkedToRail = true; + tcRail3.linkedX = x + 1; + tcRail3.linkedY = y + 1; + tcRail3.linkedZ = z + 1; + tcRail.setRailLength(12D); + tcRail3.setRailLength(3D); + + placeTrack(world, x + 7, y + 1, z + 7, BlockIDs.tcRailGag.block, l); + tileGag[16] = (TileTCRailGag) world.getTileEntity(x + 7, y + 1, z + 7); + + placeTrack(world, x + 8, y + 1, z + 8, BlockIDs.tcRailGag.block, l); + tileGag[17] = (TileTCRailGag) world.getTileEntity(x + 8, y + 1, z + 8); + + placeTrack(world, x + 6, y + 1, z + 7, BlockIDs.tcRailGag.block, l); + tileGag[18] = (TileTCRailGag) world.getTileEntity(x + 6, y + 1, z + 7); + tileGag[18].canPlaceRollingstock = false; + placeTrack(world, x + 7, y + 1, z + 6, BlockIDs.tcRailGag.block, l); + tileGag[19] = (TileTCRailGag) world.getTileEntity(x + 7, y + 1, z + 6); + tileGag[19].canPlaceRollingstock = false; + placeTrack(world, x + 7, y + 1, z + 8, BlockIDs.tcRailGag.block, l); + tileGag[20] = (TileTCRailGag) world.getTileEntity(x + 7, y + 1, z + 8); + tileGag[20].canPlaceRollingstock = false; + placeTrack(world, x + 8, y + 1, z + 7, BlockIDs.tcRailGag.block, l); + tileGag[21] = (TileTCRailGag) world.getTileEntity(x + 8, y + 1, z + 7); + tileGag[21].canPlaceRollingstock = false; + placeTrack(world, x + 8, y + 1, z + 9, BlockIDs.tcRailGag.block, l); + tileGag[22] = (TileTCRailGag) world.getTileEntity(x + 8, y + 1, z + 9); + tileGag[22].canPlaceRollingstock = false; + placeTrack(world, x + 9, y + 1, z + 8, BlockIDs.tcRailGag.block, l); + tileGag[23] = (TileTCRailGag) world.getTileEntity(x + 9, y + 1, z + 8); + tileGag[23].canPlaceRollingstock = false; + placeTrack(world, x + 9, y + 1, z + 9, BlockIDs.tcRail.block, l); + TileTCRail tcRail4 = (TileTCRail) world.getTileEntity(x + 9, y + 1, z + 9); + tcRail4.setFacing(l); + tcRail4.setType(type.getLabel()); + tcRail4.isLinkedToRail = true; + tcRail4.linkedX = x + 1; + tcRail4.linkedY = y + 1; + tcRail4.linkedZ = z + 1; + tcRail4.setRailLength(3D); + + + placeTrack(world, x + 10, y + 1, z + 10, BlockIDs.tcRailGag.block, l); + tileGag[24] = (TileTCRailGag) world.getTileEntity(x + 10, y + 1, z + 10); + + placeTrack(world, x + 11, y + 1, z + 11, BlockIDs.tcRailGag.block, l); + tileGag[25] = (TileTCRailGag) world.getTileEntity(x + 11, y + 1, z + 11); + + placeTrack(world, x + 9, y + 1, z + 10, BlockIDs.tcRailGag.block, l); + tileGag[26] = (TileTCRailGag) world.getTileEntity(x + 9, y + 1, z + 10); + tileGag[26].canPlaceRollingstock = false; + placeTrack(world, x + 10, y + 1, z + 9, BlockIDs.tcRailGag.block, l); + tileGag[27] = (TileTCRailGag) world.getTileEntity(x + 10, y + 1, z + 9); + tileGag[27].canPlaceRollingstock = false; + placeTrack(world, x + 10, y + 1, z + 11, BlockIDs.tcRailGag.block, l); + tileGag[28] = (TileTCRailGag) world.getTileEntity(x + 10, y + 1, z + 11); + tileGag[28].canPlaceRollingstock = false; + placeTrack(world, x + 11, y + 1, z + 10, BlockIDs.tcRailGag.block, l); + tileGag[29] = (TileTCRailGag) world.getTileEntity(x + 11, y + 1, z + 10); + tileGag[29].canPlaceRollingstock = false; + placeTrack(world, x + 11, y + 1, z + 12, BlockIDs.tcRailGag.block, l); + tileGag[30] = (TileTCRailGag) world.getTileEntity(x + 11, y + 1, z + 12); + tileGag[30].canPlaceRollingstock = false; + placeTrack(world, x + 12, y + 1, z + 11, BlockIDs.tcRailGag.block, l); + tileGag[31] = (TileTCRailGag) world.getTileEntity(x + 12, y + 1, z + 11); + tileGag[31].canPlaceRollingstock = false; + } + + } + + if (l == 5) { + + if (!canPlaceTrack(player, world, x, y + 1, z - 1) || !canPlaceTrack(player, world, x - 1, y + 1, z) + || !canPlaceTrack(player, world, x - 1, y + 1, z - 1) || !canPlaceTrack(player, world, x - 1, y + 1, z - 2) || !canPlaceTrack(player, world, x - 2, y + 1, z - 1) + || !canPlaceTrack(player, world, x - 2, y + 1, z - 2) || !canPlaceTrack(player, world, x - 2, y + 1, z - 3) || !canPlaceTrack(player, world, x - 3, y + 1, z - 2)) { + return false; + } + if (type == TrackTypes.LONG_DIAGONAL_STRAIGHT || type == TrackTypes.EMBEDDED_LONG_DIAGONAL_STRAIGHT) { + if (!canPlaceTrack(player, world, x - 3, y + 1, z - 3) || !canPlaceTrack(player, world, x - 3, y + 1, z - 4) || !canPlaceTrack(player, world, x - 4, y + 1, z - 3) + || !canPlaceTrack(player, world, x - 4, y + 1, z - 4) || !canPlaceTrack(player, world, x - 4, y + 1, z - 5) || !canPlaceTrack(player, world, x - 5, y + 1, z - 4) + || !canPlaceTrack(player, world, x - 5, y + 1, z - 5) || !canPlaceTrack(player, world, x - 5, y + 1, z - 6) || !canPlaceTrack(player, world, x - 6, y + 1, z - 5)) { + return false; + } + } + if (type == TrackTypes.VERY_LONG_DIAGONAL_STRAIGHT || type == TrackTypes.EMBEDDED_VERY_LONG_DIAGONAL_STRAIGHT) { + if (!canPlaceTrack(player, world, x - 3, y + 1, z - 3) || !canPlaceTrack(player, world, x - 3, y + 1, z - 4) || !canPlaceTrack(player, world, x - 4, y + 1, z - 3) + || !canPlaceTrack(player, world, x - 4, y + 1, z - 4) || !canPlaceTrack(player, world, x - 4, y + 1, z - 5) || !canPlaceTrack(player, world, x - 5, y + 1, z - 4) + || !canPlaceTrack(player, world, x - 5, y + 1, z - 5) || !canPlaceTrack(player, world, x - 5, y + 1, z - 6) || !canPlaceTrack(player, world, x - 6, y + 1, z - 5) + || !canPlaceTrack(player, world, x - 6, y + 1, z - 6) || !canPlaceTrack(player, world, x - 6, y + 1, z - 7) || !canPlaceTrack(player, world, x - 7, y + 1, z - 6) + || !canPlaceTrack(player, world, x - 7, y + 1, z - 7) || !canPlaceTrack(player, world, x - 7, y + 1, z - 8) || !canPlaceTrack(player, world, x - 8, y + 1, z - 7) + || !canPlaceTrack(player, world, x - 8, y + 1, z - 8) || !canPlaceTrack(player, world, x - 8, y + 1, z - 9) || !canPlaceTrack(player, world, x - 9, y + 1, z - 8) + || !canPlaceTrack(player, world, x - 9, y + 1, z - 9) || !canPlaceTrack(player, world, x - 9, y + 1, z - 10) || !canPlaceTrack(player, world, x - 10, y + 1, z - 9) + || !canPlaceTrack(player, world, x - 10, y + 1, z - 10) || !canPlaceTrack(player, world, x - 10, y + 1, z - 11) || !canPlaceTrack(player, world, x - 11, y + 1, z - 10) + || !canPlaceTrack(player, world, x - 11, y + 1, z - 11) || !canPlaceTrack(player, world, x - 11, y + 1, z - 12) || !canPlaceTrack(player, world, x - 12, y + 1, z - 11)) { + return false; + } + } + placeTrack(world, x, y + 1, z, BlockIDs.tcRail.block, l); + TileTCRail tcRail = (TileTCRail) world.getTileEntity(x, y + 1, z); + tcRail.setFacing(l); + tcRail.setType(type.getLabel()); + tcRail.setRailLength(3D); + + placeTrack(world, x - 1, y + 1, z - 1, BlockIDs.tcRailGag.block, l); + tileGag[0] = (TileTCRailGag) world.getTileEntity(x - 1, y + 1, z - 1); + + placeTrack(world, x - 2, y + 1, z - 2, BlockIDs.tcRailGag.block, l); + tileGag[1] = (TileTCRailGag) world.getTileEntity(x - 2, y + 1, z - 2); + + placeTrack(world, x, y + 1, z - 1, BlockIDs.tcRailGag.block, l); + tileGag[2] = (TileTCRailGag) world.getTileEntity(x, y + 1, z - 1); + tileGag[2].canPlaceRollingstock = false; + placeTrack(world, x - 1, y + 1, z, BlockIDs.tcRailGag.block, l); + tileGag[3] = (TileTCRailGag) world.getTileEntity(x - 1, y + 1, z); + tileGag[3].canPlaceRollingstock = false; + placeTrack(world, x - 1, y + 1, z - 2, BlockIDs.tcRailGag.block, l); + tileGag[4] = (TileTCRailGag) world.getTileEntity(x - 1, y + 1, z - 2); + tileGag[4].canPlaceRollingstock = false; + placeTrack(world, x - 2, y + 1, z - 1, BlockIDs.tcRailGag.block, l); + tileGag[5] = (TileTCRailGag) world.getTileEntity(x - 2, y + 1, z - 1); + tileGag[5].canPlaceRollingstock = false; + placeTrack(world, x - 2, y + 1, z - 3, BlockIDs.tcRailGag.block, l); + tileGag[6] = (TileTCRailGag) world.getTileEntity(x - 2, y + 1, z - 3); + tileGag[6].canPlaceRollingstock = false; + placeTrack(world, x - 3, y + 1, z - 2, BlockIDs.tcRailGag.block, l); + tileGag[7] = (TileTCRailGag) world.getTileEntity(x - 3, y + 1, z - 2); + tileGag[7].canPlaceRollingstock = false; + if (type == TrackTypes.LONG_DIAGONAL_STRAIGHT || type == TrackTypes.EMBEDDED_LONG_DIAGONAL_STRAIGHT) { + tcRail.idDrop = this.type.getItem().item; + } else { + tcRail.idDrop = this.type.getItem().item; + } + + + if (type == TrackTypes.LONG_DIAGONAL_STRAIGHT || type == TrackTypes.VERY_LONG_DIAGONAL_STRAIGHT || type == TrackTypes.EMBEDDED_LONG_DIAGONAL_STRAIGHT || type == TrackTypes.EMBEDDED_VERY_LONG_DIAGONAL_STRAIGHT) { + placeTrack(world, x - 3, y + 1, z - 3, BlockIDs.tcRail.block, l); + TileTCRail tcRail2 = (TileTCRail) world.getTileEntity(x - 3, y + 1, z - 3); + tcRail2.setFacing(l); + tcRail2.setType(type.getLabel()); + tcRail2.isLinkedToRail = true; + tcRail2.linkedX = x - 1; + tcRail2.linkedY = y + 1; + tcRail2.linkedZ = z - 1; + tcRail.setRailLength(6D); + tcRail2.setRailLength(3D); + + placeTrack(world, x - 4, y + 1, z - 4, BlockIDs.tcRailGag.block, l); + tileGag[8] = (TileTCRailGag) world.getTileEntity(x - 4, y + 1, z - 4); + + placeTrack(world, x - 5, y + 1, z - 5, BlockIDs.tcRailGag.block, l); + tileGag[9] = (TileTCRailGag) world.getTileEntity(x - 5, y + 1, z - 5); + + placeTrack(world, x - 3, y + 1, z - 4, BlockIDs.tcRailGag.block, l); + tileGag[10] = (TileTCRailGag) world.getTileEntity(x - 3, y + 1, z - 4); + tileGag[10].canPlaceRollingstock = false; + placeTrack(world, x - 4, y + 1, z - 3, BlockIDs.tcRailGag.block, l); + tileGag[11] = (TileTCRailGag) world.getTileEntity(x - 4, y + 1, z - 3); + tileGag[11].canPlaceRollingstock = false; + placeTrack(world, x - 5, y + 1, z - 4, BlockIDs.tcRailGag.block, l); + tileGag[12] = (TileTCRailGag) world.getTileEntity(x - 5, y + 1, z - 4); + tileGag[12].canPlaceRollingstock = false; + placeTrack(world, x - 4, y + 1, z - 5, BlockIDs.tcRailGag.block, l); + tileGag[13] = (TileTCRailGag) world.getTileEntity(x - 4, y + 1, z - 5); + tileGag[13].canPlaceRollingstock = false; + placeTrack(world, x - 6, y + 1, z - 5, BlockIDs.tcRailGag.block, l); + tileGag[14] = (TileTCRailGag) world.getTileEntity(x - 6, y + 1, z - 5); + tileGag[14].canPlaceRollingstock = false; + placeTrack(world, x - 5, y + 1, z - 6, BlockIDs.tcRailGag.block, l); + tileGag[15] = (TileTCRailGag) world.getTileEntity(x - 5, y + 1, z - 6); + tileGag[15].canPlaceRollingstock = false; + if (type == TrackTypes.VERY_LONG_DIAGONAL_STRAIGHT) { + tcRail.idDrop = this.type.getItem().item; + } else { + tcRail.idDrop = this.type.getItem().item; + } + } + if (type == TrackTypes.VERY_LONG_DIAGONAL_STRAIGHT || type == TrackTypes.EMBEDDED_VERY_LONG_DIAGONAL_STRAIGHT) { + + placeTrack(world, x - 6, y + 1, z - 6, BlockIDs.tcRail.block, l); + TileTCRail tcRail3 = (TileTCRail) world.getTileEntity(x - 6, y + 1, z - 6); + tcRail3.setFacing(l); + tcRail3.setType(type.getLabel()); + tcRail3.isLinkedToRail = true; + tcRail3.linkedX = x - 1; + tcRail3.linkedY = y + 1; + tcRail3.linkedZ = z - 1; + tcRail.setRailLength(12D); + tcRail3.setRailLength(3D); + + placeTrack(world, x - 7, y + 1, z - 7, BlockIDs.tcRailGag.block, l); + tileGag[16] = (TileTCRailGag) world.getTileEntity(x - 7, y + 1, z - 7); + + placeTrack(world, x - 8, y + 1, z - 8, BlockIDs.tcRailGag.block, l); + tileGag[17] = (TileTCRailGag) world.getTileEntity(x - 8, y + 1, z - 8); + + placeTrack(world, x - 6, y + 1, z - 7, BlockIDs.tcRailGag.block, l); + tileGag[18] = (TileTCRailGag) world.getTileEntity(x - 6, y + 1, z - 7); + tileGag[18].canPlaceRollingstock = false; + placeTrack(world, x - 7, y + 1, z - 6, BlockIDs.tcRailGag.block, l); + tileGag[19] = (TileTCRailGag) world.getTileEntity(x - 7, y + 1, z - 6); + tileGag[19].canPlaceRollingstock = false; + placeTrack(world, x - 7, y + 1, z - 8, BlockIDs.tcRailGag.block, l); + tileGag[20] = (TileTCRailGag) world.getTileEntity(x - 7, y + 1, z - 8); + tileGag[20].canPlaceRollingstock = false; + placeTrack(world, x - 8, y + 1, z - 7, BlockIDs.tcRailGag.block, l); + tileGag[21] = (TileTCRailGag) world.getTileEntity(x - 8, y + 1, z - 7); + tileGag[21].canPlaceRollingstock = false; + placeTrack(world, x - 8, y + 1, z - 9, BlockIDs.tcRailGag.block, l); + tileGag[22] = (TileTCRailGag) world.getTileEntity(x - 8, y + 1, z - 9); + tileGag[22].canPlaceRollingstock = false; + placeTrack(world, x - 9, y + 1, z - 8, BlockIDs.tcRailGag.block, l); + tileGag[23] = (TileTCRailGag) world.getTileEntity(x - 9, y + 1, z - 8); + tileGag[23].canPlaceRollingstock = false; + placeTrack(world, x - 9, y + 1, z - 9, BlockIDs.tcRail.block, l); + TileTCRail tcRail4 = (TileTCRail) world.getTileEntity(x - 9, y + 1, z - 9); + tcRail4.setFacing(l); + tcRail4.setType(type.getLabel()); + tcRail4.isLinkedToRail = true; + tcRail4.linkedX = x - 1; + tcRail4.linkedY = y + 1; + tcRail4.linkedZ = z - 1; + tcRail4.setRailLength(3D); + + + placeTrack(world, x - 10, y + 1, z - 10, BlockIDs.tcRailGag.block, l); + tileGag[24] = (TileTCRailGag) world.getTileEntity(x - 10, y + 1, z - 10); + + placeTrack(world, x - 11, y + 1, z - 11, BlockIDs.tcRailGag.block, l); + tileGag[25] = (TileTCRailGag) world.getTileEntity(x - 11, y + 1, z - 11); + + placeTrack(world, x - 9, y + 1, z - 10, BlockIDs.tcRailGag.block, l); + tileGag[26] = (TileTCRailGag) world.getTileEntity(x - 9, y + 1, z - 10); + tileGag[26].canPlaceRollingstock = false; + placeTrack(world, x - 10, y + 1, z - 9, BlockIDs.tcRailGag.block, l); + tileGag[27] = (TileTCRailGag) world.getTileEntity(x - 10, y + 1, z - 9); + tileGag[27].canPlaceRollingstock = false; + placeTrack(world, x - 10, y + 1, z - 11, BlockIDs.tcRailGag.block, l); + tileGag[28] = (TileTCRailGag) world.getTileEntity(x - 10, y + 1, z - 11); + tileGag[28].canPlaceRollingstock = false; + placeTrack(world, x - 11, y + 1, z - 10, BlockIDs.tcRailGag.block, l); + tileGag[29] = (TileTCRailGag) world.getTileEntity(x - 11, y + 1, z - 10); + tileGag[29].canPlaceRollingstock = false; + placeTrack(world, x - 11, y + 1, z - 12, BlockIDs.tcRailGag.block, l); + tileGag[30] = (TileTCRailGag) world.getTileEntity(x - 11, y + 1, z - 12); + tileGag[30].canPlaceRollingstock = false; + placeTrack(world, x - 12, y + 1, z - 11, BlockIDs.tcRailGag.block, l); + tileGag[31] = (TileTCRailGag) world.getTileEntity(x - 12, y + 1, z - 11); + tileGag[31].canPlaceRollingstock = false; + + } + + } + + for (TileTCRailGag tileTCRailGag : tileGag) { + if (player != null && tileTCRailGag == null) { + player.addChatMessage(new ChatComponentText("There was a problem when placing the track. Possibly too many tracks around")); + return false; + } + tileTCRailGag.originX = x; + tileTCRailGag.originY = y + 1; + tileTCRailGag.originZ = z; + tileTCRailGag.type = type.getLabel(); + + } + + return true; + } + + private boolean mediumRightTurn(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes tempType) { + + int[] xArray = {0, 0, 1, 1, 2}; + int[] zArray = {0, 1, 1, 2, 2}; + + if (l == 2) { + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, false), flipArraySign(zArray, z, true), l, false, 1, x + 3, z - 3, 2.5, x + 3, + y + 1, z + 1, tempType.getLabel(), tempType.getItem().item)) + return false; + } + if (l == 0) { + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, true), flipArraySign(zArray, z, false), l, false, 1, x - 3, z + 3, 2.5, x - 2, + y + 1, z, tempType.getLabel(), tempType.getItem().item)) + return false; + } + if (l == 1) { + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, true), flipArraySign(xArray, z, true), l, false, 2, x - 3, z - 3, 2.5, x + 1, + y + 1, z - 2, tempType.getLabel(), tempType.getItem().item)) + return false; + } + if (l == 3) { + return putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, false), flipArraySign(xArray, z, false), l, false, 0, x + 3, z + 3, 2.5, x, y + 1, + z + 3, tempType.getLabel(), tempType.getItem().item); + } + return true; + } + + private boolean mediumLeftTurn(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes tempType) { + + int[] xArray = {0, 0, 1, 1, 2}; + int[] zArray = {0, 1, 1, 2, 2}; + + if (l == 2) { + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, true), flipArraySign(zArray, z, true), l, false, 1, x - 3, z - 3, 2.5, x - 2, + y + 1, z + 1, tempType.getLabel(), tempType.getItem().item)) + return false; + } + if (l == 0) { + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, false), flipArraySign(zArray, z, false), l, false, 3, x + 3, z + 3, 2.5, x + 3, + y + 1, z, tempType.getLabel(), tempType.getItem().item)) + return false; + } + if (l == 1) { + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, true), flipArraySign(xArray, z, false), l, false, 0, x - 3, z + 3, 2.5, x + 1, + y + 1, z + 3, tempType.getLabel(), tempType.getItem().item)) + return false; + } + if (l == 3) { + return putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, false), flipArraySign(xArray, z, true), l, false, 2, x + 3, z - 3, 2.5, x, y + 1, + z - 2, tempType.getLabel(), tempType.getItem().item); + } + return true; + } + + private boolean largeRightTurn(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes tempType) { + + int[] xArray = {0, 0, 1, 1, 2, 0, 1, 2, 3, 4, 3, 2}; + int[] zArray = {0, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4}; + + if (l == 2) { + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, false), flipArraySign(zArray, z, true), l, false, 1, x + 5, z - 5, 4.5, x + 5, + y + 1, z + 1, tempType.getLabel(), tempType.getItem().item)) + return false; + } + if (l == 0) { + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, true), flipArraySign(zArray, z, false), l, false, 1, x - 5, z + 5, 4.5, x - 4, + y + 1, z, tempType.getLabel(), tempType.getItem().item)) + return false; + } + if (l == 1) { + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, true), flipArraySign(xArray, z, true), l, false, 2, x - 5, z - 5, 4.5, x + 1, + y + 1, z - 4, tempType.getLabel(), tempType.getItem().item)) + return false; + } + if (l == 3) { + return putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, false), flipArraySign(xArray, z, false), l, false, 0, x + 5, z + 5, 4.5, x, y + 1, + z + 5, tempType.getLabel(), tempType.getItem().item); + } + return true; + } + + private boolean largeLeftTurn(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes tempType) { + int[] xArray = {0, 0, 1, 1, 2, 0, 1, 2, 3, 4, 3, 2}; + int[] zArray = {0, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4}; + if (l == 2) { + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, true), flipArraySign(zArray, z, true), l, false, 1, x - 5, z - 5, 4.5, x - 4, + y + 1, z + 1, tempType.getLabel(), tempType.getItem().item)) + return false; + } + if (l == 0) { + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, false), flipArraySign(zArray, z, false), l, false, 1, x + 5, z + 5, 4.5, x + 5, + y + 1, z, tempType.getLabel(), tempType.getItem().item)) + return false; + } + if (l == 1) { + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, true), flipArraySign(xArray, z, false), l, false, 2, x - 5, z + 5, 4.5, x + 1, + y + 1, z + 5, tempType.getLabel(), tempType.getItem().item)) + return false; + } + if (l == 3) { + return putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, false), flipArraySign(xArray, z, true), l, false, 0, x + 5, z - 5, 4.5, x, y + 1, + z - 4, tempType.getLabel(), tempType.getItem().item); + } + return true; + } + + private boolean veryLargeRightTurn(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes tempType) { + int[] xArray = {0, 0, 0, 1, 0, 1, 0, 1, 1, 2, 2, 2, 3, 3, 4, 4, 5, 5, 5, 6, 6, 7, 7, 8, 9}; + int[] zArray = {0, 1, 2, 2, 3, 3, 4, 4, 5, 4, 5, 6, 6, 7, 7, 8, 7, 8, 9, 8, 9, 8, 9, 9, 9}; + + if (l == 2) { + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, false), flipArraySign(zArray, z, true), l, false, 1, x + 10, z - 10, 9.5, x + 10, + y + 1, z + 1, tempType.getLabel(), tempType.getItem().item)) + return false; + } + if (l == 0) { + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, true), flipArraySign(zArray, z, false), l, false, 1, x - 10, z + 10, 9.5, x - 9, + y + 1, z, tempType.getLabel(), tempType.getItem().item)) + return false; + } + if (l == 1) { + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, true), flipArraySign(xArray, z, true), l, false, 2, x - 10, z - 10, 9.5, x + 1, + y + 1, z - 9, tempType.getLabel(), tempType.getItem().item)) + return false; + } + if (l == 3) { + return putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, false), flipArraySign(xArray, z, false), l, false, 0, x + 10, z + 10, 9.5, x, y + 1, + z + 10, tempType.getLabel(), tempType.getItem().item); + } + return true; + } + + private boolean veryLargeLeftTurn(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes tempType) { + int[] xArray = {0, 0, 0, 1, 0, 1, 0, 1, 1, 2, 2, 2, 3, 3, 4, 4, 5, 5, 5, 6, 6, 7, 7, 8, 9}; + int[] zArray = {0, 1, 2, 2, 3, 3, 4, 4, 5, 4, 5, 6, 6, 7, 7, 8, 7, 8, 9, 8, 9, 8, 9, 9, 9}; + + if (l == 2) { + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, true), flipArraySign(zArray, z, true), l, false, 1, x - 10, z - 10, 9.5, x - 9, + y + 1, z + 1, tempType.getLabel(), tempType.getItem().item)) + return false; + } + if (l == 0) { + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, false), flipArraySign(zArray, z, false), l, false, 1, x + 10, z + 10, 9.5, x + 10, + y + 1, z, tempType.getLabel(), tempType.getItem().item)) + return false; + } + if (l == 1) { + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, true), flipArraySign(xArray, z, false), l, false, 2, x - 10, z + 10, 9.5, x + 1, + y + 1, z + 10, tempType.getLabel(), tempType.getItem().item)) + return false; + } + if (l == 3) { + return putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, false), flipArraySign(xArray, z, true), l, false, 0, x + 10, z - 10, 9.5, x, y + 1, + z - 9, tempType.getLabel(), tempType.getItem().item); + } + return true; + } + + private boolean superLargeRightTurn(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes tempType) { + int[] xArray = {0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 9, 9, 10, 11, 11, 12, 12, 13, 14, 15}; + int[] zArray = {0, 1, 2, 3, 4, 3, 4, 5, 6, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 13, 14, 14, 14, 15, 14, 15, 15, 15, 15}; + + if (l == 2) { + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, false), flipArraySign(zArray, z, true), l, false, 1, x + 16, z - 16, 15.5, x + 16, + y + 1, z + 1, tempType.getLabel(), tempType.getItem().item)) + return false; + } + if (l == 0) { + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, true), flipArraySign(zArray, z, false), l, false, 1, x - 15, z + 15, 15.5, x - 15, + y + 1, z, tempType.getLabel(), tempType.getItem().item)) + return false; + } + if (l == 1) { + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, true), flipArraySign(xArray, z, true), l, false, 2, x - 15, z - 15, 15.5, x + 1, + y + 1, z - 15, tempType.getLabel(), tempType.getItem().item)) + return false; + } + if (l == 3) { + return putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, false), flipArraySign(xArray, z, false), l, false, 2, x + 15, z + 15, 15.5, x, y + 1, + z + 16, tempType.getLabel(), tempType.getItem().item); + } + return true; + } + + private boolean superLargeLeftTurn(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes tempType) { + int[] xArray = {0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 9, 9, 10, 11, 11, 12, 12, 13, 14, 15}; + int[] zArray = {0, 1, 2, 3, 4, 3, 4, 5, 6, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 13, 14, 14, 14, 15, 14, 15, 15, 15, 15}; + if (l == 2) { + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, true), flipArraySign(zArray, z, true), l, false, 1, x - 15, z + 15, 15.5, x - 15, + y + 1, z + 1, tempType.getLabel(), tempType.getItem().item)) + return false; + } + if (l == 0) { + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, false), flipArraySign(zArray, z, false), l, false, 1, x + 15, z + 15, 15.5, x + 16, + y + 1, z, tempType.getLabel(), tempType.getItem().item)) + return false; + } + if (l == 1) { + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, true), flipArraySign(xArray, z, false), l, false, 2, x - 15, z + 15, 15.5, x + 1, + y + 1, z + 16, tempType.getLabel(), tempType.getItem().item)) + return false; + } + if (l == 3) { + return putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, false), flipArraySign(xArray, z, true), l, false, 0, x + 15, z - 15, 15.5, x, y + 1, + z - 15, tempType.getLabel(), tempType.getItem().item); + } + return true; + } + + private boolean mediumRight45DegreeTurn(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes tempType) { + + int[] xArray; + int[] zArray; + if (player.isSneaking()) { + xArray = new int[]{0, 0, 0, 1, 1}; + zArray = new int[]{0, 1, 2, 1, 2}; + } else { + xArray = new int[]{0, 0, 0, 1, 1, 1, 2}; + zArray = new int[]{0, 1, 2, 1, 2, 3, 2}; + } + if (l == 2) { + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, false), flipArraySign(zArray, z, true), l, false, 3, x + 1, z - 2, 3.75, x + 4.25, + y + 1, z + 1, tempType.getLabel(), tempType.getItem().item)) + return false; + } + if (l == 0) { + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, true), flipArraySign(zArray, z, false), l, false, 1, x - 1, z + 2, 3.75, x - 3.25, + y + 1, z, tempType.getLabel(), tempType.getItem().item)) + return false; + } + if (l == 1) { + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, true), flipArraySign(xArray, z, true), l, false, 2, x - 2, z - 1, 3.75, x + 1, + y + 1, z - 3.25, tempType.getLabel(), tempType.getItem().item)) + return false; + } + if (l == 3) { + return putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, false), flipArraySign(xArray, z, false), l, false, 0, x + 2, z + 1, 3.75, x, y + 1, + z + 4.25, tempType.getLabel(), tempType.getItem().item); + } + return true; + } + + private boolean mediumLeft45DegreeTurn(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes tempType) { + + int[] xArray; + int[] zArray; + if (player.isSneaking()) { + xArray = new int[]{0, 0, 0, 1, 1}; + zArray = new int[]{0, 1, 2, 1, 2}; + } else { + xArray = new int[]{0, 0, 0, 1, 1, 1, 2}; + zArray = new int[]{0, 1, 2, 1, 2, 3, 2}; + } + + if (l == 2) { + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, true), flipArraySign(zArray, z, true), l, false, 1, x - 1, z - 2, 3.75, x - 3.25, + y + 1, z + 1, tempType.getLabel(), tempType.getItem().item)) + return false; + } + if (l == 0) { + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, false), flipArraySign(zArray, z, false), l, false, 3, x + 1, z + 2, 3.75, x + 4.25, + y + 1, z, tempType.getLabel(), tempType.getItem().item)) + return false; + } + if (l == 1) { + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, true), flipArraySign(xArray, z, false), l, false, 0, x - 2, z + 1, 3.75, x + 1, + y + 1, z + 4.25, tempType.getLabel(), tempType.getItem().item)) + return false; + } + if (l == 3) { + return putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, false), flipArraySign(xArray, z, true), l, false, 2, x + 2, z - 1, 3.75, x, y + 1, + z - 3.25, tempType.getLabel(), tempType.getItem().item); + } + return true; + } + + private boolean largeRight45DegreeTurn(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes tempType) { + int[] xArray; + int[] zArray; + if (player.isSneaking()) { + xArray = new int[]{0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2}; + zArray = new int[]{0, 1, 2, 3, 1, 2, 3, 4, 5, 4, 5}; + } else { + xArray = new int[]{0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 3}; + zArray = new int[]{0, 1, 2, 3, 1, 2, 3, 4, 5, 4, 5, 6, 5}; + } + if (l == 2) { + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, false), flipArraySign(zArray, z, true), l, false, 3, x + 2, z - 5, 8.49, x + 8.99, + y + 1, z + 1, tempType.getLabel(), tempType.getItem().item)) + return false; + } + if (l == 0) { + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, true), flipArraySign(zArray, z, false), l, false, 1, x - 2, z + 5, 8.49, x - 7.99, + y + 1, z, tempType.getLabel(), tempType.getItem().item)) + return false; + } + if (l == 1) { + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, true), flipArraySign(xArray, z, true), l, false, 2, x - 5, z - 2, 8.49, x + 1, + y + 1, z - 7.99, tempType.getLabel(), tempType.getItem().item)) + return false; + } + if (l == 3) { + return putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, false), flipArraySign(xArray, z, false), l, false, 0, x + 5, z + 2, 8.49, x, + y + 1, z + 8.99, tempType.getLabel(), tempType.getItem().item); + } + return true; + } + + private boolean largeLeft45DegreeTurn(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes tempType) { + int[] xArray; + int[] zArray; + if (player.isSneaking()) { + xArray = new int[]{0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2}; + zArray = new int[]{0, 1, 2, 3, 1, 2, 3, 4, 5, 4, 5}; + } else { + xArray = new int[]{0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 3}; + zArray = new int[]{0, 1, 2, 3, 1, 2, 3, 4, 5, 4, 5, 6, 5}; + } + if (l == 2) { + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, true), flipArraySign(zArray, z, true), l, false, 1, x - 2, z - 5, 8.49, x - 7.99, + y + 1, z + 1, tempType.getLabel(), tempType.getItem().item)) + return false; + } + if (l == 0) { + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, false), flipArraySign(zArray, z, false), l, false, 3, x + 2, z + 5, 8.49, x + 8.99, + y + 1, z, tempType.getLabel(), tempType.getItem().item)) + return false; + } + if (l == 1) { + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, true), flipArraySign(xArray, z, false), l, false, 0, x - 5, z + 2, 8.49, x + 1, + y + 1, z + 8.99, tempType.getLabel(), tempType.getItem().item)) + return false; + } + if (l == 3) { + return putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, false), flipArraySign(xArray, z, true), l, false, 2, x + 5, z - 2, 8.49, x, + y + 1, z - 7.99, tempType.getLabel(), tempType.getItem().item); + } + return true; + } + + public boolean veryLargeRight45DegreeTurn(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes tempType) { + int[] xArray; + int[] zArray; + if (player.isSneaking()) { + xArray = new int[]{0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3}; + zArray = new int[]{0, 1, 2, 3, 4, 1, 2, 3, 4, 5, 6, 4, 5, 6, 7, 6, 7}; + } else { + xArray = new int[]{0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 4}; + zArray = new int[]{0, 1, 2, 3, 4, 1, 2, 3, 4, 5, 6, 4, 5, 6, 7, 6, 7, 8, 7}; + + } + if (l == 2) { + + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, false), flipArraySign(zArray, z, true), l, false, 3, x + 3, z - 7, 10.89, x + 11.39, + y + 1, z + 1, tempType.getLabel(), tempType.getItem().item)) + return false; + } + + if (l == 0) { + + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, true), flipArraySign(zArray, z, false), l, false, 1, x - 3, z + 7, 10.89, x - 10.39, + y + 1, z, tempType.getLabel(), tempType.getItem().item)) + return false; + } + if (l == 1) { + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, true), flipArraySign(xArray, z, true), l, false, 2, x - 7, z - 3, 10.89, x + 1, + y + 1, z - 10.39, tempType.getLabel(), tempType.getItem().item)) + return false; + } + + if (l == 3) { + return putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, false), flipArraySign(xArray, z, false), l, false, 0, x + 7, z + 3, 10.89, x, + y + 1, z + 11.39, tempType.getLabel(), tempType.getItem().item); + } + return true; + } + + public boolean veryLargeLeft45DegreeTurn(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes tempType) { + int[] xArray; + int[] zArray; + if (player.isSneaking()) { + xArray = new int[]{0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3}; + zArray = new int[]{0, 1, 2, 3, 4, 1, 2, 3, 4, 5, 6, 4, 5, 6, 7, 6, 7}; + } else { + xArray = new int[]{0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 4}; + zArray = new int[]{0, 1, 2, 3, 4, 1, 2, 3, 4, 5, 6, 4, 5, 6, 7, 6, 7, 8, 7}; + } + if (l == 2) { + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, true), flipArraySign(zArray, z, true), l, false, 3, x + 3, z - 7, 10.89, x - 10.39, + y + 1, z + 1, tempType.getLabel(), tempType.getItem().item)) + return false; + } + if (l == 0) { + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, false), flipArraySign(zArray, z, false), l, false, 1, x - 3, z + 7, 10.89, x + 11.39, + y + 1, z, tempType.getLabel(), tempType.getItem().item)) + return false; + } + if (l == 1) { + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, true), flipArraySign(xArray, z, false), l, false, 2, x - 7, z - 3, 10.89, x + 1, + y + 1, z + 11.39, tempType.getLabel(), tempType.getItem().item)) + return false; + } + if (l == 3) { + return putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, false), flipArraySign(xArray, z, true), l, false, 0, x + 7, z + 3, 10.89, x, + y + 1, z - 10.39, tempType.getLabel(), tempType.getItem().item); + } + return true; + } + + public boolean superLargeRight45DegreeTurn(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes tempType) { + + int[] xArray; + int[] zArray; + if (player.isSneaking()) { + xArray = new int[]{0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4}; + zArray = new int[]{0, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, 7, 5, 6, 7, 8, 9, 7, 8, 9, 10, 9, 10}; + } else { + xArray = new int[]{0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 5}; + zArray = new int[]{0, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, 7, 5, 6, 7, 8, 9, 7, 8, 9, 10, 9, 10, 11, 10}; + } + + if (l == 2) { + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, false), flipArraySign(zArray, z, true), l, false, 3, x + 4, z - 11, 15.69, x + 16.19, + y + 1, z + 1, tempType.getLabel(), tempType.getItem().item)) + return false; + } + if (l == 0) { + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, true), flipArraySign(zArray, z, false), l, false, 1, x - 4, z + 11, 15.69, x - 15.19, + y + 1, z, tempType.getLabel(), tempType.getItem().item)) + return false; + } + if (l == 1) { + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, true), flipArraySign(xArray, z, true), l, false, 2, x - 11, z - 4, 15.69, x + 1, + y + 1, z - 15.19, tempType.getLabel(), tempType.getItem().item)) + return false; + } + if (l == 3) { + return putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, false), flipArraySign(xArray, z, false), l, false, 0, x + 11, z + 4, 15.69, x, + y + 1, z + 16.19, tempType.getLabel(), tempType.getItem().item); + } + return true; + } + + public boolean superLargeLeft45DegreeTurn(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes tempType) { + + int[] xArray; + int[] zArray; + if (player.isSneaking()) { + xArray = new int[]{0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4}; + zArray = new int[]{0, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, 7, 5, 6, 7, 8, 9, 7, 8, 9, 10, 9, 10}; + } else { + xArray = new int[]{0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 5}; + zArray = new int[]{0, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, 7, 5, 6, 7, 8, 9, 7, 8, 9, 10, 9, 10, 11, 10}; + } + if (l == 2) { + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, true), flipArraySign(zArray, z, true), l, false, 1, x - 4, z - 11, 15.69, x - 15.19, + y + 1, z + 1, tempType.getLabel(), tempType.getItem().item)) + return false; + } + + if (l == 0) { + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, false), flipArraySign(zArray, z, false), l, false, 3, x + 4, z + 11, 15.69, x + 16.19, + y + 1, z, tempType.getLabel(), tempType.getItem().item)) + return false; + } + if (l == 1) { + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, true), flipArraySign(xArray, z, false), l, false, 0, x - 11, z + 4, 15.69, x + 1, + y + 1, z + 16.19, tempType.getLabel(), tempType.getItem().item)) + return false; + } + + if (l == 3) { + return putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, false), flipArraySign(xArray, z, true), l, false, 2, x + 11, z - 4, 15.69, x, + y + 1, z - 15.19, tempType.getLabel(), tempType.getItem().item); + } + return true; + } + + public boolean largeRightCurvedSlope(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes tempType) { + + int[] xArray = {0, 0, 1, 0, 1, 1, 2, 2, 2, 3, 3, 4}; + int[] zArray = {0, 1, 1, 2, 2, 3, 2, 3, 4, 3, 4, 4}; + + if (l == 2) { + return putDownSlopedTurn(player, world, x, y, z, flipArraySign(xArray, x, false), flipArraySign(zArray, z, true), l, 4.5, x + 5, + y + 1, z + 1, 0.1558f, 6.3639, tempType.getLabel(), tempType.getItem().item) + ; + } + if (l == 0) { + return putDownSlopedTurn(player, world, x, y, z, flipArraySign(xArray, x, true), flipArraySign(zArray, z, false), l, 4.5, x - 4, + y + 1, z, 0.1558f, 6.3639, tempType.getLabel(), tempType.getItem().item); + } + if (l == 1) { + return putDownSlopedTurn(player, world, x, y, z, flipArraySign(zArray, x, true), flipArraySign(xArray, z, true), l, 4.5, x + 1, + y + 1, z - 4, 0.1558f, 6.3639, tempType.getLabel(), tempType.getItem().item); + } + if (l == 3) { + return putDownSlopedTurn(player, world, x, y, z, flipArraySign(zArray, x, false), flipArraySign(xArray, z, false), l, 4.5, x, + y + 1, z + 5, 0.1558f, 6.3639, tempType.getLabel(), tempType.getItem().item); + } + return true; + } + + public boolean largeLeftCurvedSlope(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes tempType) { + + int[] xArray = {0, 0, 1, 0, 1, 1, 2, 2, 2, 3, 3, 4}; + int[] zArray = {0, 1, 1, 2, 2, 3, 2, 3, 4, 3, 4, 4}; + + if (l == 2) { + return putDownSlopedTurn(player, world, x, y, z, flipArraySign(xArray, x, true), flipArraySign(zArray, z, true), l, 4.5, x - 4, + y + 1, z + 1, 0.1558f, 6.3639, tempType.getLabel(), tempType.getItem().item) + ; + } + if (l == 0) { + return putDownSlopedTurn(player, world, x, y, z, flipArraySign(xArray, x, false), flipArraySign(zArray, z, false), l, 4.5, x + 5, + y + 1, z, 0.1558f, 6.3639, tempType.getLabel(), tempType.getItem().item); + } + if (l == 1) { + return putDownSlopedTurn(player, world, x, y, z, flipArraySign(zArray, x, true), flipArraySign(xArray, z, false), l, 4.5, x + 1, + y + 1, z + 5, 0.1558f, 6.3639, tempType.getLabel(), tempType.getItem().item); + } + if (l == 3) { + return putDownSlopedTurn(player, world, x, y, z, flipArraySign(zArray, x, false), flipArraySign(xArray, z, true), l, 4.5, x, + y + 1, z - 4, 0.1558f, 6.3639, tempType.getLabel(), tempType.getItem().item); + } + return true; + } + + public boolean veryLargeRightCurvedSlope(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes tempType) { + int[] xArray = {0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 5, 5, 6, 6, 7, 8}; + int[] zArray = {0, 1, 2, 3, 4, 2, 3, 4, 5, 4, 5, 6, 5, 6, 7, 6, 7, 7, 8, 7, 8, 8, 8}; + + if (l == 2) { + return putDownSlopedTurn(player, world, x, y, z, flipArraySign(xArray, x, false), flipArraySign(zArray, z, true), l, 8.5, x + 9, + y + 1, z + 1, 0.083003f, 12.0208, tempType.getLabel(), tempType.getItem().item) + ; + } + if (l == 0) { + return putDownSlopedTurn(player, world, x, y, z, flipArraySign(xArray, x, true), flipArraySign(zArray, z, false), l, 8.5, x - 8, + y + 1, z, 0.083003f, 12.0208, tempType.getLabel(), tempType.getItem().item); + } + if (l == 1) { + return putDownSlopedTurn(player, world, x, y, z, flipArraySign(zArray, x, true), flipArraySign(xArray, z, true), l, 8.5, x + 1, + y + 1, z - 8, 0.083003f, 12.0208, tempType.getLabel(), tempType.getItem().item); + } + if (l == 3) { + return putDownSlopedTurn(player, world, x, y, z, flipArraySign(zArray, x, false), flipArraySign(xArray, z, false), l, 8.5, x, + y + 1, z + 9, 0.083003f, 12.0208, tempType.getLabel(), tempType.getItem().item); + } + return true; + } + + public boolean veryLargeLeftCurvedSlope(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes tempType) { + + int[] xArray = {0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 5, 5, 6, 6, 7, 8}; + int[] zArray = {0, 1, 2, 3, 4, 2, 3, 4, 5, 4, 5, 6, 5, 6, 7, 6, 7, 7, 8, 7, 8, 8, 8}; + + if (l == 2) { + return putDownSlopedTurn(player, world, x, y, z, flipArraySign(xArray, x, true), flipArraySign(zArray, z, true), l, 8.5, x - 8, + y + 1, z + 1, 0.083003f, 12.0208, tempType.getLabel(), tempType.getItem().item) + ; + } + if (l == 0) { + return putDownSlopedTurn(player, world, x, y, z, flipArraySign(xArray, x, false), flipArraySign(zArray, z, false), l, 8.5, x + 9, + y + 1, z, 0.083003f, 12.0208, tempType.getLabel(), tempType.getItem().item); + } + if (l == 1) { + return putDownSlopedTurn(player, world, x, y, z, flipArraySign(zArray, x, true), flipArraySign(xArray, z, false), l, 8.5, x + 1, + y + 1, z + 9, 0.083003f, 12.0208, tempType.getLabel(), tempType.getItem().item); + } + if (l == 3) { + return putDownSlopedTurn(player, world, x, y, z, flipArraySign(zArray, x, false), flipArraySign(xArray, z, true), l, 8.5, x, + y + 1, z - 8, 0.083003f, 12.0208, tempType.getLabel(), tempType.getItem().item); + } + return true; + } + + public boolean superLargeRightCurvedSlope(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes tempType) { + int[] xArray = {0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 8, 8, 8, 9, 9, 10, 10, 10, 11, 11, 12, 12, 13, 13, 14, 15}; + int[] zArray = {0, 1, 2, 3, 4, 5, 2, 3, 4, 5, 6, 7, 5, 6, 7, 8, 9, 8, 9, 10, 9, 10, 11, 10, 11, 12, 11, 12, 13, 12, 13, 12, 13, 14, 13, 14, 13, 14, 15, 14, 15, 14, 15, 14, 15, 15, 15}; + + if (l == 2) { + return putDownSlopedTurn(player, world, x, y, z, flipArraySign(xArray, x, false), flipArraySign(zArray, z, true), l, 15.5, x + 16, + y + 1, z + 1, 0.045589f, 21.9203, tempType.getLabel(), tempType.getItem().item) + ; + } + if (l == 0) { + return putDownSlopedTurn(player, world, x, y, z, flipArraySign(xArray, x, true), flipArraySign(zArray, z, false), l, 15.5, x - 15, + y + 1, z, 0.045589f, 21.9203, tempType.getLabel(), tempType.getItem().item); + } + if (l == 1) { + return putDownSlopedTurn(player, world, x, y, z, flipArraySign(zArray, x, true), flipArraySign(xArray, z, true), l, 15.5, x + 1, + y + 1, z - 15, 0.045589f, 21.9203, tempType.getLabel(), tempType.getItem().item); + } + if (l == 3) { + return putDownSlopedTurn(player, world, x, y, z, flipArraySign(zArray, x, false), flipArraySign(xArray, z, false), l, 15.5, x, + y + 1, z + 16, 0.045589f, 21.9203, tempType.getLabel(), tempType.getItem().item); + } + return true; + } + + public boolean superLargeLeftCurvedSlope(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes tempType) { + + int[] xArray = {0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 8, 8, 8, 9, 9, 10, 10, 10, 11, 11, 12, 12, 13, 13, 14, 15}; + int[] zArray = {0, 1, 2, 3, 4, 5, 2, 3, 4, 5, 6, 7, 5, 6, 7, 8, 9, 8, 9, 10, 9, 10, 11, 10, 11, 12, 11, 12, 13, 12, 13, 12, 13, 14, 13, 14, 13, 14, 15, 14, 15, 14, 15, 14, 15, 15, 15}; + + if (l == 2) { + return putDownSlopedTurn(player, world, x, y, z, flipArraySign(xArray, x, true), flipArraySign(zArray, z, true), l, 15.5, x - 15, + y + 1, z + 1, 0.045589f, 21.9203, tempType.getLabel(), tempType.getItem().item); + } + if (l == 0) { + return putDownSlopedTurn(player, world, x, y, z, flipArraySign(xArray, x, false), flipArraySign(zArray, z, false), l, 15.5, x + 16, + y + 1, z, 0.045589f, 21.9203, tempType.getLabel(), tempType.getItem().item); + } + if (l == 1) { + return putDownSlopedTurn(player, world, x, y, z, flipArraySign(zArray, x, true), flipArraySign(xArray, z, false), l, 15.5, x + 1, + y + 1, z + 16, 0.045589f, 21.9203, tempType.getLabel(), tempType.getItem().item); + } + if (l == 3) { + return putDownSlopedTurn(player, world, x, y, z, flipArraySign(zArray, x, false), flipArraySign(xArray, z, true), l, 15.5, x, + y + 1, z - 15, 0.045589f, 21.9203, tempType.getLabel(), tempType.getItem().item); + } + return true; + } + + public boolean smallRightParallelCurve(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes tempType) { + + int[] xArray = {0, 0, 0, 0, 0, 0}; + int[] zArray = {0, 1, 2, 3, 4, 5}; + int[] xArray2 = {1, 1, 1, 1, 1, 1}; + int[] zArray2 = {7, 3, 4, 2, 6, 5}; + + + if (l == 2) { + + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, false), flipArraySign(zArray, z, true), l, false, 2, x + 1, z - 7, 16.25, x + 16.75, + y + 1, z + 1, tempType.getLabel(), tempType.getItem().item)) + return false; + TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x, y + 1, z); + + if (tcRailTurn != null) { + tcRailTurn.hasModel = true; + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray2, x, false), flipArraySign(zArray2, z, true), 3, false, 2, x + 1, z - 7, 16.25, x - 14.75, + y + 1, z - 7, TrackTypes.MEDIUM_LEFT_TURN.getLabel(), null)) + return false; + + TileTCRail tcRailTurn2 = (TileTCRail) world.getTileEntity(x + 1, y + 1, z - 7); + + if (tcRailTurn2 != null) { + tcRailTurn2.hasModel = false; + tcRailTurn2.isLinkedToRail = true; + tcRailTurn2.linkedX = x; + tcRailTurn2.linkedY = y + 1; + tcRailTurn2.linkedZ = z; + } + tcRailTurn.isLinkedToRail = true; + tcRailTurn.linkedX = x + 1; + tcRailTurn.linkedY = y + 1; + tcRailTurn.linkedZ = z - 7; + } + return true; + } + if (l == 0) { + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, true), flipArraySign(zArray, z, false), l, false, 0, x - 1, z + 8, 16.25, x - 15.75, + y + 1, z, tempType.getLabel(), tempType.getItem().item)) + return false; + TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x, y + 1, z); + if (tcRailTurn != null) { + tcRailTurn.hasModel = true; + + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray2, x, true), flipArraySign(zArray2, z, false), 1, false, 0, x - 1, z + 8, 16.25, x + 15.75, + y + 1, z + 8, TrackTypes.MEDIUM_LEFT_TURN.getLabel(), null)) + return false; + TileTCRail tcRailTurn2 = (TileTCRail) world.getTileEntity(x - 1, y + 1, z + 7); + + if (tcRailTurn2 != null) { + tcRailTurn2.hasModel = false; + tcRailTurn2.isLinkedToRail = true; + tcRailTurn2.linkedX = x; + tcRailTurn2.linkedY = y + 1; + tcRailTurn2.linkedZ = z; + } + tcRailTurn.isLinkedToRail = true; + tcRailTurn.linkedX = x - 1; + tcRailTurn.linkedY = y + 1; + tcRailTurn.linkedZ = z + 7; + } + return true; + } + + if (l == 1) { + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, true), flipArraySign(xArray, z, true), l, false, 1, x - 7, z - 1, 16.25, x + 1, + y + 1, z - 15.75, tempType.getLabel(), tempType.getItem().item)) + return false; + TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x, y + 1, z); + + if (tcRailTurn != null) { + tcRailTurn.hasModel = true; + + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray2, x, true), flipArraySign(xArray2, z, true), 2, false, 1, x - 7, z - 1, 16.25, x - 7, + y + 1, z + 15.75, TrackTypes.MEDIUM_LEFT_TURN.getLabel(), null)) + return false; + + TileTCRail tcRailTurn2 = (TileTCRail) world.getTileEntity(x - 7, y + 1, z - 1); + + if (tcRailTurn2 != null) { + tcRailTurn2.hasModel = false; + tcRailTurn2.isLinkedToRail = true; + tcRailTurn2.linkedX = x; + tcRailTurn2.linkedY = y + 1; + tcRailTurn2.linkedZ = z; + } + tcRailTurn.isLinkedToRail = true; + tcRailTurn.linkedX = x - 7; + tcRailTurn.linkedY = y + 1; + tcRailTurn.linkedZ = z - 1; + } + return true; + } + + if (l == 3) { + + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, false), flipArraySign(xArray, z, false), l, false, 3, x + 7, z + 1, 16.25, x, + y + 1, z + 16.75, tempType.getLabel(), tempType.getItem().item)) + return false; + TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x, y + 1, z); + + if (tcRailTurn != null) { + tcRailTurn.hasModel = true; + + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray2, x, false), flipArraySign(xArray2, z, false), 0, false, 3, x + 7, z + 1, 16.25, x + 8, + y + 1, z - 14.75, TrackTypes.MEDIUM_LEFT_TURN.getLabel(), null)) + return false; + + TileTCRail tcRailTurn2 = (TileTCRail) world.getTileEntity(x + 7, y + 1, z + 1); + + if (tcRailTurn2 != null) { + tcRailTurn2.hasModel = false; + tcRailTurn2.isLinkedToRail = true; + tcRailTurn2.linkedX = x; + tcRailTurn2.linkedY = y + 1; + tcRailTurn2.linkedZ = z; + } + tcRailTurn.isLinkedToRail = true; + tcRailTurn.linkedX = x + 7; + tcRailTurn.linkedY = y + 1; + tcRailTurn.linkedZ = z + 1; + } + return true; + } + return true; + } + + public boolean smallLeftParallelCurve(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes tempType) { + + int[] xArray = {0, 0, 0, 0, 0, 0}; + int[] zArray = {0, 1, 2, 3, 4, 5}; + int[] xArray2 = {1, 1, 1, 1, 1, 1}; + int[] zArray2 = {7, 3, 4, 2, 6, 5}; + + if (l == 2) { + + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, true), flipArraySign(zArray, z, true), l, false, 2, x - 1, z - 7, 16.25, x - 15.75, + y + 1, z + 1, tempType.getLabel(), tempType.getItem().item)) + return false; + TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x, y + 1, z); + + if (tcRailTurn != null) { + tcRailTurn.hasModel = true; + + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray2, x, true), flipArraySign(zArray2, z, true), 1, false, 2, x - 1, z - 7, 16.25, x + 15.75, + y + 1, z - 7, TrackTypes.MEDIUM_LEFT_TURN.getLabel(), null)) + return false; + + TileTCRail tcRailTurn2 = (TileTCRail) world.getTileEntity(x - 1, y + 1, z - 7); + + if (tcRailTurn2 != null) { + tcRailTurn2.hasModel = false; + tcRailTurn2.isLinkedToRail = true; + tcRailTurn2.linkedX = x; + tcRailTurn2.linkedY = y + 1; + tcRailTurn2.linkedZ = z; + } + tcRailTurn.isLinkedToRail = true; + tcRailTurn.linkedX = x - 1; + tcRailTurn.linkedY = y + 1; + tcRailTurn.linkedZ = z - 7; + } + return true; + } + + if (l == 0) { + + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, false), flipArraySign(zArray, z, false), l, false, 0, x + 1, z + 8, 16.25, x + 16.75, + y + 1, z, tempType.getLabel(), tempType.getItem().item)) + return false; + TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x, y + 1, z); + + if (tcRailTurn != null) { + tcRailTurn.hasModel = true; + + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray2, x, false), flipArraySign(zArray2, z, false), 3, false, 0, x + 1, z + 8, 16.25, x - 14.75, + y + 1, z + 8, TrackTypes.MEDIUM_LEFT_TURN.getLabel(), null)) + return false; + + TileTCRail tcRailTurn2 = (TileTCRail) world.getTileEntity(x + 1, y + 1, z + 7); + + if (tcRailTurn2 != null) { + tcRailTurn2.hasModel = false; + tcRailTurn2.isLinkedToRail = true; + tcRailTurn2.linkedX = x; + tcRailTurn2.linkedY = y + 1; + tcRailTurn2.linkedZ = z; + } + tcRailTurn.isLinkedToRail = true; + tcRailTurn.linkedX = x + 1; + tcRailTurn.linkedY = y + 1; + tcRailTurn.linkedZ = z + 7; + } + return true; + } + + if (l == 1) { + + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, true), flipArraySign(xArray, z, false), l, false, 1, x - 7, z + 1, 16.25, x + 1, + y + 1, z + 16.75, tempType.getLabel(), tempType.getItem().item)) + return false; + TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x, y + 1, z); + + if (tcRailTurn != null) { + tcRailTurn.hasModel = true; + + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray2, x, true), flipArraySign(xArray2, z, false), 0, false, 1, x - 7, z + 1, 16.25, x - 7, + y + 1, z - 14.75, TrackTypes.MEDIUM_LEFT_TURN.getLabel(), null)) + return false; + + TileTCRail tcRailTurn2 = (TileTCRail) world.getTileEntity(x - 7, y + 1, z + 1); + + if (tcRailTurn2 != null) { + tcRailTurn2.hasModel = false; + tcRailTurn2.isLinkedToRail = true; + tcRailTurn2.linkedX = x; + tcRailTurn2.linkedY = y + 1; + tcRailTurn2.linkedZ = z; + } + tcRailTurn.isLinkedToRail = true; + tcRailTurn.linkedX = x - 7; + tcRailTurn.linkedY = y + 1; + tcRailTurn.linkedZ = z + 1; + } + return true; + } + + if (l == 3) { + + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, false), flipArraySign(xArray, z, true), l, false, 3, x + 7, z - 1, 16.25, x, + y + 1, z - 15.75, tempType.getLabel(), tempType.getItem().item)) + return false; + TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x, y + 1, z); + + if (tcRailTurn != null) { + tcRailTurn.hasModel = true; + + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray2, x, false), flipArraySign(xArray2, z, true), 0, false, 3, x + 7, z - 1, 16.25, x + 8, + y + 1, z + 15.75, TrackTypes.MEDIUM_LEFT_TURN.getLabel(), null)) + return false; + + TileTCRail tcRailTurn2 = (TileTCRail) world.getTileEntity(x + 7, y + 1, z - 1); + + if (tcRailTurn2 != null) { + tcRailTurn2.hasModel = false; + tcRailTurn2.isLinkedToRail = true; + tcRailTurn2.linkedX = x; + tcRailTurn2.linkedY = y + 1; + tcRailTurn2.linkedZ = z; + } + tcRailTurn.isLinkedToRail = true; + tcRailTurn.linkedX = x + 7; + tcRailTurn.linkedY = y + 1; + tcRailTurn.linkedZ = z - 1; + } + return true; + } + + return true; + } + + private boolean parallelRightSwitchEast(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes tempType, String typeVariantStraight, Item idVariantSwitch) { + for (int check = 1; check < 10; check++) { + if (!canPlaceTrack(player, world, x + check, y + 1, z)) + return false; + } + if (!canPlaceTrack(player, world, x + 3, y + 1, z + 1) || !canPlaceTrack(player, world, x + 4, y + 1, z + 1) || !canPlaceTrack(player, world, x + 5, y + 1, z + 1) || !canPlaceTrack(player, world, x + 4, y + 1, z + 2) || !canPlaceTrack(player, world, x + 5, y + 1, z + 2) || !canPlaceTrack(player, world, x + 6, y + 1, z + 2) || !canPlaceTrack(player, world, x + 7, y + 1, z + 2) || !canPlaceTrack(player, world, x + 8, y + 1, z + 2) || !canPlaceTrack(player, world, x + 6, y + 1, z + 3) || !canPlaceTrack(player, world, x + 7, y + 1, z + 3) || !canPlaceTrack(player, world, x + 8, y + 1, z + 3) || !canPlaceTrack(player, world, x + 9, y + 1, z + 3) || !canPlaceTrack(player, world, x + 10, y + 1, z + 3) || !canPlaceTrack(player, world, x, y + 1, z)) { + return false; + } + int[] xArray = {x + 3, x + 2, x + 4, x + 5}; + int[] zArray = {z + 1, z + 1, z + 1, z + 1}; + if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, true, 3, x + 10, z, 8.5, x + 0.5, y + 1, z + 9, + TrackTypes.MEDIUM_RIGHT_TURN.getLabel(), idVariantSwitch)) + return false; + TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x + 3, y + 1, z + 1); + if (tcRailTurn != null) { + tcRailTurn.hasModel = false; + + /** Switch rail 1 */ + putDownSingleRail(world, x + 1, y + 1, z, l, x + 0.5, y + 1, z + 9, 8.5, tempType.getLabel(), true, x + 3, y + 1, z + 1, true, false); + + /** Switch rail 2 **/ + putDownSingleRail(world, x + 2, y + 1, z, l, x + 0.5, y + 1, z + 9, 8.5, typeVariantStraight, false, x + 3, y + 1, z + 1, true, false); + /** Switch rail 3 **/ + putDownSingleRail(world, x + 3, y + 1, z, l, x + 0.5, y + 1, z + 9, 8.5, typeVariantStraight, false, x + 3, y + 1, z + 1, true, false); + + int[] xArray2 = {x + 4, x + 5, x + 6, x + 7, x + 8, x + 6, x + 7, x + 8, x + 9}; + int[] zArray2 = {z + 2, z + 2, z + 2, z + 2, z + 2, z + 3, z + 3, z + 3, z + 3}; + if (!putDownTurn(player, world, false, x, y, z, xArray2, zArray2, 0, true, 3, x + 10, z + 3, 8.5, x + 10, y + 1, z - 5, + TrackTypes.MEDIUM_LEFT_TURN.getLabel(), null)) + return false; + TileTCRail tcRailTurn2 = (TileTCRail) world.getTileEntity(x + 4, y + 1, z + 2); + if (tcRailTurn2 != null) { + tcRailTurn2.hasModel = false; + tcRailTurn2.isLinkedToRail = true; + tcRailTurn2.linkedX = x + 3; + tcRailTurn2.linkedY = y + 1; + tcRailTurn2.linkedZ = z + 1; + } + tcRailTurn.isLinkedToRail = true; + tcRailTurn.linkedX = x + 4; + tcRailTurn.linkedY = y + 1; + tcRailTurn.linkedZ = z + 2; + } + /** Put down straight **/ + putDownSingleRail(world, x + 4, y + 1, z, l, x, y + 1, z, 0, typeVariantStraight, false, x + 3, y + 1, z + 1, false, false); + for (int straight = 5; straight < 10; straight++) { + putDownSingleRail(world, x + straight, y + 1, z, l, x, y + 1, z, 0, typeVariantStraight, true, x + 3, y + 1, z + 1, false, false); + } + return true; + } + + private boolean parallelRightSwitchWest(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes tempType, String typeVariantStraight, Item idVariantSwitch) { + for (int check = 1; check < 10; check++) { + if (!canPlaceTrack(player, world, x - check, y + 1, z)) + return false; + } + if (!canPlaceTrack(player, world, x - 3, y + 1, z - 1) || !canPlaceTrack(player, world, x - 4, y + 1, z - 1) || !canPlaceTrack(player, world, x - 5, y + 1, z - 1) || !canPlaceTrack(player, world, x - 4, y + 1, z - 2) || !canPlaceTrack(player, world, x - 5, y + 1, z - 2) || !canPlaceTrack(player, world, x - 6, y + 1, z - 2) || !canPlaceTrack(player, world, x - 7, y + 1, z - 2) || !canPlaceTrack(player, world, x - 8, y + 1, z - 2) || !canPlaceTrack(player, world, x - 6, y + 1, z - 3) || !canPlaceTrack(player, world, x - 7, y + 1, z - 3) || !canPlaceTrack(player, world, x - 8, y + 1, z - 3) || !canPlaceTrack(player, world, x - 9, y + 1, z - 3) || !canPlaceTrack(player, world, x - 10, y + 1, z - 3) || !canPlaceTrack(player, world, x, y + 1, z)) { + return false; + } + int[] xArray = {x - 3, x - 2, x - 4, x - 5}; + int[] zArray = {z - 1, z - 1, z - 1, z - 1}; + if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, true, 1, x - 10, z, 8.5, x + 0.5, y + 1, z - 8, + TrackTypes.MEDIUM_RIGHT_TURN.getLabel(), idVariantSwitch)) + return false; + TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x - 3, y + 1, z - 1); + if (tcRailTurn != null) { + tcRailTurn.hasModel = false; + + /** Switch rail 1 */ + putDownSingleRail(world, x - 1, y + 1, z, l, x + 0.5, y + 1, z - 8, 8.5, tempType.getLabel(), true, x - 3, y + 1, z - 1, true, false); + + /** Switch rail 2 **/ + putDownSingleRail(world, x - 2, y + 1, z, l, x + 0.5, y + 1, z - 8, 8.5, typeVariantStraight, false, x - 3, y + 1, z - 1, true, false); + /** Switch rail 3 **/ + putDownSingleRail(world, x - 3, y + 1, z, l, x + 0.5, y + 1, z - 8, 8.5, typeVariantStraight, false, x - 3, y + 1, z - 1, true, false); + + int[] xArray2 = {x - 4, x - 5, x - 6, x - 7, x - 8, x - 6, x - 7, x - 8, x - 9}; + int[] zArray2 = {z - 2, z - 2, z - 2, z - 2, z - 2, z - 3, z - 3, z - 3, z - 3}; + if (!putDownTurn(player, world, false, x, y, z, xArray2, zArray2, 2, true, 1, x - 10, z - 3, 8.5, x - 9, y + 1, z + 6, + TrackTypes.MEDIUM_LEFT_TURN.getLabel(), null)) + return false; + TileTCRail tcRailTurn2 = (TileTCRail) world.getTileEntity(x - 4, y + 1, z - 2); + if (tcRailTurn2 != null) { + tcRailTurn2.hasModel = false; + tcRailTurn2.isLinkedToRail = true; + tcRailTurn2.linkedX = x - 3; + tcRailTurn2.linkedY = y + 1; + tcRailTurn2.linkedZ = z - 1; + } + tcRailTurn.isLinkedToRail = true; + tcRailTurn.linkedX = x - 4; + tcRailTurn.linkedY = y + 1; + tcRailTurn.linkedZ = z - 2; + } + + /** Put down straight **/ + putDownSingleRail(world, x - 4, y + 1, z, l, x, y + 1, z, 0, typeVariantStraight, false, x - 3, y + 1, z - 1, false, false); + for (int straight = 5; straight < 10; straight++) { + putDownSingleRail(world, x - straight, y + 1, z, l, x, y + 1, z, 0, typeVariantStraight, true, x - 3, y + 1, z - 1, false, false); + } + return true; + } + + private boolean parallelRightSwitchSouth(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes tempType, String typeVariantStraight, Item idVariantSwitch) { + for (int check = 1; check < 10; check++) { + if (!canPlaceTrack(player, world, x, y + 1, z + check)) + return false; + } + if (!canPlaceTrack(player, world, x - 1, y + 1, z + 3) || !canPlaceTrack(player, world, x - 1, y + 1, z + 4) || !canPlaceTrack(player, world, x - 1, y + 1, z + 5) || !canPlaceTrack(player, world, x - 2, y + 1, z + 4) || !canPlaceTrack(player, world, x - 2, y + 1, z + 5) || !canPlaceTrack(player, world, x - 2, y + 1, z + 6) || !canPlaceTrack(player, world, x - 2, y + 1, z + 7) || !canPlaceTrack(player, world, x - 2, y + 1, z + 8) || !canPlaceTrack(player, world, x - 3, y + 1, z + 6) || !canPlaceTrack(player, world, x - 3, y + 1, z + 7) || !canPlaceTrack(player, world, x - 3, y + 1, z + 8) || !canPlaceTrack(player, world, x - 3, y + 1, z + 9) || !canPlaceTrack(player, world, x - 3, y + 1, z + 10) || !canPlaceTrack(player, world, x, y + 1, z)) { + return false; + } + int[] xArray = {x - 1, x - 1, x - 1, x - 1}; + int[] zArray = {z + 3, z + 2, z + 4, z + 5}; + if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, true, 0, x, z + 10, 8.5, x - 8, y + 1, z + 0.5, + TrackTypes.MEDIUM_RIGHT_TURN.getLabel(), idVariantSwitch)) + return false; + TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x - 1, y + 1, z + 3); + if (tcRailTurn != null) { + tcRailTurn.hasModel = false; + + /** Switch rail 1 */ + putDownSingleRail(world, x, y + 1, z + 1, l, x - 8, y + 1, z + 0.5, 8.5, tempType.getLabel(), true, x - 1, y + 1, z + 3, true, false); + + /** Switch rail 2 **/ + putDownSingleRail(world, x, y + 1, z + 2, l, x - 8, y + 1, z + 0.5, 8.5, typeVariantStraight, false, x - 1, y + 1, z + 3, true, false); + /** Switch rail 3 **/ + putDownSingleRail(world, x, y + 1, z + 3, l, x - 8, y + 1, z + 0.5, 8.5, typeVariantStraight, false, x - 1, y + 1, z + 3, true, false); + + int[] xArray2 = {x - 2, x - 2, x - 2, x - 2, x - 2, x - 3, x - 3, x - 3, x - 3}; + int[] zArray2 = {z + 4, z + 5, z + 6, z + 7, z + 8, z + 6, z + 7, z + 8, z + 9}; + if (!putDownTurn(player, world, false, x, y, z, xArray2, zArray2, 1, true, 0, x - 3, z + 10, 8.5, x + 6, y + 1, z + 10, + TrackTypes.MEDIUM_LEFT_TURN.getLabel(), null)) + return false; + TileTCRail tcRailTurn2 = (TileTCRail) world.getTileEntity(x - 2, y + 1, z + 4); + if (tcRailTurn2 != null) { + tcRailTurn2.hasModel = false; + tcRailTurn2.isLinkedToRail = true; + tcRailTurn2.linkedX = x - 1; + tcRailTurn2.linkedY = y + 1; + tcRailTurn2.linkedZ = z + 3; + } + tcRailTurn.isLinkedToRail = true; + tcRailTurn.linkedX = x - 2; + tcRailTurn.linkedY = y + 1; + tcRailTurn.linkedZ = z + 4; + } + /** Put down straight **/ + putDownSingleRail(world, x, y + 1, z + 4, l, x, y + 1, z, 0, typeVariantStraight, false, x - 1, y + 1, z + 3, false, false); + for (int straight = 5; straight < 10; straight++) { + putDownSingleRail(world, x, y + 1, z + straight, l, x, y + 1, z, 0, typeVariantStraight, true, x - 1, y + 1, z + 3, false, false); + } + return true; + } + + private boolean parallelRightSwitchNorth(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes tempType, String typeVariantStraight, Item idVariantSwitch) { + for (int check = 1; check < 10; check++) { + if (!canPlaceTrack(player, world, x, y + 1, z - check)) + return false; /** checks if the next 11 blocks can be placed */ + } + if (!canPlaceTrack(player, world, x + 1, y + 1, z - 3) || !canPlaceTrack(player, world, x + 1, y + 1, z - 4) || !canPlaceTrack(player, world, x + 1, y + 1, z - 5) || !canPlaceTrack(player, world, x + 2, y + 1, z - 4) || !canPlaceTrack(player, world, x + 2, y + 1, z - 5) || !canPlaceTrack(player, world, x + 2, y + 1, z - 6) || !canPlaceTrack(player, world, x + 2, y + 1, z - 7) || !canPlaceTrack(player, world, x + 2, y + 1, z - 8) || !canPlaceTrack(player, world, x + 3, y + 1, z - 6) || !canPlaceTrack(player, world, x + 3, y + 1, z - 7) || !canPlaceTrack(player, world, x + 3, y + 1, z - 8) || !canPlaceTrack(player, world, x + 3, y + 1, z - 9) || !canPlaceTrack(player, world, x + 3, y + 1, z - 10) || !canPlaceTrack(player, world, x, y + 1, z)) { + return false; + } + int[] xArray = {x + 1, x + 1, x + 1, x + 1}; + int[] zArray = {z - 3, z - 2, z - 4, z - 5}; + if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, true, 2, x, z - 10, 8.5, x + 9, y + 1, z + 0.5, + TrackTypes.MEDIUM_RIGHT_TURN.getLabel(), idVariantSwitch)) + return false; + TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x + 1, y + 1, z - 3); + if (tcRailTurn != null) { + tcRailTurn.hasModel = false; + + /** Switch rail 1 */ + putDownSingleRail(world, x, y + 1, z - 1, l, x + 9, y + 1, z + 0.5, 8.5, tempType.getLabel(), true, x + 1, y + 1, z - 3, true, false); + + /** Switch rail 2 **/ + putDownSingleRail(world, x, y + 1, z - 2, l, x + 9, y + 1, z + 0.5, 8.5, typeVariantStraight, false, x + 1, y + 1, z - 3, true, false); + /** Switch rail 3 **/ + putDownSingleRail(world, x, y + 1, z - 3, l, x + 9, y + 1, z + 0.5, 8.5, typeVariantStraight, false, x + 1, y + 1, z - 3, true, false); + + int[] xArray2 = {x + 2, x + 2, x + 2, x + 2, x + 2, x + 3, x + 3, x + 3, x + 3}; + int[] zArray2 = {z - 4, z - 5, z - 6, z - 7, z - 8, z - 6, z - 7, z - 8, z - 9}; + if (!putDownTurn(player, world, false, x, y, z, xArray2, zArray2, 3, true, 2, x + 3, z - 10, 8.5, x - 5, y + 1, z - 9, + TrackTypes.MEDIUM_LEFT_TURN.getLabel(), null)) + return false; + TileTCRail tcRailTurn2 = (TileTCRail) world.getTileEntity(x + 2, y + 1, z - 4); + if (tcRailTurn2 != null) { + tcRailTurn2.hasModel = false; + tcRailTurn2.isLinkedToRail = true; + tcRailTurn2.linkedX = x + 1; + tcRailTurn2.linkedY = y + 1; + tcRailTurn2.linkedZ = z - 3; + } + tcRailTurn.isLinkedToRail = true; + tcRailTurn.linkedX = x + 2; + tcRailTurn.linkedY = y + 1; + tcRailTurn.linkedZ = z - 4; + } + /** Put down straight **/ + putDownSingleRail(world, x, y + 1, z - 4, l, x, y + 1, z, 0, typeVariantStraight, false, x + 1, y + 1, z - 3, false, false); + for (int straight = 5; straight < 10; straight++) { + putDownSingleRail(world, x, y + 1, z - straight, l, x, y + 1, z, 0, typeVariantStraight, true, x + 1, y + 1, z - 3, false, false); + } + + return true; + } + + private boolean parallelLeftSwitchNorth(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes tempType, String variantStraight, Item idVariantSwitch) { + for (int check = 1; check < 10; check++) { + if (!canPlaceTrack(player, world, x, y + 1, z - check)) + return false; + } + if (!canPlaceTrack(player, world, x - 1, y + 1, z - 3) || !canPlaceTrack(player, world, x - 1, y + 1, z - 4) || !canPlaceTrack(player, world, x - 1, y + 1, z - 5) || !canPlaceTrack(player, world, x - 2, y + 1, z - 4) || !canPlaceTrack(player, world, x - 2, y + 1, z - 5) || !canPlaceTrack(player, world, x - 2, y + 1, z - 6) || !canPlaceTrack(player, world, x - 2, y + 1, z - 7) || !canPlaceTrack(player, world, x - 2, y + 1, z - 8) || !canPlaceTrack(player, world, x - 3, y + 1, z - 6) || !canPlaceTrack(player, world, x - 3, y + 1, z - 7) || !canPlaceTrack(player, world, x - 3, y + 1, z - 8) || !canPlaceTrack(player, world, x - 3, y + 1, z - 9) || !canPlaceTrack(player, world, x - 3, y + 1, z - 10) || !canPlaceTrack(player, world, x, y + 1, z)) { + return false; + } + int[] xArray = {x - 1, x - 1, x - 1, x - 1}; + int[] zArray = {z - 3, z - 2, z - 4, z - 5}; + if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, true, 2, x, z - 10, 8.5, x - 8, y + 1, z + 0.5, + TrackTypes.MEDIUM_LEFT_TURN.getLabel(), idVariantSwitch)) + return false; + TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x - 1, y + 1, z - 3); + if (tcRailTurn != null) { + tcRailTurn.hasModel = false; + + /** Switch rail 1 */ + putDownSingleRail(world, x, y + 1, z - 1, l, x - 8, y + 1, z + 0.5, 8.5, tempType.getLabel(), true, x - 1, y + 1, z - 3, true, false); + + /** Switch rail 2 **/ + putDownSingleRail(world, x, y + 1, z - 2, l, x - 8, y + 1, z + 0.5, 8.5, typeVariantStraight, false, x - 1, y + 1, z - 3, true, false); + /** Switch rail 3 **/ + putDownSingleRail(world, x, y + 1, z - 3, l, x - 8, y + 1, z + 0.5, 8.5, typeVariantStraight, false, x - 1, y + 1, z - 3, true, false); + + int[] xArray2 = {x - 2, x - 2, x - 2, x - 2, x - 2, x - 3, x - 3, x - 3, x - 3}; + int[] zArray2 = {z - 4, z - 5, z - 6, z - 7, z - 8, z - 6, z - 7, z - 8, z - 9}; + if (!putDownTurn(player, world, false, x, y, z, xArray2, zArray2, 1, true, 2, x - 3, z - 10, 8.5, x + 6, y + 1, z - 9, + TrackTypes.MEDIUM_RIGHT_TURN.getLabel(), null)) + return false; + TileTCRail tcRailTurn2 = (TileTCRail) world.getTileEntity(x - 2, y + 1, z - 4); + if (tcRailTurn2 != null) { + tcRailTurn2.hasModel = false; + tcRailTurn2.isLinkedToRail = true; + tcRailTurn2.linkedX = x - 1; + tcRailTurn2.linkedY = y + 1; + tcRailTurn2.linkedZ = z - 3; + } + tcRailTurn.isLinkedToRail = true; + tcRailTurn.linkedX = x - 2; + tcRailTurn.linkedY = y + 1; + tcRailTurn.linkedZ = z - 4; + } + /** Put down straight **/ + putDownSingleRail(world, x, y + 1, z - 4, l, x, y + 1, z, 0, typeVariantStraight, false, x - 1, y + 1, z - 3, false, false); + for (int straight = 5; straight < 10; straight++) { + putDownSingleRail(world, x, y + 1, z - straight, l, x, y + 1, z, 0, typeVariantStraight, true, x - 1, y + 1, z - 3, false, false); + } + return true; + } + + private boolean parallelLeftSwitchSouth(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes tempType, String typeVariantStraight, Item idVariantSwitch) { + for (int check = 1; check < 10; check++) { + if (!canPlaceTrack(player, world, x, y + 1, z + check)) + return false; + } + if (!canPlaceTrack(player, world, x + 1, y + 1, z + 3) || !canPlaceTrack(player, world, x + 1, y + 1, z + 4) || !canPlaceTrack(player, world, x + 1, y + 1, z + 5) || !canPlaceTrack(player, world, x + 2, y + 1, z + 4) || !canPlaceTrack(player, world, x + 2, y + 1, z + 5) || !canPlaceTrack(player, world, x + 2, y + 1, z + 6) || !canPlaceTrack(player, world, x + 2, y + 1, z + 7) || !canPlaceTrack(player, world, x + 2, y + 1, z + 8) || !canPlaceTrack(player, world, x + 3, y + 1, z + 6) || !canPlaceTrack(player, world, x + 3, y + 1, z + 7) || !canPlaceTrack(player, world, x + 3, y + 1, z + 8) || !canPlaceTrack(player, world, x + 3, y + 1, z + 9) || !canPlaceTrack(player, world, x + 3, y + 1, z + 10) || !canPlaceTrack(player, world, x, y + 1, z)) { + return false; + } + int[] xArray = {x + 1, x + 1, x + 1, x + 1}; + int[] zArray = {z + 3, z + 2, z + 4, z + 5}; + if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, true, 0, x, z + 10, 8.5, x + 9, y + 1, z + 0.5, + TrackTypes.MEDIUM_LEFT_TURN.getLabel(), idVariantSwitch)) + return false; + TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x + 1, y + 1, z + 3); + if (tcRailTurn != null) { + tcRailTurn.hasModel = false; + + /** Switch rail 1 */ + putDownSingleRail(world, x, y + 1, z + 1, l, x + 9, y + 1, z + 0.5, 8.5, tempType.getLabel(), true, x + 1, y + 1, z + 3, true, false); + + /** Switch rail 2 **/ + putDownSingleRail(world, x, y + 1, z + 2, l, x + 9, y + 1, z + 0.5, 8.5, typeVariantStraight, false, x + 1, y + 1, z + 3, true, false); + /** Switch rail 3 **/ + putDownSingleRail(world, x, y + 1, z + 3, l, x + 9, y + 1, z + 0.5, 8.5, typeVariantStraight, false, x + 1, y + 1, z + 3, true, false); + + int[] xArray2 = {x + 2, x + 2, x + 2, x + 2, x + 2, x + 3, x + 3, x + 3, x + 3}; + int[] zArray2 = {z + 4, z + 5, z + 6, z + 7, z + 8, z + 6, z + 7, z + 8, z + 9}; + if (!putDownTurn(player, world, false, x, y, z, xArray2, zArray2, 3, true, 0, x + 3, z + 10, 8.5, x - 5, y + 1, z + 10, + TrackTypes.MEDIUM_RIGHT_TURN.getLabel(), null)) + return false; + TileTCRail tcRailTurn2 = (TileTCRail) world.getTileEntity(x + 2, y + 1, z + 4); + if (tcRailTurn2 != null) { + tcRailTurn2.hasModel = false; + tcRailTurn2.isLinkedToRail = true; + tcRailTurn2.linkedX = x + 1; + tcRailTurn2.linkedY = y + 1; + tcRailTurn2.linkedZ = z + 3; + } + tcRailTurn.isLinkedToRail = true; + tcRailTurn.linkedX = x + 2; + tcRailTurn.linkedY = y + 1; + tcRailTurn.linkedZ = z + 4; + } + /** Put down straight **/ + putDownSingleRail(world, x, y + 1, z + 4, l, x, y + 1, z, 0, typeVariantStraight, false, x + 1, y + 1, z + 3, false, false); + for (int straight = 5; straight < 10; straight++) { + putDownSingleRail(world, x, y + 1, z + straight, l, x, y + 1, z, 0, typeVariantStraight, true, x + 1, y + 1, z + 3, false, false); + } + return true; + } + + private boolean parallelLeftSwitchEast(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes tempType, String typeVariantStraight, Item idVariantSwitch) { + for (int check = 1; check < 10; check++) { + if (!canPlaceTrack(player, world, x + check, y + 1, z)) + return false; + } + if (!canPlaceTrack(player, world, x + 3, y + 1, z - 1) || !canPlaceTrack(player, world, x + 4, y + 1, z - 1) || !canPlaceTrack(player, world, x + 5, y + 1, z - 1) || !canPlaceTrack(player, world, x + 4, y + 1, z - 2) || !canPlaceTrack(player, world, x + 5, y + 1, z - 2) || !canPlaceTrack(player, world, x + 6, y + 1, z - 2) || !canPlaceTrack(player, world, x + 7, y + 1, z - 2) || !canPlaceTrack(player, world, x + 8, y + 1, z - 2) || !canPlaceTrack(player, world, x + 6, y + 1, z - 3) || !canPlaceTrack(player, world, x + 7, y + 1, z - 3) || !canPlaceTrack(player, world, x + 8, y + 1, z - 3) || !canPlaceTrack(player, world, x + 9, y + 1, z - 3) || !canPlaceTrack(player, world, x + 10, y + 1, z - 3) || !canPlaceTrack(player, world, x, y + 1, z)) { + return false; + } + int[] xArray = {x + 3, x + 2, x + 4, x + 5}; + int[] zArray = {z - 1, z - 1, z - 1, z - 1}; + if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, true, 3, x + 10, z, 8.5, x + 0.5, y + 1, z - 8, + TrackTypes.MEDIUM_LEFT_TURN.getLabel(), idVariantSwitch)) + return false; + TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x + 3, y + 1, z - 1); + if (tcRailTurn != null) { + tcRailTurn.hasModel = false; + + /** Switch rail 1 */ + putDownSingleRail(world, x + 1, y + 1, z, l, x + 0.5, y + 1, z - 8, 8.5, tempType.getLabel(), true, x + 3, y + 1, z - 1, true, false); + + /** Switch rail 2 **/ + putDownSingleRail(world, x + 2, y + 1, z, l, x + 0.5, y + 1, z - 8, 8.5, typeVariantStraight, false, x + 3, y + 1, z - 1, true, false); + /** Switch rail 3 **/ + putDownSingleRail(world, x + 3, y + 1, z, l, x + 0.5, y + 1, z - 8, 8.5, typeVariantStraight, false, x + 3, y + 1, z - 1, true, false); + + int[] xArray2 = {x + 4, x + 5, x + 6, x + 7, x + 8, x + 6, x + 7, x + 8, x + 9}; + int[] zArray2 = {z - 2, z - 2, z - 2, z - 2, z - 2, z - 3, z - 3, z - 3, z - 3}; + if (!putDownTurn(player, world, false, x, y, z, xArray2, zArray2, 2, true, 3, x + 10, z - 3, 8.5, x + 10, y + 1, z + 6, + TrackTypes.MEDIUM_RIGHT_TURN.getLabel(), null)) + return false; + TileTCRail tcRailTurn2 = (TileTCRail) world.getTileEntity(x + 4, y + 1, z - 2); + if (tcRailTurn2 != null) { + tcRailTurn2.hasModel = false; + + tcRailTurn2.isLinkedToRail = true; + tcRailTurn2.linkedX = x + 3; + tcRailTurn2.linkedY = y + 1; + tcRailTurn2.linkedZ = z - 1; + } + tcRailTurn.isLinkedToRail = true; + tcRailTurn.linkedX = x + 4; + tcRailTurn.linkedY = y + 1; + tcRailTurn.linkedZ = z - 2; + } + /** Put down straight **/ + putDownSingleRail(world, x + 4, y + 1, z, l, x, y + 1, z, 0, typeVariantStraight, false, x + 3, y + 1, z - 1, false, false); + for (int straight = 5; straight < 10; straight++) { + putDownSingleRail(world, x + straight, y + 1, z, l, x, y + 1, z, 0, typeVariantStraight, true, x + 3, y + 1, z - 1, false, false); + } + return true; + } + + private boolean parallelLeftSwitchWest(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes tempType, String typeVariantStraight, Item idVariantSwitch) { + for (int check = 1; check < 10; check++) { + if (!canPlaceTrack(player, world, x - check, y + 1, z)) + return false; + } + if (!canPlaceTrack(player, world, x - 3, y + 1, z + 1) || !canPlaceTrack(player, world, x - 4, y + 1, z + 1) || !canPlaceTrack(player, world, x - 5, y + 1, z + 1) || !canPlaceTrack(player, world, x - 4, y + 1, z + 2) || !canPlaceTrack(player, world, x - 5, y + 1, z + 2) || !canPlaceTrack(player, world, x - 6, y + 1, z + 2) || !canPlaceTrack(player, world, x - 7, y + 1, z + 2) || !canPlaceTrack(player, world, x - 8, y + 1, z + 2) || !canPlaceTrack(player, world, x - 6, y + 1, z + 3) || !canPlaceTrack(player, world, x - 7, y + 1, z + 3) || !canPlaceTrack(player, world, x - 8, y + 1, z + 3) || !canPlaceTrack(player, world, x - 9, y + 1, z + 3) || !canPlaceTrack(player, world, x - 10, y + 1, z + 3) || !canPlaceTrack(player, world, x, y + 1, z)) { + return false; + } + int[] xArray = {x - 3, x - 2, x - 4, x - 5}; + int[] zArray = {z + 1, z + 1, z + 1, z + 1}; + if (!putDownTurn(player, world, true, x, y, z, xArray, zArray, l, true, 1, x - 10, z, 8.5, x + 0.5, y + 1, z + 9, + TrackTypes.MEDIUM_LEFT_TURN.getLabel(), idVariantSwitch)) + return false; + TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x - 3, y + 1, z + 1); + if (tcRailTurn != null) { + tcRailTurn.hasModel = false; + + /** Switch rail 1 */ + putDownSingleRail(world, x - 1, y + 1, z, l, x + 0.5, y + 1, z + 9, 8.5, tempType.getLabel(), true, x - 3, y + 1, z + 1, true, false); + + /** Switch rail 2 **/ + putDownSingleRail(world, x - 2, y + 1, z, l, x + 0.5, y + 1, z + 9, 8.5, typeVariantStraight, false, x - 3, y + 1, z + 1, true, false); + /** Switch rail 3 **/ + putDownSingleRail(world, x - 3, y + 1, z, l, x + 0.5, y + 1, z + 9, 8.5, typeVariantStraight, false, x - 3, y + 1, z + 1, true, false); + + int[] xArray2 = {x - 4, x - 5, x - 6, x - 7, x - 8, x - 6, x - 7, x - 8, x - 9}; + int[] zArray2 = {z + 2, z + 2, z + 2, z + 2, z + 2, z + 3, z + 3, z + 3, z + 3}; + if (!putDownTurn(player, world, false, x, y, z, xArray2, zArray2, 0, true, 1, x - 10, z + 3, 8.5, x - 9, y + 1, z - 5, + TrackTypes.MEDIUM_RIGHT_TURN.getLabel(), null)) + return false; + TileTCRail tcRailTurn2 = (TileTCRail) world.getTileEntity(x - 4, y + 1, z + 2); + if (tcRailTurn2 != null) { + tcRailTurn2.hasModel = false; + tcRailTurn2.isLinkedToRail = true; + tcRailTurn2.linkedX = x - 3; + tcRailTurn2.linkedY = y + 1; + tcRailTurn2.linkedZ = z + 1; + } + tcRailTurn.isLinkedToRail = true; + tcRailTurn.linkedX = x - 4; + tcRailTurn.linkedY = y + 1; + tcRailTurn.linkedZ = z + 2; + } + /** Put down straight **/ + putDownSingleRail(world, x - 4, y + 1, z, l, x, y + 1, z, 0, typeVariantStraight, false, x - 3, y + 1, z + 1, false, false); + for (int straight = 5; straight < 10; straight++) { + putDownSingleRail(world, x - straight, y + 1, z, l, x, y + 1, z, 0, typeVariantStraight, true, x - 3, y + 1, z + 1, false, false); + } + return true; + } + + private boolean mediumRightParallelCurve(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes tempType) { + + int[] xArray = {0, 0, 0, 0, 0, 1, 1, 1}; + int[] zArray = {0, 1, 2, 3, 4, 3, 4, 5}; + + int[] xArray2 = {2, 1, 1, 1, 2, 2, 2, 2}; + int[] zArray2 = {11, 6, 7, 8, 7, 8, 9, 10}; + + if (l == 2) { + + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, false), flipArraySign(zArray, z, true), l, false, 2, x + 2, z - 11, 18.5, x + 19, + y + 1, z + 1, tempType.getLabel(), tempType.getItem().item)) + return false; + TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x, y + 1, z); + + if (tcRailTurn != null) { + tcRailTurn.hasModel = true; + + + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray2, x, false), flipArraySign(zArray2, z, true), 3, false, 2, x + 2, z - 11, 18.5, x - 16, + y + 1, z - 11, TrackTypes.MEDIUM_LEFT_TURN.getLabel(), null)) + return false; + + TileTCRail tcRailTurn2 = (TileTCRail) world.getTileEntity(x + 2, y + 1, z - 11); + + if (tcRailTurn2 != null) { + tcRailTurn2.hasModel = false; + tcRailTurn2.isLinkedToRail = true; + tcRailTurn2.linkedX = x; + tcRailTurn2.linkedY = y + 1; + tcRailTurn2.linkedZ = z; + + } + tcRailTurn.isLinkedToRail = true; + tcRailTurn.linkedX = x + 2; + tcRailTurn.linkedY = y + 1; + tcRailTurn.linkedZ = z - 11; + } + return true; + } + + if (l == 0) { + + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, true), flipArraySign(zArray, z, false), l, false, 0, x - 2, z + 11, 18.5, x - 18, + y + 1, z, tempType.getLabel(), tempType.getItem().item)) + return false; + TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x, y + 1, z); + + if (tcRailTurn != null) { + tcRailTurn.hasModel = true; + + + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray2, x, true), flipArraySign(zArray2, z, false), 3, false, 0, x - 2, z + 11, 18.5, x + 17, + y + 1, z + 12, TrackTypes.MEDIUM_LEFT_TURN.getLabel(), null)) + return false; + + TileTCRail tcRailTurn2 = (TileTCRail) world.getTileEntity(x - 2, y + 1, z + 11); + + if (tcRailTurn2 != null) { + tcRailTurn2.hasModel = false; + tcRailTurn2.isLinkedToRail = true; + tcRailTurn2.linkedX = x; + tcRailTurn2.linkedY = y + 1; + tcRailTurn2.linkedZ = z; + + } + tcRailTurn.isLinkedToRail = true; + tcRailTurn.linkedX = x - 2; + tcRailTurn.linkedY = y + 1; + tcRailTurn.linkedZ = z + 11; + } + return true; + } + + if (l == 1) { + + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, true), flipArraySign(xArray, z, true), l, false, 1, x - 11, z - 2, 18.5, x + 1, + y + 1, z - 18, tempType.getLabel(), tempType.getItem().item)) + return false; + TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x, y + 1, z); + + if (tcRailTurn != null) { + tcRailTurn.hasModel = true; + + + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray2, x, true), flipArraySign(xArray2, z, true), 2, false, 1, x - 11, z - 2, 18.5, x - 11, + y + 1, z + 17, TrackTypes.MEDIUM_LEFT_TURN.getLabel(), null)) + return false; + + TileTCRail tcRailTurn2 = (TileTCRail) world.getTileEntity(x - 11, y + 1, z - 2); + + if (tcRailTurn2 != null) { + tcRailTurn2.hasModel = false; + tcRailTurn2.isLinkedToRail = true; + tcRailTurn2.linkedX = x; + tcRailTurn2.linkedY = y + 1; + tcRailTurn2.linkedZ = z; - return false; + } + tcRailTurn.isLinkedToRail = true; + tcRailTurn.linkedX = x - 11; + tcRailTurn.linkedY = y + 1; + tcRailTurn.linkedZ = z - 2; + } + return true; + } - } - private boolean mediumLeftParallelCurve(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes tempType) { - - int[] xArray = {0,0,0,0,0,1,1,1}; - int[] zArray = {0,1,2,3,4,3,4,5}; - int[] xArray2 = {2,1,1,1,2,2,2,2}; - int[] zArray2 = {11,6,7,8,7,8,9,10}; - - if (l == 2) { - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, true), flipArraySign(zArray, z, true), l, false, 2, x - 2, z - 11, 18.5, x - 18, - y + 1, z + 1, tempType.getLabel(), tempType.getItem().item)) - return false; - TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x , y + 1, z ); - - if (tcRailTurn != null) { - tcRailTurn.hasModel = true; - - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray2, x, true), flipArraySign(zArray2, z, true), 1, false, 2, x - 2, z - 11, 18.5, x + 17, - y + 1, z - 11, TrackTypes.MEDIUM_RIGHT_TURN.getLabel(), null)) - return false; - - TileTCRail tcRailTurn2 = (TileTCRail) world.getTileEntity(x - 2, y + 1, z - 11); - - if (tcRailTurn2 != null) { - tcRailTurn2.hasModel = false; - tcRailTurn2.isLinkedToRail = true; - tcRailTurn2.linkedX = x; - tcRailTurn2.linkedY = y + 1; - tcRailTurn2.linkedZ = z ; - - } - tcRailTurn.isLinkedToRail = true; - tcRailTurn.linkedX = x - 2; - tcRailTurn.linkedY = y + 1; - tcRailTurn.linkedZ = z - 11; - } - return true; - } - - if (l == 0) { - - - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, false), flipArraySign(zArray, z, false), l, false, 0, x + 2, z + 11, 18.5, x + 19, - y + 1, z , tempType.getLabel(), tempType.getItem().item)) - return false; - TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x , y + 1, z ); - - if (tcRailTurn != null) { - tcRailTurn.hasModel = true; - - - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray2, x, false), flipArraySign(zArray2, z, false), 3, false, 0, x + 2, z + 11, 18.5, x - 16, - y + 1, z + 12, TrackTypes.MEDIUM_RIGHT_TURN.getLabel(), null)) - return false; + if (l == 3) { + + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, false), flipArraySign(xArray, z, false), l, false, 3, x + 11, z + 2, 18.5, x, + y + 1, z + 19, tempType.getLabel(), tempType.getItem().item)) + return false; + TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x, y + 1, z); + + if (tcRailTurn != null) { + tcRailTurn.hasModel = true; + + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray2, x, false), flipArraySign(xArray2, z, false), 0, false, 3, x + 11, z + 2, 18.5, x + 12, + y + 1, z - 16, TrackTypes.MEDIUM_LEFT_TURN.getLabel(), null)) + return false; + + TileTCRail tcRailTurn2 = (TileTCRail) world.getTileEntity(x + 11, y + 1, z + 2); + + if (tcRailTurn2 != null) { + tcRailTurn2.hasModel = false; + tcRailTurn2.isLinkedToRail = true; + tcRailTurn2.linkedX = x; + tcRailTurn2.linkedY = y + 1; + tcRailTurn2.linkedZ = z; + + } + tcRailTurn.isLinkedToRail = true; + tcRailTurn.linkedX = x + 11; + tcRailTurn.linkedY = y + 1; + tcRailTurn.linkedZ = z + 2; + } + return true; + } - TileTCRail tcRailTurn2 = (TileTCRail) world.getTileEntity(x + 2, y + 1, z + 11); + return false; - if (tcRailTurn2 != null) { - tcRailTurn2.hasModel = false; - tcRailTurn2.isLinkedToRail = true; - tcRailTurn2.linkedX = x; - tcRailTurn2.linkedY = y + 1; - tcRailTurn2.linkedZ = z ; + } - } - tcRailTurn.isLinkedToRail = true; - tcRailTurn.linkedX = x + 2; - tcRailTurn.linkedY = y + 1; - tcRailTurn.linkedZ = z + 11; - } - return true; - } - - if (l == 1) { - - - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, true), flipArraySign(xArray, z, false), l, false, 1, x - 11, z + 2, 18.5, x + 1, - y + 1, z + 19 , tempType.getLabel(), tempType.getItem().item)) - return false; - TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x , y + 1, z ); - - if (tcRailTurn != null) { - tcRailTurn.hasModel = true; - - - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray2, x, true), flipArraySign(xArray2, z, false), 0, false, 1, x - 11, z + 2, 18.5, x - 11, - y + 1, z - 16, TrackTypes.MEDIUM_RIGHT_TURN.getLabel(), null)) - return false; + private boolean mediumLeftParallelCurve(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes tempType) { + + int[] xArray = {0, 0, 0, 0, 0, 1, 1, 1}; + int[] zArray = {0, 1, 2, 3, 4, 3, 4, 5}; + int[] xArray2 = {2, 1, 1, 1, 2, 2, 2, 2}; + int[] zArray2 = {11, 6, 7, 8, 7, 8, 9, 10}; + + if (l == 2) { + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, true), flipArraySign(zArray, z, true), l, false, 2, x - 2, z - 11, 18.5, x - 18, + y + 1, z + 1, tempType.getLabel(), tempType.getItem().item)) + return false; + TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x, y + 1, z); + + if (tcRailTurn != null) { + tcRailTurn.hasModel = true; + + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray2, x, true), flipArraySign(zArray2, z, true), 1, false, 2, x - 2, z - 11, 18.5, x + 17, + y + 1, z - 11, TrackTypes.MEDIUM_RIGHT_TURN.getLabel(), null)) + return false; + + TileTCRail tcRailTurn2 = (TileTCRail) world.getTileEntity(x - 2, y + 1, z - 11); - TileTCRail tcRailTurn2 = (TileTCRail) world.getTileEntity(x - 11, y + 1, z + 2); + if (tcRailTurn2 != null) { + tcRailTurn2.hasModel = false; + tcRailTurn2.isLinkedToRail = true; + tcRailTurn2.linkedX = x; + tcRailTurn2.linkedY = y + 1; + tcRailTurn2.linkedZ = z; - if (tcRailTurn2 != null) { - tcRailTurn2.hasModel = false; - tcRailTurn2.isLinkedToRail = true; - tcRailTurn2.linkedX = x; - tcRailTurn2.linkedY = y + 1; - tcRailTurn2.linkedZ = z ; + } + tcRailTurn.isLinkedToRail = true; + tcRailTurn.linkedX = x - 2; + tcRailTurn.linkedY = y + 1; + tcRailTurn.linkedZ = z - 11; + } + return true; + } + + if (l == 0) { + + + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, false), flipArraySign(zArray, z, false), l, false, 0, x + 2, z + 11, 18.5, x + 19, + y + 1, z, tempType.getLabel(), tempType.getItem().item)) + return false; + TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x, y + 1, z); + + if (tcRailTurn != null) { + tcRailTurn.hasModel = true; + + + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray2, x, false), flipArraySign(zArray2, z, false), 3, false, 0, x + 2, z + 11, 18.5, x - 16, + y + 1, z + 12, TrackTypes.MEDIUM_RIGHT_TURN.getLabel(), null)) + return false; + + TileTCRail tcRailTurn2 = (TileTCRail) world.getTileEntity(x + 2, y + 1, z + 11); + + if (tcRailTurn2 != null) { + tcRailTurn2.hasModel = false; + tcRailTurn2.isLinkedToRail = true; + tcRailTurn2.linkedX = x; + tcRailTurn2.linkedY = y + 1; + tcRailTurn2.linkedZ = z; - } - tcRailTurn.isLinkedToRail = true; - tcRailTurn.linkedX = x - 11; - tcRailTurn.linkedY = y + 1; - tcRailTurn.linkedZ = z + 2; - } - return true; - } - - if (l == 3) { - - - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, false), flipArraySign(xArray, z, true), l, false, 3, x + 11, z - 2, 18.5, x, - y + 1, z - 18 , tempType.getLabel(), tempType.getItem().item)) - return false; - TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x , y + 1, z ); - - if (tcRailTurn != null) { - tcRailTurn.hasModel = true; - - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray2, x, false), flipArraySign(xArray2, z, true), 2, false, 3, x + 11, z - 2, 18.5, x + 12, - y + 1, z + 17, TrackTypes.MEDIUM_RIGHT_TURN.getLabel(), null)) - return false; - - TileTCRail tcRailTurn2 = (TileTCRail) world.getTileEntity(x + 11, y + 1, z - 2); - - if (tcRailTurn2 != null) { - tcRailTurn2.hasModel = false; - tcRailTurn2.isLinkedToRail = true; - tcRailTurn2.linkedX = x; - tcRailTurn2.linkedY = y + 1; - tcRailTurn2.linkedZ = z ; - - } - tcRailTurn.isLinkedToRail = true; - tcRailTurn.linkedX = x + 11; - tcRailTurn.linkedY = y + 1; - tcRailTurn.linkedZ = z - 2; - } - return true; - } - return false; - } - - private boolean largeRightParallelCurve(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes tempType) { - - int[] xArray = {0, 0 , 0 , 0 , 0 , 0 ,1,1,1,1,1}; - int[] zArray = {0,1,2,3,4,5,4,5,6,7,8}; - int[] xArray2 = {3 ,2,2,2,2 ,2 ,3 ,3 ,3 ,3 ,3}; - int[] zArray2 = {15,7,8,9,10,11,10,11,12,13,14}; - - if (l == 2) { - - - - - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, false), flipArraySign(zArray, z, true), l, false, 2, x+3, z-15, 22, x + 22.5, - y + 1, z + 1 , tempType.getLabel(), tempType.getItem().item)) - return false; - TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x , y + 1, z ); - - if (tcRailTurn != null) { - tcRailTurn.hasModel = true; - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray2, x, false), flipArraySign(zArray2, z, true), 3, false, 2, x+3, z-15, 22, x - 18.5, - y + 1, z - 15, TrackTypes.MEDIUM_LEFT_TURN.getLabel(), null)) - return false; - TileTCRail tcRailTurn2 = (TileTCRail) world.getTileEntity(x+3, y + 1, z-15); - - if (tcRailTurn2 != null) { - tcRailTurn2.hasModel = false; - tcRailTurn2.isLinkedToRail = true; - tcRailTurn2.linkedX = x; - tcRailTurn2.linkedY = y + 1; - tcRailTurn2.linkedZ = z ; - } - tcRailTurn.isLinkedToRail = true; - tcRailTurn.linkedX = x+3; - tcRailTurn.linkedY = y + 1; - tcRailTurn.linkedZ = z-15; - } - return true; - - } - - if (l == 0) { - - - - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, true), flipArraySign(zArray, z, false), l, false, 0, x-3, z+15, 22, x - 21.5, - y + 1, z , tempType.getLabel(), tempType.getItem().item)) - return false; - TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x , y + 1, z ); - - - if (tcRailTurn != null) { - tcRailTurn.hasModel = true; - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray2, x, true), flipArraySign(zArray2, z, false), 1, false, 0, x - 3, z + 15, 22, x + 19.5, - y + 1, z + 16, TrackTypes.MEDIUM_LEFT_TURN.getLabel(), null)) - return false; - TileTCRail tcRailTurn2 = (TileTCRail) world.getTileEntity(x-3, y + 1, z+15); - - if (tcRailTurn2 != null) { - tcRailTurn2.hasModel = false; - tcRailTurn2.isLinkedToRail = true; - tcRailTurn2.linkedX = x; - tcRailTurn2.linkedY = y + 1; - tcRailTurn2.linkedZ = z ; - } - tcRailTurn.isLinkedToRail = true; - tcRailTurn.linkedX = x - 3; - tcRailTurn.linkedY = y + 1; - tcRailTurn.linkedZ = z + 15; - } - return true; - - } - - if (l == 1) { - - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, true), flipArraySign(xArray, z, true), l, false, 1, x-15, z-3, 22, x + 1, - y + 1, z - 21.5 , tempType.getLabel(), tempType.getItem().item)) - return false; - TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x , y + 1, z ); - - - if (tcRailTurn != null) { - tcRailTurn.hasModel = true; - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray2, x, true), flipArraySign(xArray2, z, true), 2, false, 1, x - 15, z - 3, 22, x - 15, - y + 1, z + 19.5, TrackTypes.MEDIUM_LEFT_TURN.getLabel(), null)) - return false; - TileTCRail tcRailTurn2 = (TileTCRail) world.getTileEntity(x-15, y + 1, z-3); - - if (tcRailTurn2 != null) { - tcRailTurn2.hasModel = false; - tcRailTurn2.isLinkedToRail = true; - tcRailTurn2.linkedX = x; - tcRailTurn2.linkedY = y + 1; - tcRailTurn2.linkedZ = z ; - } - tcRailTurn.isLinkedToRail = true; - tcRailTurn.linkedX = x - 15; - tcRailTurn.linkedY = y + 1; - tcRailTurn.linkedZ = z- 3; - } - return true; - - } - if (l == 3) { - - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, false), flipArraySign(xArray, z, false), l, false, 3, x+15, z+3, 22, x , - y + 1, z + 22.5 , tempType.getLabel(), tempType.getItem().item)) - return false; - TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x , y + 1, z ); - - if (tcRailTurn != null) { - tcRailTurn.hasModel = true; - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray2, x, false), flipArraySign(xArray2, z, false), 0, false, 3, x - 15, z + 3, 22, x +16, - y + 1, z - 18.5, TrackTypes.MEDIUM_LEFT_TURN.getLabel(), null)) - return false; - TileTCRail tcRailTurn2 = (TileTCRail) world.getTileEntity(x+15, y + 1, z+3); - - if (tcRailTurn2 != null) { - tcRailTurn2.hasModel = false; - tcRailTurn2.isLinkedToRail = true; - tcRailTurn2.linkedX = x; - tcRailTurn2.linkedY = y + 1; - tcRailTurn2.linkedZ = z ; - } - tcRailTurn.isLinkedToRail = true; - tcRailTurn.linkedX = x + 15; - tcRailTurn.linkedY = y + 1; - tcRailTurn.linkedZ = z+ 3; - } - return true; - - } - return false; - } - - private boolean largeLeftParallelCurve(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes tempType){ - - int[] xArray = {0, 0 , 0 , 0 , 0 , 0 ,1,1,1,1,1}; - int[] zArray = {0,1,2,3,4,5,4,5,6,7,8}; - int[] xArray2 = {3 ,2,2,2,2 ,2 ,3 ,3 ,3 ,3 ,3}; - int[] zArray2 = {15,7,8,9,10,11,10,11,12,13,14}; - - if (l == 2) { - - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, true), flipArraySign(zArray, z, true), l, false, 2, x-3, z-15, 22, x -21.5, - y + 1, z + 1 ,tempType.getLabel(), tempType.getItem().item)) - return false; - TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x , y + 1, z ); - - - - if (tcRailTurn != null) { - tcRailTurn.hasModel = true; - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray2, x, true), flipArraySign(zArray2, z, true), 1, false, 2, x-3, z-15, 22, x + 19.5, - y + 1, z - 15, TrackTypes.MEDIUM_RIGHT_TURN.getLabel(), null)) - return false; - TileTCRail tcRailTurn2 = (TileTCRail) world.getTileEntity(x-3, y + 1, z-15); - - if (tcRailTurn2 != null) { - tcRailTurn2.hasModel = false; - tcRailTurn2.isLinkedToRail = true; - tcRailTurn2.linkedX = x; - tcRailTurn2.linkedY = y + 1; - tcRailTurn2.linkedZ = z ; - } - tcRailTurn.isLinkedToRail = true; - tcRailTurn.linkedX = x-3; - tcRailTurn.linkedY = y + 1; - tcRailTurn.linkedZ = z-15; - } - return true; - - } - - if (l == 0) { - - if (!putDownTurn(player, world, false, x, y, z,flipArraySign(xArray, x, false), flipArraySign(zArray, z, false), l, false, 0, x+3, z+15, 22, x + 22.5, - y + 1, z , tempType.getLabel(), tempType.getItem().item)) - return false; - TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x , y + 1, z ); - - if (tcRailTurn != null) { - tcRailTurn.hasModel = true; - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray2, x, false), flipArraySign(zArray2, z, false), 3, false, 0, x + 3, z +15, 22, x - 18.5, - y + 1, z + 16, TrackTypes.MEDIUM_RIGHT_TURN.getLabel(), null)) - return false; - TileTCRail tcRailTurn2 = (TileTCRail) world.getTileEntity(x+3, y + 1, z+15); - - if (tcRailTurn2 != null) { - tcRailTurn2.hasModel = false; - tcRailTurn2.isLinkedToRail = true; - tcRailTurn2.linkedX = x; - tcRailTurn2.linkedY = y + 1; - tcRailTurn2.linkedZ = z ; - } - tcRailTurn.isLinkedToRail = true; - tcRailTurn.linkedX = x + 3; - tcRailTurn.linkedY = y + 1; - tcRailTurn.linkedZ = z + 15; - } - return true; - - } - - if (l == 1) { - - - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, true), flipArraySign(xArray, z, false), l, false, 1, x-15, z+3, 22, x + 1, - y + 1, z + 22.5 , tempType.getLabel(), tempType.getItem().item)) - return false; - TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x , y + 1, z ); - - if (tcRailTurn != null) { - tcRailTurn.hasModel = true; - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray2, x, true), flipArraySign(xArray2, z, false), 0, false, 1, x - 15, z + 3, 22, x - 15, - y + 1, z - 18.5, TrackTypes.MEDIUM_LEFT_TURN.getLabel(), null)) - return false; - TileTCRail tcRailTurn2 = (TileTCRail) world.getTileEntity(x-15, y + 1, z+3); - - if (tcRailTurn2 != null) { - tcRailTurn2.hasModel = false; - tcRailTurn2.isLinkedToRail = true; - tcRailTurn2.linkedX = x; - tcRailTurn2.linkedY = y + 1; - tcRailTurn2.linkedZ = z ; - } - tcRailTurn.isLinkedToRail = true; - tcRailTurn.linkedX = x - 15; - tcRailTurn.linkedY = y + 1; - tcRailTurn.linkedZ = z+ 3; - } - return true; - - } - if (l == 3) { - - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, false), flipArraySign(xArray, z, true), l, false, 0, x+15, z-3, 22, x , - y + 1, z - 21.5 , tempType.getLabel(), tempType.getItem().item)) - return false; - TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x , y + 1, z ); - - - if (tcRailTurn != null) { - tcRailTurn.hasModel = true; - if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray2, x, false), flipArraySign(xArray2, z, true), 0, false, 0, x - 15, z - 3, 22, x +16, - y + 1, z + 19.5, TrackTypes.MEDIUM_LEFT_TURN.getLabel(), null)) - return false; - TileTCRail tcRailTurn2 = (TileTCRail) world.getTileEntity(x+15, y + 1, z-3); - - if (tcRailTurn2 != null) { - tcRailTurn2.hasModel = false; - tcRailTurn2.isLinkedToRail = true; - tcRailTurn2.linkedX = x; - tcRailTurn2.linkedY = y + 1; - tcRailTurn2.linkedZ = z ; - } - tcRailTurn.isLinkedToRail = true; - tcRailTurn.linkedX = x + 15; - tcRailTurn.linkedY = y + 1; - tcRailTurn.linkedZ = z- 3; - } - return true; - - } - return false; - } - - /** - * Drop the previous block before placing the track. - */ - private void placeTrack(World world, int x, int y, int z, Block block, int metadata){ - Block removed = world.getBlock(x, y, z); - if(removed != null){ - removed.dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), 0); - } - world.setBlock(x, y, z, block, metadata, 3); - } - - @SideOnly(Side.CLIENT) - @Override - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - par3List.add("\u00a77" + type.getTooltip()); - } - - public TrackTypes getTrackType() { - return this.type; - - } + } + tcRailTurn.isLinkedToRail = true; + tcRailTurn.linkedX = x + 2; + tcRailTurn.linkedY = y + 1; + tcRailTurn.linkedZ = z + 11; + } + return true; + } + + if (l == 1) { + + + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, true), flipArraySign(xArray, z, false), l, false, 1, x - 11, z + 2, 18.5, x + 1, + y + 1, z + 19, tempType.getLabel(), tempType.getItem().item)) + return false; + TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x, y + 1, z); + + if (tcRailTurn != null) { + tcRailTurn.hasModel = true; + + + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray2, x, true), flipArraySign(xArray2, z, false), 0, false, 1, x - 11, z + 2, 18.5, x - 11, + y + 1, z - 16, TrackTypes.MEDIUM_RIGHT_TURN.getLabel(), null)) + return false; + + TileTCRail tcRailTurn2 = (TileTCRail) world.getTileEntity(x - 11, y + 1, z + 2); + + if (tcRailTurn2 != null) { + tcRailTurn2.hasModel = false; + tcRailTurn2.isLinkedToRail = true; + tcRailTurn2.linkedX = x; + tcRailTurn2.linkedY = y + 1; + tcRailTurn2.linkedZ = z; + + } + tcRailTurn.isLinkedToRail = true; + tcRailTurn.linkedX = x - 11; + tcRailTurn.linkedY = y + 1; + tcRailTurn.linkedZ = z + 2; + } + return true; + } + + if (l == 3) { + + + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, false), flipArraySign(xArray, z, true), l, false, 3, x + 11, z - 2, 18.5, x, + y + 1, z - 18, tempType.getLabel(), tempType.getItem().item)) + return false; + TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x, y + 1, z); + + if (tcRailTurn != null) { + tcRailTurn.hasModel = true; + + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray2, x, false), flipArraySign(xArray2, z, true), 2, false, 3, x + 11, z - 2, 18.5, x + 12, + y + 1, z + 17, TrackTypes.MEDIUM_RIGHT_TURN.getLabel(), null)) + return false; + + TileTCRail tcRailTurn2 = (TileTCRail) world.getTileEntity(x + 11, y + 1, z - 2); + + if (tcRailTurn2 != null) { + tcRailTurn2.hasModel = false; + tcRailTurn2.isLinkedToRail = true; + tcRailTurn2.linkedX = x; + tcRailTurn2.linkedY = y + 1; + tcRailTurn2.linkedZ = z; + + } + tcRailTurn.isLinkedToRail = true; + tcRailTurn.linkedX = x + 11; + tcRailTurn.linkedY = y + 1; + tcRailTurn.linkedZ = z - 2; + } + return true; + } + return false; + } + + private boolean largeRightParallelCurve(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes tempType) { + + int[] xArray = {0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1}; + int[] zArray = {0, 1, 2, 3, 4, 5, 4, 5, 6, 7, 8}; + int[] xArray2 = {3, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3}; + int[] zArray2 = {15, 7, 8, 9, 10, 11, 10, 11, 12, 13, 14}; + + if (l == 2) { + + + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, false), flipArraySign(zArray, z, true), l, false, 2, x + 3, z - 15, 22, x + 22.5, + y + 1, z + 1, tempType.getLabel(), tempType.getItem().item)) + return false; + TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x, y + 1, z); + + if (tcRailTurn != null) { + tcRailTurn.hasModel = true; + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray2, x, false), flipArraySign(zArray2, z, true), 3, false, 2, x + 3, z - 15, 22, x - 18.5, + y + 1, z - 15, TrackTypes.MEDIUM_LEFT_TURN.getLabel(), null)) + return false; + TileTCRail tcRailTurn2 = (TileTCRail) world.getTileEntity(x + 3, y + 1, z - 15); + + if (tcRailTurn2 != null) { + tcRailTurn2.hasModel = false; + tcRailTurn2.isLinkedToRail = true; + tcRailTurn2.linkedX = x; + tcRailTurn2.linkedY = y + 1; + tcRailTurn2.linkedZ = z; + } + tcRailTurn.isLinkedToRail = true; + tcRailTurn.linkedX = x + 3; + tcRailTurn.linkedY = y + 1; + tcRailTurn.linkedZ = z - 15; + } + return true; + + } + + if (l == 0) { + + + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, true), flipArraySign(zArray, z, false), l, false, 0, x - 3, z + 15, 22, x - 21.5, + y + 1, z, tempType.getLabel(), tempType.getItem().item)) + return false; + TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x, y + 1, z); + + + if (tcRailTurn != null) { + tcRailTurn.hasModel = true; + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray2, x, true), flipArraySign(zArray2, z, false), 1, false, 0, x - 3, z + 15, 22, x + 19.5, + y + 1, z + 16, TrackTypes.MEDIUM_LEFT_TURN.getLabel(), null)) + return false; + TileTCRail tcRailTurn2 = (TileTCRail) world.getTileEntity(x - 3, y + 1, z + 15); + + if (tcRailTurn2 != null) { + tcRailTurn2.hasModel = false; + tcRailTurn2.isLinkedToRail = true; + tcRailTurn2.linkedX = x; + tcRailTurn2.linkedY = y + 1; + tcRailTurn2.linkedZ = z; + } + tcRailTurn.isLinkedToRail = true; + tcRailTurn.linkedX = x - 3; + tcRailTurn.linkedY = y + 1; + tcRailTurn.linkedZ = z + 15; + } + return true; + + } + + if (l == 1) { + + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, true), flipArraySign(xArray, z, true), l, false, 1, x - 15, z - 3, 22, x + 1, + y + 1, z - 21.5, tempType.getLabel(), tempType.getItem().item)) + return false; + TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x, y + 1, z); + + + if (tcRailTurn != null) { + tcRailTurn.hasModel = true; + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray2, x, true), flipArraySign(xArray2, z, true), 2, false, 1, x - 15, z - 3, 22, x - 15, + y + 1, z + 19.5, TrackTypes.MEDIUM_LEFT_TURN.getLabel(), null)) + return false; + TileTCRail tcRailTurn2 = (TileTCRail) world.getTileEntity(x - 15, y + 1, z - 3); + + if (tcRailTurn2 != null) { + tcRailTurn2.hasModel = false; + tcRailTurn2.isLinkedToRail = true; + tcRailTurn2.linkedX = x; + tcRailTurn2.linkedY = y + 1; + tcRailTurn2.linkedZ = z; + } + tcRailTurn.isLinkedToRail = true; + tcRailTurn.linkedX = x - 15; + tcRailTurn.linkedY = y + 1; + tcRailTurn.linkedZ = z - 3; + } + return true; + + } + if (l == 3) { + + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, false), flipArraySign(xArray, z, false), l, false, 3, x + 15, z + 3, 22, x, + y + 1, z + 22.5, tempType.getLabel(), tempType.getItem().item)) + return false; + TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x, y + 1, z); + + if (tcRailTurn != null) { + tcRailTurn.hasModel = true; + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray2, x, false), flipArraySign(xArray2, z, false), 0, false, 3, x - 15, z + 3, 22, x + 16, + y + 1, z - 18.5, TrackTypes.MEDIUM_LEFT_TURN.getLabel(), null)) + return false; + TileTCRail tcRailTurn2 = (TileTCRail) world.getTileEntity(x + 15, y + 1, z + 3); + + if (tcRailTurn2 != null) { + tcRailTurn2.hasModel = false; + tcRailTurn2.isLinkedToRail = true; + tcRailTurn2.linkedX = x; + tcRailTurn2.linkedY = y + 1; + tcRailTurn2.linkedZ = z; + } + tcRailTurn.isLinkedToRail = true; + tcRailTurn.linkedX = x + 15; + tcRailTurn.linkedY = y + 1; + tcRailTurn.linkedZ = z + 3; + } + return true; + + } + return false; + } + + private boolean largeLeftParallelCurve(EntityPlayer player, World world, int x, int y, int z, int l, TrackTypes tempType) { + + int[] xArray = {0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1}; + int[] zArray = {0, 1, 2, 3, 4, 5, 4, 5, 6, 7, 8}; + int[] xArray2 = {3, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3}; + int[] zArray2 = {15, 7, 8, 9, 10, 11, 10, 11, 12, 13, 14}; + + if (l == 2) { + + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, true), flipArraySign(zArray, z, true), l, false, 2, x - 3, z - 15, 22, x - 21.5, + y + 1, z + 1, tempType.getLabel(), tempType.getItem().item)) + return false; + TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x, y + 1, z); + + + if (tcRailTurn != null) { + tcRailTurn.hasModel = true; + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray2, x, true), flipArraySign(zArray2, z, true), 1, false, 2, x - 3, z - 15, 22, x + 19.5, + y + 1, z - 15, TrackTypes.MEDIUM_RIGHT_TURN.getLabel(), null)) + return false; + TileTCRail tcRailTurn2 = (TileTCRail) world.getTileEntity(x - 3, y + 1, z - 15); + + if (tcRailTurn2 != null) { + tcRailTurn2.hasModel = false; + tcRailTurn2.isLinkedToRail = true; + tcRailTurn2.linkedX = x; + tcRailTurn2.linkedY = y + 1; + tcRailTurn2.linkedZ = z; + } + tcRailTurn.isLinkedToRail = true; + tcRailTurn.linkedX = x - 3; + tcRailTurn.linkedY = y + 1; + tcRailTurn.linkedZ = z - 15; + } + return true; + + } + + if (l == 0) { + + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray, x, false), flipArraySign(zArray, z, false), l, false, 0, x + 3, z + 15, 22, x + 22.5, + y + 1, z, tempType.getLabel(), tempType.getItem().item)) + return false; + TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x, y + 1, z); + + if (tcRailTurn != null) { + tcRailTurn.hasModel = true; + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(xArray2, x, false), flipArraySign(zArray2, z, false), 3, false, 0, x + 3, z + 15, 22, x - 18.5, + y + 1, z + 16, TrackTypes.MEDIUM_RIGHT_TURN.getLabel(), null)) + return false; + TileTCRail tcRailTurn2 = (TileTCRail) world.getTileEntity(x + 3, y + 1, z + 15); + + if (tcRailTurn2 != null) { + tcRailTurn2.hasModel = false; + tcRailTurn2.isLinkedToRail = true; + tcRailTurn2.linkedX = x; + tcRailTurn2.linkedY = y + 1; + tcRailTurn2.linkedZ = z; + } + tcRailTurn.isLinkedToRail = true; + tcRailTurn.linkedX = x + 3; + tcRailTurn.linkedY = y + 1; + tcRailTurn.linkedZ = z + 15; + } + return true; + + } + + if (l == 1) { + + + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, true), flipArraySign(xArray, z, false), l, false, 1, x - 15, z + 3, 22, x + 1, + y + 1, z + 22.5, tempType.getLabel(), tempType.getItem().item)) + return false; + TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x, y + 1, z); + + if (tcRailTurn != null) { + tcRailTurn.hasModel = true; + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray2, x, true), flipArraySign(xArray2, z, false), 0, false, 1, x - 15, z + 3, 22, x - 15, + y + 1, z - 18.5, TrackTypes.MEDIUM_LEFT_TURN.getLabel(), null)) + return false; + TileTCRail tcRailTurn2 = (TileTCRail) world.getTileEntity(x - 15, y + 1, z + 3); + + if (tcRailTurn2 != null) { + tcRailTurn2.hasModel = false; + tcRailTurn2.isLinkedToRail = true; + tcRailTurn2.linkedX = x; + tcRailTurn2.linkedY = y + 1; + tcRailTurn2.linkedZ = z; + } + tcRailTurn.isLinkedToRail = true; + tcRailTurn.linkedX = x - 15; + tcRailTurn.linkedY = y + 1; + tcRailTurn.linkedZ = z + 3; + } + return true; + + } + if (l == 3) { + + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray, x, false), flipArraySign(xArray, z, true), l, false, 0, x + 15, z - 3, 22, x, + y + 1, z - 21.5, tempType.getLabel(), tempType.getItem().item)) + return false; + TileTCRail tcRailTurn = (TileTCRail) world.getTileEntity(x, y + 1, z); + + + if (tcRailTurn != null) { + tcRailTurn.hasModel = true; + if (!putDownTurn(player, world, false, x, y, z, flipArraySign(zArray2, x, false), flipArraySign(xArray2, z, true), 0, false, 0, x - 15, z - 3, 22, x + 16, + y + 1, z + 19.5, TrackTypes.MEDIUM_LEFT_TURN.getLabel(), null)) + return false; + TileTCRail tcRailTurn2 = (TileTCRail) world.getTileEntity(x + 15, y + 1, z - 3); + + if (tcRailTurn2 != null) { + tcRailTurn2.hasModel = false; + tcRailTurn2.isLinkedToRail = true; + tcRailTurn2.linkedX = x; + tcRailTurn2.linkedY = y + 1; + tcRailTurn2.linkedZ = z; + } + tcRailTurn.isLinkedToRail = true; + tcRailTurn.linkedX = x + 15; + tcRailTurn.linkedY = y + 1; + tcRailTurn.linkedZ = z - 3; + } + return true; + + } + return false; + } + + /** + * Drop the previous block before placing the track. + */ + private void placeTrack(World world, int x, int y, int z, Block block, int metadata) { + Block removed = world.getBlock(x, y, z); + if (removed != null) { + removed.dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), 0); + } + world.setBlock(x, y, z, block, metadata, 3); + } + + @SideOnly(Side.CLIENT) + @Override + public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { + par3List.add("\u00a77" + type.getTooltip()); + } + + public TrackTypes getTrackType() { + return this.type; + + } } diff --git a/src/main/java/train/common/items/TCRailTypes.java b/src/main/java/train/common/items/TCRailTypes.java new file mode 100644 index 0000000000..0b3e9b7fb2 --- /dev/null +++ b/src/main/java/train/common/items/TCRailTypes.java @@ -0,0 +1,17 @@ +package train.common.items; + +public enum TCRailTypes { + + STRAIGHT(), + DIAGONAL(), + TURN(), + SHARP_TURN(), + CURVE(), + CROSSING(), + DIAGONAL_CROSSING(), + SWITCH(), + SLOPE(), + CURVED_SLOPE(), + + +}