Résolu Crash custom bloc directionnel
-
Salut,
Aujourd’hui j’ai regardé les tutos oraux et écrits sur les TESR etc et j’arrive à faire tourner le model mais le jeu crash instantanément après avoir posé le bloc qui est alors dans la bonne direction de l’aide s’il vous plaît ?
package fr.altiscraft.altiscraft.proxy; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; import fr.altiscraft.altiscraft.client.ModelBlockATM; import fr.altiscraft.altiscraft.common.ModAltisCraft; import fr.altiscraft.altiscraft.common.TileEntityATM; public class TileEntityATMSpecialRenderer extends TileEntitySpecialRenderer{ public static ModelBlockATM model = new ModelBlockATM(); public static ResourceLocation texture = new ResourceLocation(ModAltisCraft.MODID, "textures/models/blocks/ModelBlockATM.png"); public TileEntityATMSpecialRenderer() { this.func_147497_a(TileEntityRendererDispatcher.instance); } @Override public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float partialRenderTick) { this.renderTileEntityATMAt((TileEntityATM) tile, x, y, z, partialRenderTick); } private void renderTileEntityATMAt(TileEntityATM tile, double x, double y, double z, float partialRenderTick) { GL11.glPushMatrix(); GL11.glTranslated(x + 0.5D, y + 1.5D, z + 0.5D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); this.bindTexture(texture); model.renderAll(); GL11.glPopMatrix(); } }
package fr.altiscraft.altiscraft.common; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.NetworkManager; import net.minecraft.network.Packet; import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.tileentity.TileEntity; public class TileEntityATM extends TileEntity { private byte direction; @Override public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); this.direction = compound.getByte("Direction"); } @Override public void writeToNBT(NBTTagCompound compound) { super.writeToNBT(compound); compound.setByte("Direction", this.direction); } public byte getDirection() { return direction; } public void setDirection(byte direction) { this.direction = direction; this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); } 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); } }
package fr.altiscraft.altiscraft.client; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; public class ModelBlockATM extends ModelBase { ModelRenderer base; ModelRenderer coteG; ModelRenderer coteI; ModelRenderer coteD; ModelRenderer coteH; ModelRenderer coteF; public ModelBlockATM() { textureWidth = 128; textureHeight = 32; base = new ModelRenderer(this, 0, 0); base.addBox(0F, 0F, 0F, 16, 1, 16); base.setRotationPoint(-8F, 8F, -8F); base.setTextureSize(128, 32); setRotation(base, 0F, 0F, 0F); coteG = new ModelRenderer(this, 0, 0); coteG.addBox(0F, 0F, 0F, 1, 14, 15); coteG.setRotationPoint(7F, 9F, -8F); coteG.setTextureSize(128, 32); setRotation(coteG, 0F, 0F, 0F); coteI = new ModelRenderer(this, 95, 0); coteI.addBox(0F, 0F, 0F, 14, 15, 1); coteI.setRotationPoint(-7F, 9F, 2F); coteI.setTextureSize(128, 32); setRotation(coteI, -0.3490659F, 0F, 0F); coteD = new ModelRenderer(this, 0, 0); coteD.addBox(0F, 0F, 0F, 1, 14, 15); coteD.setRotationPoint(-8F, 9F, -8F); coteD.setTextureSize(128, 32); setRotation(coteD, 0F, 0F, 0F); coteH = new ModelRenderer(this, 0, 0); coteH.addBox(0F, 0F, 0F, 16, 1, 16); coteH.setRotationPoint(-8F, 23F, -8F); coteH.setTextureSize(128, 32); setRotation(coteH, 0F, 0F, 0F); coteF = new ModelRenderer(this, 0, 0); coteF.addBox(0F, 0F, 0F, 16, 14, 1); coteF.setRotationPoint(-8F, 9F, 7F); coteF.setTextureSize(128, 32); setRotation(coteF, 0F, 0F, 0F); } public void renderAll() { base.render(0.0625F); coteG.render(0.0625F); coteI.render(0.0625F); coteD.render(0.0625F); coteH.render(0.0625F); coteF.render(0.0625F); } private void setRotation(ModelRenderer model, float x, float y, float z) { model.rotateAngleX = x; model.rotateAngleY = y; model.rotateAngleZ = z; } }
package fr.altiscraft.altiscraft.common; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.MathHelper; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; import fr.altiscraft.altiscraft.proxy.ClientProxy; public class BlocATM extends Block { protected BlocATM() { super(Material.ground); } @Override public boolean hasTileEntity(int metadata) { return true; } @Override public TileEntity createTileEntity(World world, int metadata) { return new TileEntityATM(); } public boolean isOpaqueCube() { return false; } public boolean renderAsNormalBlock() { return false; } public int getRenderType() { return ClientProxy.tesrRenderId; } public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase living, ItemStack stack) { if(stack.getItemDamage() == 0) { TileEntity tile = world.getTileEntity(x, y, z); if(tile instanceof TileEntityATM) { int direction = MathHelper.floor_double((double)(living.rotationYaw * 4.0F / 360.0F) + 2.5D) & 3; ((TileEntityATM)tile).setDirection((byte)direction); } } } @Override public boolean rotateBlock(World world, int x, int y, int z, ForgeDirection axis) { if((axis == ForgeDirection.UP || axis == ForgeDirection.DOWN) && !world.isRemote && world.getBlockMetadata(x, y, z) == 0) { TileEntity tile = world.getTileEntity(x, y, z); if(tile instanceof TileEntityATM) { TileEntityATM tileATM = (TileEntityATM)tile; byte direction = tileATM.getDirection(); direction++; if(direction > 3) { direction = 0; } tileATM.setDirection(direction); return true; } } return false; } public ForgeDirection[] getValidRotations(World world, int x, int y, int z) { return world.getBlockMetadata(x, y, z) == 0 ? new ForgeDirection[] {ForgeDirection.UP, ForgeDirection.DOWN} : ForgeDirection.VALID_DIRECTIONS; } }
-
Rapport de crash ?
-
A oui oublié désolé : http://pastebin.com/ne860Erc
-
Ton tile entity n’est pas enregistré.
-
Ça devait être ça