Jump to content

MrRumpell

Members
  • Posts

    3
  • Joined

  • Last visited

Everything posted by MrRumpell

  1. Hey all! I've made a custom train entity that extends the EntityMinecart class. However i'm having some issues with the Yaw when on rails (north-south vs east-west) and the rotation around curves seem backwards (counterclockwise when should be clockwise and visa versa) Ive made multiple adjustments to no avail. Is there anyone in here that would mind taking a glance at this code and seeing if you can see anything I'm missing? public class TrainEntity extends EntityMinecart implements IWorldNameable{ private boolean isFirstUpdate = true; public TrainEntity(World world) { super(world); } @Override public EntityMinecart.Type getType() { return EntityMinecart.Type.RIDEABLE; } @Override public void onUpdate() { super.onUpdate(); if (isFirstUpdate) { adjustInitialRotation(); isFirstUpdate = false; } else { adjustRotationOnCurve(); } } private void adjustInitialRotation() { BlockPos pos = new BlockPos(this.posX, this.posY - 1, this.posZ); IBlockState state = this.world.getBlockState(pos); if (state.getBlock() instanceof BlockRailBase) { BlockRailBase.EnumRailDirection railDirection = ((BlockRailBase) state.getBlock()).getRailDirection(world, pos, state, this); this.rotationYaw = getInitialYaw(railDirection); } } private void adjustRotationOnCurve() { BlockPos pos = new BlockPos(this.posX, this.posY - 1, this.posZ); IBlockState state = this.world.getBlockState(pos); if (state.getBlock() instanceof BlockRailBase) { BlockRailBase.EnumRailDirection railDirection = ((BlockRailBase) state.getBlock()).getRailDirection(world, pos, state, this); if (isCurve(railDirection)) { this.rotationYaw = getCurveYaw(railDirection, this.rotationYaw); } } } private boolean isCurve(BlockRailBase.EnumRailDirection railDirection) { return railDirection == BlockRailBase.EnumRailDirection.NORTH_EAST || railDirection == BlockRailBase.EnumRailDirection.NORTH_WEST || railDirection == BlockRailBase.EnumRailDirection.SOUTH_EAST || railDirection == BlockRailBase.EnumRailDirection.SOUTH_WEST; } private float getInitialYaw(BlockRailBase.EnumRailDirection railDirection) { switch (railDirection) { case EAST_WEST: return 90f; case NORTH_SOUTH: return 0f; // Add cases for diagonals if your model is designed to align with them initially default: return 0f; // Default North } } private float getCurveYaw(BlockRailBase.EnumRailDirection railDirection, float currentYaw) { // This simplified approach assumes a 90-degree rotation for curves. // You'll need to adjust this based on your rail's actual geometry and how you want the train to appear when entering/exiting curves. switch (railDirection) { case NORTH_EAST: return (currentYaw + 90) % 360; case NORTH_WEST: return (currentYaw - 90 + 360) % 360; case SOUTH_EAST: return (currentYaw + 90) % 360; case SOUTH_WEST: return (currentYaw - 90 + 360) % 360; default: return currentYaw; // No adjustment for straight paths } } }
  2. This Issue has been resolved. A @admin can close this thread.
  3. Hey all! This is my first post here so please bear with me as I may not initially post all of the needed information. I am trying to create a train. Built the model, have it in java code, and using the EntityMinecart class as an extension. Although when I right click (currently)my egg to spawn it, it does nothing. Would any of you be willing to glance at my code and see what the problem could be? If any more code is needed just let me know and I'll be happy to provide it. I want to add that I'm no longer using MCreator. I started in there and then quickly learned of the limitations. I did take everything over to Eclipse and left the structure it came up with because I have a custom rail block that works correctly that I would like to not break. lol This is my TrainEntity.java package net.mcreator.diagonalrails.entity; import net.minecraft.entity.Entity; import net.minecraft.entity.item.EntityMinecart; import net.minecraft.world.World; import net.minecraftforge.fml.common.registry.EntityRegistry; public class TrainEntity extends EntityMinecart { public TrainEntity(World world) { super(world); } @Override public EntityMinecart.Type getType() { // Customize your minecart type or use an existing one return EntityMinecart.Type.RIDEABLE; } // Custom methods and overrides for your entity behavior } This is my TrainModel.java // Made with Blockbench 4.9.3 // Exported for Minecraft version 1.7 - 1.12 // Paste this class into your mod and generate all required imports package net.mcreator.diagonalrails.Client.Model; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; import net.mcreator.diagonalrails.Client.Renderer.Entity.*; public class TrainModel extends ModelBase { private final ModelRenderer train; private final ModelRenderer light2_r1; private final ModelRenderer firebox4_r1; public TrainModel() { textureWidth = 300; textureHeight = 300; train = new ModelRenderer(this); train.setRotationPoint(0.0F, 16.0F, 0.0F); train.setTextureOffset(8, 135).addBox(-60, -50, -230, 120, 120, 240); train.setTextureOffset(129, 54).addBox(-70, 60, 10, 140, 10, 130); train.setTextureOffset(32, 123).addBox(60, -170, 10, 10, 230, 10); train.setTextureOffset(35, 154).addBox(-70, -170, 10, 10, 230, 10); train.setTextureOffset(0, 112).addBox(50, -40, 20, 20, 100, 120); train.setTextureOffset(0, 112).addBox(-70, -40, 20, 20, 100, 120); train.setTextureOffset(51, 147).addBox(-70, -170, 130, 10, 130, 10); train.setTextureOffset(25, 130).addBox(60, -170, 130, 10, 130, 10); train.setTextureOffset(8, 102).addBox(-70, -180, 10, 140, 10, 130); train.setTextureOffset(0, 128).addBox(-14, -141, -190, 29, 85, 170); train.setTextureOffset(0, 128).addBox(-42, -114, -190, 84, 29, 170); train.setTextureOffset(18, 118).addBox(-14, -60, -190, 30, 10, 170); train.setTextureOffset(131, 136).addBox(50, -60, -210, 10, 10, 220); train.setTextureOffset(120, 115).addBox(-60, -60, -210, 10, 10, 220); train.setTextureOffset(131, 36).addBox(70, 0, 50, 10, 80, 40); train.setTextureOffset(139, 51).addBox(70, 20, 30, 10, 40, 80); train.setTextureOffset(173, 48).addBox(70, 10, 40, 10, 60, 60); train.setTextureOffset(248, 42).addBox(80, 10, 60, 10, 60, 20); train.setTextureOffset(261, 39).addBox(80, 30, 40, 10, 20, 60); train.setTextureOffset(136, 22).addBox(60, 0, -80, 10, 80, 40); train.setTextureOffset(138, 35).addBox(60, 20, -100, 10, 40, 80); train.setTextureOffset(128, 43).addBox(60, 10, -90, 10, 60, 60); train.setTextureOffset(267, 38).addBox(70, 10, -70, 10, 60, 20); train.setTextureOffset(243, 42).addBox(70, 30, -90, 10, 20, 60); train.setTextureOffset(140, 29).addBox(-80, 0, 50, 10, 80, 40); train.setTextureOffset(118, 39).addBox(-80, 20, 30, 10, 40, 80); train.setTextureOffset(126, 38).addBox(-80, 10, 40, 10, 60, 60); train.setTextureOffset(269, 47).addBox(-90, 10, 60, 10, 60, 20); train.setTextureOffset(225, 49).addBox(-90, 30, 40, 10, 20, 60); train.setTextureOffset(130, 22).addBox(-70, 0, -80, 10, 80, 40); train.setTextureOffset(133, 32).addBox(-70, 20, -100, 10, 40, 80); train.setTextureOffset(124, 29).addBox(-70, 10, -90, 10, 60, 60); train.setTextureOffset(280, 59).addBox(-80, 10, -70, 10, 60, 20); train.setTextureOffset(243, 40).addBox(-80, 30, -90, 10, 20, 60); train.setTextureOffset(130, 146).addBox(-50, 20, -240, 100, 40, 10); train.setTextureOffset(237, 30).addBox(-20, -200, -170, 40, 70, 50); train.setTextureOffset(239, 21).addBox(-30, -210, -180, 60, 20, 70); train.setTextureOffset(251, 25).addBox(-10, -180, -80, 20, 50, 20); train.setTextureOffset(142, 36).addBox(60, 50, -200, 10, 30, 30); train.setTextureOffset(234, 30).addBox(70, 60, -190, 10, 10, 10); train.setTextureOffset(135, 32).addBox(-70, 50, -200, 10, 30, 30); train.setTextureOffset(238, 33).addBox(-80, 60, -190, 10, 10, 10); light2_r1 = new ModelRenderer(this); light2_r1.setRotationPoint(0.0F, 0.0F, 0.0F); train.addChild(light2_r1); setRotationAngle(light2_r1, 0.0F, 0.0F, -0.7854F); light2_r1.setTextureOffset(1, 14).addBox(60, -80, -210, 20, 20, 10); light2_r1.setTextureOffset(241, 31).addBox(50, -90, -200, 40, 40, 10); light2_r1.setTextureOffset(0, 128).addBox(30, -90, -190, 80, 40, 170); firebox4_r1 = new ModelRenderer(this); firebox4_r1.setRotationPoint(0.0F, 0.0F, 0.0F); train.addChild(firebox4_r1); setRotationAngle(firebox4_r1, 0.0F, 0.0F, 0.7854F); firebox4_r1.setTextureOffset(0, 128).addBox(-110, -90, -190, 80, 40, 170); } @Override public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { train.render(f5); } public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) { modelRenderer.rotateAngleX = x; modelRenderer.rotateAngleY = y; modelRenderer.rotateAngleZ = z; } } And I can add my entity registering code too or i can update my github with everything so yall could take a look
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.