From 71eaf377ec4049d1eaaf62f4336ff9da9e4b8512 Mon Sep 17 00:00:00 2001 From: CBwagen Date: Fri, 13 Oct 2023 11:50:41 +0200 Subject: [PATCH] Added second bogie to B80 cars ...yis :) --- .../java/train/client/render/RenderEnum.java | 4 +- .../rollingStock/EntityElectricB80C_A.java | 2 +- .../rollingStock/EntityElectricKVB_2300.java | 2 +- .../rollingStock/EntityPassengerB80C_B.java | 37 +++++++++++++++++-- .../EntityPassengerKVB_2300_B.java | 37 +++++++++++++++++-- .../java/train/common/library/EnumTrains.java | 4 +- 6 files changed, 72 insertions(+), 14 deletions(-) diff --git a/src/main/java/train/client/render/RenderEnum.java b/src/main/java/train/client/render/RenderEnum.java index 55cee276bb..3cb977750b 100644 --- a/src/main/java/train/client/render/RenderEnum.java +++ b/src/main/java/train/client/render/RenderEnum.java @@ -1211,7 +1211,7 @@ public enum RenderEnum { PSRPOPM(EntityFreightPSRPOPM.class, new ModelPSRPOPM(), "PSRPOPM_", true, new float[] { 0F, 0.15F, 0.0F }, new float[] { 0F, 180F, 180F }, null, "", 0, null, "", null, 0, false), PSRPO(EntityFreightPSRPO.class, new ModelPSRPO(), "PSRPO_", true, new float[] { 0F, 0.15F, 0.0F }, new float[] { 0F, 180F, 180F }, null, "", 0, null, "", null, 0, false), KVB_2300(EntityElectricKVB_2300.class, new ModelKVB_2300(), "kvb_2300_", true,new float[] {-1.25F, 0.15F, 0F}, new float[] { 0F, 180F, 180F }, null, "", 0, null, "", null, 0, false), - KVB_2300_B( EntityPassengerKVB_2300_B.class, new ModelKVB_2300_B(),"kvb_2300_", true, new float[] {0F, 0.15F, 0F}, new float[] { 0F, 0F, 180F },null, "", 0, null, "", null, 0, false), + KVB_2300_B( EntityPassengerKVB_2300_B.class, new ModelKVB_2300_B(),"kvb_2300_", true, new float[] {-1.25F, 0.15F, 0F}, new float[] { 0F, 180F, 180F },null, "", 0, null, "", null, 0, false), //tcce5 new stuff (its mixed around in the file tbh) BR_MK2F_Coach( EntityPassengerBR_MK2F_Coach.class, new ModelBR_MK2F_Coach(), "BR_Mk2f_", true, new float[] {0.485F,0F,0F}, new float[] {0F, 180F, 180F}, null, "",0,null, "", null, 0, false), BR_MK2F_BSO(EntityPassengerBR_MK2F_BSO.class, new ModelBR_MK2F_BSO(), "BR_Mk2f_BSO_", true, new float[] {0.485F,0F,0F}, new float[] {0F, 180F, 180F}, null, "", 0 , null, "", null, 0, false), @@ -1309,7 +1309,7 @@ public enum RenderEnum { MetalTramCoach(EntityPassengerMetalTramCoach.class, new ModelMetalTramCoach(), "Metal_Tram_", true, new float[]{ 0.0F, 0.18F, 0.0F}, new float[]{ 0.0F, 180F, 180F} , null, "", 0, null, "", null, 0 , false ), HopperUK(EntityFreightHopperUK.class, new ModelHopper_UK(), "Hopper_UK_", true, new float[] {0F,0.1F,0F}, new float[] { 0F, 180F, 180F }, null, "", 0, null, "", null, 0, false), B80C_A(EntityElectricB80C_A.class, new ModelB80C_A(), "B80C_", true,new float[] {-1.25F, 0.15F, 0F}, new float[] { 0F, 180F, 180F }, null, "", 0, null, "", null, 0, false), - B80C_B( EntityPassengerB80C_B.class, new ModelB80C_B(),"B80C_", true, new float[] {0F, 0.15F, 0F}, new float[] { 0F, 0F, 180F },null, "", 0, null, "", null, 0, false), + B80C_B( EntityPassengerB80C_B.class, new ModelB80C_B(),"B80C_", true, new float[] {-1.25F, 0.15F, 0F}, new float[] { 0F, 180F, 180F },null, "", 0, null, "", null, 0, false), WoodenTramCoach(EntityPassengerWoodenTramCoach.class, new ModelWoodenTramCoach(), "Wooden_Tram_Coach_", true, new float[]{ 0.0F, 0.18F, 0.0F}, new float[]{ 0.0F, 180F, 180F} , null, "", 0, null, "", null, 0 , false ), MA100_Loco(EntityElectricMA100_Loco.class, new ModelMA100_Loco(), "MA100_", true,new float[] {-0.95F, 0.16F, 0F}, new float[] { 0F, 180F, 180F }, null, "", 0, null, "", null, 0, false), MA100_Tail(EntityPassengerMA100_Tail.class, new ModelMA100_Tail(), "MA100_",true,new float[] {0F, 0.16F, 0F}, new float[] { 0F, 0F, 180F }, null, "", 0, null, "", null, 0, false), diff --git a/src/main/java/train/common/entity/rollingStock/EntityElectricB80C_A.java b/src/main/java/train/common/entity/rollingStock/EntityElectricB80C_A.java index 9339b7aaad..795f28159e 100644 --- a/src/main/java/train/common/entity/rollingStock/EntityElectricB80C_A.java +++ b/src/main/java/train/common/entity/rollingStock/EntityElectricB80C_A.java @@ -138,7 +138,7 @@ public boolean interactFirst(EntityPlayer entityplayer) { } @Override public float getOptimalDistance(EntityMinecart cart) { - return 1.3F; + return 0.7F; } @Override diff --git a/src/main/java/train/common/entity/rollingStock/EntityElectricKVB_2300.java b/src/main/java/train/common/entity/rollingStock/EntityElectricKVB_2300.java index 03a96f663a..da919c38f7 100644 --- a/src/main/java/train/common/entity/rollingStock/EntityElectricKVB_2300.java +++ b/src/main/java/train/common/entity/rollingStock/EntityElectricKVB_2300.java @@ -138,7 +138,7 @@ public boolean interactFirst(EntityPlayer entityplayer) { } @Override public float getOptimalDistance(EntityMinecart cart) { - return 1.3F; + return 0.7F; } @Override diff --git a/src/main/java/train/common/entity/rollingStock/EntityPassengerB80C_B.java b/src/main/java/train/common/entity/rollingStock/EntityPassengerB80C_B.java index e29988696a..132abf9759 100644 --- a/src/main/java/train/common/entity/rollingStock/EntityPassengerB80C_B.java +++ b/src/main/java/train/common/entity/rollingStock/EntityPassengerB80C_B.java @@ -6,6 +6,7 @@ import net.minecraft.world.World; import train.common.api.EntityRollingStock; import train.common.api.IPassenger; +import train.common.api.ISecondBogie; public class EntityPassengerB80C_B extends EntityRollingStock implements IPassenger { //public TiltingHandler tiltingHandler = new TiltingHandler(7); @@ -27,9 +28,37 @@ public EntityPassengerB80C_B(World world, double d, double d1, double d2){ @Override public void updateRiderPosition() { - if(riddenByEntity!=null) { - riddenByEntity.setPosition(posX, posY + getMountedYOffset() + riddenByEntity.getYOffset() + 0.0, posZ); - }//ew yucky rider position code, good thing its a passenger car so it doesnt matter! Wheeze.png + if (riddenByEntity == null) {return;} + double pitchRads = this.anglePitchClient * Math.PI / 180.0D; + double distance = 1.8; + double yOffset = -0.1; + float rotationCos1 = (float) Math.cos(Math.toRadians(this.renderYaw + 90)); + float rotationSin1 = (float) Math.sin(Math.toRadians((this.renderYaw + 90))); + if(side.isServer()){ + rotationCos1 = (float) Math.cos(Math.toRadians(this.serverRealRotation + 90)); + rotationSin1 = (float) Math.sin(Math.toRadians((this.serverRealRotation + 90))); + anglePitchClient = serverRealPitch*60; + } + float pitch = (float) (posY + ((Math.tan(pitchRads) * distance) + getMountedYOffset()) + + riddenByEntity.getYOffset() + yOffset); + float pitch1 = (float) (posY + getMountedYOffset() + riddenByEntity.getYOffset() + yOffset); + double bogieX1 = (this.posX + (rotationCos1 * distance)); + double bogieZ1 = (this.posZ + (rotationSin1* distance)); + //System.out.println(rotationCos1+" "+rotationSin1); + if(anglePitchClient>20 && rotationCos1 == 1){ + bogieX1-=pitchRads*2; + pitch-=pitchRads*1.2; + } + if(anglePitchClient>20 && rotationSin1 == 1){ + bogieZ1-=pitchRads*2 + 1; + pitch-=pitchRads*1.2; + } + if (pitchRads == 0.0) { + riddenByEntity.setPosition(bogieX1, pitch1, bogieZ1); + } + if (pitchRads > -1.01 && pitchRads < 1.01) { + riddenByEntity.setPosition(bogieX1, pitch, bogieZ1); + } } @Override @@ -74,6 +103,6 @@ public boolean isPoweredCart() { @Override public float getOptimalDistance(EntityMinecart cart) { - return 2.4F; + return 1.75F; } } \ No newline at end of file diff --git a/src/main/java/train/common/entity/rollingStock/EntityPassengerKVB_2300_B.java b/src/main/java/train/common/entity/rollingStock/EntityPassengerKVB_2300_B.java index 6268d91230..d16364fba6 100644 --- a/src/main/java/train/common/entity/rollingStock/EntityPassengerKVB_2300_B.java +++ b/src/main/java/train/common/entity/rollingStock/EntityPassengerKVB_2300_B.java @@ -6,6 +6,7 @@ import net.minecraft.world.World; import train.common.api.EntityRollingStock; import train.common.api.IPassenger; +import train.common.api.ISecondBogie; public class EntityPassengerKVB_2300_B extends EntityRollingStock implements IPassenger { //public TiltingHandler tiltingHandler = new TiltingHandler(7); @@ -27,9 +28,37 @@ public EntityPassengerKVB_2300_B(World world, double d, double d1, double d2){ @Override public void updateRiderPosition() { - if(riddenByEntity!=null) { - riddenByEntity.setPosition(posX, posY + getMountedYOffset() + riddenByEntity.getYOffset() + 0.0, posZ); - }//ew yucky rider position code, good thing its a passenger car so it doesnt matter! Wheeze.png + if (riddenByEntity == null) {return;} + double pitchRads = this.anglePitchClient * Math.PI / 180.0D; + double distance = 1.8; + double yOffset = -0.1; + float rotationCos1 = (float) Math.cos(Math.toRadians(this.renderYaw + 90)); + float rotationSin1 = (float) Math.sin(Math.toRadians((this.renderYaw + 90))); + if(side.isServer()){ + rotationCos1 = (float) Math.cos(Math.toRadians(this.serverRealRotation + 90)); + rotationSin1 = (float) Math.sin(Math.toRadians((this.serverRealRotation + 90))); + anglePitchClient = serverRealPitch*60; + } + float pitch = (float) (posY + ((Math.tan(pitchRads) * distance) + getMountedYOffset()) + + riddenByEntity.getYOffset() + yOffset); + float pitch1 = (float) (posY + getMountedYOffset() + riddenByEntity.getYOffset() + yOffset); + double bogieX1 = (this.posX + (rotationCos1 * distance)); + double bogieZ1 = (this.posZ + (rotationSin1* distance)); + //System.out.println(rotationCos1+" "+rotationSin1); + if(anglePitchClient>20 && rotationCos1 == 1){ + bogieX1-=pitchRads*2; + pitch-=pitchRads*1.2; + } + if(anglePitchClient>20 && rotationSin1 == 1){ + bogieZ1-=pitchRads*2 + 1; + pitch-=pitchRads*1.2; + } + if (pitchRads == 0.0) { + riddenByEntity.setPosition(bogieX1, pitch1, bogieZ1); + } + if (pitchRads > -1.01 && pitchRads < 1.01) { + riddenByEntity.setPosition(bogieX1, pitch, bogieZ1); + } } @Override @@ -74,6 +103,6 @@ public boolean isPoweredCart() { @Override public float getOptimalDistance(EntityMinecart cart) { - return 2.4F; + return 1.75F; } } \ No newline at end of file diff --git a/src/main/java/train/common/library/EnumTrains.java b/src/main/java/train/common/library/EnumTrains.java index 8299e893b9..a2b19a74b5 100644 --- a/src/main/java/train/common/library/EnumTrains.java +++ b/src/main/java/train/common/library/EnumTrains.java @@ -440,7 +440,7 @@ public enum EnumTrains { PSRPO("PSRPO", EntityFreightPSRPO.class, ItemIDs.minecartPSRPO.item, "freight", 1.5, TraincraftUtil.getBytesFromColors(new String[]{"Blue", "Yellow", "Cyan"}), 18, 27,"Pack: Bap"), BoulderWagon("BoulderWagon", EntityBoulderWagon.class, ItemIDs.minecartBoulderWagon.item, "freight", 5, TraincraftUtil.getBytesFromColors(new String[]{"Grey", "Orange"}), 0, 9, "Made by hariesh"), KVB_2300("KVB_2300", EntityElectricKVB_2300.class, ItemIDs.minecartKVB_2300.item, "electric", 300, 60, 0,60, 0, 100, 0.7, 0.8, 1000, TraincraftUtil.getBytesFromColors(new String[] {"Red", "Grey", "White"}), 18, -2.4, "Made by Kranker"), - KVB_2300_B("KVB_2300_B", EntityPassengerKVB_2300_B.class, ItemIDs.minecartKVB_2300_B.item, "passenger", 0, 0, 3,0 , 0, 0, 0,0,0,TraincraftUtil.getBytesFromColors(new String[] {"Red", "Grey", "White"}),0,0, "Made by Kranker"), + KVB_2300_B("KVB_2300_B", EntityPassengerKVB_2300_B.class, ItemIDs.minecartKVB_2300_B.item, "passenger", 0, 0, 3,0 , 0, 0, 0,0,0,TraincraftUtil.getBytesFromColors(new String[] {"Red", "Grey", "White"}),0,-2.4, "Made by Kranker"), BR_MK2C_BSO("BR_MK2C_BSO", EntityPassengerBR_MK2C_BSO.class, ItemIDs.minecartBR_Mk2c_BSO.item, "passenger",0, 0, 3,0 , 0, 0, 0,0,0,TraincraftUtil.getBytesFromColors(new String[] {"Blue", "Brown", "Cyan", "Grey", "Magenta", "Lime", "Purple", "LightGrey", "LightBlue", "Green"}),0, 0, "Pack: B.I.P."), BR_MK2C_Coach("BR_MK2C_Coach", EntityPassengerBR_MK2C_Coach.class, ItemIDs.minecartBR_MK2C_Coach.item, "passenger", 0, 0, 3,0 , 0, 0, 0,0,0,TraincraftUtil.getBytesFromColors(new String[] {"Blue", "Brown", "Cyan", "Grey", "Magenta", "Red", "LightBlue", "Green", "Black", "LightGrey", "Yellow", "Lime", "Pink", "Purple"}),0, 0, "Pack: B.I.P."), BR_MK2F_BSO("BR_MK2F_BSO", EntityPassengerBR_MK2F_BSO.class, ItemIDs.minecartBR_Mk2f_BSO.item, "passenger",0, 0, 3,0 , 0, 0, 0,0,0,TraincraftUtil.getBytesFromColors(new String[] {"Blue", "Brown", "Cyan", "Grey", "Magenta", "Red", "Lime", "Purple", "Black", "Orange", "LightGrey", "Green"}),0, 0, "Pack: B.I.P."), @@ -518,7 +518,7 @@ public enum EnumTrains { GWR_72xx("GWR72xx", EntityLocoSteamGWR72xx.class, ItemIDs.minecartGWR72xx.item, "steam", 1375, 105, 0, 10, 10 , 100, 0.7, 0.7, 9000, TraincraftUtil.getBytesFromColors(new String[] {"Black", "Blue", "Green", "Lime"}), 18, -5.0f, "Pack: B.I.P."), GWR_101_Class("GWR101Class", EntityLocoSteamGWR101Class.class, ItemIDs.minecartGWR101Class.item, "steam", 550, 51, 0, 10, 10 , 100, 0.7, 0.7, 9500, TraincraftUtil.getBytesFromColors(new String[] {"Blue", "Brown", "Green", "Grey", "Lime", "Purple", "Red", "Black", "Magenta", "Grey", "LightGrey", "White"}), 18, -2.4f, "Pack: B.I.P."), B80C_A("B80C_A", EntityElectricB80C_A.class, ItemIDs.minecartB80C_A.item, "electric", 300, 80, 0,60, 0, 100, 0.7, 0.8, 1000, TraincraftUtil.getBytesFromColors(new String[] {"Red", "Grey", "White","Pink","Yellow","Green", "Orange","Magenta"}), 18, -2.4, "Pack: Metro In Motion"), - B80C_B("B80C_B", EntityPassengerB80C_B.class, ItemIDs.minecartB80C_B.item, "passenger", 0, 0, 3,0 , 0, 0, 0,0,0,TraincraftUtil.getBytesFromColors(new String[] {"Red", "Grey", "White","Pink","Yellow","Green","Orange","Magenta"}),0,0, "Pack: Metro In Motion"), + B80C_B("B80C_B", EntityPassengerB80C_B.class, ItemIDs.minecartB80C_B.item, "passenger", 0, 0, 3,0 , 0, 0, 0,0,0,TraincraftUtil.getBytesFromColors(new String[] {"Red", "Grey", "White","Pink","Yellow","Green","Orange","Magenta"}),0,-2.4, "Pack: Metro In Motion"), WoodenTramCoach("WoodenTramCoach", EntityPassengerWoodenTramCoach.class, ItemIDs.minecartWoodenTramCoach.item, "passenger", 0, 0, 1, 0, 0, 0, 0, 0, 0, TraincraftUtil.getBytesFromColors(new String[]{"Green", "Pink","Yellow","Lime"}), 18, 0), MA100_Loco("MA100_Loco", EntityElectricMA100_Loco.class, ItemIDs.minecartMA100_Loco.item, "electric", 600, 70, 0, 10, 0, 100, 0.7, 0.8, 1000, TraincraftUtil.getBytesFromColors(new String[]{"Yellow", "Cyan", "Purple","Orange"}), 18, -2, "Pack: MetroIM"), MA100_Tail("MA100_Tail", EntityPassengerMA100_Tail.class, ItemIDs.minecartMA100_Tail.item, "passenger", 0, 0, 2, 0, 0, 0, 0, 0, 0, TraincraftUtil.getBytesFromColors(new String[]{"Yellow", "Cyan", "Purple","Orange"}), 10, 0, "Pack: MetroIM"),