Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

My model for some reason floating in air.

2021-05-30_19_29_22.thumb.png.ee7444901a22c50987ea9b8d013836cb.png2021-05-30_19_29_16.thumb.png.ca4ea32dded26702d570e851c39334f0.png

Renderer:

Spoiler

public class CarRenderer extends MobRenderer<Car, CarModel> {
    public static final ResourceLocation TEXTURE = new ResourceLocation("testcar", "textures/entities/car.png");

    public CarRenderer(EntityRendererManager manager) {
        super(manager, new CarModel(), 0.5f);
    }

    @Override
    public ResourceLocation getTextureLocation(Car p_110775_1_) {
        return TEXTURE;
    }
}

 

Model:

Spoiler

public class CarModel extends EntityModel<Car> {
	private final ModelRenderer bb_main;

	public CarModel() {
		bb_main = new ModelRenderer(this);
		bb_main.setTexSize(40, 25);
		bb_main.texOffs(0, 0).addBox(-4.0F, -2.0F, -6.0F, 8.0F, 1.0F, 12.0F, 0.0F, false);
		bb_main.texOffs(0, 13).addBox(-3.0F, -6.0F, -5.0F, 6.0F, 4.0F, 8.0F, 0.0F, false);
		bb_main.texOffs(28, 13).addBox(-5.0F, -3.0F, 3.0F, 1.0F, 3.0F, 3.0F, 0.0F, false);
		bb_main.texOffs(28, 13).addBox(-5.0F, -3.0F, -6.0F, 1.0F, 3.0F, 3.0F, 0.0F, false);
		bb_main.texOffs(28, 13).addBox(4.0F, -3.0F, -6.0F, 1.0F, 3.0F, 3.0F, 0.0F, false);
		bb_main.texOffs(28, 13).addBox(4.0F, -3.0F, 3.0F, 1.0F, 3.0F, 3.0F, 0.0F, false);
	}

	@Override
	public void setupAnim(Car p_225597_1_, float p_225597_2_, float p_225597_3_, float p_225597_4_, float p_225597_5_, float p_225597_6_) {}

	@Override
	public void renderToBuffer(MatrixStack matrixStack, IVertexBuilder buffer, int packedLight, int packedOverlay, float red, float green, float blue, float alpha) {
		bb_main.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha);
	}
}

 

Entity:

Spoiler

public class Car extends MonsterEntity {
    public Car(EntityType<? extends MonsterEntity> type, World world) {
        super(type, world);
    }

    @Override
    protected void registerGoals() {
        this.goalSelector.addGoal(1, new SwimGoal(this));
        this.goalSelector.addGoal(1, new MeleeAttackGoal(this, 1.5d, true));
        this.targetSelector.addGoal(1, new NearestAttackableTargetGoal<>(this, PlayerEntity.class, true));
        this.goalSelector.addGoal(2, new LookAtGoal(this, PlayerEntity.class, 8.0F));
        this.goalSelector.addGoal(4, new OpenDoorGoal(this, false));
        this.goalSelector.addGoal(3, new WaterAvoidingRandomWalkingGoal(this, 1.0d));
        this.goalSelector.addGoal(3, new LookRandomlyGoal(this));
    }

    public static AttributeModifierMap.MutableAttribute createMobAttributes() {
        return MonsterEntity.createMonsterAttributes()
                .add(Attributes.ATTACK_DAMAGE, 6.0D)
                .add(Attributes.MAX_HEALTH, 8.0D)
                .add(Attributes.FOLLOW_RANGE, 40.0D);
    }
}

 

 

1 hour ago, stopper said:

My model for some reason floating in air.

You can either lower the boxes in the model by changing the y values, or do a translation on the matrix stack just before rendering the entity.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.