Résolu Probleme avec les directions
-
Bonjour (encore moi) j’ai un autre problème (je cherche longtemps), j’ai mon block qui ne veut pas se diriger la ou je le pose, alors apres avoir chercher partout j’ai trouvé un code mais qui fais crash mon jeux et je ne sais pas faire:
Mes codes:
Mon block “BlockRangement”:
public class BlockRangement extends Block { public BlockRangement(Material material) { super(material); } public TileEntity createTileEntity(World world, int metadata) { return new TileEntityBlockRangement(); } public boolean renderAsNormalBlock() { return false; } public boolean isOpaqueCube() { return false; } @SideOnly(Side.CLIENT) public int getRenderType() { return ClientProxy.renderBlockRangement; } public boolean hasTileEntity(int metadata) { return true; } public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase living, ItemStack stack) { int direction = MathHelper.floor_double((double)(living.rotationYaw * 4.0F / 360.0F) + 2.5D) & 3; TileEntity te = world.getTileEntity(x, y, z); if(te instanceof TileEntityBlockRangement) { ((TileEntityBlockRangement)te).setDirection((byte)direction); world.markBlockForUpdate(x, y, z); } } }
mon TileEntityBlockRangement:
public class TileEntityBlockRangement extends TileEntity { public byte direction; public void readFromNBT(NBTTagCompound nbtTag) { super.readFromNBT(nbtTag); direction = nbtTag.getByte("direction"); } public void writeToNBT(NBTTagCompound nbtTag) { super.writeToNBT(nbtTag); for(int i = 0; i < 5; i++) { nbtTag.setByte("direction", direction); } } public void setDirection(byte direct) { direction = direct; } public byte getDirection() { return direction; } public Packet getDescriptionPacket() { NBTTagCompound nbttagcompound = new NBTTagCompound(); this.writeToNBT(nbttagcompound); return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 0, nbttagcompound); } public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { this.readFromNBT(pkt.func_148857_g()); this.worldObj.markBlockRangeForRenderUpdate(this.xCoord, this.yCoord, this.zCoord, this.xCoord, this.yCoord, this.zCoord); } }
Mon TileEntityBlockRangementSpecialRender
public class TileEntityBlockRangementSpecialRender extends TileEntitySpecialRenderer implements IInventoryRenderer { public static final ResourceLocation textureLocation = new ResourceLocation(Machines.MODID, "textures/blocks/blockrangement.png"); private final ModelBlockRangement model = new ModelBlockRangement(); public TileEntityBlockRangementSpecialRender() { this.func_147497_a(TileEntityRendererDispatcher.instance); } @Override public void renderInventory(double x, double y, double z) { this.renderTileEntityBlockRangementAt(null, x, y, z, 0.0F); } @Override public void renderTileEntityAt(TileEntity te, double x, double y, double z, float tick) { this.renderTileEntityBlockRangementAt((TileEntityBlockRangement)te, x, y, z, tick); } public void renderTileEntityBlockRangementAt(TileEntityBlockRangement te, double x, double y, double z, float tick) { GL11.glPushMatrix(); GL11.glTranslated(x + 0.5F, y + 1.5F, z + 0.5F); this.bindTexture(textureLocation); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); if(te != null) { GL11.glRotatef(90F * te.getDirection(), 0.0F, 1.0F, 0.0F); } this.model.render(0.0625F); GL11.glPopMatrix(); } }
Mon model:
public class ModelBlockRangement extends ModelBase { // fields ModelRenderer Pied1; ModelRenderer Pied2; ModelRenderer Pied3; ModelRenderer Pied4; ModelRenderer Shape1; ModelRenderer Shape2; ModelRenderer Shape3; ModelRenderer Shape4; ModelRenderer Shape5; ModelRenderer Shape6; ModelRenderer Shape7; ModelRenderer Shape8; ModelRenderer Shape9; ModelRenderer Shape10; public ModelBlockRangement() { textureWidth = 128; textureHeight = 32; Pied1 = new ModelRenderer(this, 12, 16); Pied1.addBox(0F, 0F, 0F, 1, 15, 1); Pied1.setRotationPoint(-7F, 9F, -6F); Pied1.setTextureSize(128, 32); Pied1.mirror = true; setRotation(Pied1, 0F, 0F, 0F); Pied2 = new ModelRenderer(this, 4, 16); Pied2.addBox(0F, 0F, 0F, 1, 15, 1); Pied2.setRotationPoint(-7F, 9F, 6F); Pied2.setTextureSize(128, 32); Pied2.mirror = true; setRotation(Pied2, 0F, 0F, 0F); Pied3 = new ModelRenderer(this, 8, 16); Pied3.addBox(0F, 0F, 0F, 1, 15, 1); Pied3.setRotationPoint(6F, 9F, -6F); Pied3.setTextureSize(128, 32); Pied3.mirror = true; setRotation(Pied3, 0F, 0F, 0F); Pied4 = new ModelRenderer(this, 0, 16); Pied4.addBox(0F, 0F, 0F, 1, 15, 1); Pied4.setRotationPoint(6F, 9F, 6F); Pied4.setTextureSize(128, 32); Pied4.mirror = true; setRotation(Pied4, 0F, 0F, 0F); Shape1 = new ModelRenderer(this, 104, 20); Shape1.addBox(0F, 0F, 0F, 1, 1, 11); Shape1.setRotationPoint(6F, 9F, -5F); Shape1.setTextureSize(128, 32); Shape1.mirror = true; setRotation(Shape1, 0F, 0F, 0F); Shape2 = new ModelRenderer(this, 63, 20); Shape2.addBox(0F, 0F, 0F, 1, 1, 11); Shape2.setRotationPoint(-7F, 9F, -5F); Shape2.setTextureSize(128, 32); Shape2.mirror = true; setRotation(Shape2, 0F, 0F, 0F); Shape3 = new ModelRenderer(this, 0, 6); Shape3.addBox(0F, 0F, 0F, 12, 1, 1); Shape3.setRotationPoint(-6F, 9F, 6F); Shape3.setTextureSize(128, 32); Shape3.mirror = true; setRotation(Shape3, 0F, 0F, 0F); Shape4 = new ModelRenderer(this, 36, 0); Shape4.addBox(0F, 0F, 0F, 12, 1, 1); Shape4.setRotationPoint(-6F, 9F, -6F); Shape4.setTextureSize(128, 32); Shape4.mirror = true; setRotation(Shape4, 0F, 0F, 0F); Shape5 = new ModelRenderer(this, 17, 8); Shape5.addBox(0F, 0F, 0F, 12, 1, 11); Shape5.setRotationPoint(-6F, 9F, -5F); Shape5.setTextureSize(128, 32); Shape5.mirror = true; setRotation(Shape5, 0F, 0F, 0F); Shape6 = new ModelRenderer(this, 17, 20); Shape6.addBox(0F, 0F, 0F, 12, 1, 11); Shape6.setRotationPoint(-6F, 18F, -5F); Shape6.setTextureSize(128, 32); Shape6.mirror = true; setRotation(Shape6, 0F, 0F, 0F); Shape7 = new ModelRenderer(this, 83, 20); Shape7.addBox(0F, 0F, 0F, 1, 1, 11); Shape7.setRotationPoint(6F, 18F, -5F); Shape7.setTextureSize(128, 32); Shape7.mirror = true; setRotation(Shape7, 0F, 0F, 0F); Shape8 = new ModelRenderer(this, 104, 20); Shape8.addBox(0F, 0F, 0F, 1, 1, 11); Shape8.setRotationPoint(-7F, 18F, -5F); Shape8.setTextureSize(128, 32); Shape8.mirror = true; setRotation(Shape8, 0F, 0F, 0F); Shape9 = new ModelRenderer(this, 63, 0); Shape9.addBox(0F, 0F, 0F, 12, 1, 1); Shape9.setRotationPoint(-6F, 18F, 6F); Shape9.setTextureSize(128, 32); Shape9.mirror = true; setRotation(Shape9, 0F, 0F, 0F); Shape10 = new ModelRenderer(this, 103, 0); Shape10.addBox(0F, 1F, 0F, 12, 15, 0); Shape10.setRotationPoint(-6F, 8.4F, -6F); Shape10.setTextureSize(128, 32); Shape10.mirror = true; setRotation(Shape10, 0F, 0F, 0F); } public void render(float f) { Pied1.render(f); Pied2.render(f); Pied3.render(f); Pied4.render(f); Shape1.render(f); Shape2.render(f); Shape3.render(f); Shape4.render(f); Shape5.render(f); Shape6.render(f); Shape7.render(f); Shape8.render(f); Shape9.render(f); Shape10.render(f); } private void setRotation(ModelRenderer model, float x, float y, float z) { model.rotateAngleX = x; model.rotateAngleY = y; model.rotateAngleZ = z; } }
J’épère que vous pourrez m’aider.
-
ya un tuto pour ca: https://www.minecraftforgefrance.fr/topic/99/direction-de-bloc
a modifier pour qu’il marche en 1.7 -
J’ai déjà regarder le tuto, mais j’ai essayer plusieurs fois sans succes ^^
-
Envoie ton crash
-
ha oui m**** :x
Avant j’aimerai voir, car j’ai fait un changement et je vais regarder si ca marche
Heu…Ca marche…Un coup ca marche et un coup sa marche pas…Bizarre, bin du coup je peux le mettre en resolue Oo.
Je sais, enfaite il y avait une faute mais comme eclipse a un probleme il n’avait pas marquer l’erreur, et la je viens de changer et ca marche Oo.
Bon ba on peut dire “Résolue”