Jump to content
  • Home
  • Files
  • Docs
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • How do I make my Truck work? Help Me!!!
Currently Supported: 1.16.X (Latest) and 1.15.X (LTS)
Sign in to follow this  
Followers 0
WitherBoss2000

How do I make my Truck work? Help Me!!!

By WitherBoss2000, August 27, 2015 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

WitherBoss2000    2

WitherBoss2000

WitherBoss2000    2

  • Tree Puncher
  • WitherBoss2000
  • Members
  • 2
  • 25 posts
Posted August 27, 2015
[shadow=red,left][font=arial][glow=red,4,400]Ok, so I am wondering how I can make a truck. So, I made code for it and it works, but it doesnt move. It rotates and everything, but it stays stationary. Why does it do that? How do I fix it? Please help.
[/glow]
Here is my code for the Entity:
package com.camp.entity;

[/font][/shadow]

import net.minecraft.entity.Entity;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.monster.EntityMob;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;

public class EntityTruck extends EntityMob // this to make mob hostile
{
  public boolean stationary;
  public EntityTruck(World par1World)
  {
    super(par1World);
    isImmuneToFire = false;
  }
  protected void applEntityAttributes() {
      super.applyEntityAttributes();
      this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(20000.0d);
      this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.4f);
      this.getEntityAttribute(SharedMonsterAttributes.knockbackResistance).setBaseValue(1.0f);
      this.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(100f);
      this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(10.0f);

  }
  protected boolean canDespawn()
  {
    return false;
  }
  public boolean interact(EntityPlayer entityplayer)
  {
    if (riddenByEntity == null || riddenByEntity == entityplayer)
    {
      entityplayer.mountEntity(this);
      return true;
    }
    else
    {
      return false;
    }
  }
  protected boolean isMovementCeased()
  {
    return stationary;
  }
  public void moveEntity(double d, double d1, double d2)
  {
    if (riddenByEntity != null)
    {
      this.prevRotationYaw = this.rotationYaw = this.riddenByEntity.rotationYaw;
      this.rotationPitch = this.riddenByEntity.rotationPitch * 0.5F;
      this.setRotation(this.rotationYaw, this.rotationPitch);
      this.rotationYawHead = this.renderYawOffset = this.rotationYaw;
      stationary = true;
      motionX += riddenByEntity.motionX * 2F; // * 0.20000000000000001D;
      motionZ += riddenByEntity.motionZ * 2F; // * 0.20000000000000001D;
      if (isCollidedHorizontally)
      {
        isJumping = true;
      }
      else
      {
        isJumping = false;
      }
      super.moveEntity(motionX, motionY, motionZ);
    }
    else
    {
      stationary = false;
      super.moveEntity(d, d1, d2);
    }
  }
  public void onUpdate()
  {
    super.onUpdate();
    if (riddenByEntity != null) //check if there is a rider
    {
      //currentTarget = this;
      this.randomYawVelocity = 0; //try not to let the horse control where to look.
      this.rotationYaw = riddenByEntity.rotationYaw;
    }
  }
  protected boolean isAIEnabled() //Allow your AI task to work?
  {
    return true;
  }
}

[shadow=red,left][/shadow]

  • Quote

I AM SUS

Share this post


Link to post
Share on other sites

WitherBoss2000    2

WitherBoss2000

WitherBoss2000    2

  • Tree Puncher
  • WitherBoss2000
  • Members
  • 2
  • 25 posts
Posted August 27, 2015

[glow=red,20,200] Anyone out there that can help me? Please? [/glow]

  • Quote

I AM SUS

Share this post


Link to post
Share on other sites

ItsAMysteriousYT    7

ItsAMysteriousYT

ItsAMysteriousYT    7

  • Dragon Slayer
  • ItsAMysteriousYT
  • Members
  • 7
  • 785 posts
Posted August 28, 2015

Only one hint - how should the players motionX move the truck if the player sits ON the truck?

  • Quote

Share this post


Link to post
Share on other sites

WitherBoss2000    2

WitherBoss2000

WitherBoss2000    2

  • Tree Puncher
  • WitherBoss2000
  • Members
  • 2
  • 25 posts
Posted August 29, 2015

[glow=red,20,200]Oh... Well I dont know any other way of making it move, I have never made one before. If I put a solid number there, it will move, but only in one direction and non-controllable. I was thinking that I could use keybindings, but I have no idea how to do that.[/glow]

  • Quote

I AM SUS

Share this post


Link to post
Share on other sites

LordMastodon    8

LordMastodon

LordMastodon    8

  • Creeper Killer
  • LordMastodon
  • Forge Modder
  • 8
  • 173 posts
Posted August 29, 2015

Watch Pahimar's video tutorial on YouTube about Keybindings, that should help.

  • Quote

Who are you? Why have you brought me here? And why are there so many PewDiePie fanboys surrounding meeeeeeeee....... *falls into pit and dies*.

 

Also this. Check it out.

width=700 height=200http://i.imgur.com/J4rrGt6.png[/img]

Share this post


Link to post
Share on other sites

ItsAMysteriousYT    7

ItsAMysteriousYT

ItsAMysteriousYT    7

  • Dragon Slayer
  • ItsAMysteriousYT
  • Members
  • 7
  • 785 posts
Posted August 29, 2015

[glow=red,20,200]Oh... Well I dont know any other way of making it move, I have never made one before. If I put a solid number there, it will move, but only in one direction and non-controllable. I was thinking that I could use keybindings, but I have no idea how to do that.[/glow]

First of all why do you write in red and second - think of what you need. Youll need a speed and the propper calculations hint - have a look at minecrafts entity boat class

  • Quote

Share this post


Link to post
Share on other sites

WitherBoss2000    2

WitherBoss2000

WitherBoss2000    2

  • Tree Puncher
  • WitherBoss2000
  • Members
  • 2
  • 25 posts
Posted August 30, 2015

[glow=red,20,200] I tried the keybinding, and it doesnt work. Also, I couldnt find it in the EntityBoat class. I have no idea what I am doing. If anyone knows how to help me, please tell me! [/glow]

  • Quote

I AM SUS

Share this post


Link to post
Share on other sites

WitherBoss2000    2

WitherBoss2000

WitherBoss2000    2

  • Tree Puncher
  • WitherBoss2000
  • Members
  • 2
  • 25 posts
Posted August 30, 2015

Anyone?

 

  • Quote

I AM SUS

Share this post


Link to post
Share on other sites

N247S    16

N247S

N247S    16

  • Creeper Killer
  • N247S
  • Forge Modder
  • 16
  • 222 posts
Posted August 30, 2015

Nobody is going to program the whole mod for you. So please try to search for the answer in the classes full of working examples forge is providing you. (E.g. EntityBoat, EntityPig, EntityHorse - names may be slightly different though with a bit of effort easy to find).

 

A few tips are already given for a possible solution. You need some way of keybinding. And the Entity that needs to recieve the motion is the Entity the player is riding, not the Player itself.

  • Quote

Projects:

Discontinued:

- N2ConfigAPI

- Meachanical Crafting Table

 

Latest:

- CollectionUtils

 

Coöperations:

- InGameConfigManager

Share this post


Link to post
Share on other sites

ItsAMysteriousYT    7

ItsAMysteriousYT

ItsAMysteriousYT    7

  • Dragon Slayer
  • ItsAMysteriousYT
  • Members
  • 7
  • 785 posts
Posted August 31, 2015

Another tip - write your code on paper, then in code so youll find buggs easier. Planning is most of the work done :D

  • Quote

Share this post


Link to post
Share on other sites

SanAndreasP    402

SanAndreasP

SanAndreasP    402

  • World Shaper
  • SanAndreasP
  • Forge Modder
  • 402
  • 1689 posts
Posted September 1, 2015

No need for keybindings...

Just set the entity's

[b]moveStrafing[/b]

and

[b]moveForward[/b]

fields to the same value as the riding entity's

moveStrafing

and

moveForward

.

Do that in the

onLivingUpdate

method of your entity (after the super call), check if it's ridden by anything of course (

[b]riddenByEntity[/b]

is not

null

).

 

To steer it, you'd need to set the

[b]rotationYaw[/b]

and

[b]rotationYawHead[/b]

fields of your entity to the ones of the riding one. Do it right before setting the move* fields.

Also override

[b]canBeSteered()[/b]

and return true.

  • Quote

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Share this post


Link to post
Share on other sites

starwarsmace    18

starwarsmace

starwarsmace    18

  • Diamond Finder
  • starwarsmace
  • Members
  • 18
  • 333 posts
Posted September 1, 2015

No need for keybindings...

Just set the entity's

[b]moveStrafing[/b]

and

[b]moveForward[/b]

fields to the same value as the riding entity's

moveStrafing

and

moveForward

.

Do that in the

onLivingUpdate

method of your entity (after the super call), check if it's ridden by anything of course (

[b]riddenByEntity[/b]

is not

null

).

 

To steer it, you'd need to set the

[b]rotationYaw[/b]

and

[b]rotationYawHead[/b]

fields of your entity to the ones of the riding one. Do it right before setting the move* fields.

Also override

[b]canBeSteered()[/b]

and return true.

Wow, I have to say you've got some of the best explanations. Very thorough, tells you where to look, and at the same time isn't spoonfeeding. Not sure you can get any better than that.  :P

  • Quote

I'm back from being gone for... I think its been about a year. I'm pretty sure nobody remembers me, but hello anybody who does!

Share this post


Link to post
Share on other sites

WitherBoss2000    2

WitherBoss2000

WitherBoss2000    2

  • Tree Puncher
  • WitherBoss2000
  • Members
  • 2
  • 25 posts
Posted September 6, 2015

Ok, but there is no moveForward field in the riding entity. Or a moveStrafing.

  • Quote

I AM SUS

Share this post


Link to post
Share on other sites

WitherBoss2000    2

WitherBoss2000

WitherBoss2000    2

  • Tree Puncher
  • WitherBoss2000
  • Members
  • 2
  • 25 posts
Posted September 6, 2015

No need for keybindings...

Just set the entity's

[b]moveStrafing[/b]

and

[b]moveForward[/b]

fields to the same value as the riding entity's

moveStrafing

and

moveForward

.

Do that in the

onLivingUpdate

method of your entity (after the super call), check if it's ridden by anything of course (

[b]riddenByEntity[/b]

is not

null

).

 

To steer it, you'd need to set the

[b]rotationYaw[/b]

and

[b]rotationYawHead[/b]

fields of your entity to the ones of the riding one. Do it right before setting the move* fields.

Also override

[b]canBeSteered()[/b]

and return true.

Wow, I have to say you've got some of the best explanations. Very thorough, tells you where to look, and at the same time isn't spoonfeeding. Not sure you can get any better than that.  :P

Dude, this isnt a praise area.

  • Quote

I AM SUS

Share this post


Link to post
Share on other sites

ItsAMysteriousYT    7

ItsAMysteriousYT

ItsAMysteriousYT    7

  • Dragon Slayer
  • ItsAMysteriousYT
  • Members
  • 7
  • 785 posts
Posted September 6, 2015

Ok, but there is no moveForward field in the riding entity. Or a moveStrafing.

I say this only one more time - before you start messing up your code - PLAN THE WHOLE THING ON PAPER! And the move straffing field is not in the entitity itself, it is in the ridingEntity. We will not write your mod for you, try figuring it out. We will help you if you run in some problems, but youll have to do the main part of it on your own.

  • Quote

Share this post


Link to post
Share on other sites

SanAndreasP    402

SanAndreasP

SanAndreasP    402

  • World Shaper
  • SanAndreasP
  • Forge Modder
  • 402
  • 1689 posts
Posted September 7, 2015

Ok, but there is no moveForward field in the riding entity. Or a moveStrafing.

And the move straffing field is not in the entitity itself, it is in the ridingEntity.

I'd say it is...

https://github.com/SanAndreasP/EnderStuffPlus/blob/master/java/de/sanandrew/mods/enderstuffp/entity/living/EntityEnderMiss.java#L591-L592

  • Quote

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Share this post


Link to post
Share on other sites

WitherBoss2000    2

WitherBoss2000

WitherBoss2000    2

  • Tree Puncher
  • WitherBoss2000
  • Members
  • 2
  • 25 posts
Posted September 12, 2015

Sorry, but still it refuses to move.

  • Quote

I AM SUS

Share this post


Link to post
Share on other sites

ItsAMysteriousYT    7

ItsAMysteriousYT

ItsAMysteriousYT    7

  • Dragon Slayer
  • ItsAMysteriousYT
  • Members
  • 7
  • 785 posts
Posted September 12, 2015

Show your code

  • Quote

Share this post


Link to post
Share on other sites

WitherBoss2000    2

WitherBoss2000

WitherBoss2000    2

  • Tree Puncher
  • WitherBoss2000
  • Members
  • 2
  • 25 posts
Posted September 27, 2015

Sorry it took me so long to respond, here is my most recent updated code. Also, I am not asking you to code my entire mod, this is only MY FIRST MOD!!! Please, just tell me how to do it and then I will know. Here it is...

 

package com.camp.entity;

import net.minecraft.entity.Entity;
import net.minecraft.entity.monster.EntityMob;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;

public class EntityTruck extends EntityMob // this to make mob hostile
{
  public boolean stationary;
  public EntityTruck(World par1World)
  {
    super(par1World);
    isImmuneToFire = false;
  }
  
  protected boolean canDespawn()
  {
    return false;
  }
  public boolean interact(EntityPlayer entityplayer)
  {
    if (riddenByEntity == null || riddenByEntity == entityplayer)
    {
      entityplayer.mountEntity(this);
      return true;
    }
    else
    {
      return false;
    }
  }
  protected boolean isMovementCeased()
  {
    return stationary;
  }
  public void moveEntity(double d, double d1, double d2)
  {
    if (riddenByEntity != null)
    {
      EntityPlayer player = (EntityPlayer) this.riddenByEntity;
      this.prevRotationYaw = this.rotationYaw = this.riddenByEntity.rotationYaw;
      this.rotationPitch = this.riddenByEntity.rotationPitch * 0.5F;
      this.setRotation(this.rotationYaw, this.rotationPitch);
      this.rotationYawHead = player.rotationYawHead;
      stationary = false;
      motionX += riddenByEntity.motionX * 10; // * 0.20000000000000001D;
      motionZ += riddenByEntity.motionZ * 10; // * 0.20000000000000001D;
      //this.moveStrafing = player.moveStrafing;
      //this.moveForward = player.moveForward;
      if (isCollidedHorizontally)
      {
        isJumping = true;
      }
      else
      {
        isJumping = false;
      }
      super.moveEntity(motionX, motionY, motionZ);
    }
    else
    {
      stationary = false;
      super.moveEntity(d, d1, d2);
    }
  }
  public void onUpdate()
  {
    super.onUpdate();
    if (riddenByEntity != null) //check if there is a rider
    {
      //currentTarget = this;
      this.randomYawVelocity = 0; //try not to let the horse control where to look.
      this.rotationYaw = riddenByEntity.rotationYaw;
    }
  }
  protected boolean isAIEnabled() //Allow your AI task to work?
  {
    return true;
  }
}

  • Quote

I AM SUS

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

    • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 0
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • kiou.23
      [1.16] Custom Sign won't render

      By kiou.23 · Posted 3 minutes ago

      Okay, so my Custom Sign Tile Entity has to extend SignTileEntity, because PlayerEntity#openSignEditor() expects a SignTileEntity. but from there I can't call super() and pass in my custom Tile Entity Type, because the TileEntityType for SignTileEntity is hardcoded in the constructor. How to proceed?
    • diesieben07
      (1.16.2) Making a new capability(2)

      By diesieben07 · Posted 4 minutes ago

      Have you looked at the methods that LazyOptional offers?  
    • Bailym
      Cant Get a Config File Working 1.16.5

      By Bailym · Posted 9 minutes ago

      Having followed those instructions I am getting the same results.   It seems my lack of understanding of forge in general is the issue   Thanks for the advice, its been really helpful.   Just one final thing. If i were to disable recipes and creative tab entries as you suggested, would i do so inside the FMLCommonSetupEvent handler or some place else?   Thanks    
    • e2rifia
      (1.16.2) Making a new capability(2)

      By e2rifia · Posted 12 minutes ago

      I have a capability STATE_CAPABILITY in IHaveMana, of class IState. I want to take out the IState an entity has, probably using getCapability. As below. But, I couldn't find a way to convert LazyOptional<IState> to IState.   @Nullable     public static IState getIStates(Entity entityliving)     {         if (entityliving instanceof LivingEntity)             return (IState) entityliving.getCapability(IHaveMana.STATE_CAPABILITY, null).cast();         return null;     }   Should I give more detail?
    • diesieben07
      whenever I join a server it shows me this error

      By diesieben07 · Posted 32 minutes ago

      1.12 is no longer supported on this forum. Please update to a modern version of Minecraft to receive support.
  • Topics

    • kiou.23
      12
      [1.16] Custom Sign won't render

      By kiou.23
      Started 9 hours ago

    • e2rifia
      1
      (1.16.2) Making a new capability(2)

      By e2rifia
      Started 12 minutes ago

    • Bailym
      12
      Cant Get a Config File Working 1.16.5

      By Bailym
      Started 1 hour ago

    • gamer650xd
      2
      whenever I join a server it shows me this error

      By gamer650xd
      Started 41 minutes ago

    • e2rifia
      4
      (1.16.2) How do I use onPlayerTick?

      By e2rifia
      Started 4 hours ago

  • Who's Online (See full list)

    • loordgek
    • Bailym
    • Redpo
    • JackRaidenPH
    • diesieben07
    • Ipsissimus418
    • Gabbyboy1233539
    • Lellian
    • e2rifia
    • kreezxil
    • qwepo
    • Caaruzo
    • Telmoun
    • st4s1k
    • Talp1
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • How do I make my Truck work? Help Me!!!
  • Theme

Copyright © 2019 ForgeDevelopment LLC · Ads by Longitude Ads LLC Powered by Invision Community