stopper Posted May 30, 2021 Share Posted May 30, 2021 My model for some reason floating in air. 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); } } Quote Link to comment Share on other sites More sharing options...
vemerion Posted May 30, 2021 Share Posted May 30, 2021 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. Quote Link to comment Share on other sites More sharing options...
stopper Posted May 31, 2021 Author Share Posted May 31, 2021 matrixStack.translate(0d, 1.5d, 0d); Worked perfectly! Thanks! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.