hello! SO i have item1 and block1. I want to make it so that item1 looses durability (set to 10 at the moment) when it hits block1. Here are my codes :
BLOCK1
package net.minecraft.src;
import net.minecraft.client.*;
import java.util.Map;
import java.util.Random;
public class M_DeathFog extends Block {
public M_DeathFog(int i, int j)
{
super(i, j, Material.wood);
}
public boolean isOpaqueCube()
{
return false;
}
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int i, int j, int k)
{
return null;
}
public int getRenderType()
{
return 1;
}
public boolean renderAsNormalBlock()
{
return false;
}
Minecraft mc = ModLoader.getMinecraftInstance();
World world = mc.theWorld; //get the current world.
EntityPlayer player = mc.thePlayer; //get the player entity.
public void onEntityCollidedWithBlock(World world, int i, int j, int k, Entity entity)
{
if(mc.thePlayer.inventory.hasItem(mod_Metro.GasMask.shiftedIndex) && mc.thePlayer.inventory.hasItem(mod_Metro.Filters.shiftedIndex))
{
}
else
{
entity.attackEntityFrom(DamageSource.generic, 4);
}
}
}
package net.minecraft.src;
import net.minecraft.client.*;
import java.util.List;
import java.util.Map;
import java.util.Random;
public class mod_Metro extends BaseMod
{
public static final Block DeathFog = new M_DeathFog(235, 44).setHardness(0.1F).setStepSound(Block.soundGlassFootstep).setBlockName("Death Fog");
public static final Block MetroPortal = new M_BlockMetro(230).setHardness(0.1F).setStepSound(Block.soundGlassFootstep).setLightValue(0.75F).setBlockName("Metro Portal");
public static final Block Starter = new M_BlockStarter(236, 45).setHardness(0.1F).setBlockName("Starter");
public static final BiomeGenBase Metro = (new M_BiomeGen(24)).setColor(0xf13a01).setBiomeName("Metro 2033");
public static final Item GasMask = new ItemArmor(231, EnumArmorMaterial.CLOTH, ModLoader.addArmor("Gas Mask Armor"), 0).setItemName("Gas Mask");
public static final Item Filters = new M_Filters(232).setItemName("Filters");
public static final Item GoodAmmo = new M_GoodAmmo(233).setItemName("Good Ammo");
public static final Item BastardGun = new M_BastardGun(234).setItemName("******* Gun");
public mod_Metro()
{
//It is vital that you register your dimension:
DimensionAPI.registerDimension(new M_WorldProviderMetro());
ModLoader.registerEntityID(M_EntityRanger.class, "Ranger", ModLoader.getUniqueEntityId());
ModLoader.registerEntityID(M_EntityRat.class, "Rat", ModLoader.getUniqueEntityId());
ModLoader.setInGameHook(this, true, true);
}
public void load()
{
//The portal can be crafted out of dirt and placed freely.
ModLoader.registerBlock(MetroPortal);
ModLoader.registerBlock(DeathFog);
ModLoader.registerBlock(Starter);
ModLoader.addRecipe(new ItemStack(MetroPortal, 64), new Object[] { "dd", Character.valueOf('d'), Block.dirt });
ModLoader.addRecipe(new ItemStack(Filters, 4), new Object[] { " X ", "X X", " X ", Character.valueOf('X'), Item.ingotIron });
ModLoader.addRecipe(new ItemStack(GasMask, 1), new Object[] { "###", "XXX", "#S#", Character.valueOf('#'), Item.leather, Character.valueOf('X'), Block.thinGlass, Character.valueOf('S'), Item.ingotIron });
ModLoader.addRecipe(new ItemStack(GoodAmmo, 8), new Object[] { " # ", " X ", " X ", Character.valueOf('#'), Item.ingotGold, Character.valueOf('X'), Item.ingotIron, });
ModLoader.addRecipe(new ItemStack(BastardGun, 8), new Object[] { "##", Character.valueOf('#'), Item.ingotGold, });
ModLoader.addName(MetroPortal, "Metro Portal");
ModLoader.addName(GasMask , "Gas Mask");
ModLoader.addName(Filters, "Gas Filters");
ModLoader.addName(GoodAmmo, "Good Ammo");
ModLoader.addName(BastardGun, "******* Gun");
ModLoader.addName(DeathFog, "Death Fog");
ModLoader.addName(Starter, "Starter Block");
}
public String getVersion()
{
return "hi";
}
public void addRenderer(Map map)
{
map.put(M_EntityRanger.class, new M_RenderRanger(new M_ModelRanger(), 0.5F));
map.put(M_EntityRat.class, new M_RenderRat(new M_ModelRat(), 0.5F));
}
Minecraft mc = ModLoader.getMinecraftInstance();
private static int create = 0;
public boolean onTickInGame(float tick, Minecraft game) {
World world = mc.theWorld;
int i = world.worldInfo.getSpawnX();
int j = world.worldInfo.getSpawnY();
int k = world.worldInfo.getSpawnZ();
create++;
if(world != null && world.isNewWorld && create == 2)
{
System.out.println(create);
M_WorldGenSpawn VinylFountain = new M_WorldGenSpawn(world, i, j, k);
VinylFountain.create();
}
return true;
}
}
M_DeathFog (Block1)
package net.minecraft.src;
import net.minecraft.client.*;
import java.util.Map;
import java.util.Random;
public class M_DeathFog extends Block {
public M_DeathFog(int i, int j)
{
super(i, j, Material.wood);
}
public boolean isOpaqueCube()
{
return false;
}
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int i, int j, int k)
{
return null;
}
public int getRenderType()
{
return 1;
}
public boolean renderAsNormalBlock()
{
return false;
}
Minecraft mc = ModLoader.getMinecraftInstance();
World world = mc.theWorld; //get the current world.
EntityPlayer player = mc.thePlayer; //get the player entity.
public void onEntityCollidedWithBlock(World world, int i, int j, int k, Entity entity)
{
if(mc.thePlayer.inventory.hasItem(mod_Metro.GasMask.shiftedIndex) && mc.thePlayer.inventory.hasItem(mod_Metro.Filters.shiftedIndex))
{
}
else
{
entity.attackEntityFrom(DamageSource.generic, 1);
}
}
}
M_Filters (Item1)
package net.minecraft.src;
import net.minecraft.client.Minecraft;
public class M_Filters extends Item
{
public M_Filters(int i)
{
super(i);
maxStackSize = 64;
setMaxDamage(10);
}
}
BLOCK1
M_DeathFog (Block1)
M_Filters (Item1)
If you can get it to work I will +5 <3
Did you get it?