Résolu Problèmes avec un véhicule
-
Salut
J’ai créé un traîneau mais j’ai deux problèmes (j’espère que ce seront les derniers de ce mod).Il y a quelque chose qui foire dans le modèle. Il existe bien, mais niveau rendu, c’est pas ça. En fait, il apparaît en-dessous de la hitbox. Au départ, j’avais pas pensé à afficher la hitbox, donc je pensait que c’était dans l’entité que ça se passait. Mais après j’y ai pensé et voilà ce que j’ai eu. Je sais que c’est dans le model et non dans le render car j’ai essayé de remplacer mon model par celui du bateau et ça marche bien.
Le voilà : ```java
package This_is_Christmas.Entity;import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;public class ModelSleigh extends ModelBase
{
//fields
ModelRenderer BottomWoodRight1;
ModelRenderer BottomWoodLeft1;
ModelRenderer BottomWoodRight2;
ModelRenderer BottomWoodRight4;
ModelRenderer BottomWoodRight5;
ModelRenderer AboveTheBottomWoodRight1;
ModelRenderer AboveTheBottomWoodRight3;
ModelRenderer AboveTheBottomWoodRight2;
ModelRenderer SupportRight;
ModelRenderer Support;
ModelRenderer BottomWoodRight3;
ModelRenderer BottomWoodRight6;
ModelRenderer BottomWoodLeft2;
ModelRenderer BottomWoodLeft3;
ModelRenderer BottomWoodLeft4;
ModelRenderer BottomWoodLeft5;
ModelRenderer BottomWoodLeft6;
ModelRenderer AboveTheBottomWoodRight4;
ModelRenderer AboveTheBottomWoodLeft1;
ModelRenderer AboveTheBottomWoodLeft2;
ModelRenderer AboveTheBottomWoodLeft3;
ModelRenderer AboveTheBottomWoodLeft4;
ModelRenderer SupportLeft;
ModelRenderer Ahead8;
ModelRenderer Rear1;
ModelRenderer Rear2;
ModelRenderer Rear3;
ModelRenderer Rear4;
ModelRenderer Rear5;
ModelRenderer Ahead9;
ModelRenderer Ahead7;
ModelRenderer Seat;
ModelRenderer SeatSupport;
ModelRenderer Edge;
ModelRenderer AngledEdgeRight1;
ModelRenderer AngledEdgeRight2;
ModelRenderer AngledEdgeRight3;
ModelRenderer AngledEdgeRight4;
ModelRenderer AngledEdgeRight5;
ModelRenderer AngledEdgeRight6;
ModelRenderer AngledEdgeRight7;
ModelRenderer AngledEdgeRight8;
ModelRenderer AngledEdgeRight9;
ModelRenderer AngledEdgeRight10;
ModelRenderer AngledEdgeRight11;
ModelRenderer AngledEdgeRight12;
ModelRenderer AngledEdgeRight13;
ModelRenderer Ahead1;
ModelRenderer Ahead2;
ModelRenderer Ahead3;
ModelRenderer Ahead4;
ModelRenderer Ahead5;
ModelRenderer Ahead6;
ModelRenderer FlangeRight1;
ModelRenderer FlangeRight2;
ModelRenderer FlangeRight3;
ModelRenderer FlangeRight4;
ModelRenderer FlangeRight5;
ModelRenderer FlangeRight6;
ModelRenderer FlangeRight7;
ModelRenderer FlangeRight8;
ModelRenderer FlangeLeft1;
ModelRenderer FlangeLeft2;
ModelRenderer FlangeLeft3;
ModelRenderer FlangeLeft4;
ModelRenderer AngledEdgeLeft7;
ModelRenderer AngledEdgeLeft8;
ModelRenderer AngledEdgeLeft9;
ModelRenderer AngledEdgeLeft10;
ModelRenderer AngledEdgeLeft11;
ModelRenderer AngledEdgeLeft12;
ModelRenderer AngledEdgeLeft13;
ModelRenderer AngledEdgeLeft4;
ModelRenderer AngledEdgeLeft5;
ModelRenderer AngledEdgeLeft1;
ModelRenderer AngledEdgeLeft2;
ModelRenderer AngledEdgeLeft3;
ModelRenderer AngledEdgeLeft6;
ModelRenderer FlangeLeft5;
ModelRenderer FlangeLeft6;
ModelRenderer FlangeLeft7;
ModelRenderer FlangeLeft8;
ModelRenderer EdgeLeft;
ModelRenderer AheadEdgeLeft1;
ModelRenderer AheadEdgeLeft2;
ModelRenderer AheadEdgeLeft3;
ModelRenderer AheadEdgeLeft4;
ModelRenderer AheadEdgeRight1;
ModelRenderer AheadEdgeRight2;
ModelRenderer AheadEdgeRight3;
ModelRenderer AheadEdgeRight4;
ModelRenderer FlangeLeft9;public ModelSleigh()
{
textureWidth = 64;
textureHeight = 32;BottomWoodRight1 = new ModelRenderer(this, 0, 0);
BottomWoodRight1.addBox(0F, 0F, 0F, 2, 1, 25);
BottomWoodRight1.setRotationPoint(-9F, 23F, -4.2F);
BottomWoodRight1.setTextureSize(64, 32);
BottomWoodRight1.mirror = true;
setRotation(BottomWoodRight1, 0F, 0F, 0F);
BottomWoodLeft1 = new ModelRenderer(this, 0, 0);
BottomWoodLeft1.addBox(0F, 0F, 0F, 2, 1, 26);
BottomWoodLeft1.setRotationPoint(7F, 23F, -5.2F);
BottomWoodLeft1.setTextureSize(64, 32);
BottomWoodLeft1.mirror = true;
setRotation(BottomWoodLeft1, 0F, 0F, 0F);
BottomWoodRight2 = new ModelRenderer(this, 0, 0);
BottomWoodRight2.addBox(0F, 0F, 0F, 2, 1, 2);
BottomWoodRight2.setRotationPoint(-9F, 22.2F, -5.4F);
BottomWoodRight2.setTextureSize(64, 32);
BottomWoodRight2.mirror = true;
setRotation(BottomWoodRight2, -0.5235988F, 0F, 0F);
BottomWoodRight4 = new ModelRenderer(this, 0, 0);
BottomWoodRight4.addBox(0F, 0F, 0F, 2, 1, 5);
BottomWoodRight4.setRotationPoint(-9F, 16.5F, -5.8F);
BottomWoodRight4.setTextureSize(64, 32);
BottomWoodRight4.mirror = true;
setRotation(BottomWoodRight4, -1.570796F, 0F, 0F);
BottomWoodRight5 = new ModelRenderer(this, 0, 0);
BottomWoodRight5.addBox(0F, 0F, 0F, 2, 1, 2);
BottomWoodRight5.setRotationPoint(-9F, 16.5F, -6.8F);
BottomWoodRight5.setTextureSize(64, 32);
BottomWoodRight5.mirror = true;
setRotation(BottomWoodRight5, 1.047198F, 0F, 0F);
AboveTheBottomWoodRight1 = new ModelRenderer(this, 0, 0);
AboveTheBottomWoodRight1.addBox(0F, 0F, 0F, 1, 4, 1);
AboveTheBottomWoodRight1.setRotationPoint(-8F, 19F, 17F);
AboveTheBottomWoodRight1.setTextureSize(64, 32);
AboveTheBottomWoodRight1.mirror = true;
setRotation(AboveTheBottomWoodRight1, 0F, 0F, 0F);
AboveTheBottomWoodRight3 = new ModelRenderer(this, 0, 0);
AboveTheBottomWoodRight3.addBox(0F, 0F, 0F, 1, 4, 1);
AboveTheBottomWoodRight3.setRotationPoint(-8F, 19F, 4F);
AboveTheBottomWoodRight3.setTextureSize(64, 32);
AboveTheBottomWoodRight3.mirror = true;
setRotation(AboveTheBottomWoodRight3, 0F, 0F, 0F);
AboveTheBottomWoodRight2 = new ModelRenderer(this, 0, 0);
AboveTheBottomWoodRight2.addBox(0F, 0F, 0F, 1, 4, 1);
AboveTheBottomWoodRight2.setRotationPoint(-8F, 19F, 11F);
AboveTheBottomWoodRight2.setTextureSize(64, 32);
AboveTheBottomWoodRight2.mirror = true;
setRotation(AboveTheBottomWoodRight2, 0F, 0F, 0F);
SupportRight = new ModelRenderer(this, 0, 0);
SupportRight.addBox(0F, 0F, 0F, 1, 1, 22);
SupportRight.setRotationPoint(-8F, 18F, -3F);
SupportRight.setTextureSize(64, 32);
SupportRight.mirror = true;
setRotation(SupportRight, 0F, 0F, 0F);
Support = new ModelRenderer(this, 0, 0);
Support.addBox(0F, 0F, 0F, 17, 1, 17);
Support.setRotationPoint(-8.5F, 17F, -1F);
Support.setTextureSize(64, 32);
Support.mirror = true;
setRotation(Support, 0F, 0F, 0F);
BottomWoodRight3 = new ModelRenderer(this, 0, 0);
BottomWoodRight3.addBox(0F, 0F, 0F, 2, 1, 2);
BottomWoodRight3.setRotationPoint(-9F, 21F, -5.9F);
BottomWoodRight3.setTextureSize(64, 32);
BottomWoodRight3.mirror = true;
setRotation(BottomWoodRight3, -1.047198F, 0F, 0F);
BottomWoodRight6 = new ModelRenderer(this, 0, 0);
BottomWoodRight6.addBox(0F, 0F, 0F, 2, 1, 2);
BottomWoodRight6.setRotationPoint(-9F, 14.8F, -5.8F);
BottomWoodRight6.setTextureSize(64, 32);
BottomWoodRight6.mirror = true;
setRotation(BottomWoodRight6, 0.5235988F, 0F, 0F);
BottomWoodLeft2 = new ModelRenderer(this, 0, 0);
BottomWoodLeft2.addBox(0F, 0F, 0F, 2, 1, 2);
BottomWoodLeft2.setRotationPoint(7F, 22.2F, -5.44F);
BottomWoodLeft2.setTextureSize(64, 32);
BottomWoodLeft2.mirror = true;
setRotation(BottomWoodLeft2, -0.5235988F, 0F, 0F);
BottomWoodLeft3 = new ModelRenderer(this, 0, 0);
BottomWoodLeft3.addBox(0F, 0F, 0F, 2, 1, 2);
BottomWoodLeft3.setRotationPoint(7F, 21F, -5.9F);
BottomWoodLeft3.setTextureSize(64, 32);
BottomWoodLeft3.mirror = true;
setRotation(BottomWoodLeft3, -1.047198F, 0F, 0F);
BottomWoodLeft4 = new ModelRenderer(this, 0, 0);
BottomWoodLeft4.addBox(0F, 0F, 0F, 2, 1, 5);
BottomWoodLeft4.setRotationPoint(7F, 16.5F, -5.8F);
BottomWoodLeft4.setTextureSize(64, 32);
BottomWoodLeft4.mirror = true;
setRotation(BottomWoodLeft4, -1.570796F, 0F, 0F);
BottomWoodLeft5 = new ModelRenderer(this, 0, 0);
BottomWoodLeft5.addBox(0F, 0F, 0F, 2, 1, 2);
BottomWoodLeft5.setRotationPoint(7F, 16.5F, -6.8F);
BottomWoodLeft5.setTextureSize(64, 32);
BottomWoodLeft5.mirror = true;
setRotation(BottomWoodLeft5, 1.047198F, 0F, 0F);
BottomWoodLeft6 = new ModelRenderer(this, 0, 0);
BottomWoodLeft6.addBox(0F, 0F, 0F, 2, 1, 2);
BottomWoodLeft6.setRotationPoint(7F, 14.8F, -5.8F);
BottomWoodLeft6.setTextureSize(64, 32);
BottomWoodLeft6.mirror = true;
setRotation(BottomWoodLeft6, 0.5235988F, 0F, 0F);
AboveTheBottomWoodRight4 = new ModelRenderer(this, 0, 0);
AboveTheBottomWoodRight4.addBox(0F, 0F, 0F, 1, 4, 1);
AboveTheBottomWoodRight4.setRotationPoint(-8F, 19F, -2F);
AboveTheBottomWoodRight4.setTextureSize(64, 32);
AboveTheBottomWoodRight4.mirror = true;
setRotation(AboveTheBottomWoodRight4, 0F, 0F, 0F);
AboveTheBottomWoodLeft1 = new ModelRenderer(this, 0, 0);
AboveTheBottomWoodLeft1.addBox(0F, 0F, 0F, 1, 4, 1);
AboveTheBottomWoodLeft1.setRotationPoint(7F, 19F, 17F);
AboveTheBottomWoodLeft1.setTextureSize(64, 32);
AboveTheBottomWoodLeft1.mirror = true;
setRotation(AboveTheBottomWoodLeft1, 0F, 0F, 0F);
AboveTheBottomWoodLeft2 = new ModelRenderer(this, 0, 0);
AboveTheBottomWoodLeft2.addBox(0F, 0F, 0F, 1, 4, 1);
AboveTheBottomWoodLeft2.setRotationPoint(7F, 19F, 11F);
AboveTheBottomWoodLeft2.setTextureSize(64, 32);
AboveTheBottomWoodLeft2.mirror = true;
setRotation(AboveTheBottomWoodLeft2, 0F, 0F, 0F);
AboveTheBottomWoodLeft3 = new ModelRenderer(this, 0, 0);
AboveTheBottomWoodLeft3.addBox(0F, 0F, 0F, 1, 4, 1);
AboveTheBottomWoodLeft3.setRotationPoint(7F, 19F, 4F);
AboveTheBottomWoodLeft3.setTextureSize(64, 32);
AboveTheBottomWoodLeft3.mirror = true;
setRotation(AboveTheBottomWoodLeft3, 0F, 0F, 0F);
AboveTheBottomWoodLeft4 = new ModelRenderer(this, 0, 0);
AboveTheBottomWoodLeft4.addBox(0F, 0F, 0F, 1, 4, 1);
AboveTheBottomWoodLeft4.setRotationPoint(7F, 19F, -2F);
AboveTheBottomWoodLeft4.setTextureSize(64, 32);
AboveTheBottomWoodLeft4.mirror = true;
setRotation(AboveTheBottomWoodLeft4, 0F, 0F, 0F);
SupportLeft = new ModelRenderer(this, 0, 0);
SupportLeft.addBox(0F, 0F, 0F, 1, 1, 22);
SupportLeft.setRotationPoint(7F, 18F, -3F);
SupportLeft.setTextureSize(64, 32);
SupportLeft.mirror = true;
setRotation(SupportLeft, 0F, 0F, 0F);
Ahead8 = new ModelRenderer(this, 0, 0);
Ahead8.addBox(0F, 0F, 0F, 17, 1, 7);
Ahead8.setRotationPoint(-8.5F, 11F, -3.6F);
Ahead8.setTextureSize(64, 32);
Ahead8.mirror = true;
setRotation(Ahead8, -1.047198F, 0F, 0F);
Rear1 = new ModelRenderer(this, 0, 0);
Rear1.addBox(0F, 0F, 0F, 17, 1, 1);
Rear1.setRotationPoint(-8.5F, 16.6F, 16.3F);
Rear1.setTextureSize(64, 32);
Rear1.mirror = true;
setRotation(Rear1, -1.047198F, 0F, 0F);
Rear2 = new ModelRenderer(this, 0, 0);
Rear2.addBox(0F, 0F, 0F, 17, 1, 1);
Rear2.setRotationPoint(-8.5F, 16.1F, 16.4F);
Rear2.setTextureSize(64, 32);
Rear2.mirror = true;
setRotation(Rear2, -0.5235988F, 0F, 0F);
Rear3 = new ModelRenderer(this, 0, 0);
Rear3.addBox(0F, 0F, 0F, 17, 1, 4);
Rear3.setRotationPoint(-8.5F, 16.6F, 16.3F);
Rear3.setTextureSize(64, 32);
Rear3.mirror = true;
setRotation(Rear3, 1.570796F, 0F, 0F);
Rear4 = new ModelRenderer(this, 0, 0);
Rear4.addBox(0F, 0F, 0F, 17, 1, 1);
Rear4.setRotationPoint(-8.5F, 12.3F, 16F);
Rear4.setTextureSize(64, 32);
Rear4.mirror = true;
setRotation(Rear4, 0.5235988F, 0F, 0F);
Rear5 = new ModelRenderer(this, 0, 0);
Rear5.addBox(0F, 0F, 0F, 17, 7, 1);
Rear5.setRotationPoint(-8.5F, 5.3F, 16F);
Rear5.setTextureSize(64, 32);
Rear5.mirror = true;
setRotation(Rear5, 0F, 0F, 0F);
Ahead9 = new ModelRenderer(this, 0, 0);
Ahead9.addBox(0F, 0F, 0F, 17, 1, 1);
Ahead9.setRotationPoint(-8.5F, 10.8F, -3.2F);
Ahead9.setTextureSize(64, 32);
Ahead9.mirror = true;
setRotation(Ahead9, -1.832596F, 0F, 0F);
Ahead7 = new ModelRenderer(this, 0, 0);
Ahead7.addBox(0F, 0F, 0F, 17, 1, 2);
Ahead7.setRotationPoint(-8.5F, 10.5F, -2F);
Ahead7.setTextureSize(64, 32);
Ahead7.mirror = true;
setRotation(Ahead7, -2.617994F, 0F, 0F);
Seat = new ModelRenderer(this, 0, 0);
Seat.addBox(0F, 0F, 0F, 15, 1, 8);
Seat.setRotationPoint(-7.5F, 12F, 8.4F);
Seat.setTextureSize(64, 32);
Seat.mirror = true;
setRotation(Seat, 0F, 0F, 0F);
SeatSupport = new ModelRenderer(this, 0, 0);
SeatSupport.addBox(0F, 0F, 0F, 15, 4, 1);
SeatSupport.setRotationPoint(-7.5F, 13F, 9F);
SeatSupport.setTextureSize(64, 32);
SeatSupport.mirror = true;
setRotation(SeatSupport, 0F, 0F, 0F);
Edge = new ModelRenderer(this, 0, 0);
Edge.addBox(0F, 0F, 0F, 1, 5, 18);
Edge.setRotationPoint(-8.5F, 12F, -1.2F);
Edge.setTextureSize(64, 32);
Edge.mirror = true;
setRotation(Edge, 0F, 0F, 0F);
AngledEdgeRight1 = new ModelRenderer(this, 0, 0);
AngledEdgeRight1.addBox(0F, 0F, 0F, 1, 1, 1);
AngledEdgeRight1.setRotationPoint(-8.5F, 11.7F, 7.3F);
AngledEdgeRight1.setTextureSize(64, 32);
AngledEdgeRight1.mirror = true;
setRotation(AngledEdgeRight1, 1.308997F, 0F, 0F);
AngledEdgeRight2 = new ModelRenderer(this, 0, 0);
AngledEdgeRight2.addBox(0F, 0F, 0F, 1, 1, 1);
AngledEdgeRight2.setRotationPoint(-8.5F, 10.8F, 7.6F);
AngledEdgeRight2.setTextureSize(64, 32);
AngledEdgeRight2.mirror = true;
setRotation(AngledEdgeRight2, 1.134464F, 0F, 0F);
AngledEdgeRight3 = new ModelRenderer(this, 0, 0);
AngledEdgeRight3.addBox(0F, 0F, 0F, 1, 1, 1);
AngledEdgeRight3.setRotationPoint(-8.5F, 7.3F, 10.7F);
AngledEdgeRight3.setTextureSize(64, 32);
AngledEdgeRight3.mirror = true;
setRotation(AngledEdgeRight3, 0.5235988F, 0F, 0F);
AngledEdgeRight4 = new ModelRenderer(this, 0, 0);
AngledEdgeRight4.addBox(0F, 0F, 0F, 1, 1, 1);
AngledEdgeRight4.setRotationPoint(-8.5F, 6.8F, 11.5F);
AngledEdgeRight4.setTextureSize(64, 32);
AngledEdgeRight4.mirror = true;
setRotation(AngledEdgeRight4, 0.4363323F, 0F, 0F);
AngledEdgeRight5 = new ModelRenderer(this, 0, 0);
AngledEdgeRight5.addBox(0F, 0F, 0F, 1, 1, 1);
AngledEdgeRight5.setRotationPoint(-8.5F, 6.3F, 12.3F);
AngledEdgeRight5.setTextureSize(64, 32);
AngledEdgeRight5.mirror = true;
setRotation(AngledEdgeRight5, 0.3490659F, 0F, 0F);
AngledEdgeRight6 = new ModelRenderer(this, 0, 0);
AngledEdgeRight6.addBox(0F, 0F, 0F, 1, 1, 1);
AngledEdgeRight6.setRotationPoint(-8.5F, 5.9F, 13.2F);
AngledEdgeRight6.setTextureSize(64, 32);
AngledEdgeRight6.mirror = true;
setRotation(AngledEdgeRight6, 0.2617994F, 0F, 0F);
AngledEdgeRight7 = new ModelRenderer(this, 0, 0);
AngledEdgeRight7.addBox(0F, 0F, 0F, 1, 1, 1);
AngledEdgeRight7.setRotationPoint(-8.5F, 5.4F, 15.05F);
AngledEdgeRight7.setTextureSize(64, 32);
AngledEdgeRight7.mirror = true;
setRotation(AngledEdgeRight7, 0.0872665F, 0F, 0F);
AngledEdgeRight8 = new ModelRenderer(this, 0, 0);
AngledEdgeRight8.addBox(0F, 0F, 0F, 1, 1, 1);
AngledEdgeRight8.setRotationPoint(-8.5F, 5.6F, 14.1F);
AngledEdgeRight8.setTextureSize(64, 32);
AngledEdgeRight8.mirror = true;
setRotation(AngledEdgeRight8, 0.1745329F, 0F, 0F);
AngledEdgeRight9 = new ModelRenderer(this, 0, 0);
AngledEdgeRight9.addBox(0F, 0F, 0F, 1, 1, 1);
AngledEdgeRight9.setRotationPoint(-8.5F, 7.9F, 9.9F);
AngledEdgeRight9.setTextureSize(64, 32);
AngledEdgeRight9.mirror = true;
setRotation(AngledEdgeRight9, 0.6108652F, 0F, 0F);
AngledEdgeRight10 = new ModelRenderer(this, 0, 0);
AngledEdgeRight10.addBox(0F, 0F, 0F, 1, 1, 1);
AngledEdgeRight10.setRotationPoint(-8.5F, 8.5F, 9.2F);
AngledEdgeRight10.setTextureSize(64, 32);
AngledEdgeRight10.mirror = true;
setRotation(AngledEdgeRight10, 0.6981317F, 0F, 0F);
AngledEdgeRight11 = new ModelRenderer(this, 0, 0);
AngledEdgeRight11.addBox(0F, 0F, 0F, 1, 1, 1);
AngledEdgeRight11.setRotationPoint(-8.5F, 9.1F, 8.6F);
AngledEdgeRight11.setTextureSize(64, 32);
AngledEdgeRight11.mirror = true;
setRotation(AngledEdgeRight11, 0.7853982F, 0F, 0F);
AngledEdgeRight12 = new ModelRenderer(this, 0, 0);
AngledEdgeRight12.addBox(0F, 0F, 0F, 1, 1, 1);
AngledEdgeRight12.setRotationPoint(-8.5F, 9.9F, 8F);
AngledEdgeRight12.setTextureSize(64, 32);
AngledEdgeRight12.mirror = true;
setRotation(AngledEdgeRight12, 0.9599311F, 0F, 0F);
AngledEdgeRight13 = new ModelRenderer(this, 0, 0);
AngledEdgeRight13.addBox(0F, 0F, 0F, 1, 1, 1);
AngledEdgeRight13.setRotationPoint(-8.5F, 12.7F, 7.3F);
AngledEdgeRight13.setTextureSize(64, 32);
AngledEdgeRight13.mirror = true;
setRotation(AngledEdgeRight13, 1.570796F, 0F, 0F);
Ahead1 = new ModelRenderer(this, 0, 0);
Ahead1.addBox(0F, 0F, 0F, 17, 1, 1);
Ahead1.setRotationPoint(-8.5F, 9.7F, -2.6F);
Ahead1.setTextureSize(64, 32);
Ahead1.mirror = true;
setRotation(Ahead1, 0.1745329F, 0F, 0F);
Ahead2 = new ModelRenderer(this, 0, 0);
Ahead2.addBox(0F, 0F, 0F, 17, 1, 1);
Ahead2.setRotationPoint(-8.5F, 9.5F, -1.7F);
Ahead2.setTextureSize(64, 32);
Ahead2.mirror = true;
setRotation(Ahead2, -0.1745329F, 0F, 0F);
Ahead3 = new ModelRenderer(this, 0, 0);
Ahead3.addBox(0F, 0F, 0F, 17, 1, 1);
Ahead3.setRotationPoint(-8.5F, 9.6F, -0.8F);
Ahead3.setTextureSize(64, 32);
Ahead3.mirror = true;
setRotation(Ahead3, -0.5235988F, 0F, 0F);
Ahead4 = new ModelRenderer(this, 0, 0);
Ahead4.addBox(0F, 0F, 0F, 17, 1, 1);
Ahead4.setRotationPoint(-8.5F, 10F, 0.1F);
Ahead4.setTextureSize(64, 32);
Ahead4.mirror = true;
setRotation(Ahead4, -0.8726646F, 0F, 0F);
Ahead5 = new ModelRenderer(this, 0, 0);
Ahead5.addBox(0F, 0F, 0F, 17, 1, 1);
Ahead5.setRotationPoint(-8.5F, 10.7F, 0.8F);
Ahead5.setTextureSize(64, 32);
Ahead5.mirror = true;
setRotation(Ahead5, -1.22173F, 0F, 0F);
Ahead6 = new ModelRenderer(this, 0, 0);
Ahead6.addBox(0F, 0F, 0F, 17, 1, 1);
Ahead6.setRotationPoint(-8.5F, 11.6F, 0.2F);
Ahead6.setTextureSize(64, 32);
Ahead6.mirror = true;
setRotation(Ahead6, 0F, 0F, 0F);
FlangeRight1 = new ModelRenderer(this, 0, 0);
FlangeRight1.addBox(0F, 0F, 0F, 1, 6, 1);
FlangeRight1.setRotationPoint(-8.5F, 6F, 15F);
FlangeRight1.setTextureSize(64, 32);
FlangeRight1.mirror = true;
setRotation(FlangeRight1, 0F, 0F, 0F);
FlangeRight2 = new ModelRenderer(this, 0, 0);
FlangeRight2.addBox(0F, 0F, 0F, 1, 6, 1);
FlangeRight2.setRotationPoint(-8.5F, 6F, 14F);
FlangeRight2.setTextureSize(64, 32);
FlangeRight2.mirror = true;
setRotation(FlangeRight2, 0F, 0F, 0F);
FlangeRight3 = new ModelRenderer(this, 0, 0);
FlangeRight3.addBox(0F, 0F, 0F, 1, 6, 1);
FlangeRight3.setRotationPoint(-8.5F, 6.5F, 13F);
FlangeRight3.setTextureSize(64, 32);
FlangeRight3.mirror = true;
setRotation(FlangeRight3, 0F, 0F, 0F);
FlangeRight4 = new ModelRenderer(this, 0, 0);
FlangeRight4.addBox(0F, 0F, 0F, 1, 5, 1);
FlangeRight4.setRotationPoint(-8.5F, 7F, 12F);
FlangeRight4.setTextureSize(64, 32);
FlangeRight4.mirror = true;
setRotation(FlangeRight4, 0F, 0F, 0F);
FlangeRight5 = new ModelRenderer(this, 0, 0);
FlangeRight5.addBox(0F, 0F, 0F, 1, 5, 1);
FlangeRight5.setRotationPoint(-8.5F, 7.6F, 11F);
FlangeRight5.setTextureSize(64, 32);
FlangeRight5.mirror = true;
setRotation(FlangeRight5, 0F, 0F, 0F);
FlangeRight6 = new ModelRenderer(this, 0, 0);
FlangeRight6.addBox(0F, 0F, 0F, 1, 4, 1);
FlangeRight6.setRotationPoint(-8.5F, 8.3F, 10F);
FlangeRight6.setTextureSize(64, 32);
FlangeRight6.mirror = true;
setRotation(FlangeRight6, 0F, 0F, 0F);
FlangeRight7 = new ModelRenderer(this, 0, 0);
FlangeRight7.addBox(0F, 0F, 0F, 1, 3, 1);
FlangeRight7.setRotationPoint(-8.5F, 9F, 9F);
FlangeRight7.setTextureSize(64, 32);
FlangeRight7.mirror = true;
setRotation(FlangeRight7, 0F, 0F, 0F);
FlangeRight8 = new ModelRenderer(this, 0, 0);
FlangeRight8.addBox(0F, 0F, 0F, 1, 2, 1);
FlangeRight8.setRotationPoint(-8.5F, 10F, 8F);
FlangeRight8.setTextureSize(64, 32);
FlangeRight8.mirror = true;
setRotation(FlangeRight8, 0F, 0F, 0F);
FlangeLeft1 = new ModelRenderer(this, 0, 0);
FlangeLeft1.addBox(0F, 0F, 0F, 1, 11, 1);
FlangeLeft1.setRotationPoint(7.5F, 6F, 15F);
FlangeLeft1.setTextureSize(64, 32);
FlangeLeft1.mirror = true;
setRotation(FlangeLeft1, 0F, 0F, 0F);
FlangeLeft2 = new ModelRenderer(this, 0, 0);
FlangeLeft2.addBox(0F, 0F, 0F, 1, 11, 1);
FlangeLeft2.setRotationPoint(7.5F, 6F, 14F);
FlangeLeft2.setTextureSize(64, 32);
FlangeLeft2.mirror = true;
setRotation(FlangeLeft2, 0F, 0F, 0F);
FlangeLeft3 = new ModelRenderer(this, 0, 0);
FlangeLeft3.addBox(0F, 0F, 0F, 1, 11, 1);
FlangeLeft3.setRotationPoint(7.5F, 6.5F, 13F);
FlangeLeft3.setTextureSize(64, 32);
FlangeLeft3.mirror = true;
setRotation(FlangeLeft3, 0F, 0F, 0F);
FlangeLeft4 = new ModelRenderer(this, 0, 0);
FlangeLeft4.addBox(0F, 0F, 0F, 1, 10, 1);
FlangeLeft4.setRotationPoint(7.5F, 7F, 12F);
FlangeLeft4.setTextureSize(64, 32);
FlangeLeft4.mirror = true;
setRotation(FlangeLeft4, 0F, 0F, 0F);
AngledEdgeLeft7 = new ModelRenderer(this, 0, 0);
AngledEdgeLeft7.addBox(0F, 0F, 0F, 1, 1, 1);
AngledEdgeLeft7.setRotationPoint(7.5F, 5.4F, 15.1F);
AngledEdgeLeft7.setTextureSize(64, 32);
AngledEdgeLeft7.mirror = true;
setRotation(AngledEdgeLeft7, 0.0872665F, 0F, 0F);
AngledEdgeLeft8 = new ModelRenderer(this, 0, 0);
AngledEdgeLeft8.addBox(0F, 0F, 0F, 1, 1, 1);
AngledEdgeLeft8.setRotationPoint(7.5F, 5.6F, 14.1F);
AngledEdgeLeft8.setTextureSize(64, 32);
AngledEdgeLeft8.mirror = true;
setRotation(AngledEdgeLeft8, 0.1745329F, 0F, 0F);
AngledEdgeLeft9 = new ModelRenderer(this, 0, 0);
AngledEdgeLeft9.addBox(0F, 0F, 0F, 1, 1, 1);
AngledEdgeLeft9.setRotationPoint(7.5F, 5.9F, 13.2F);
AngledEdgeLeft9.setTextureSize(64, 32);
AngledEdgeLeft9.mirror = true;
setRotation(AngledEdgeLeft9, 0.2617994F, 0F, 0F);
AngledEdgeLeft10 = new ModelRenderer(this, 0, 0);
AngledEdgeLeft10.addBox(0F, 0F, 0F, 1, 1, 1);
AngledEdgeLeft10.setRotationPoint(7.5F, 6.3F, 12.3F);
AngledEdgeLeft10.setTextureSize(64, 32);
AngledEdgeLeft10.mirror = true;
setRotation(AngledEdgeLeft10, 0.3490659F, 0F, 0F);
AngledEdgeLeft11 = new ModelRenderer(this, 0, 0);
AngledEdgeLeft11.addBox(0F, 0F, 0F, 1, 1, 1);
AngledEdgeLeft11.setRotationPoint(7.5F, 6.8F, 11.5F);
AngledEdgeLeft11.setTextureSize(64, 32);
AngledEdgeLeft11.mirror = true;
setRotation(AngledEdgeLeft11, 0.4363323F, 0F, 0F);
AngledEdgeLeft12 = new ModelRenderer(this, 0, 0);
AngledEdgeLeft12.addBox(0F, 0F, 0F, 1, 1, 1);
AngledEdgeLeft12.setRotationPoint(7.5F, 7.3F, 10.7F);
AngledEdgeLeft12.setTextureSize(64, 32);
AngledEdgeLeft12.mirror = true;
setRotation(AngledEdgeLeft12, 0.5235988F, 0F, 0F);
AngledEdgeLeft13 = new ModelRenderer(this, 0, 0);
AngledEdgeLeft13.addBox(0F, 0F, 0F, 1, 1, 1);
AngledEdgeLeft13.setRotationPoint(7.5F, 7.9F, 9.9F);
AngledEdgeLeft13.setTextureSize(64, 32);
AngledEdgeLeft13.mirror = true;
setRotation(AngledEdgeLeft13, 0.6108652F, 0F, 0F);
AngledEdgeLeft4 = new ModelRenderer(this, 0, 0);
AngledEdgeLeft4.addBox(0F, 0F, 0F, 1, 1, 1);
AngledEdgeLeft4.setRotationPoint(7.5F, 9.1F, 8.6F);
AngledEdgeLeft4.setTextureSize(64, 32);
AngledEdgeLeft4.mirror = true;
setRotation(AngledEdgeLeft4, 0.7853982F, 0F, 0F);
AngledEdgeLeft5 = new ModelRenderer(this, 0, 0);
AngledEdgeLeft5.addBox(0F, 0F, 0F, 1, 1, 1);
AngledEdgeLeft5.setRotationPoint(7.5F, 12.7F, 7.3F);
AngledEdgeLeft5.setTextureSize(64, 32);
AngledEdgeLeft5.mirror = true;
setRotation(AngledEdgeLeft5, 1.570796F, 0F, 0F);
AngledEdgeLeft1 = new ModelRenderer(this, 0, 0);
AngledEdgeLeft1.addBox(0F, 0F, 0F, 1, 1, 1);
AngledEdgeLeft1.setRotationPoint(7.5F, 11.7F, 7.3F);
AngledEdgeLeft1.setTextureSize(64, 32);
AngledEdgeLeft1.mirror = true;
setRotation(AngledEdgeLeft1, 1.308997F, 0F, 0F);
AngledEdgeLeft2 = new ModelRenderer(this, 0, 0);
AngledEdgeLeft2.addBox(0F, 0F, 0F, 1, 1, 1);
AngledEdgeLeft2.setRotationPoint(7.5F, 10.8F, 7.6F);
AngledEdgeLeft2.setTextureSize(64, 32);
AngledEdgeLeft2.mirror = true;
setRotation(AngledEdgeLeft2, 1.134464F, 0F, 0F);
AngledEdgeLeft3 = new ModelRenderer(this, 0, 0);
AngledEdgeLeft3.addBox(0F, 0F, 0F, 1, 1, 1);
AngledEdgeLeft3.setRotationPoint(7.5F, 9.9F, 8F);
AngledEdgeLeft3.setTextureSize(64, 32);
AngledEdgeLeft3.mirror = true;
setRotation(AngledEdgeLeft3, 0.9599311F, 0F, 0F);
AngledEdgeLeft6 = new ModelRenderer(this, 0, 0);
AngledEdgeLeft6.addBox(0F, 0F, 0F, 1, 1, 1);
AngledEdgeLeft6.setRotationPoint(7.5F, 8.5F, 9.2F);
AngledEdgeLeft6.setTextureSize(64, 32);
AngledEdgeLeft6.mirror = true;
setRotation(AngledEdgeLeft6, 0.6981317F, 0F, 0F);
FlangeLeft5 = new ModelRenderer(this, 0, 0);
FlangeLeft5.addBox(0F, 0F, 0F, 1, 4, 1);
FlangeLeft5.setRotationPoint(7.5F, 8.3F, 11F);
FlangeLeft5.setTextureSize(64, 32);
FlangeLeft5.mirror = true;
setRotation(FlangeLeft5, 0F, 0F, 0F);
FlangeLeft6 = new ModelRenderer(this, 0, 0);
FlangeLeft6.addBox(0F, 0F, 0F, 1, 4, 1);
FlangeLeft6.setRotationPoint(7.5F, 8.3F, 10F);
FlangeLeft6.setTextureSize(64, 32);
FlangeLeft6.mirror = true;
setRotation(FlangeLeft6, 0F, 0F, 0F);
FlangeLeft7 = new ModelRenderer(this, 0, 0);
FlangeLeft7.addBox(0F, 0F, 0F, 1, 3, 1);
FlangeLeft7.setRotationPoint(7.5F, 9F, 9F);
FlangeLeft7.setTextureSize(64, 32);
FlangeLeft7.mirror = true;
setRotation(FlangeLeft7, 0F, 0F, 0F);
FlangeLeft8 = new ModelRenderer(this, 0, 0);
FlangeLeft8.addBox(0F, 0F, 0F, 1, 2, 1);
FlangeLeft8.setRotationPoint(7.5F, 10F, 8F);
FlangeLeft8.setTextureSize(64, 32);
FlangeLeft8.mirror = true;
setRotation(FlangeLeft8, 0F, 0F, 0F);
EdgeLeft = new ModelRenderer(this, 0, 0);
EdgeLeft.addBox(0F, 0F, 0F, 1, 5, 18);
EdgeLeft.setRotationPoint(7.5F, 12F, -1.2F);
EdgeLeft.setTextureSize(64, 32);
EdgeLeft.mirror = true;
setRotation(EdgeLeft, 0F, 0F, 0F);
AheadEdgeLeft1 = new ModelRenderer(this, 0, 0);
AheadEdgeLeft1.addBox(0F, 0F, 0F, 1, 6, 1);
AheadEdgeLeft1.setRotationPoint(7.5F, 9.7F, -2F);
AheadEdgeLeft1.setTextureSize(64, 32);
AheadEdgeLeft1.mirror = true;
setRotation(AheadEdgeLeft1, 0F, 0F, 0F);
AheadEdgeLeft2 = new ModelRenderer(this, 0, 0);
AheadEdgeLeft2.addBox(0F, 0F, 0F, 1, 1, 4);
AheadEdgeLeft2.setRotationPoint(7.5F, 11F, -3.5F);
AheadEdgeLeft2.setTextureSize(64, 32);
AheadEdgeLeft2.mirror = true;
setRotation(AheadEdgeLeft2, 0F, 0F, 0F);
AheadEdgeLeft3 = new ModelRenderer(this, 0, 0);
AheadEdgeLeft3.addBox(0F, 0F, 0F, 1, 1, 3);
AheadEdgeLeft3.setRotationPoint(7.5F, 10F, -3.1F);
AheadEdgeLeft3.setTextureSize(64, 32);
AheadEdgeLeft3.mirror = true;
setRotation(AheadEdgeLeft3, 0F, 0F, 0F);
AheadEdgeLeft4 = new ModelRenderer(this, 0, 0);
AheadEdgeLeft4.addBox(0F, 0F, 0F, 1, 2, 1);
AheadEdgeLeft4.setRotationPoint(7.5F, 11.8F, -3F);
AheadEdgeLeft4.setTextureSize(64, 32);
AheadEdgeLeft4.mirror = true;
setRotation(AheadEdgeLeft4, 0F, 0F, 0F);
AheadEdgeRight1 = new ModelRenderer(this, 0, 0);
AheadEdgeRight1.addBox(0F, 0F, 0F, 1, 6, 1);
AheadEdgeRight1.setRotationPoint(-8.5F, 9.7F, -2F);
AheadEdgeRight1.setTextureSize(64, 32);
AheadEdgeRight1.mirror = true;
setRotation(AheadEdgeRight1, 0F, 0F, 0F);
AheadEdgeRight2 = new ModelRenderer(this, 0, 0);
AheadEdgeRight2.addBox(0F, 0F, 0F, 1, 2, 1);
AheadEdgeRight2.setRotationPoint(-8.5F, 11.8F, -3F);
AheadEdgeRight2.setTextureSize(64, 32);
AheadEdgeRight2.mirror = true;
setRotation(AheadEdgeRight2, 0F, 0F, 0F);
AheadEdgeRight3 = new ModelRenderer(this, 0, 0);
AheadEdgeRight3.addBox(0F, 0F, 0F, 1, 1, 3);
AheadEdgeRight3.setRotationPoint(-8.5F, 10F, -3.1F);
AheadEdgeRight3.setTextureSize(64, 32);
AheadEdgeRight3.mirror = true;
setRotation(AheadEdgeRight3, 0F, 0F, 0F);
AheadEdgeRight4 = new ModelRenderer(this, 0, 0);
AheadEdgeRight4.addBox(0F, 0F, 0F, 1, 1, 4);
AheadEdgeRight4.setRotationPoint(-8.5F, 11F, -3.5F);
AheadEdgeRight4.setTextureSize(64, 32);
AheadEdgeRight4.mirror = true;
setRotation(AheadEdgeRight4, 0F, 0F, 0F);
FlangeLeft9 = new ModelRenderer(this, 0, 0);
FlangeLeft9.addBox(0F, 0F, 0F, 1, 5, 1);
FlangeLeft9.setRotationPoint(7.5F, 7.6F, 11F);
FlangeLeft9.setTextureSize(64, 32);
FlangeLeft9.mirror = true;
setRotation(FlangeLeft9, 0F, 0F, 0F);
}public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5)
{
super.render(entity, f, f1, f2, f3, f4, f5);
setRotationAngles(f, f1, f2, f3, f4, f5, entity);
BottomWoodRight1.render(f5);
BottomWoodLeft1.render(f5);
BottomWoodRight2.render(f5);
BottomWoodRight4.render(f5);
BottomWoodRight5.render(f5);
AboveTheBottomWoodRight1.render(f5);
AboveTheBottomWoodRight3.render(f5);
AboveTheBottomWoodRight2.render(f5);
SupportRight.render(f5);
Support.render(f5);
BottomWoodRight3.render(f5);
BottomWoodRight6.render(f5);
BottomWoodLeft2.render(f5);
BottomWoodLeft3.render(f5);
BottomWoodLeft4.render(f5);
BottomWoodLeft5.render(f5);
BottomWoodLeft6.render(f5);
AboveTheBottomWoodRight4.render(f5);
AboveTheBottomWoodLeft1.render(f5);
AboveTheBottomWoodLeft2.render(f5);
AboveTheBottomWoodLeft3.render(f5);
AboveTheBottomWoodLeft4.render(f5);
SupportLeft.render(f5);
Ahead8.render(f5);
Rear1.render(f5);
Rear2.render(f5);
Rear3.render(f5);
Rear4.render(f5);
Rear5.render(f5);
Ahead9.render(f5);
Ahead7.render(f5);
Seat.render(f5);
SeatSupport.render(f5);
Edge.render(f5);
AngledEdgeRight1.render(f5);
AngledEdgeRight2.render(f5);
AngledEdgeRight3.render(f5);
AngledEdgeRight4.render(f5);
AngledEdgeRight5.render(f5);
AngledEdgeRight6.render(f5);
AngledEdgeRight7.render(f5);
AngledEdgeRight8.render(f5);
AngledEdgeRight9.render(f5);
AngledEdgeRight10.render(f5);
AngledEdgeRight11.render(f5);
AngledEdgeRight12.render(f5);
AngledEdgeRight13.render(f5);
Ahead1.render(f5);
Ahead2.render(f5);
Ahead3.render(f5);
Ahead4.render(f5);
Ahead5.render(f5);
Ahead6.render(f5);
FlangeRight1.render(f5);
FlangeRight2.render(f5);
FlangeRight3.render(f5);
FlangeRight4.render(f5);
FlangeRight5.render(f5);
FlangeRight6.render(f5);
FlangeRight7.render(f5);
FlangeRight8.render(f5);
FlangeLeft1.render(f5);
FlangeLeft2.render(f5);
FlangeLeft3.render(f5);
FlangeLeft4.render(f5);
AngledEdgeLeft7.render(f5);
AngledEdgeLeft8.render(f5);
AngledEdgeLeft9.render(f5);
AngledEdgeLeft10.render(f5);
AngledEdgeLeft11.render(f5);
AngledEdgeLeft12.render(f5);
AngledEdgeLeft13.render(f5);
AngledEdgeLeft4.render(f5);
AngledEdgeLeft5.render(f5);
AngledEdgeLeft1.render(f5);
AngledEdgeLeft2.render(f5);
AngledEdgeLeft3.render(f5);
AngledEdgeLeft6.render(f5);
FlangeLeft5.render(f5);
FlangeLeft6.render(f5);
FlangeLeft7.render(f5);
FlangeLeft8.render(f5);
EdgeLeft.render(f5);
AheadEdgeLeft1.render(f5);
AheadEdgeLeft2.render(f5);
AheadEdgeLeft3.render(f5);
AheadEdgeLeft4.render(f5);
AheadEdgeRight1.render(f5);
AheadEdgeRight2.render(f5);
AheadEdgeRight3.render(f5);
AheadEdgeRight4.render(f5);
FlangeLeft9.render(f5);
}private void setRotation(ModelRenderer model, float x, float y, float z)
{
model.rotateAngleX = x;
model.rotateAngleY = y;
model.rotateAngleZ = z;
}public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity)
{
super.setRotationAngles(f, f1, f2, f3, f4, f5, entity);
}}
Mon deuxième problème est aussi sur l'image, mais passe un peu inaperçu. Le joueur est trop avancé et j'aimerai le reculer, pour qu'il soit bien positionner dans le siège. Est-ce que c'est possible directement dans le code ou est-ce qu'il faut modifier le model du traineau ? Merci d'avance PS : j'ai une question pour le model : j'ai lu que cette ligne : ```java BottomWoodRight1.mirror = true; ``` ne servait à rien et qu'on peut lasupprimer. Mais pourquoi Techne (j'utilise Techne pour les model (comme beaucoup de gens je pense)) l'ajoute alors ? Et à quoi sert-elle réellement ?
-
nomDuMorceau.mirror = true est utile.
C’est nomDuMorceau.mirror = false; qui est inutile car cette booléen vaut false par défaut.Ça sert à inverser la texture qui s’applique sur le morceau du modèle.
Si ton modèle est trop bas il suffit de faire un petit GL11.glTranslatef(0.0F, 0.6F, 0.0F); avant de rendre le modèle dans la classe du rendu.
Pour l’emplacement du joueur, il faut override cette fonction :public void updatePassenger(Entity passenger) { if (this.isPassenger(passenger)) { passenger.setPosition(this.posX, this.posY + this.getMountedYOffset() + passenger.getYOffset(), this.posZ); } }
et adapter la position (j’ai ma workspace en 1.10, c’est peut-être différent en 1.9).
-
merci
Je test et je reviens vers toiEDIT : Je n’ai pas encore testé de bouger le joueur. J’ai juste testé de monté le model. Ca fait un truc complètement bizarre. Voilà en 3 images ce que ça donne :
Je n’ai pas bougé ni redémarré le jeu, j’ai juste regarder de plus en plus haut.
Je l’ai mis dans la fonction doRender de mon Render. Voilà la classe en entière :```java
package This_is_Christmas.Client;import org.lwjgl.opengl.GL11;
import This_is_Christmas.Entity.EntitySleigh;
import This_is_Christmas.Entity.ModelSleigh;
import net.minecraft.client.model.IMultipassModel;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.MathHelper;public class RenderSleigh extends Render <entitysleigh>{
protected static final ResourceLocation texture = new ResourceLocation(This_is_Christmas.ThisisChristmas.MODID + “:” + “textures/entity/sleigh.png”);
protected ModelBase modelSleigh = new ModelSleigh();public RenderSleigh(RenderManager rendermanager, float shadow)
{
super(rendermanager);
this.shadowSize = shadow;
}public void doRender(EntitySleigh entity, double x, double y, double z, float entityYaw, float partialTicks)
{
GL11.glTranslatef(0.0F, 1.0F, 0.0F);
GlStateManager.pushMatrix();
this.setupTranslation(x, y, z);
this.setupRotation(entity, entityYaw, partialTicks);
this.bindEntityTexture(entity);if (this.renderOutlines)
{
GlStateManager.enableColorMaterial();
GlStateManager.enableOutlineMode(this.getTeamColor(entity));
}this.modelSleigh.render(entity, partialTicks, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
if (this.renderOutlines)
{
GlStateManager.disableOutlineMode();
GlStateManager.disableColorMaterial();
}GlStateManager.popMatrix();
super.doRender(entity, x, y, z, entityYaw, partialTicks);
}public void setupRotation(EntitySleigh p_188311_1_, float p_188311_2_, float p_188311_3_)
{
GlStateManager.rotate(180.0F - p_188311_2_, 0.0F, 1.0F, 0.0F);
//float f = (float)p_188311_1_.getTimeSinceHit() - p_188311_3_;
// float f1 = p_188311_1_.getDamageTaken() - p_188311_3_;/* if (f1 < 0.0F)
{
f1 = 0.0F;
}if (f > 0.0F)
{
GlStateManager.rotate(MathHelper.sin(f) * f * f1 / 10.0F * (float)p_188311_1_.getForwardDirection(), 1.0F, 0.0F, 0.0F);
}*/GlStateManager.scale(-1.0F, -1.0F, 1.0F);
}public void setupTranslation(double p_188309_1_, double p_188309_3_, double p_188309_5_)
{
GlStateManager.translate((float)p_188309_1_, (float)p_188309_3_ + 0.375F, (float)p_188309_5_);
}/**
* Returns the location of an entity’s texture. Doesn’t seem to be called unless you call Render.bindEntityTexture.
*/
protected ResourceLocation getEntityTexture(EntitySleigh entity)
{
return texture;
}public boolean isMultipass()
{
return true;
}public void renderMultipass(EntitySleigh p_188300_1_, double p_188300_2_, double p_188300_4_, double p_188300_6_, float p_188300_8_, float p_188300_9_)
{
GlStateManager.pushMatrix();
this.setupTranslation(p_188300_2_, p_188300_4_, p_188300_6_);
this.setupRotation(p_188300_1_, p_188300_8_, p_188300_9_);
this.bindEntityTexture(p_188300_1_);
(this.modelSleigh).render(p_188300_1_, p_188300_9_, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
GlStateManager.popMatrix();
}}
D'ailleurs, je sais pas si c'est normal mais ça a également monté la hitbox. Je vais testé le joueur et je réédite ce message. J'ai préféré faire étape par étape EDIT n°2 : Pour changer la position du joueur, ça marche plus ou moins. Ca ne marche seulement dans une direction, si je met dans l'autre ça bug. C'est plus parlant avec images : [![](http://image.noelshack.com/minis/2016/42/1476978130-2016-10-20-17-40-22.png)](http://www.noelshack.com/2016-42-1476978130-2016-10-20-17-40-22.png) [![](http://image.noelshack.com/minis/2016/42/1476978130-2016-10-20-17-40-27.png)](http://www.noelshack.com/2016-42-1476978130-2016-10-20-17-40-27.png) Sur la 1ère image, c'est correct mais pas sur la deuxième. Et c'est normal, je change la position en X, mais pas en Z</entitysleigh>
-
Le problème est que tu as mis le translate avant le pushMatrix, ce qui fait que tout ce qui sera rendu après ton entité sera lui aussi placé plus haut. Modifies plutôt cette fonction : ```java
public void setupTranslation(double p_188309_1_, double p_188309_3_, double p_188309_5_)
{
GlStateManager.translate((float)p_188309_1_, (float)p_188309_3_ + 0.375F, (float)p_188309_5_);
} -
Salut
Merci, ça marche mieux qu’avant. J’ai mis ```java
GL11.glTranslatef(0.0F, 1.13F, 0.0F);Ce problème est réolu, mais il me reste l'autre, à savoir le joueur qui est mal placé. J'utilise cette fonction : ```java passenger.setPosition(this.posX + vec3d.xCoord - 0.8, this.posY + (double)f1 - 0.5, this.posZ + vec3d.zCoord); ``` qui est dans la fonction ```java @Override public void updatePassenger(Entity passenger) { if (this.isPassenger(passenger)) { float f = 0.0F; float f1 = (float)((this.isDead ? 0.009999999776482582D : this.getMountedYOffset()) + passenger.getYOffset() + 1.15); if (this.getPassengers().size() > 1) { int i = this.getPassengers().indexOf(passenger); if (i == 0) { f = 0.2F; } else { f = -0.6F; } if (passenger instanceof EntityAnimal) { f = (float)((double)f + 0.2D); } } Vec3d vec3d = (new Vec3d((double)f, 0.0D, 0.0D)).rotateYaw(-this.rotationYaw * 0.017453292F - ((float)Math.PI / 2F)); passenger.setPosition(this.posX + vec3d.xCoord - 0.8, this.posY + (double)f1 - 0.5, this.posZ + vec3d.zCoord); passenger.rotationYaw += this.deltaRotation; passenger.setRotationYawHead(passenger.getRotationYawHead() + this.deltaRotation); this.applyYawToEntity(passenger); if (passenger instanceof EntityAnimal && this.getPassengers().size() > 1) { int j = passenger.getEntityId() % 2 == 0 ? 90 : 270; passenger.setRenderYawOffset(((EntityAnimal)passenger).renderYawOffset + (float)j); passenger.setRotationYawHead(passenger.getRotationYawHead() + (float)j); } } } ``` Ce que j'ai modifié, c'est dans la variable f1, j'ai ajouté le 1.15 à la fin. Mais le problème, c'est que le joueur est bien placé seulement dans une direction, pas dans les 3 autres. Voyez par vous même : [![](http://image.noelshack.com/minis/2016/42/1477042943-2016-10-21-11-38-34.png)](http://www.noelshack.com/2016-42-1477042943-2016-10-21-11-38-34.png) [![](http://image.noelshack.com/minis/2016/42/1477042945-2016-10-21-11-38-41.png)](http://www.noelshack.com/2016-42-1477042945-2016-10-21-11-38-41.png) [![](http://image.noelshack.com/minis/2016/42/1477042947-2016-10-21-11-38-47.png)](http://www.noelshack.com/2016-42-1477042947-2016-10-21-11-38-47.png) [![](http://image.noelshack.com/minis/2016/42/1477042947-2016-10-21-11-38-52.png)](http://www.noelshack.com/2016-42-1477042947-2016-10-21-11-38-52.png) Ce qui faudrait, c'est changer la position en fonction de la direction, mais il y a deux problèmes à ça : ça risque de faire buguer quand on bouge et il y aura quand même un bug dans deux directions (car ici il y a X, Z, -X et -Z). Il doit y avoir une fonction qui permet de faire ça je pense, mais reste à trouver laquelle … Merci d'avance
-
Les coordonnées x, y, z d’une entité sont les centre de cette entité. C’est le fait que tu cherche à assoir le joueur vers l’arrière et non au centre de l’entité qui complique la tache.
Minecraft n’a qu’une fonction pour ajouter le niveau y (le cas le plus simple) avec getMountedYOffset().Il n’y a rien pour x et z. Donc tu vas devoir faire toutes les fonctions pour et si, le seul moyen pour faire faire est de prendre en compte la rotation de l’entité.
Il faudrait commencer par faire une recherche de solution du côté théorique (mathématique) avant de faire le code. -
Je pence que tu peut aller chercher dans les bateau de la 1.9 car la deuxième personne dans le bateau est décalée vers l’arrière.
-
Très bonne remarque, je n’y avais plus pensé.
-
Salut
Ca marche bien. Dans la fonction :@Override public void updatePassenger(Entity passenger) { if (this.isPassenger(passenger)) { float f = 0.0F; float f1 = (float)((this.isDead ? 0.009999999776482582D : this.getMountedYOffset()) + passenger.getYOffset() + 1.15); if (this.getPassengers().size() == 1) { int i = this.getPassengers().indexOf(passenger); if (i == 0) { f = -0.9F; } else { f = -0.6F; } if (passenger instanceof EntityAnimal) { f = (float)((double)f + 0.2D); } } Vec3d vec3d = (new Vec3d((double)f, 0.0D, 0.0D)).rotateYaw(-this.rotationYaw * 0.017453292F - ((float)Math.PI / 2F)); passenger.setPosition(this.posX + vec3d.xCoord, this.posY + (double)f1 - 0.5, this.posZ + vec3d.zCoord); passenger.rotationYaw += this.deltaRotation; passenger.setRotationYawHead(passenger.getRotationYawHead() + this.deltaRotation); this.applyYawToEntity(passenger); if (passenger instanceof EntityAnimal && this.getPassengers().size() > 1) { int j = passenger.getEntityId() % 2 == 0 ? 90 : 270; passenger.setRenderYawOffset(((EntityAnimal)passenger).renderYawOffset + (float)j); passenger.setRotationYawHead(passenger.getRotationYawHead() + (float)j); } } } ``` j'ai modifié le f dans ```java if (i == 0) { f = -0.9F; }
Merci à vous trois
-
Re
Désolé de vous re-déranger avec ce sujet, mais j’ai un autre problème qui concerne encore le traîneau. Ce problème est plutôt problématique
En fait, je ne peux pas du tout bouger avec. Que je sois à terre ou dans l’eau, je ne peux rien faire. Pourtant, ce qui est bizarre, c’est que même en copiant/collant le code du bateau, ça ne marche pas. Il doit y avoir un autre truc qui fait déplacer la bâteau, mais je sais pas quoi.Voilà l’entité de mon traîneau :
package This_is_Christmas.Entity; import java.util.List; import javax.annotation.Nullable; import com.google.common.collect.Lists; import This_is_Christmas.CreateItems; import net.minecraft.block.BlockLiquid; import net.minecraft.block.BlockPlanks; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.passive.EntityAnimal; import net.minecraft.entity.passive.EntityWaterMob; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.datasync.DataParameter; import net.minecraft.network.datasync.DataSerializers; import net.minecraft.network.datasync.EntityDataManager; import net.minecraft.network.play.client.CPacketSteerBoat; import net.minecraft.util.DamageSource; import net.minecraft.util.EntityDamageSourceIndirect; import net.minecraft.util.EntitySelectors; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class EntitySleigh extends Entity { private static final DataParameter <integer>TIME_SINCE_HIT = EntityDataManager.<integer>createKey(EntitySleigh.class, DataSerializers.VARINT); private static final DataParameter <integer>FORWARD_DIRECTION = EntityDataManager.<integer>createKey(EntitySleigh.class, DataSerializers.VARINT); private static final DataParameter <float>DAMAGE_TAKEN = EntityDataManager.<float>createKey(EntitySleigh.class, DataSerializers.FLOAT); private static final DataParameter <integer>BOAT_TYPE = EntityDataManager.<integer>createKey(EntitySleigh.class, DataSerializers.VARINT); private static final DataParameter<boolean>[] DATA_ID_PADDLE = new DataParameter[] {EntityDataManager.createKey(EntitySleigh.class, DataSerializers.BOOLEAN), EntityDataManager.createKey(EntitySleigh.class, DataSerializers.BOOLEAN)}; private float[] paddlePositions; /** How much of current speed to retain. Value zero to one. */ private float momentum; private float outOfControlTicks; private float deltaRotation; private int lerpSteps; private double boatPitch; private double lerpY; private double lerpZ; private double boatYaw; private double lerpXRot; private boolean leftInputDown; private boolean rightInputDown; private boolean forwardInputDown; private boolean backInputDown; private double waterLevel; /** * How much the boat should glide given the slippery blocks it's currently gliding over. * Halved every tick. */ private float boatGlide; private EntitySleigh.Status status; private EntitySleigh.Status previousStatus; private double lastYd; public EntitySleigh(World worldIn) { super(worldIn); this.paddlePositions = new float[2]; this.preventEntitySpawning = true; this.setSize(1.375F, 0.5625F); } public EntitySleigh(World worldIn, double x, double y, double z) { this(worldIn); this.setPosition(x, y, z); this.motionX = 0.0D; this.motionY = 0.0D; this.motionZ = 0.0D; this.prevPosX = x; this.prevPosY = y; this.prevPosZ = z; } /** * returns if this entity triggers Block.onEntityWalking on the blocks they walk on. used for spiders and wolves to * prevent them from trampling crops */ protected boolean canTriggerWalking() { return false; } protected void entityInit() { this.dataManager.register(TIME_SINCE_HIT, Integer.valueOf(0)); this.dataManager.register(FORWARD_DIRECTION, Integer.valueOf(1)); this.dataManager.register(DAMAGE_TAKEN, Float.valueOf(0.0F)); this.dataManager.register(BOAT_TYPE, Integer.valueOf(EntitySleigh.Type.OAK.ordinal())); for (int i = 0; i < DATA_ID_PADDLE.length; ++i) { this.dataManager.register(DATA_ID_PADDLE*, Boolean.valueOf(false)); } } /** * Returns a boundingBox used to collide the entity with other entities and blocks. This enables the entity to be * pushable on contact, like boats or minecarts. */ @Nullable public AxisAlignedBB getCollisionBox(Entity entityIn) { return entityIn.getEntityBoundingBox(); } /** * Returns the collision bounding box for this entity */ @Nullable public AxisAlignedBB getCollisionBoundingBox() { return this.getEntityBoundingBox(); } /** * Returns true if this entity should push and be pushed by other entities when colliding. */ public boolean canBePushed() { return true; } /** * Returns the Y offset from the entity's position for any entity riding this one. */ public double getMountedYOffset() { return -0.1D; } /** * Called when the entity is attacked. */ public boolean attackEntityFrom(DamageSource source, float amount) { if (this.isEntityInvulnerable(source)) { return false; } else if (!this.worldObj.isRemote && !this.isDead) { if (source instanceof EntityDamageSourceIndirect && source.getEntity() != null && this.isPassenger(source.getEntity())) { return false; } else { this.setForwardDirection(-this.getForwardDirection()); this.setTimeSinceHit(10); this.setDamageTaken(this.getDamageTaken() + amount * 10.0F); this.setBeenAttacked(); boolean flag = source.getEntity() instanceof EntityPlayer && ((EntityPlayer)source.getEntity()).capabilities.isCreativeMode; if (flag || this.getDamageTaken() > 40.0F) { this.dropItemWithOffset(CreateItems.Sleigh, 1, 0.0F); this.setDead(); } return true; } } else { return true; } } /** * Applies a velocity to the entities, to push them away from eachother. */ public void applyEntityCollision(Entity entityIn) { if (entityIn instanceof EntitySleigh) { if (entityIn.getEntityBoundingBox().minY < this.getEntityBoundingBox().maxY) { super.applyEntityCollision(entityIn); } } else if (entityIn.getEntityBoundingBox().minY <= this.getEntityBoundingBox().minY) { super.applyEntityCollision(entityIn); } } @SideOnly(Side.CLIENT) public void performHurtAnimation() { this.setForwardDirection(-this.getForwardDirection()); this.setTimeSinceHit(10); this.setDamageTaken(this.getDamageTaken() * 11.0F); } /** * Returns true if other Entities should be prevented from moving through this Entity. */ public boolean canBeCollidedWith() { return !this.isDead; } /** * Set the position and rotation values directly without any clamping. */ @SideOnly(Side.CLIENT) public void setPositionAndRotationDirect(double x, double y, double z, float yaw, float pitch, int posRotationIncrements, boolean teleport) { this.boatPitch = x; this.lerpY = y; this.lerpZ = z; this.boatYaw = (double)yaw; this.lerpXRot = (double)pitch; this.lerpSteps = 10; } /** * Gets the horizontal facing direction of this Entity, adjusted to take specially-treated entity types into * account. */ public EnumFacing getAdjustedHorizontalFacing() { return this.getHorizontalFacing().rotateY(); } /** * Called to update the entity's position/logic. */ public void onUpdate() { this.previousStatus = this.status; this.status = this.getBoatStatus(); if (this.status != EntitySleigh.Status.UNDER_WATER && this.status != EntitySleigh.Status.UNDER_FLOWING_WATER) { this.outOfControlTicks = 0.0F; } else { ++this.outOfControlTicks; } if (!this.worldObj.isRemote && this.outOfControlTicks >= 60.0F) { this.removePassengers(); } if (this.getTimeSinceHit() > 0) { this.setTimeSinceHit(this.getTimeSinceHit() - 1); } if (this.getDamageTaken() > 0.0F) { this.setDamageTaken(this.getDamageTaken() - 1.0F); } this.prevPosX = this.posX; this.prevPosY = this.posY; this.prevPosZ = this.posZ; super.onUpdate(); this.tickLerp(); if (this.canPassengerSteer()) { if (this.getPassengers().size() == 0 || !(this.getPassengers().get(0) instanceof EntityPlayer)) { this.setPaddleState(false, false); } this.updateMotion(); if (this.worldObj.isRemote) { this.controlBoat(); this.worldObj.sendPacketToServer(new CPacketSteerBoat(this.getPaddleState(0), this.getPaddleState(1))); } this.moveEntity(this.motionX, this.motionY, this.motionZ); } else { this.motionX = 0.0D; this.motionY = 0.0D; this.motionZ = 0.0D; } for (int i = 0; i <= 1; ++i) { if (this.getPaddleState(i)) { this.paddlePositions* = (float)((double)this.paddlePositions* + 0.01D); } else { this.paddlePositions* = 0.0F; } } this.doBlockCollisions(); List <entity>list = this.worldObj.getEntitiesInAABBexcluding(this, this.getEntityBoundingBox().expand(0.20000000298023224D, -0.009999999776482582D, 0.20000000298023224D), EntitySelectors.<entity>getTeamCollisionPredicate(this)); if (!list.isEmpty()) { boolean flag = !this.worldObj.isRemote && !(this.getControllingPassenger() instanceof EntityPlayer); for (int j = 0; j < list.size(); ++j) { Entity entity = (Entity)list.get(j); if (!entity.isPassenger(this)) { if (flag && this.getPassengers().size() < 2 && !entity.isRiding() && entity.width < this.width && entity instanceof EntityLivingBase && !(entity instanceof EntityWaterMob) && !(entity instanceof EntityPlayer)) { entity.startRiding(this); } else { this.applyEntityCollision(entity); } } } } } private void tickLerp() { if (this.lerpSteps > 0 && !this.canPassengerSteer()) { double d0 = this.posX + (this.boatPitch - this.posX) / (double)this.lerpSteps; double d1 = this.posY + (this.lerpY - this.posY) / (double)this.lerpSteps; double d2 = this.posZ + (this.lerpZ - this.posZ) / (double)this.lerpSteps; double d3 = MathHelper.wrapDegrees(this.boatYaw - (double)this.rotationYaw); this.rotationYaw = (float)((double)this.rotationYaw + d3 / (double)this.lerpSteps); this.rotationPitch = (float)((double)this.rotationPitch + (this.lerpXRot - (double)this.rotationPitch) / (double)this.lerpSteps); –this.lerpSteps; this.setPosition(d0, d1, d2); this.setRotation(this.rotationYaw, this.rotationPitch); } } public void setPaddleState(boolean p_184445_1_, boolean p_184445_2_) { this.dataManager.set(DATA_ID_PADDLE[0], Boolean.valueOf(p_184445_1_)); this.dataManager.set(DATA_ID_PADDLE[1], Boolean.valueOf(p_184445_2_)); } @SideOnly(Side.CLIENT) public float getRowingTime(int p_184448_1_, float limbSwing) { return this.getPaddleState(p_184448_1_) ? (float)MathHelper.denormalizeClamp((double)this.paddlePositions[p_184448_1_] - 0.01D, (double)this.paddlePositions[p_184448_1_], (double)limbSwing) : 0.0F; } /** * Determines whether the boat is in water, gliding on land, or in air */ private EntitySleigh.Status getBoatStatus() { EntitySleigh.Status entityboat$status = this.getUnderwaterStatus(); if (entityboat$status != null) { this.waterLevel = this.getEntityBoundingBox().maxY; return entityboat$status; } else if (this.checkInWater()) { return EntitySleigh.Status.IN_WATER; } else { float f = this.getBoatGlide(); if (f > 0.0F) { this.boatGlide = f; return EntitySleigh.Status.ON_LAND; } else { return EntitySleigh.Status.IN_AIR; } } } public float getWaterLevelAbove() { AxisAlignedBB axisalignedbb = this.getEntityBoundingBox(); int i = MathHelper.floor_double(axisalignedbb.minX); int j = MathHelper.ceiling_double_int(axisalignedbb.maxX); int k = MathHelper.floor_double(axisalignedbb.maxY); int l = MathHelper.ceiling_double_int(axisalignedbb.maxY - this.lastYd); int i1 = MathHelper.floor_double(axisalignedbb.minZ); int j1 = MathHelper.ceiling_double_int(axisalignedbb.maxZ); BlockPos.PooledMutableBlockPos blockpos$pooledmutableblockpos = BlockPos.PooledMutableBlockPos.retain(); try { label78: for (int k1 = k; k1 < l; ++k1) { float f = 0.0F; int l1 = i; while (true) { if (l1 >= j) { if (f < 1.0F) { float f2 = (float)blockpos$pooledmutableblockpos.getY() + f; return f2; } break; } for (int i2 = i1; i2 < j1; ++i2) { blockpos$pooledmutableblockpos.set(l1, k1, i2); IBlockState iblockstate = this.worldObj.getBlockState(blockpos$pooledmutableblockpos); if (iblockstate.getMaterial() == Material.WATER) { f = Math.max(f, getBlockLiquidHeight(iblockstate, this.worldObj, blockpos$pooledmutableblockpos)); } if (f >= 1.0F) { continue label78; } } ++l1; } } float f1 = (float)(l + 1); return f1; } finally { blockpos$pooledmutableblockpos.release(); } } /** * Decides how much the boat should be gliding on the land (based on any slippery blocks) */ public float getBoatGlide() { AxisAlignedBB axisalignedbb = this.getEntityBoundingBox(); AxisAlignedBB axisalignedbb1 = new AxisAlignedBB(axisalignedbb.minX, axisalignedbb.minY - 0.001D, axisalignedbb.minZ, axisalignedbb.maxX, axisalignedbb.minY, axisalignedbb.maxZ); int i = MathHelper.floor_double(axisalignedbb1.minX) - 1; int j = MathHelper.ceiling_double_int(axisalignedbb1.maxX) + 1; int k = MathHelper.floor_double(axisalignedbb1.minY) - 1; int l = MathHelper.ceiling_double_int(axisalignedbb1.maxY) + 1; int i1 = MathHelper.floor_double(axisalignedbb1.minZ) - 1; int j1 = MathHelper.ceiling_double_int(axisalignedbb1.maxZ) + 1; List <axisalignedbb>list = Lists.<axisalignedbb>newArrayList(); float f = 0.0F; int k1 = 0; BlockPos.PooledMutableBlockPos blockpos$pooledmutableblockpos = BlockPos.PooledMutableBlockPos.retain(); try { for (int l1 = i; l1 < j; ++l1) { for (int i2 = i1; i2 < j1; ++i2) { int j2 = (l1 != i && l1 != j - 1 ? 0 : 1) + (i2 != i1 && i2 != j1 - 1 ? 0 : 1); if (j2 != 2) { for (int k2 = k; k2 < l; ++k2) { if (j2 <= 0 || k2 != k && k2 != l - 1) { blockpos$pooledmutableblockpos.set(l1, k2, i2); IBlockState iblockstate = this.worldObj.getBlockState(blockpos$pooledmutableblockpos); iblockstate.addCollisionBoxToList(this.worldObj, blockpos$pooledmutableblockpos, axisalignedbb1, list, this); if (!list.isEmpty()) { f += iblockstate.getBlock().slipperiness; ++k1; } list.clear(); } } } } } } finally { blockpos$pooledmutableblockpos.release(); } return f / (float)k1; } private boolean checkInWater() { AxisAlignedBB axisalignedbb = this.getEntityBoundingBox(); int i = MathHelper.floor_double(axisalignedbb.minX); int j = MathHelper.ceiling_double_int(axisalignedbb.maxX); int k = MathHelper.floor_double(axisalignedbb.minY); int l = MathHelper.ceiling_double_int(axisalignedbb.minY + 0.001D); int i1 = MathHelper.floor_double(axisalignedbb.minZ); int j1 = MathHelper.ceiling_double_int(axisalignedbb.maxZ); boolean flag = false; this.waterLevel = Double.MIN_VALUE; BlockPos.PooledMutableBlockPos blockpos$pooledmutableblockpos = BlockPos.PooledMutableBlockPos.retain(); try { for (int k1 = i; k1 < j; ++k1) { for (int l1 = k; l1 < l; ++l1) { for (int i2 = i1; i2 < j1; ++i2) { blockpos$pooledmutableblockpos.set(k1, l1, i2); IBlockState iblockstate = this.worldObj.getBlockState(blockpos$pooledmutableblockpos); if (iblockstate.getMaterial() == Material.WATER) { float f = getLiquidHeight(iblockstate, this.worldObj, blockpos$pooledmutableblockpos); this.waterLevel = Math.max((double)f, this.waterLevel); flag |= axisalignedbb.minY < (double)f; } } } } } finally { blockpos$pooledmutableblockpos.release(); } return flag; } /** * Decides whether the boat is currently underwater. */ @Nullable private EntitySleigh.Status getUnderwaterStatus() { AxisAlignedBB axisalignedbb = this.getEntityBoundingBox(); double d0 = axisalignedbb.maxY + 0.001D; int i = MathHelper.floor_double(axisalignedbb.minX); int j = MathHelper.ceiling_double_int(axisalignedbb.maxX); int k = MathHelper.floor_double(axisalignedbb.maxY); int l = MathHelper.ceiling_double_int(d0); int i1 = MathHelper.floor_double(axisalignedbb.minZ); int j1 = MathHelper.ceiling_double_int(axisalignedbb.maxZ); boolean flag = false; BlockPos.PooledMutableBlockPos blockpos$pooledmutableblockpos = BlockPos.PooledMutableBlockPos.retain(); try { for (int k1 = i; k1 < j; ++k1) { for (int l1 = k; l1 < l; ++l1) { for (int i2 = i1; i2 < j1; ++i2) { blockpos$pooledmutableblockpos.set(k1, l1, i2); IBlockState iblockstate = this.worldObj.getBlockState(blockpos$pooledmutableblockpos); if (iblockstate.getMaterial() == Material.WATER && d0 < (double)getLiquidHeight(iblockstate, this.worldObj, blockpos$pooledmutableblockpos)) { if (((Integer)iblockstate.getValue(BlockLiquid.LEVEL)).intValue() != 0) { EntitySleigh.Status entityboat$status = EntitySleigh.Status.UNDER_FLOWING_WATER; return entityboat$status; } flag = true; } } } } } finally { blockpos$pooledmutableblockpos.release(); } return flag ? EntitySleigh.Status.UNDER_WATER : null; } public static float getBlockLiquidHeight(IBlockState p_184456_0_, IBlockAccess p_184456_1_, BlockPos p_184456_2_) { int i = ((Integer)p_184456_0_.getValue(BlockLiquid.LEVEL)).intValue(); return (i & 7) == 0 && p_184456_1_.getBlockState(p_184456_2_.up()).getMaterial() == Material.WATER ? 1.0F : 1.0F - BlockLiquid.getLiquidHeightPercent(i); } public static float getLiquidHeight(IBlockState p_184452_0_, IBlockAccess p_184452_1_, BlockPos p_184452_2_) { return (float)p_184452_2_.getY() + getBlockLiquidHeight(p_184452_0_, p_184452_1_, p_184452_2_); } /** * Update the boat's speed, based on momentum. */ private void updateMotion() { double d0 = -0.03999999910593033D; double d1 = d0; double d2 = 0.0D; this.momentum = 0.05F; if (this.previousStatus == EntitySleigh.Status.IN_AIR && this.status != EntitySleigh.Status.IN_AIR && this.status != EntitySleigh.Status.ON_LAND) { this.waterLevel = this.getEntityBoundingBox().minY + (double)this.height; this.setPosition(this.posX, (double)(this.getWaterLevelAbove() - this.height) + 0.101D, this.posZ); this.motionY = 0.0D; this.lastYd = 0.0D; this.status = EntitySleigh.Status.IN_WATER; } else { if (this.status == EntitySleigh.Status.IN_WATER) { d2 = (this.waterLevel - this.getEntityBoundingBox().minY) / (double)this.height; this.momentum = 0.9F; } else if (this.status == EntitySleigh.Status.UNDER_FLOWING_WATER) { d1 = -7.0E-4D; this.momentum = 0.9F; } else if (this.status == EntitySleigh.Status.UNDER_WATER) { d2 = 0.009999999776482582D; this.momentum = 0.45F; } else if (this.status == EntitySleigh.Status.IN_AIR) { this.momentum = 0.9F; } else if (this.status == EntitySleigh.Status.ON_LAND) { this.momentum = this.boatGlide; if (this.getControllingPassenger() instanceof EntityPlayer) { this.boatGlide /= 2.0F; } } this.motionX *= (double)this.momentum; this.motionZ *= (double)this.momentum; this.deltaRotation *= this.momentum; this.motionY += d1; if (d2 > 0.0D) { double d3 = 0.65D; this.motionY += d2 * (-d0 / 0.65D); double d4 = 0.75D; this.motionY *= 0.75D; } } } private void controlBoat() { if (this.isBeingRidden()) { float f = 0.0F; if (this.leftInputDown) { this.deltaRotation += -1.0F; } if (this.rightInputDown) { ++this.deltaRotation; } if (this.rightInputDown != this.leftInputDown && !this.forwardInputDown && !this.backInputDown) { f += 0.005F; } this.rotationYaw += this.deltaRotation; if (this.forwardInputDown) { f += 0.04F; } if (this.backInputDown) { f -= 0.005F; } this.motionX += (double)(MathHelper.sin(-this.rotationYaw * 0.017453292F) * f); this.motionZ += (double)(MathHelper.cos(this.rotationYaw * 0.017453292F) * f); this.setPaddleState(this.rightInputDown || this.forwardInputDown, this.leftInputDown || this.forwardInputDown); } } @Override public void updatePassenger(Entity passenger) { if (this.isPassenger(passenger)) { float f = 0.0F; float f1 = (float)((this.isDead ? 0.009999999776482582D : this.getMountedYOffset()) + passenger.getYOffset() + 1.15); float f2 = 0.0F; if (this.getPassengers().size() == 1) { int i = this.getPassengers().indexOf(passenger); if (i == 0) { f = -1.5F; f2 = -0.05F; } else { f = -1.5F; } if (passenger instanceof EntityAnimal) { f = (float)((double)f + 0.2D); } } if (this.getPassengers().size() == 2) { int i = this.getPassengers().indexOf(passenger); if (i == 0) { f = -1.5F; f2 = -1.25F; } else { f = -1.5F; f2 = -1.25F; } if (passenger instanceof EntityAnimal) { f = (float)((double)f + 0.2D); } } Vec3d vec3d = (new Vec3d((double)f, 0.0D, (double)f2)).rotateYaw(-this.rotationYaw * 0.017453292F - ((float)Math.PI / 2F)); passenger.setPosition(this.posX + vec3d.xCoord, this.posY + (double)f1 - 0.5, this.posZ + vec3d.zCoord); passenger.rotationYaw += this.deltaRotation; passenger.setRotationYawHead(passenger.getRotationYawHead() + this.deltaRotation); this.applyYawToEntity(passenger); if (passenger instanceof EntityAnimal && this.getPassengers().size() > 1) { int j = passenger.getEntityId() % 2 == 0 ? 90 : 270; passenger.setRenderYawOffset(((EntityAnimal)passenger).renderYawOffset + (float)j); passenger.setRotationYawHead(passenger.getRotationYawHead() + (float)j); } } } /** * Applies this boat's yaw to the given entity. Used to update the orientation of its passenger. */ protected void applyYawToEntity(Entity entityToUpdate) { entityToUpdate.setRenderYawOffset(this.rotationYaw); float f = MathHelper.wrapDegrees(entityToUpdate.rotationYaw - this.rotationYaw); float f1 = MathHelper.clamp_float(f, -105.0F, 105.0F); entityToUpdate.prevRotationYaw += f1 - f; entityToUpdate.rotationYaw += f1 - f; entityToUpdate.setRotationYawHead(entityToUpdate.rotationYaw); } /** * Applies this entity's orientation (pitch/yaw) to another entity. Used to update passenger orientation. */ @SideOnly(Side.CLIENT) public void applyOrientationToEntity(Entity entityToUpdate) { this.applyYawToEntity(entityToUpdate); } /** * (abstract) Protected helper method to write subclass entity data to NBT. */ protected void writeEntityToNBT(NBTTagCompound compound) { compound.setString("Type", this.getBoatType().getName()); } /** * (abstract) Protected helper method to read subclass entity data from NBT. */ protected void readEntityFromNBT(NBTTagCompound compound) { if (compound.hasKey("Type", 8)) { this.setBoatType(EntitySleigh.Type.getTypeFromString(compound.getString("Type"))); } } public boolean processInitialInteract(EntityPlayer player, @Nullable ItemStack stack, EnumHand hand) { if (!this.worldObj.isRemote && !player.isSneaking() && this.outOfControlTicks < 60.0F) { player.startRiding(this); } return true; } protected void updateFallState(double y, boolean onGroundIn, IBlockState state, BlockPos pos) { this.lastYd = this.motionY; if (!this.isRiding()) { if (onGroundIn) { if (this.fallDistance > 3.0F) { if (this.status != EntitySleigh.Status.ON_LAND) { this.fallDistance = 0.0F; return; } this.fall(this.fallDistance, 1.0F); if (!this.worldObj.isRemote && !this.isDead) { this.setDead(); if (this.worldObj.getGameRules().getBoolean("doEntityDrops")) { for (int i = 0; i < 3; ++i) { this.entityDropItem(new ItemStack(Item.getItemFromBlock(Blocks.PLANKS), 1, this.getBoatType().getMetadata()), 0.0F); } for (int j = 0; j < 2; ++j) { this.dropItemWithOffset(Items.STICK, 1, 0.0F); } } } } this.fallDistance = 0.0F; } else if (this.worldObj.getBlockState((new BlockPos(this)).down()).getMaterial() != Material.WATER && y < 0.0D) { this.fallDistance = (float)((double)this.fallDistance - y); } } } public boolean getPaddleState(int p_184457_1_) { return ((Boolean)this.dataManager.get(DATA_ID_PADDLE[p_184457_1_])).booleanValue() && this.getControllingPassenger() != null; } /** * Sets the damage taken from the last hit. */ public void setDamageTaken(float damageTaken) { this.dataManager.set(DAMAGE_TAKEN, Float.valueOf(damageTaken)); } /** * Gets the damage taken from the last hit. */ public float getDamageTaken() { return ((Float)this.dataManager.get(DAMAGE_TAKEN)).floatValue(); } /** * Sets the time to count down from since the last time entity was hit. */ public void setTimeSinceHit(int timeSinceHit) { this.dataManager.set(TIME_SINCE_HIT, Integer.valueOf(timeSinceHit)); } /** * Gets the time since the last hit. */ public int getTimeSinceHit() { return ((Integer)this.dataManager.get(TIME_SINCE_HIT)).intValue(); } /** * Sets the forward direction of the entity. */ public void setForwardDirection(int forwardDirection) { this.dataManager.set(FORWARD_DIRECTION, Integer.valueOf(forwardDirection)); } /** * Gets the forward direction of the entity. */ public int getForwardDirection() { return ((Integer)this.dataManager.get(FORWARD_DIRECTION)).intValue(); } public void setBoatType(EntitySleigh.Type boatType) { this.dataManager.set(BOAT_TYPE, Integer.valueOf(boatType.ordinal())); } public EntitySleigh.Type getBoatType() { return EntitySleigh.Type.byId(((Integer)this.dataManager.get(BOAT_TYPE)).intValue()); } protected boolean canFitPassenger(Entity passenger) { return this.getPassengers().size() < 2; } /** * For vehicles, the first passenger is generally considered the controller and "drives" the vehicle. For example, * Pigs, Horses, and Boats are generally "steered" by the controlling passenger. */ @Nullable public Entity getControllingPassenger() { List <entity>list = this.getPassengers(); return list.isEmpty() ? null : (Entity)list.get(0); } @SideOnly(Side.CLIENT) public void updateInputs(boolean p_184442_1_, boolean p_184442_2_, boolean p_184442_3_, boolean p_184442_4_) { this.leftInputDown = p_184442_1_; this.rightInputDown = p_184442_2_; this.forwardInputDown = p_184442_3_; this.backInputDown = p_184442_4_; } public static enum Status { IN_WATER, UNDER_WATER, UNDER_FLOWING_WATER, ON_LAND, IN_AIR; } public static enum Type { OAK(BlockPlanks.EnumType.OAK.getMetadata(), "oak"), SPRUCE(BlockPlanks.EnumType.SPRUCE.getMetadata(), "spruce"), BIRCH(BlockPlanks.EnumType.BIRCH.getMetadata(), "birch"), JUNGLE(BlockPlanks.EnumType.JUNGLE.getMetadata(), "jungle"), ACACIA(BlockPlanks.EnumType.ACACIA.getMetadata(), "acacia"), DARK_OAK(BlockPlanks.EnumType.DARK_OAK.getMetadata(), "dark_oak"); private final String name; private final int metadata; private Type(int metadataIn, String nameIn) { this.name = nameIn; this.metadata = metadataIn; } public String getName() { return this.name; } public int getMetadata() { return this.metadata; } public String toString() { return this.name; } /** * Get a boat type by it's enum ordinal */ public static EntitySleigh.Type byId(int id) { if (id < 0 || id >= values().length) { id = 0; } return values()[id]; } public static EntitySleigh.Type getTypeFromString(String nameIn) { for (int i = 0; i < values().length; ++i) { if (values()*.getName().equals(nameIn)) { return values()*; } } return values()[0]; } } } ```(Comme vous pouvez le voir, il y a des choses en rapport avec les bateaux qui ne servent à rien, mais je les enlèverai plus tard). Si vous avez une idée, je suis preneur. Merci d'avance PS : J'ai placé ce problème à la fin de ce post au lieu de créer un autre sujet. Certes, j'ai mis ce sujet en résolu, mais il n'a pas encore été placé comme résolu. Ai-je eu raison de mettre ce problème ici ou aurais-je dû créer un autre sujet ?</entity></axisalignedbb></axisalignedbb></entity></entity></boolean></integer></integer></float></float></integer></integer></integer></integer>
-
Si le bateau ne bouge pas, c’est surement que les variable “forwardInputDown”, “leftInputDown” , … sont toujours à false (coté serveur) donc regarde si la fonction “updateInputs” est bien appelée. Si elle est bien appelée, il faut surement envoyer les info au serveur je ne sait pas si il y as une fonction pour faire ça mais sinon, il faut surement passer par un packet. (je ne m’y connais pas trop en entité donc c’est peut-être pas ça le problème mais c’est ce qui me parait le plus probable)
-
Salut
Désolé pour le temps de la réponse, j’essayait d’ajouter un inventaire au traîneau, qui veut pas s’ouvrir.Bref. J’avais vu un packet dans la classe de l’entité, je suis allé à l’intérieur et j’ai vu qu’il servait aux mouvements. Je m’étais dit que ça pouvait l’utiliser. On dirait bien que non. Je vais en faire un autre et je reviens.
Comme dit ci-dessus, j’ai essayer d’ajouter un inventaire (donc un gui, un container et un inventaire) à mon traîneau, mais il veut pas s’ouvrir. J’y ai passé toute l’après-midi à lire le tuto, le comprendre et tout. J’ai également dû “bidouiller” quelques trucs pour l’adapter à mon traîneau vu que le tuto à été créer pour un block.
Voici les classes :
Ce qui sert à ouvrir le gui dans la classe de l’entité :else if (!this.worldObj.isRemote && player.isSneaking() && this.outOfControlTicks < 60.0F) { System.out.println("must open GUI"); player.openGui(ThisisChristmas.instance, 0, this.worldObj, (int)this.posX, (int)this.posY, (int)this.posZ); }
Mon GuiHandler
package This_is_Christmas; import This_is_Christmas.Entity.EntitySleigh; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.world.World; import net.minecraftforge.fml.common.network.IGuiHandler; public class GuiHandlerChristmas implements IGuiHandler { @Override public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { if(ID == 0) { System.out.println("must call container"); EntitySleigh sleigh = new EntitySleigh(world); InventorySleigh invSleigh = new InventorySleigh(world); return new ContainerSleigh(player.inventory, invSleigh, sleigh, player); } return null; } @Override public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { if(ID == 0) { System.out.println("must call GUI"); EntitySleigh sleigh = new EntitySleigh(world); InventorySleigh invSleigh = new InventorySleigh(world); return new GuiSleigh(player.inventory, invSleigh, sleigh, player); } return null; } }
Mon GUI :
package This_is_Christmas; import org.lwjgl.opengl.GL11; import This_is_Christmas.Entity.EntitySleigh; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.resources.I18n; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.util.ResourceLocation; public class GuiSleigh extends GuiContainer{ private static final ResourceLocation texture = new ResourceLocation(ThisisChristmas.MODID + ":" + "textures/gui/inventorySleigh"); private IInventory playerInv; private EntitySleigh theSleigh; private InventorySleigh sleighInventory; public GuiSleigh(InventoryPlayer inventory, InventorySleigh invSleigh, EntitySleigh sleigh, EntityPlayer player) { super(new ContainerSleigh(inventory, invSleigh, sleigh, player)); System.out.println("GUI has been call"); this.theSleigh = sleigh; this.playerInv = inventory; this.sleighInventory = invSleigh; this.allowUserInput = false; this.xSize = 176; this.ySize = 222; System.out.println("GUI has been initialize"); } @Override protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) { System.out.println("drawGuiContainerBackgroundLayer has been call"); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(texture); int k = (this.width - this.xSize) / 2; int l = (this.height - this.ySize) / 2; this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); System.out.println("GUI has been draw"); } protected void drawGuiContainerForegroundLayer(int x, int y) { String invSleighName = this.sleighInventory.hasCustomName() ? this.sleighInventory.getName() : I18n.format(this.sleighInventory.getName()); this.fontRendererObj.drawStringWithShadow(invSleighName, (this.xSize - this.fontRendererObj.getStringWidth(invSleighName)) / 2, 6, 0); String invPlayerName = this.playerInv.hasCustomName() ? this.playerInv.getName() : I18n.format(this.playerInv.getName()); this.fontRendererObj.drawStringWithShadow(invPlayerName, (this.xSize - this.fontRendererObj.getStringWidth(invPlayerName)) / 2, this.ySize - 96, 0); } }
Mon Container :
package This_is_Christmas; import This_is_Christmas.Entity.EntitySleigh; import net.minecraft.entity.passive.EntityHorse; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; public class ContainerSleigh extends Container{ private InventorySleigh sleighInventory; private EntitySleigh theSleigh; public ContainerSleigh(IInventory playerInventory, final InventorySleigh sleighInventoryIn, final EntitySleigh sleigh, EntityPlayer player) { System.out.println("Container has been call"); sleighInventory = sleighInventoryIn; theSleigh = sleigh; sleighInventoryIn.openInventory(player); for(int i=0; i < 3; i++) { for(int j = 0; j < 9; j++) { this.addSlotToContainer(new Slot(sleighInventoryIn, j + i * 9, 8 + j * 18, 18 + i * 18)); } } this.bindPlayerInventory(player.inventory); } @Override public boolean canInteractWith(EntityPlayer playerIn) { return this.sleighInventory.isUseableByPlayer(playerIn) && this.theSleigh.isEntityAlive() && this.theSleigh.getDistanceToEntity(playerIn) < 8.0F; } private void bindPlayerInventory(InventoryPlayer inventory) { int i; for(i = 0; i < 3; i++) { for(int j = 0; j < 9; j++) { this.addSlotToContainer(new Slot(inventory, j + i * 9 + 9, 8 + j * 18, 86 + i * 18)); } } for(i = 0; i < 9; i++) { this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 144)); } } public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) { ItemStack itemstack = null; Slot slot = (Slot)this.inventorySlots.get(index); if (slot != null && slot.getHasStack()) { ItemStack itemstack1 = slot.getStack(); itemstack = itemstack1.copy(); if (index < this.sleighInventory.getSizeInventory()) { if (!this.mergeItemStack(itemstack1, this.sleighInventory.getSizeInventory(), this.inventorySlots.size(), true)) { return null; } } else if (this.getSlot(1).isItemValid(itemstack1) && !this.getSlot(1).getHasStack()) { if (!this.mergeItemStack(itemstack1, 1, 2, false)) { return null; } } else if (this.getSlot(0).isItemValid(itemstack1)) { if (!this.mergeItemStack(itemstack1, 0, 1, false)) { return null; } } else if (this.sleighInventory.getSizeInventory() <= 2 || !this.mergeItemStack(itemstack1, 2, this.sleighInventory.getSizeInventory(), false)) { return null; } if (itemstack1.stackSize == 0) { slot.putStack((ItemStack)null); } else { slot.onSlotChanged(); } } return itemstack; } }
Et mon Inventaire :
package This_is_Christmas; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.text.ITextComponent; import net.minecraft.world.World; public class InventorySleigh extends Entity implements IInventory{ public InventorySleigh(World worldIn) { super(worldIn); System.out.println("Inventory has been call"); } private ItemStack[] contents = new ItemStack[54]; private String customName; @Override public String getName() { return this.hasCustomName() ? this.customName : "entity.sleigh"; } @Override public boolean hasCustomName() { // TODO Auto-generated method stub return false; } @Override public ITextComponent getDisplayName() { // TODO Auto-generated method stub return null; } @Override public int getSizeInventory() { return this.contents.length; } @Override public ItemStack getStackInSlot(int slotIndex) { return this.contents[slotIndex]; } @Override public ItemStack decrStackSize(int slotIndex, int count) { if(this.contents[slotIndex] != null) { ItemStack itemStack; if(this.contents[slotIndex].stackSize <= count) { itemStack = this.contents[slotIndex]; this.contents[slotIndex] = null; this.markDirty(); return itemStack; } else { itemStack = this.contents[slotIndex].splitStack(count); if(this.contents[slotIndex].stackSize == 0) { this.contents[slotIndex] = null; } this.markDirty(); return itemStack; } } else { return null; } } @Override public ItemStack removeStackFromSlot(int slotIndex) { if(this.contents[slotIndex] != null) { ItemStack itemStack = this.contents[slotIndex]; this.contents[slotIndex] = null; return itemStack; } return null; } @Override public void setInventorySlotContents(int slotIndex, ItemStack stack) { this.contents[slotIndex] = stack; if(stack != null && stack.stackSize > this.getInventoryStackLimit()) { stack.stackSize = this.getInventoryStackLimit(); } this.markDirty(); } @Override public int getInventoryStackLimit() { return 64; } @Override public void markDirty() { // TODO Auto-generated method stub } @Override public boolean isUseableByPlayer(EntityPlayer player) { if(player.getDistanceSq((double)this.posX + 0.5D, (double)this.posY + 0.5D, (double)this.posZ + 0.5D) <= 64.0D) { return true; } else { return false; } } @Override public void openInventory(EntityPlayer player) { } @Override public void closeInventory(EntityPlayer player) { } @Override public boolean isItemValidForSlot(int index, ItemStack stack) { return true; } @Override public int getField(int id) { // TODO Auto-generated method stub return 0; } @Override public void setField(int id, int value) { // TODO Auto-generated method stub } @Override public int getFieldCount() { // TODO Auto-generated method stub return 0; } @Override public void clear() { // TODO Auto-generated method stub } public void setCustomName(String customName) { this.customName = customName; } @Override protected void entityInit() { // TODO Auto-generated method stub } @Override protected void readEntityFromNBT(NBTTagCompound compound) { // TODO Auto-generated method stub } @Override protected void writeEntityToNBT(NBTTagCompound compound) { // TODO Auto-generated method stub } }
Je sais pas pourquoi mais j’ai l’impression qu’il y a des erreurs dans l’inventaire. Mais c’est pas là le problème. Comme vous voyez, dans chaque classe j’ai mis des sytem.out.println pour voir si c’est appelé ou pas. Voilà ce que j’obtient :
[17:42:26] [Server thread/INFO] [STDOUT]: [This_is_Christmas.Entity.EntitySleigh:processInitialInteract:851]: must open GUI [17:42:26] [Server thread/INFO] [STDOUT]: [This_is_Christmas.GuiHandlerChristmas:getServerGuiElement:15]: must call container [17:42:26] [Server thread/INFO] [STDOUT]: [This_is_Christmas.InventorySleigh:<init>:16]: Inventory has been call [17:42:26] [Server thread/INFO] [STDOUT]: [This_is_Christmas.ContainerSleigh:<init>:19]: Container has been call [17:42:26] [Client thread/INFO] [STDOUT]: [This_is_Christmas.GuiHandlerChristmas:getClientGuiElement:28]: must call GUI [17:42:26] [Client thread/INFO] [STDOUT]: [This_is_Christmas.InventorySleigh:<init>:16]: Inventory has been call [17:42:26] [Client thread/INFO] [STDOUT]: [This_is_Christmas.ContainerSleigh:<init>:19]: Container has been call [17:42:26] [Client thread/INFO] [STDOUT]: [This_is_Christmas.GuiSleigh:<init>:23]: GUI has been call [17:42:26] [Client thread/INFO] [STDOUT]: [This_is_Christmas.GuiSleigh:<init>:30]: GUI has been initialize
On peut voir que tout est appelé à l’exception d’une fonction : la fonction drawGuiContainerBackgroundLayer de la classe Gui. Je sais pas pourquoi ça ne marche pas, pourtant le gui est bien initialisé.
Si vous avez une idée, n’hsitez pas
C’est peut-être le fait que j’ai bidouillé quelques trucs pour l’adapter à une entité qui fait foirer quelque choseMerci d’avance
EDIT : Pour le mouvement du traîneau, ce n’est pas un packet en fait, parce qu’il a des paramètres en rapport avec les palles. Pour être sûr, j’ai ouvert un src 1.8, et il n’y a pas de packet.</init></init></init></init></init></init>
-
Ton gui se referme car la condition suivante :
return this.sleighInventory.isUseableByPlayer(playerIn) && this.theSleigh.isEntityAlive() && this.theSleigh.getDistanceToEntity(playerIn) < 8.0F;
n’est pas satisfaite (canInteractWith du container).
Car ici :
EntitySleigh sleigh = new EntitySleigh(world); InventorySleigh invSleigh = new InventorySleigh(world); return new GuiSleigh(player.inventory, invSleigh, sleigh, player);
Tu créés une nouvelle instance au lieu de get l’entité existante.
Utilises Entity entity = world.getEntityById(x) pour get l’entité, et lors du openGui utilise ça :player.openGui(ThisisChristmas.instance, 0, this.worldObj, this.getEntityId(), 0, 0);
x, y et z n’ont pas forcement besoin d’être des coordonnées, et c’est seulement utile dans le cas d’un bloc.
Pour une entité faire passer l’id de l’entité suffit.Et pour ton inventaire, au lieu de créer une classe à part (qui te fait encore une instance de plus que tu gère déjà mal) fusionne-le dans la classe de l’entité. Ça sera beaucoup plus simple pour gérer l’instance et pour l’enregistrement des items dans le nbt de l’entité (d’ailleurs on fait exactement la même chose avec les tile entity, l’inventaire est dans la classe même et non dans une classe à part).
-
Salut
J’ai tout fait et ça marche bien, à part les slots qui étaient décalés. Je pensais que ça serait chaud de les déplacer, mais non : une fois qu’on a compris le calcul, c’est simple. Là, tout est bien positionné. Voilà le résultat :
Il me reste plus que le problème que je ne peux pas bouger avec. A mon avis, la solution au problème doit être la même que mon problème de Renne que je ne peux pas contrôler non plus.
Merci d’avance
-
Salut
Ce n’est pas la même solution que mon problème de renne, le renne étant extend de EntityAnimal. Mais je pense avoir trouvé. J’ai essayé de voir où était appelé ma classe entity, elle est appelé dans l’itemSleigh (en gros, c’est l’item pour le faire spawn). J’ai comparé à l’entityBoat, elle est appelé à trois endroits : dans l’item (comme pour moin traîneau, il sert a le faire spawn), dans la sous-classe BehaviorDispenseBoat de la classe Bootstrap et dans la classe NetHandlerPlayClient. Pour la sous-classe BehaviorDispenseBoat, si je comprend bien le commentaire (le voici : Dispense the specified stack, play the dispense sound and spawn particles.), ça sert pour le dispenser. Dans la classe NetHandlerPlayClient, je pense que c’est des packets vu que ça concerne le réseau. En tout cas, si c’est ça, tu avais raison LeBossMax2. Mais je suis pas sûr, voici la classe (je met juste ce qui est utile, demandez moi si vous voulez la classe en entière, elle est dans le package net/minecraft/client/network) :package net.minecraft.client.network; […] @SideOnly(Side.CLIENT) public class NetHandlerPlayClient implements INetHandlerPlayClient { […] private WorldClient clientWorldController; […] /** * Spawns an instance of the objecttype indicated by the packet and sets its position and momentum */ public void handleSpawnObject(SPacketSpawnObject packetIn) { PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController); double d0 = packetIn.getX(); double d1 = packetIn.getY(); double d2 = packetIn.getZ(); Entity entity = null; […] else if (packetIn.getType() == 1) { entity = new EntityBoat(this.clientWorldController, d0, d1, d2); } […] if (entity != null) { EntityTracker.updateServerPosition(entity, d0, d1, d2); entity.rotationPitch = (float)(packetIn.getPitch() * 360) / 256.0F; entity.rotationYaw = (float)(packetIn.getYaw() * 360) / 256.0F; Entity[] aentity = entity.getParts(); if (aentity != null) { int i = packetIn.getEntityID() - entity.getEntityId(); for (int j = 0; j < aentity.length; ++j) { aentity[j].setEntityId(aentity[j].getEntityId() + i); } } entity.setEntityId(packetIn.getEntityID()); entity.setUniqueId(packetIn.getUniqueId()); this.clientWorldController.addEntityToWorld(packetIn.getEntityID(), entity); if (packetIn.getData() > 0) { if (packetIn.getType() == 60 || packetIn.getType() == 91) { Entity entity2 = this.clientWorldController.getEntityByID(packetIn.getData() - 1); if (entity2 instanceof EntityLivingBase && entity instanceof EntityArrow) { ((EntityArrow)entity).shootingEntity = entity2; } } entity.setVelocity((double)packetIn.getSpeedX() / 8000.0D, (double)packetIn.getSpeedY() / 8000.0D, (double)packetIn.getSpeedZ() / 8000.0D); } } } […] }
Merci d’avance
-
Salut
J’ai enfin réussi. J’ai mis :Entity player = this.getControllingPassenger(); EntityTracker.updateServerPosition(this, this.posX, this.posY, this.posZ); this.rotationPitch = (float)((MathHelper.floor_float(player.rotationPitch * 256.0F / 360.0F)) * 360) / 256.0F; this.rotationYaw = (float)((MathHelper.floor_float(player.rotationYaw * 256.0F / 360.0F)) * 360) / 256.0F; Entity[] aentity = this.getParts(); if(aentity != null) { int i = player.getEntityId() - this.getEntityId(); for(int j=0; j < aentity.length; ++j) { aentity[j].setEntityId(aentity[j].getEntityId() + i); } } this.setVelocity((double)((int)(MathHelper.clamp_double(player.motionX, -3.9D, 3.9D) * 8000.0D)) / 500.0D, (double)((int)(MathHelper.clamp_double(player.motionY, -3.9D, 3.9D) * 8000.0D)) / 500.0D, (double)((int)(MathHelper.clamp_double(player.motionZ, -3.9D, 3.9D) * 8000.0D)) / 500.0D); ``` dans la fonction controlBoat. Je me suis inspiré de la fonction que j'ai donné dans le post précédent. Par contre, j'ai un autre problème et une question. Mon autre problème concerne la hitbox. Je l'ai modifié et ça met fait ça : [![](http://image.noelshack.com/minis/2016/43/1477837960-2016-10-30-15-06-51.png)](http://www.noelshack.com/2016-43-1477837960-2016-10-30-15-06-51.png) (j'ai mis la hitbox en rouge pour bien la voir) Comme vous voyez, elle est trop grande. J'ai essayé de la réduire, mais le problème c'est que ça la réduit des 4 côtés. Je pense qu'il y a une fonction pour repositionner la hitbox mais je ne la trouve pas. Ce que je pensais faire, c'est placer le traîneau centre de la hitbox pour ensuite la réduire. Et ma question, c'est que je vais faire d'autres modifs assez dur selon moi (pouvoir accroché des rennes aux traîneau et ne pouvoir avancer seulement si il y a des rennes). J'ai une petite idée mais si je n'y arrive pas, je demande ici ou je créer un nouveau sujet ?
-
En effet ton rendu n’est pas centré par rapport à la boite de collision, il faut adapter le code du rendu avec un petit glTranslate.
(et du-coup il faudra aussi adapter tes valeurs pour la position de l’entité qui monte le traineau).Pour les rennes, il serait mieux de créer une nouvelle discussion.
-
Je n’arrive pas à bien positionner le rendu par rapport à la hitbox. Je sais pas trop comment expliquer, je met des images (ça me fait pareil que quand j’ai voulu positionner le joueur)
Quand je ne touche à rien :
Quand je décale de 1 sur l’axe Z :Je pense que je vais modifier le model, ça sera sans doute plus rapide. Mais j’ai juste une question : je ne vois pas de différence entre ces deux fonctions :
GL11.glTranslated(x, y, z); GL11.glTranslatef(x, y, z);
Pourquoi avoir mis deux fonctions qui font la même chose ?
-
Le premier prend un argument des doubles, l’autre des float.
Donc l’une permet plus de précision que l’autre mais est plus lourde. -
Salut
Merci de ces précisions
J’ai modifié le model. C’est bien positionner maintenantMerci à tous