Signal redstone
-
je me permet de up le message
-
Regarde le code de la plaque de pression, c’est BlockBasePressurePlate.java
-
je n’arrive pas a trouver …
-
en effet, y a la fonction qui indique aux blocs alentours le changement de bloc mais je vois rien non plus qui gère la partie redstone, ou bien j’ai pas comrpis le fonctionnement.
-
A moins que je me trompe, c’est ces deux méthodes pour le courant de redstone:
/** * Returns true if the block is emitting indirect/weak redstone power on the specified side. If isBlockNormalCube * returns true, standard redstone propagation rules will apply instead and this will not be called. Args: World, X, * Y, Z, side. Note that the side is reversed - eg it is 1 (up) when checking the bottom of the block. */ public int isProvidingWeakPower(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5) { return this.getPowerSupply(par1IBlockAccess.getBlockMetadata(par2, par3, par4)); } /** * Returns true if the block is emitting direct/strong redstone power on the specified side. Args: World, X, Y, Z, * side. Note that the side is reversed - eg it is 1 (up) when checking the bottom of the block. */ public int isProvidingStrongPower(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5) { return par5 == 1 ? this.getPowerSupply(par1IBlockAccess.getBlockMetadata(par2, par3, par4)) : 0; } -
cela ne marche pas…
-
Au vu des commentaires qui y sont liés, je pense que cela en fait partie, mais qu’il en manque un bout, peut être le bout dont je parlais plus tôt?
-
BlockPresurePlate.java, il y a tout ce que tu as besoin.
-
public void onEntityCollidedWithBlock(World par1World, int par2, int par3, int par4, Entity par5Entity) { //ton action public int isProvidingStrongPower(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5) { return par5 == 1 ? this.getPowerSupply(par1IBlockAccess.getBlockMetadata(par2, par3, par4)) : 0; } }ce serai sa?
-
Et les autres fonctions qui vont avec.
En fait la plaque de pression a deux metadata, un lorsqu’elle est activé, et un lorsqu’elle est désactivé. Si son metadata est 2, elle envoie un signale de redstone. -
J’intègre les metadata au onEntityCollidedWithBlock?
-
Dans la classe de ton bloc, ajoute tout ça :
public int isProvidingWeakPower(IBlockAccess par1IBlockAccess, int x, int y, int z, int par5) { return this.getPowerSupply(par1IBlockAccess.getBlockMetadata(x, y, z)); } public void breakBlock(World world, int x, int y, int z, int par5, int par6) { if(this.getPowerSupply(par6) > 0) { this.notifyChange(world, x, y, z); } super.breakBlock(world, x, y, z, par5, par6); } protected void notifyChange(World world, int x, int y, int z) { world.notifyBlocksOfNeighborChange(x, y, z, this.blockID); world.notifyBlocksOfNeighborChange(x, y - 1, z, this.blockID); } public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) { if(!world.isRemote) { int l = this.getPowerSupply(world.getBlockMetadata(x, y, z)); if(l == 0) { this.setStateIfMobInteractsWithPlate(world, x, y, z, l); } } } protected void setStateIfMobInteractsWithPlate(World world, int x, int y, int z, int par5) { int i1 = this.getPlateState(world, x, y, z); boolean flag = par5 > 0; boolean flag1 = i1 > 0; if(par5 != i1) { world.setBlockMetadataWithNotify(x, y, z, this.getMetaFromWeight(i1), 2); this.notifyChange(world, x, y, z); world.markBlockRangeForRenderUpdate(x, y, z, x, y, z); } if(!flag1 && flag) { world.playSoundEffect((double)x + 0.5D, (double)y + 0.1D, (double)z + 0.5D, "random.click", 0.3F, 0.5F); } else if(flag1 && !flag) { world.playSoundEffect((double)x + 0.5D, (double)y + 0.1D, (double)z + 0.5D, "random.click", 0.3F, 0.6F); } if(flag1) { world.scheduleBlockUpdate(x, y, z, this.blockID, this.tickRate(world)); } } public void updateTick(World world, int x, int y, int z, Random rand) { if(!world.isRemote) { int l = this.getPowerSupply(world.getBlockMetadata(x, y, z)); if(l > 0) { this.setStateIfMobInteractsWithPlate(world, x, y, z, l); } } } public int tickRate(World world) { return 20; } public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) { return null; } protected int getPowerSupply(int metadata) { return metadata == 1 ? 15 : 0; } protected int getMetaFromWeight(int metadata) { return metadata > 0 ? 1 : 0; } protected int getPlateState(World world, int x, int y, int z) { List list = world.getEntitiesWithinAABBExcludingEntity((Entity)null, this.getSensitiveAABB(x, y, z)); //List list = world.getEntitiesWithinAABB(EntityLivingBase.class, this.getSensitiveAABB(x, y, z)); //List list = world.getEntitiesWithinAABB(EntityPlayer.class, this.getSensitiveAABB(x, y, z)); if(list != null && !list.isEmpty()) { Iterator iterator = list.iterator(); while(iterator.hasNext()) { Entity entity = (Entity)iterator.next(); if(!entity.doesEntityNotTriggerPressurePlate()) { return 15; } } } return 0; } protected AxisAlignedBB getSensitiveAABB(int x, int y, int z) { float f = 0.125F; return AxisAlignedBB.getAABBPool().getAABB((double)((float)x + f), (double)y, (double)((float)z + f), (double)((float)(x + 1) - f), (double)y + 0.25D, (double)((float)(z + 1) - f)); } public int isProvidingStrongPower(IBlockAccess blockAccess, int x, int y, int z, int side) { return side == 1 ? this.getPowerSupply(blockAccess.getBlockMetadata(x, y, z)) : 0; }Je viens de tester, ça fonctionne exactement comme la plaque de pression.
-
Merci je testerai ça demain
EDIT: Çà marche merci

-
Par contre pour mon autre post sur le rendu du portail (http://www.minecraftforgefrance.fr/showthread.php?tid=444&pid=4750#pid4750) on ma parlez d’un rendu TESR mais je n’ai aucune idée comment le réaliser (il peut ajuster la “taille” de la texture?)
-
Il y a un tutoriel sur le site pour les rendus TESR. Dans la fonction qui rend le bloc, il suffirait de mettre un GL11.glScale(x, y, z) pour agrandir.
-
À D’accord merci je vous tien au courant
-
Le tuto de robin ya un truc dessus je crois

-
merci je vais voir ca.
PS: si quelqu’un si connais bien en rendu TESR qu’il me MP avec son pseudo skype
PS2: obliger d’utiliser un modèle techne pour mon bloc?
PS3: obliger de faire un rendu TESR (on ne peut pas faire un rendu ISBRH)? -
Petit up
on peut faire un rendu ISBRH pour utiliser la fonction GL11.glScale(x, y, z)
-
Il me semble que oui, normalement les GL11 fonctionnent dans les rendus ISBRH.
