From 9d1ca7bbe8d284bf34603a213df940bf6c0bd8c4 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Mon, 11 Sep 2023 21:35:46 -0500 Subject: [PATCH] major bugfixes - Fixed porting issues from new features in the 1.7 branch. - Fixed a couple crashes. - Hearth Furnace GUI opens. - Fixed player collisions with blocks. - Fixed trains and stock not moving. Shout out to my manager, "S" for the inspiration to keep a fire lit. --- .../java/ebf/tim/blocks/BlockDynamic.java | 9 +++-- .../java/ebf/tim/entities/EntitySeat.java | 10 ++++-- .../tim/entities/GenericRailTransport.java | 16 +++++---- src/main/java/ebf/tim/gui/GUIPaintBucket.java | 2 +- src/main/java/ebf/tim/gui/GUISeatManager.java | 22 ++++++------ src/main/java/ebf/tim/gui/GUITransport.java | 16 +++++---- .../ebf/tim/networking/PacketSeatUpdate.java | 21 +++++------ .../java/ebf/tim/utility/CommonProxy.java | 1 + .../hearth/ContainerOpenHearthFurnace.java | 36 ++++++++++--------- 9 files changed, 75 insertions(+), 58 deletions(-) diff --git a/src/main/java/ebf/tim/blocks/BlockDynamic.java b/src/main/java/ebf/tim/blocks/BlockDynamic.java index 268a4b7b40..74f9f77f6a 100644 --- a/src/main/java/ebf/tim/blocks/BlockDynamic.java +++ b/src/main/java/ebf/tim/blocks/BlockDynamic.java @@ -3,6 +3,7 @@ import depreciated.minecraft.util.IIcon; import ebf.tim.TrainsInMotion; import ebf.tim.utility.CommonUtil; +import ebf.tim.utility.DebugUtil; import ebf.tim.utility.TransportSlotManager; import fexcraft.tmt.slim.ModelBase; import net.minecraft.block.Block; @@ -114,13 +115,15 @@ public TileEntity createNewTileEntity(World world, int meta) { //@Override public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) { - return new AxisAlignedBB((double)x + hitboxShape()[0], (double)y + hitboxShape()[1], (double)z + hitboxShape()[2], - (double)x + hitboxShape()[3], (double)y + hitboxShape()[4], (double)z + hitboxShape()[5]); + return new AxisAlignedBB((double)hitboxShape()[0], (double)hitboxShape()[1], (double)hitboxShape()[2], + (double)hitboxShape()[3], (double)hitboxShape()[4], (double)hitboxShape()[5]).offset(x,y,z); } @Override public void addCollisionBoxToList(IBlockState state, World world, BlockPos pos, AxisAlignedBB entityBox, List collidingBoxes, @Nullable Entity entityIn, boolean isActualState) { //this.setBlockBoundsBasedOnState(world, x, y, z); - collidingBoxes.add(this.getCollisionBoundingBoxFromPool(world, pos.getX(),pos.getY(),pos.getZ())); + if (entityBox.intersects(this.getCollisionBoundingBoxFromPool(world, pos.getX(), pos.getY(), pos.getZ()))) { + collidingBoxes.add(this.getCollisionBoundingBoxFromPool(world, pos.getX(), pos.getY(), pos.getZ())); + } } @Override public boolean isPassable(IBlockAccess worldIn, BlockPos pos) { diff --git a/src/main/java/ebf/tim/entities/EntitySeat.java b/src/main/java/ebf/tim/entities/EntitySeat.java index 4d5dca29d1..6feb15c0c7 100644 --- a/src/main/java/ebf/tim/entities/EntitySeat.java +++ b/src/main/java/ebf/tim/entities/EntitySeat.java @@ -142,9 +142,9 @@ public void writeSpawnData(ByteBuf buffer) { } @Override - public void updateRiderPosition() { - if (this.getPassenger() != null) { - this.getPassenger().setPosition(this.posX, this.posY+(getWorld().isRemote?(this.getPassenger()==Minecraft.getMinecraft().thePlayer?0.4:-1.3):-1.5), this.posZ); + public void updatePassenger(Entity passenger) { + if (this.isPassenger(passenger)) { + passenger.setPosition(this.posX, this.posY+(getWorld().isRemote?(passenger==Minecraft.getMinecraft().player?0.4:-1.3):-1.5), this.posZ); } } @@ -158,6 +158,10 @@ public void addPassenger(Entity passenger) { super.addPassenger(passenger); } + @Override + public void removePassenger(Entity passenger) { + super.removePassenger(passenger); + } public boolean isControlSeat(){return controller;} public boolean isLocoControlSeat(){return controller && locomotive;} diff --git a/src/main/java/ebf/tim/entities/GenericRailTransport.java b/src/main/java/ebf/tim/entities/GenericRailTransport.java index ce509992cc..3bad171bd8 100644 --- a/src/main/java/ebf/tim/entities/GenericRailTransport.java +++ b/src/main/java/ebf/tim/entities/GenericRailTransport.java @@ -412,7 +412,7 @@ public AxisAlignedBB getCollisionBox(Entity collidedWith){ public boolean canBeCollidedWith() {return true;} /**client only positioning of the transport, this should help to smooth the movement*/ @SideOnly(Side.CLIENT) - public void setPositionAndRotation2(double p_70056_1_, double p_70056_3_, double p_70056_5_, float p_70056_7_, float p_70056_8_, int p_70056_9_) { + public void setPositionAndRotationDirect(double x, double y, double z, float yaw, float pitch, int posRotationIncrements, boolean teleport){ if (backBogie !=null && frontBogie != null){ setRotation(CommonUtil.atan2degreesf( @@ -420,10 +420,10 @@ public void setPositionAndRotation2(double p_70056_1_, double p_70056_3_, double backBogie.posX - frontBogie.posX), CommonUtil.calculatePitch(backBogie.posY, frontBogie.posY,Math.abs(rotationPoints()[0]) + Math.abs(rotationPoints()[1]))); - transportX=p_70056_1_; - transportY=p_70056_3_; - transportZ=p_70056_5_; - tickOffset = p_70056_9_+2; + transportX=x; + transportY=y; + transportZ=z; + tickOffset = posRotationIncrements+2; //handle bogie rotations if(renderData!=null && renderData.bogies!=null){ @@ -446,7 +446,7 @@ public void setPositionAndRotation2(double p_70056_1_, double p_70056_3_, double } } }else { - this.setPosition(p_70056_1_, p_70056_3_, p_70056_5_); + this.setPosition(x, y, z); } } @@ -1171,6 +1171,10 @@ public void onUpdate() { prevPosX = posX; prevPosZ = posZ; if(tickOffset >0) { + + cachedVectors[1] = new Vec3f(-rotationPoints()[0], 0, 0).rotatePoint(0, rotationYaw, 0) + .addVector(backBogie.posX,backBogie.posY,backBogie.posZ); + setPosition(cachedVectors[1].xCoord, cachedVectors[1].yCoord,cachedVectors[1].zCoord); setPosition( this.posX + (this.transportX - this.posX) / (double) this.tickOffset, this.posY + (this.transportY - this.posY) / (double) this.tickOffset, diff --git a/src/main/java/ebf/tim/gui/GUIPaintBucket.java b/src/main/java/ebf/tim/gui/GUIPaintBucket.java index 50455297f2..66c2d063d3 100644 --- a/src/main/java/ebf/tim/gui/GUIPaintBucket.java +++ b/src/main/java/ebf/tim/gui/GUIPaintBucket.java @@ -212,7 +212,7 @@ public void onClick() { @Override public FontRenderer getFont() { - return fontRendererObj; + return fontRenderer; } } ); diff --git a/src/main/java/ebf/tim/gui/GUISeatManager.java b/src/main/java/ebf/tim/gui/GUISeatManager.java index 3ab8eae34b..27cff6827a 100644 --- a/src/main/java/ebf/tim/gui/GUISeatManager.java +++ b/src/main/java/ebf/tim/gui/GUISeatManager.java @@ -48,15 +48,15 @@ public void drawScreen(int parWidth, int parHeight, float p_73863_3_) { this.drawDefaultBackground(); super.drawScreen(parWidth, parHeight, p_73863_3_); locations = new ArrayList<>(); - guiLeft=new ScaledResolution(Minecraft.getMinecraft(), Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight).getScaledWidth(); - guiTop=new ScaledResolution(Minecraft.getMinecraft(), Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight).getScaledHeight(); + guiLeft=new ScaledResolution(Minecraft.getMinecraft()).getScaledWidth(); + guiTop=new ScaledResolution(Minecraft.getMinecraft()).getScaledHeight(); if (entity.getRiderOffsets().length==0 || entity.getRiderOffsets() == null){ return; } for(EntitySeat seat : entity.seats) { if (seat.getPassenger() != null) { - if (seat.getPassenger() == Minecraft.getMinecraft().thePlayer) { + if (seat.getPassenger() == Minecraft.getMinecraft().player) { currentSeat = seat; } filledSeatIDs.add(seat.getEntityId()); @@ -93,16 +93,16 @@ public void defineButtons(){ column++; activeRow=0; } - int width = fontRendererObj.getStringWidth("Empty Seat") + 6; + int width = fontRenderer.getStringWidth("Empty Seat") + 6; if (entity.seats.get(i).getPassenger() instanceof EntityPlayer) { - if (fontRendererObj.getStringWidth(entity.seats.get(i).getPassenger().getCommandSenderName()) > width) { - width = fontRendererObj.getStringWidth(entity.seats.get(i).getPassenger().getCommandSenderName()) + 7; + if (fontRenderer.getStringWidth(entity.seats.get(i).getPassenger().getName()) > width) { + width = fontRenderer.getStringWidth(entity.seats.get(i).getPassenger().getName()) + 7; if(width%2 !=0) width++; } buttonList.add( - new GUIButton(percentLeft(50)-60-(totalColumns/2)+(column*120)-(width/2), percentTop(25)+(28*activeRow+1)-11, width,20,entity.seats.get(i).getPassenger().getCommandSenderName()) { + new GUIButton(percentLeft(50)-60-(totalColumns/2)+(column*120)-(width/2), percentTop(25)+(28*activeRow+1)-11, width,20,entity.seats.get(i).getPassenger().getName()) { @Override public String getHoverText() { return "Seat is currently occupied"; @@ -110,7 +110,7 @@ public String getHoverText() { @Override public void onClick() {} @Override - public FontRenderer getFont(){return fontRendererObj;} + public FontRenderer getFont(){return fontRenderer;} } ); } else { //TODO: add an else if for things that aren't players. this becomes important for stuff like stock cars or putting villagers in player seats @@ -126,7 +126,7 @@ public void onClick() { } @Override - public FontRenderer getFont(){return fontRendererObj;} + public FontRenderer getFont(){return fontRenderer;} } ); } @@ -134,7 +134,7 @@ public void onClick() { activeRow++; } buttonList.add( - new GUIButton( percentLeft(50)-((fontRendererObj.getStringWidth("Close")+7)/2), percentTop(75)-10, fontRendererObj.getStringWidth("Close")+7,20,"Close") { + new GUIButton( percentLeft(50)-((fontRenderer.getStringWidth("Close")+7)/2), percentTop(75)-10, fontRenderer.getStringWidth("Close")+7,20,"Close") { @Override public String getHoverText() { return "Close Inventory"; @@ -144,7 +144,7 @@ public void onClick() { mc.displayGuiScreen(null); } @Override - public FontRenderer getFont(){return fontRendererObj;} + public FontRenderer getFont(){return fontRenderer;} } ); break; diff --git a/src/main/java/ebf/tim/gui/GUITransport.java b/src/main/java/ebf/tim/gui/GUITransport.java index a0e512f6a0..ea4d434e78 100644 --- a/src/main/java/ebf/tim/gui/GUITransport.java +++ b/src/main/java/ebf/tim/gui/GUITransport.java @@ -269,7 +269,7 @@ public void onClick() { @Override public FontRenderer getFont(){return fontRenderer;} }); - if (transport.getRiderOffsets().length > 0 || transport.getRiderOffsets() != null) { + if (transport.getRiderOffsets() != null && transport.getRiderOffsets().length > 0) { this.buttons.add(new GUIButton((int)guiLeft+166,(int)guiTop+166, 18,18) { @Override public String getHoverText() { @@ -287,7 +287,7 @@ public void onClick() { } @Override - public FontRenderer getFont(){return fontRendererObj;} + public FontRenderer getFont(){return fontRenderer;} }); } //train specific @@ -433,11 +433,11 @@ private void renderPassengerInventory(Minecraft mc){ if (i/(rows+1) >=5*(rows+1)){ rows++; } - if (i==0 && transport.riddenByEntity instanceof AbstractClientPlayer){ - mc.getTextureManager().bindTexture(((AbstractClientPlayer) transport.riddenByEntity).getLocationSkin()); + if (i==0 && transport.getPassengers().get(0) instanceof AbstractClientPlayer){ + mc.getTextureManager().bindTexture(((AbstractClientPlayer) transport.getPassengers().get(0)).getLocationSkin()); ClientUtil.drawTexturedRect(guiLeft + 108 + (30*(i-(rows * 5))), guiTop + 32+(30*rows), 30, 70, 23, 23, 36, 56); - } else if (i>0 && transport.seats.get(i-1).riddenByEntity instanceof AbstractClientPlayer){ - mc.getTextureManager().bindTexture(((AbstractClientPlayer) transport.seats.get(i-1).riddenByEntity).getLocationSkin()); + } else if (i>0 && transport.seats.get(i-1).getPassengers().get(0) instanceof AbstractClientPlayer){ + mc.getTextureManager().bindTexture(((AbstractClientPlayer) transport.seats.get(i-1).getPassengers().get(0)).getLocationSkin()); ClientUtil.drawTexturedRect(guiLeft + 108 + (30*(i-(rows * 5))), guiTop + 32+(30*rows), 30, 70, 23, 23, 36, 56); } } @@ -507,7 +507,9 @@ private void renderTankerInventory(Minecraft mc, int mouseX, int mouseY){ Tessellator.bindTexture(URIRegistry.GUI_PREFIX.getResource("gui.png")); ClientUtil.drawTexturedRect(186, 40 + (-20 * i), 16, 0, 90, 18, 16, 16); - if (transport.getTankInfo()[i] != null && transport.getTankInfo()[i].fluid.amount > 0) { + if (transport.getTankInfo()[i] != null && transport.getTankInfo()[i].fluid != null && + transport.getTankInfo()[i].fluid.getFluid() != null && + transport.getTankInfo()[i].fluid.getFluid().getBlock() !=null&& transport.getTankInfo()[i].fluid.amount > 0) { liquid = transport.getTankInfo()[i].fluid.amount; if (liquid != 0) { liquid /= transport.getTankInfo()[i].capacity; diff --git a/src/main/java/ebf/tim/networking/PacketSeatUpdate.java b/src/main/java/ebf/tim/networking/PacketSeatUpdate.java index f37bbaa876..60f0edefd8 100644 --- a/src/main/java/ebf/tim/networking/PacketSeatUpdate.java +++ b/src/main/java/ebf/tim/networking/PacketSeatUpdate.java @@ -1,16 +1,17 @@ package ebf.tim.networking; -import cpw.mods.fml.common.network.NetworkRegistry; -import cpw.mods.fml.common.network.simpleimpl.IMessage; -import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; -import cpw.mods.fml.common.network.simpleimpl.MessageContext; -import cpw.mods.fml.relauncher.Side; import ebf.tim.TrainsInMotion; import ebf.tim.entities.EntitySeat; import ebf.tim.entities.GenericRailTransport; import io.netty.buffer.ByteBuf; import net.minecraft.client.Minecraft; import net.minecraft.entity.Entity; +import net.minecraftforge.fml.common.network.NetworkRegistry; +import net.minecraftforge.fml.common.network.simpleimpl.IMessage; +import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; +import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; +import net.minecraftforge.fml.relauncher.Side; + /** *

Seat Packet

* bi-directional packet for managing seat changes while in a piece of stock. @@ -52,18 +53,18 @@ public static class Handler implements IMessageHandler