Customiser votre bloc
-
Comment on fais pour afficher les lignes déjà ?
J’ai sa moi
package net.minecraft.network.packet; import java.io.DataInput; import java.io.DataOutput; import java.io.IOException; import net.minecraft.nbt.NBTTagCompound; public class Packet132TileEntityData extends Packet { /** The X position of the tile entity to update. */ public int xPosition; /** The Y position of the tile entity to update. */ public int yPosition; /** The Z position of the tile entity to update. */ public int zPosition; /** The type of update to perform on the tile entity. */ public int actionType; /** Custom parameter 1 passed to the tile entity on update. */ public NBTTagCompound customParam1; public Packet132TileEntityData() { this.isChunkDataPacket = true; } public Packet132TileEntityData(int par1, int par2, int par3, int par4, NBTTagCompound par5NBTTagCompound) { this.isChunkDataPacket = true; this.xPosition = par1; this.yPosition = par2; this.zPosition = par3; this.actionType = par4; this.customParam1 = par5NBTTagCompound; } /** * Abstract. Reads the raw packet data from the data stream. */ public void readPacketData(DataInput par1DataInput) throws IOException { this.xPosition = par1DataInput.readInt(); this.yPosition = par1DataInput.readShort(); this.zPosition = par1DataInput.readInt(); this.actionType = par1DataInput.readByte(); this.customParam1 = readNBTTagCompound(par1DataInput); } /** * Abstract. Writes the raw packet data to the data stream. */ public void writePacketData(DataOutput par1DataOutput) throws IOException { par1DataOutput.writeInt(this.xPosition); par1DataOutput.writeShort(this.yPosition); par1DataOutput.writeInt(this.zPosition); par1DataOutput.writeByte((byte)this.actionType); writeNBTTagCompound(this.customParam1, par1DataOutput); } /** * Passes this Packet on to the NetHandler for processing. */ public void processPacket(NetHandler par1NetHandler) { par1NetHandler.handleTileEntityData(this); } /** * Abstract. Return the size of the packet (not counting the header). */ public int getPacketSize() { return 25; } }PS : Desolé mais la fonction Edit veut pas marcher.
-
Il s’appelle customParam1
Pour afficher les lignes, tu vas dans Windows, Preferences, General, Editor, Text Editor (sans dérouler, clic dessus), show line number -
C’est bon j’ai affiché les lignes mais maintenant, j’ai déclaré mon item:
Block BlockLedVerte = new BlockLedVerte(2004).func_111022_d("assabody-mod:led_verte_off"); GameRegistry.registerBlock(BlockLedVerte, "BlockLedVerte"); LanguageRegistry.addName(BlockLedVerte, "BlockLedVerte");public static Block BlockLedVerte;Ainsi que la TileEntity :
GameRegistry.registerTileEntity(TileEntityLedVerte.class,"tileEntityLedVerte");Mais aucune des deux icones n’est affiché sur le block et avec un signal de redstone non plus.
-
.func_111022_d(“assabody-mod:led_verte_off”) retire-ça et LanguageRegistry.addName(BlockLedVerte, “BlockLedVerte”); ça, c’est inutile et ta version de Forge est très ancienne.
-
forge1.6.2-9.10.0.804
La derniere version est la .871, je la prend sur http://files.minecraftforge.net/ ? -
Oui, mais prends plutôt minecraftforge-1.6.4-9.11.1.958
-
La 1.6.4, elle change beaucoup sur forge ?
-
Juste un changement au niveau de la génération des structures, mais tu auras plus de chances de réussir à passer en 1.7.
-
Ok lol, bah je passe en 1.6.4 mais je sais pas si sa reglera le problème
-
public void updateEntity() { if(this.enable) { if(!this.worldObj.isBlockIndirectlyGettingPowered(this.xCoord, this.yCoord, this.zCoord) || this.worldObj.getBlockPowerInput(this.xCoord, this.yCoord, this.zCoord) <= 8) { this.enable = false; world.markBlockForUpdate(x, y, z); } } else { if(this.worldObj.isBlockIndirectlyGettingPowered(this.xCoord, this.yCoord, this.zCoord) && this.worldObj.getBlockPowerInput(this.xCoord, this.yCoord, this.zCoord) > 8) { this.enable = true; world.markBlockForUpdate(x, y, z); } } }Utilise plutôt ça, avec l’autre fonction que je t’ai donné ça envoyait pas un update du rendu.
-
Lol mon eclipse adore les erreurs, il m’en met sur world, x, y et z
-
Heu non, c’est pas ton eclipse qui adore les erreurs, c’est moi qui t’envoie des codes que je tape directement sur le forum x)
this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); -
Sa ne marche pas, le bloc ne change pas de texture. je ne sais pas pourquoi.
BlockLedVerte:package Assabody.mod; import java.util.Random; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Icon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; public class BlockLedVerte extends Block{ private Icon iconDark; private Icon iconGreen; public BlockLedVerte(int par1) { super(par1, Material.rock); this.setCreativeTab(ModAssabody.AssabodyCreativeTabs); } public void registerIcons(IconRegister iconRegister) { iconDark = iconRegister.registerIcon("mod-assabody:led_led_verte_on"); iconGreen = iconRegister.registerIcon("mod-assabody:led_led_verte_off"); } @Override public TileEntity createTileEntity(World world, int metadata) { return new TileEntityLedVerte(); } @SideOnly(Side.CLIENT) public Icon getBlockTexture(IBlockAccess blockaccess, int x, int y, int z, int side) { TileEntity te = blockaccess.getBlockTileEntity(x, y, z); if(te != null && te instanceof TileEntityLedVerte) { TileEntityLedVerte tetuto = (TileEntityLedVerte)te; return tetuto.isEnable() ? this.iconGreen : this.iconDark; } return this.getIcon(side, blockaccess.getBlockMetadata(x, y, z)); } public boolean hasTileEntity(int metadata) { return true; } public void onNeighborBlockChange(World world, int x, int y, int z, int neighborblockid, World par1World, int par2, int par3, int par4) { if(world.isBlockIndirectlyGettingPowered(x, y, z) && world.getBlockPowerInput(x, y, z) > 8) { } } public int idDropped(int par1, Random par2Random, int par3) { return this.blockID; } public boolean renderAsNormalBlock() { return true; } public boolean isOpaqueCube() { return false; } }TileEntityLedVerte:
package Assabody.mod; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.INetworkManager; import net.minecraft.network.packet.Packet; import net.minecraft.network.packet.Packet132TileEntityData; import net.minecraft.tileentity.TileEntity; public class TileEntityLedVerte extends TileEntity { private boolean enable; public void updateEntity() { if(this.enable) { if(!this.worldObj.isBlockIndirectlyGettingPowered(this.xCoord, this.yCoord, this.zCoord) || this.worldObj.getBlockPowerInput(this.xCoord, this.yCoord, this.zCoord) <= 8) { this.enable = false; this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); } } else { if(this.worldObj.isBlockIndirectlyGettingPowered(this.xCoord, this.yCoord, this.zCoord) && this.worldObj.getBlockPowerInput(this.xCoord, this.yCoord, this.zCoord) > 8) { this.enable = true; this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); } } } public boolean isEnable() { return enable; } public Packet getDescriptionPacket() { NBTTagCompound nbttagcompound = new NBTTagCompound(); this.writeToNBT(nbttagcompound); return new Packet132TileEntityData(this.xCoord, this.yCoord, this.zCoord, 4, nbttagcompound); } public void onDataPacket(INetworkManager net, Packet132TileEntityData pkt) { this.readFromNBT(pkt.customParam1); } public void readFromNBT(NBTTagCompound nbtTag) { super.readFromNBT(nbtTag); enable = nbtTag.getBoolean("enable"); } public void writeToNBT(NBTTagCompound nbtTag) { super.writeToNBT(nbtTag); nbtTag.setBoolean("enable", enable); } }Déclaration dans la classe principale :
Block BlockLedVerte = new BlockLedVerte(2004); GameRegistry.registerBlock(BlockLedVerte, "BlockLedVerte"); -
bloc :
package tutoriel.common; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Icon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public class BlockLed extends Block { private Icon iconDark; private Icon iconGreen; public BlockLed(int id) { super(id, Material.rock); } public void registerIcons(IconRegister iconRegister) { iconDark = iconRegister.registerIcon("stone"); iconGreen = iconRegister.registerIcon("glass"); } @Override public TileEntity createTileEntity(World world, int metadata) { return new TileEntityLedVerte(); } @SideOnly(Side.CLIENT) @Override public Icon getBlockTexture(IBlockAccess blockaccess, int x, int y, int z, int side) { TileEntity te = blockaccess.getBlockTileEntity(x, y, z); if(te != null && te instanceof TileEntityLedVerte) { TileEntityLedVerte tetuto = (TileEntityLedVerte)te; return tetuto.isEnable() ? this.iconGreen : this.iconDark; } return this.getIcon(side, blockaccess.getBlockMetadata(x, y, z)); } public boolean hasTileEntity(int metadata) { return true; } @Override public void onNeighborBlockChange(World world, int x, int y, int z, int neighborblockid) { if(!world.isRemote) { TileEntity te = world.getBlockTileEntity(x, y, z); if( && te != null && te instanceof TileEntityLedVerte) { TileEntityLedVerte tetuto = (TileEntityLedVerte)te; if(world.getBlockPowerInput(x, y, z) > 8 || world.getBlockPowerInput(x, y + 1, z) > 8) { tetuto.setEnable(true); } else { tetuto.setEnable(false); } } } } }Tile entity :
package tutoriel.common; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.INetworkManager; import net.minecraft.network.packet.Packet; import net.minecraft.network.packet.Packet132TileEntityData; import net.minecraft.tileentity.TileEntity; public class TileEntityLedVerte extends TileEntity { private boolean enable; public void setEnable(boolean b) { enable = b; this.worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); } public boolean isEnable() { return enable; } public Packet getDescriptionPacket() { NBTTagCompound nbttagcompound = new NBTTagCompound(); this.writeToNBT(nbttagcompound); return new Packet132TileEntityData(this.xCoord, this.yCoord, this.zCoord, 4, nbttagcompound); } public void onDataPacket(INetworkManager net, Packet132TileEntityData pkt) { this.readFromNBT(pkt.customParam1); } public void readFromNBT(NBTTagCompound nbtTag) { super.readFromNBT(nbtTag); enable = nbtTag.getBoolean("enable"); } public void writeToNBT(NBTTagCompound nbtTag) { super.writeToNBT(nbtTag); nbtTag.setBoolean("enable", enable); } }Cette fois si j’ai fais les tests, ça fonctionne.
En revanche la fonction world.getBlockPowerInput(x, y, z) > 8 ne fonctionne que si tu as une poudre de redstone à côté, si tu mets une torche ça ne marchera pas. -
Ok merci beaucoup pour ton aide, je teste sa tout de suite___
MERCI BEAUCOUP
Sa marche !
Je vais enfin pouvoir finir ma salle de concert !!! -
Bonjour. est-ce qu’il y a une fonction pour empêcher que mon bloc puisse être poussé par un piston ? J’ai déjà regardé dans la class Block, et je n’ai rien trouvé.

-
En regardant dans le code du piston, on trouve :
private static boolean canPushBlock(int par0, World par1World, int par2, int par3, int par4, boolean par5) { if (par0 == Block.obsidian.blockID) { return false; } -
public int getMobilityFlag(){ return X; }X = 0 (laisse le bloc être poussé par un piston) ou 1 (droppe le bloc lorsqu’il est poussé) ou 2 (Le bloc ne peut pas être poussé par un piston).
-
+1 pour TheCreeper999, il te suffit de mettre cette fonction dans la classe du bloc alors qu’avec la réponse de Superloup10 tu aurai eu besoin de modifier la classe du piston.
-
A ma décharge, je n’ai pas regardé en détail comment le piston déplaçait les blocs, mais je me doutais qu’il y avait une fonction beaucoup plus simple.
