Outil pour dropper (reprendre le principe du drop de la neige)

  • Auteur de la discussion Auteur de la discussion bece
  • Date de début Date de début

bece

Aventurier
24 Juin 2011
2
0
0
Bonjour à tous,

Je suis en train de développer un mod. Ce mod ajoute du verre fumé et un outil qui permettra de faire dropper le verre.
Cependant j'ai un petit soucis, je n'arrive pas à faire dropper du verre par seulement un seul outil. Ce que je cherche à faire reprend le principe de la neige : si c'est l'outil X (appelons-le X) qui casse le verre, alors il droppera, sinon cela casse juste le verre.

Avez-vous des pistes qui pourraient m'aiguiller ?

Merci d'avance,
bece
 
Merci pour la réponse.
C'est ce que j'ai déjà fait et justement je ne comprend pas très bien. Par exemple le BlockSnow ne drop rien d'après la fonction quantityDrop, alors que le BlockSnowBlock drop 4.
Du côté de la pelle il y a la fonction canHarvestBlock, je pense que c'est de ce côté là qu'il faut que j'essaye, mais je ne trouve pas.

Je vous montre mon code :
Verre fumé :
Code:
/* 
@author: Jérémy Chevrier
*/

package net.minecraft.src;

import java.util.Random;

public class BlockColouredGlass extends BlockGlass {
	private String color;
	
	public BlockColouredGlass(int i, int j, String color) {
		super(i, j, Material.glass, true);
		this.color = color;
	}
	
	public int idDropped(int i, Random random) {
		if (color.equalsIgnoreCase ("black")) return mod_ColouredGlass.blockColouredGlassBlack.blockID;
		else if (color.equalsIgnoreCase ("red")) return mod_ColouredGlass.blockColouredGlassRed.blockID;
		else if (color.equalsIgnoreCase ("green")) return mod_ColouredGlass.blockColouredGlassGreen.blockID;
		else if (color.equalsIgnoreCase ("brown")) return mod_ColouredGlass.blockColouredGlassBrown.blockID;
		else if (color.equalsIgnoreCase ("blue")) return mod_ColouredGlass.blockColouredGlassBlue.blockID;
		else if (color.equalsIgnoreCase ("purple")) return mod_ColouredGlass.blockColouredGlassPurple.blockID;
		else if (color.equalsIgnoreCase ("cyan")) return mod_ColouredGlass.blockColouredGlassCyan.blockID;
		else if (color.equalsIgnoreCase ("silver")) return mod_ColouredGlass.blockColouredGlassSilver.blockID;
		else if (color.equalsIgnoreCase ("gray")) return mod_ColouredGlass.blockColouredGlassGray.blockID;
		else if (color.equalsIgnoreCase ("pink")) return mod_ColouredGlass.blockColouredGlassPink.blockID;
		else if (color.equalsIgnoreCase ("lime")) return mod_ColouredGlass.blockColouredGlassLime.blockID;
		else if (color.equalsIgnoreCase ("yellow")) return mod_ColouredGlass.blockColouredGlassYellow.blockID;
		else if (color.equalsIgnoreCase ("lightBlue")) return mod_ColouredGlass.blockColouredGlassLightBlue.blockID;
		else if (color.equalsIgnoreCase ("magenta")) return mod_ColouredGlass.blockColouredGlassMagenta.blockID;
		else if (color.equalsIgnoreCase ("orange")) return mod_ColouredGlass.blockColouredGlassOrange.blockID;
		else return mod_ColouredGlass.blockColouredGlassBlack.blockID;
	}
	
	public int quantityDropped(Random random) {
        return 0;
    }
	
	public int getRenderBlockPass() {
        return 1;
    }
}
Et l'outil :
Code:
/*
 * @author : Jérémy Chevrier
 */

package net.minecraft.src;

public class ItemGlassCutter extends ItemTool {
	
	private static Block blocksEffectiveAgainst[];
    static {
        blocksEffectiveAgainst = (new Block[] {mod_ColouredGlass.blockColouredGlassBlack, mod_ColouredGlass.blockColouredGlassBlue, mod_ColouredGlass.blockColouredGlassBrown, 
        mod_ColouredGlass.blockColouredGlassCyan, mod_ColouredGlass.blockColouredGlassGray, mod_ColouredGlass.blockColouredGlassGreen, mod_ColouredGlass.blockColouredGlassLightBlue, 
        mod_ColouredGlass.blockColouredGlassLime, mod_ColouredGlass.blockColouredGlassMagenta, mod_ColouredGlass.blockColouredGlassOrange, mod_ColouredGlass.blockColouredGlassPink, 
        mod_ColouredGlass.blockColouredGlassPurple, mod_ColouredGlass.blockColouredGlassRed, mod_ColouredGlass.blockColouredGlassSilver, mod_ColouredGlass.blockColouredGlassYellow, Block.glass});
    }
	
	public ItemGlassCutter (int i, EnumToolMaterial enumtoolmaterial) {
		super (i, 1, enumtoolmaterial, blocksEffectiveAgainst);
	}
	
	public boolean canHarvestBlock (Block block) {
		System.out.println ("Here !!! " + "id : " + block.blockID + " | name : " + block.getBlockName ());
        if (block == mod_ColouredGlass.blockColouredGlassBlack || block == mod_ColouredGlass.blockColouredGlassBlue || block == mod_ColouredGlass.blockColouredGlassBrown 
			|| block == mod_ColouredGlass.blockColouredGlassCyan || block == mod_ColouredGlass.blockColouredGlassGray || block == mod_ColouredGlass.blockColouredGlassGreen 
			|| block == mod_ColouredGlass.blockColouredGlassLightBlue || block == mod_ColouredGlass.blockColouredGlassLime || block == mod_ColouredGlass.blockColouredGlassMagenta 
			|| block == mod_ColouredGlass.blockColouredGlassOrange || block == mod_ColouredGlass.blockColouredGlassPink || block == mod_ColouredGlass.blockColouredGlassPurple 
			|| block == mod_ColouredGlass.blockColouredGlassRed || block == mod_ColouredGlass.blockColouredGlassSilver || block == mod_ColouredGlass.blockColouredGlassYellow) {
				System.out.println ("Ici !!!!!!!!!!!!!!!!!");
				return true;
        }
        return block == Block.glass;
    }
}

EDIT : C'est bon, j'ai trouvé, il faut utiliser la fonction harvestBlock (). Désolé d'avoir créer un sujet inutile.

bece