@‘robin4002’:
Heu ouai envoie toutes tes classes.
Donc de retour cette fois avec toutes les classe:
les corrections donné par robin ont était effectuer sur la classe block
merci de votre aide
Classe principal:
| |
| package craftz; |
| |
| import net.minecraft.block.Block; |
| import net.minecraft.block.material.Material; |
| import net.minecraft.client.gui.Gui; |
| import net.minecraft.creativetab.CreativeTabs; |
| import net.minecraft.entity.Entity; |
| import net.minecraft.entity.EnumCreatureType; |
| import net.minecraft.item.EnumToolMaterial; |
| import net.minecraft.item.Item; |
| import net.minecraft.item.ItemFood; |
| import net.minecraft.item.ItemSeeds; |
| import net.minecraft.world.biome.BiomeGenBase; |
| import net.minecraftforge.common.DimensionManager; |
| import net.minecraftforge.common.EnumHelper; |
| import cpw.mods.fml.common.Mod; |
| import cpw.mods.fml.common.Mod.Init; |
| import cpw.mods.fml.common.Mod.Instance; |
| import cpw.mods.fml.common.Mod.PostInit; |
| import cpw.mods.fml.common.Mod.PreInit; |
| import cpw.mods.fml.common.SidedProxy; |
| import cpw.mods.fml.common.event.FMLInitializationEvent; |
| import cpw.mods.fml.common.event.FMLPostInitializationEvent; |
| import cpw.mods.fml.common.event.FMLPreInitializationEvent; |
| import cpw.mods.fml.common.network.NetworkMod; |
| import cpw.mods.fml.common.network.NetworkRegistry; |
| import cpw.mods.fml.common.registry.EntityRegistry; |
| import cpw.mods.fml.common.registry.GameRegistry; |
| import cpw.mods.fml.common.registry.LanguageRegistry; |
| import cpw.mods.fml.common.registry.TickRegistry; |
| import cpw.mods.fml.relauncher.Side; |
| |
| @Mod(modid = "craftz", name = "craftz", version = "0.1") |
| @NetworkMod(clientSideRequired = true, serverSideRequired = false) |
| |
| public class ModCatnos |
| { |
| @SidedProxy(clientSide = "craftz.ClientProxy", serverSide = "craftz.CommonProxy") |
| public static CommonProxy proxy; |
| public static Block BlockOrgeCulture, matrixportalblock, porte, porte2, mychest, wallwood, sculture, yolo; |
| public static Item itemcake, poire, sniper, couteau, ItemOrge, ItemOrgeGraines, cleporte, itemporte2; |
| public static CreativeTabs TestCreativeTabs = new TestCreativeTabs("TestCreativeTabs"); |
| public static boolean zoom; |
| public static Gui guitest; |
| public static BiomeGenBase Biomedetest; |
| public static final int dimensionId = 8; |
| |
| @Instance("ModCatnos") |
| public static ModCatnos instance; |
| |
| static EnumToolMaterial cut = EnumHelper.addToolMaterial("cut", 3, 1561, 8.0F, 3, 10); |
| |
| @PreInit |
| public void preload(FMLPreInitializationEvent event) |
| { |
| |
| |
| |
| matrixportalblock = new BlockPortalmatrixblock(4001).setCreativeTab(ModCatnos.TestCreativeTabs).setUnlocalizedName("matrixlock"); |
| porte = new BlockPorte(4002, Material.rock).setCreativeTab(ModCatnos.TestCreativeTabs).setBlockUnbreakable().setUnlocalizedName("porte"); |
| porte2 = new PorteBlock(4003, Material.rock).setCreativeTab(ModCatnos.TestCreativeTabs).setBlockUnbreakable().setUnlocalizedName("porte2"); |
| wallwood = new WallWoodBlock(4004, Block.planks).setCreativeTab(ModCatnos.TestCreativeTabs).setUnlocalizedName("wallwood"); |
| |
| yolo = new BlockCoffre(4006, Material.wood).setCreativeTab(ModCatnos.TestCreativeTabs).setUnlocalizedName("coffre"); |
| |
| sniper = new ItemSniper1(3001).setCreativeTab(ModCatnos.TestCreativeTabs).setUnlocalizedName("sniper"); |
| couteau = new ItemCouteau(3002, cut).setCreativeTab(ModCatnos.TestCreativeTabs).setUnlocalizedName("cut"); |
| poire = new ItemPoire(3003, 3, false).setCreativeTab(ModCatnos.TestCreativeTabs).setUnlocalizedName("poire"); |
| cleporte = new ItemClePorte(3004).setCreativeTab(ModCatnos.TestCreativeTabs).setUnlocalizedName("cleporte"); |
| itemporte2 = new Itemporte2(3005, Material.wood).setCreativeTab(ModCatnos.TestCreativeTabs).setUnlocalizedName("itemporte2"); |
| |
| |
| |
| |
| |
| |
| Biomedetest = new biomeDeTest(40).setBiomeName("Biome De test").setDisableRain().setTemperatureRainfall(1.2F, 0.9F).setEnableSnow().setMinMaxHeight(0.3F, 0.5F); |
| |
| } |
| |
| @Init |
| public void load(FMLInitializationEvent event) |
| { |
| |
| GameRegistry.registerBlock(matrixportalblock, "matrixportalblock"); |
| GameRegistry.registerBlock(wallwood, "mur en bois"); |
| GameRegistry.registerBlock(porte, "porte"); |
| GameRegistry.registerBlock(porte2,"porte2"); |
| |
| GameRegistry.registerBlock(yolo, "yolo"); |
| |
| |
| GameRegistry.registerItem(sniper, "sniper"); |
| GameRegistry.registerItem(poire, "poire"); |
| GameRegistry.registerItem(couteau, "couteau"); |
| GameRegistry.registerItem(cleporte, "cleporte"); |
| |
| |
| GameRegistry.addBiome(Biomedetest); |
| |
| |
| GameRegistry.registerTileEntity(TileEntityBigChest.class, "TileEntityBigChest"); |
| |
| NetworkRegistry.instance().registerGuiHandler(this.instance, new GuiHandlerTutorial()); |
| |
| TickRegistry.registerTickHandler(new TickClientHandler(), Side.CLIENT); |
| |
| DimensionManager.registerProviderType(ModCatnos.dimensionId, WorldProviderMatrix.class, false); |
| DimensionManager.registerDimension(ModCatnos.dimensionId, ModCatnos.dimensionId); |
| |
| |
| |
| proxy.registerRender(); |
| proxy.registerTileEntityRender(); |
| |
| } |
| |
| @PostInit |
| public void modloaded(FMLPostInitializationEvent event) |
| { |
| |
| LanguageRegistry.addName(sniper, "sniper"); |
| LanguageRegistry.addName(couteau, "couteau"); |
| LanguageRegistry.addName(poire, "poire"); |
| LanguageRegistry.addName(matrixportalblock, "matrixportalblock"); |
| LanguageRegistry.addName(cleporte, "cle de securite"); |
| LanguageRegistry.addName(porte, "porte de securite"); |
| LanguageRegistry.addName(yolo, "coffre geant"); |
| |
| LanguageRegistry.instance().addStringLocalization("entity.AnyZob.name", "AnyZob"); |
| |
| |
| } |
| |
| } |
| |
Classe block
| |
| package craftz; |
| |
| import java.util.List; |
| |
| import net.minecraft.block.BlockContainer; |
| import net.minecraft.block.material.Material; |
| import net.minecraft.client.renderer.texture.IconRegister; |
| import net.minecraft.creativetab.CreativeTabs; |
| import net.minecraft.entity.EntityLivingBase; |
| import net.minecraft.entity.item.EntityItem; |
| import net.minecraft.entity.player.EntityPlayer; |
| import net.minecraft.item.ItemStack; |
| import net.minecraft.nbt.NBTTagCompound; |
| import net.minecraft.tileentity.TileEntity; |
| import net.minecraft.tileentity.TileEntityChest; |
| import net.minecraft.util.Icon; |
| import net.minecraft.util.MathHelper; |
| import net.minecraft.world.IBlockAccess; |
| import net.minecraft.world.World; |
| import cpw.mods.fml.common.network.FMLNetworkHandler; |
| import cpw.mods.fml.relauncher.Side; |
| import cpw.mods.fml.relauncher.SideOnly; |
| |
| public class BlockCoffre extends BlockContainer |
| { |
| |
| protected BlockCoffre(int par1, Material par2Material) { |
| super(par1, par2Material); |
| } |
| public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) |
| { |
| FMLNetworkHandler.openGui(player, ModCatnos.instance, 0, world, x, y, z); |
| return true; |
| } |
| public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase living, ItemStack stack) |
| { |
| TileEntity te = world.getBlockTileEntity(x, y, z); |
| if(te instanceof TileEntityBigChest && stack.hasDisplayName()) |
| { |
| ((TileEntityBigChest)te).setCustomGuiName(stack.getDisplayName()); |
| } |
| } |
| public void breakBlock(World world, int x, int y, int z, int side, int metadata) |
| { |
| dropContainerItem(world, x, y, z); |
| super.breakBlock(world, x, y, z, side, metadata); |
| } |
| @Override |
| public TileEntity createNewTileEntity(World world) { |
| return new TileEntityBigChest(); |
| } |
| protected void dropContainerItem(World world, int x, int y, int z) |
| { |
| TileEntityBigChest bigchest = (TileEntityBigChest)world.getBlockTileEntity(x, y, z); |
| |
| if (bigchest != null) |
| { |
| for (int slotId = 0; slotId < bigchest.getSizeInventory(); slotId++) |
| { |
| ItemStack stack = bigchest.getStackInSlot(slotId); |
| |
| if (stack != null) |
| { |
| float f = world.rand.nextFloat() * 0.8F + 0.1F; |
| float f1 = world.rand.nextFloat() * 0.8F + 0.1F; |
| EntityItem entityitem; |
| |
| for (float f2 = world.rand.nextFloat() * 0.8F + 0.1F; stack.stackSize > 0; world.spawnEntityInWorld(entityitem)) |
| { |
| int k1 = world.rand.nextInt(21) + 10; |
| |
| if (k1 > stack.stackSize) |
| { |
| k1 = stack.stackSize; |
| } |
| |
| stack.stackSize -= k1; |
| entityitem = new EntityItem(world, (double)((float)x + f), (double)((float)y + f1), (double)((float)z + f2), new ItemStack(stack.itemID, k1, stack.getItemDamage())); |
| float f3 = 0.05F; |
| entityitem.motionX = (double)((float)world.rand.nextGaussian() * f3); |
| entityitem.motionY = (double)((float)world.rand.nextGaussian() * f3 + 0.2F); |
| entityitem.motionZ = (double)((float)world.rand.nextGaussian() * f3); |
| |
| if (stack.hasTagCompound()) |
| { |
| entityitem.getEntityItem().setTagCompound((NBTTagCompound)stack.getTagCompound().copy()); |
| } |
| } |
| } |
| } |
| } |
| } |
| public boolean onBlockEventReceived(World world, int x, int y, int z, int eventId, int eventValue) |
| { |
| super.onBlockEventReceived(world, x, y, z, eventId, eventValue); |
| TileEntity tileentity = world.getBlockTileEntity(x, y, z); |
| return tileentity != null ? tileentity.receiveClientEvent(eventId, eventValue) : false; |
| } |
| } |
| |
Classe Container
| |
| package craftz; |
| |
| import net.minecraft.entity.player.EntityPlayer; |
| import net.minecraft.entity.player.InventoryPlayer; |
| import net.minecraft.inventory.Container; |
| import net.minecraft.inventory.Slot; |
| import net.minecraft.item.ItemStack; |
| |
| public class ContainerBigChest extends Container |
| { |
| private TileEntityBigChest tileEntity; |
| |
| public ContainerBigChest(InventoryPlayer playerInventory, TileEntityBigChest teChest) |
| { |
| this.tileEntity = teChest; |
| teChest.openChest(); |
| |
| for(int i = 0; i < 6; i++) |
| { |
| for(int j = 0; j < 9; j++) |
| { |
| this.addSlotToContainer(new Slot(teChest, j + i * 9, 8 + j * 18, 18 + i * 18)); |
| } |
| } |
| this.bindPlayerInventory(playerInventory); |
| } |
| |
| private void bindPlayerInventory(InventoryPlayer playerInventory) |
| { |
| int i; |
| for(i = 0; i < 3; i++) |
| { |
| for(int j = 0; j < 9; j++) |
| { |
| this.addSlotToContainer(new Slot(playerInventory, j + i * 9 + 9, 8 + j * 18, 103 + i * 18 + 37)); |
| } |
| } |
| |
| for(i = 0; i < 9; i++) |
| { |
| this.addSlotToContainer(new Slot(playerInventory, i, 8 + i * 18, 161 + 37)); |
| } |
| } |
| |
| @Override |
| public boolean canInteractWith(EntityPlayer player) |
| { |
| return tileEntity.isUseableByPlayer(player); |
| } |
| |
| public ItemStack transferStackInSlot(EntityPlayer player, int slotId) |
| { |
| ItemStack itemstack = null; |
| Slot slot = (Slot)this.inventorySlots.get(slotId); |
| |
| if(slot != null && slot.getHasStack()) |
| { |
| ItemStack itemstack1 = slot.getStack(); |
| itemstack = itemstack1.copy(); |
| |
| if(slotId < 9) |
| { |
| if(!this.mergeItemStack(itemstack1, 9, this.inventorySlots.size(), true)) |
| { |
| return null; |
| } |
| } |
| else if(!this.mergeItemStack(itemstack1, 0, 9, false)) |
| { |
| return null; |
| } |
| |
| if(itemstack1.stackSize == 0) |
| { |
| slot.putStack((ItemStack)null); |
| } |
| else |
| { |
| slot.onSlotChanged(); |
| } |
| } |
| return itemstack; |
| } |
| public void onContainerClosed(EntityPlayer player) |
| { |
| super.onContainerClosed(player); |
| tileEntity.closeChest(); |
| } |
| |
| } |
| |
Classe Guihandler
| |
| package craftz; |
| |
| import cpw.mods.fml.common.network.IGuiHandler; |
| import net.minecraft.entity.player.EntityPlayer; |
| import net.minecraft.tileentity.TileEntity; |
| import net.minecraft.world.World; |
| |
| public class GuiHandlerTutorial implements IGuiHandler |
| |
| { |
| |
| @Override |
| public Object getServerGuiElement(int ID, EntityPlayer player, World world, |
| int x, int y, int z) { |
| TileEntity te = world.getBlockTileEntity(x, y, z); |
| if(te instanceof TileEntityBigChest) |
| { |
| return new ContainerBigChest(player.inventory, (TileEntityBigChest)te); |
| } |
| return null; |
| } |
| |
| @Override |
| public Object getClientGuiElement(int ID, EntityPlayer player, World world, |
| int x, int y, int z) { |
| |
| TileEntity te = world.getBlockTileEntity(x, y, z); |
| if(te instanceof TileEntityBigChest) |
| { |
| return new GuiBigChest(player.inventory, (TileEntityBigChest)te); |
| } |
| return null; |
| } |
| } |
| |
Classe TileEntity
| |
| package craftz; |
| |
| import net.minecraft.entity.player.EntityPlayer; |
| import net.minecraft.inventory.IInventory; |
| import net.minecraft.item.ItemStack; |
| import net.minecraft.nbt.NBTTagCompound; |
| import net.minecraft.nbt.NBTTagList; |
| import net.minecraft.tileentity.TileEntity; |
| |
| import net.minecraft.entity.player.EntityPlayer; |
| import net.minecraft.inventory.IInventory; |
| import net.minecraft.item.ItemStack; |
| import net.minecraft.nbt.NBTTagCompound; |
| import net.minecraft.nbt.NBTTagList; |
| import net.minecraft.tileentity.TileEntity; |
| |
| public class TileEntityBigChest extends TileEntity implements IInventory |
| { |
| private ItemStack[] inventory = new ItemStack[72]; |
| private String customName; |
| |
| public void readFromNBT(NBTTagCompound nbttag) |
| { |
| super.readFromNBT(nbttag); |
| NBTTagList nbttaglist = nbttag.getTagList("Items"); |
| this.inventory = new ItemStack[this.getSizeInventory()]; |
| |
| if (nbttag.hasKey("CustomName")) |
| { |
| this.customName = nbttag.getString("CustomName"); |
| } |
| |
| for (int i = 0; i < nbttaglist.tagCount(); i++) |
| { |
| NBTTagCompound nbttagcompound1 = (NBTTagCompound)nbttaglist.tagAt(i); |
| int j = nbttagcompound1.getByte("Slot"); |
| |
| if (j >= 0 && j < this.inventory.length) |
| { |
| this.inventory[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); |
| } |
| } |
| } |
| |
| public void writeToNBT(NBTTagCompound nbttag) |
| { |
| super.writeToNBT(nbttag); |
| NBTTagList nbttaglist = new NBTTagList(); |
| |
| for (int i = 0; i < this.inventory.length; i++) |
| { |
| if (this.inventory* != null) |
| { |
| NBTTagCompound nbttagcompound1 = new NBTTagCompound(); |
| nbttagcompound1.setByte("Slot", (byte)i); |
| this.inventory*.writeToNBT(nbttagcompound1); |
| nbttaglist.appendTag(nbttagcompound1); |
| } |
| } |
| |
| nbttag.setTag("Items", nbttaglist); |
| |
| if (this.isInvNameLocalized()) |
| { |
| nbttag.setString("CustomName", this.customName); |
| } |
| } |
| @Override |
| public int getSizeInventory() |
| { |
| return inventory.length; |
| } |
| @Override |
| public ItemStack getStackInSlot(int slotId) |
| { |
| return inventory[slotId]; |
| } |
| @Override |
| public ItemStack decrStackSize(int slotId, int quantity) |
| { |
| if (this.inventory[slotId] != null) |
| { |
| ItemStack itemstack; |
| |
| if (this.inventory[slotId].stackSize <= quantity) |
| { |
| itemstack = this.inventory[slotId]; |
| this.inventory[slotId] = null; |
| this.onInventoryChanged(); |
| return itemstack; |
| } |
| else |
| { |
| itemstack = this.inventory[slotId].splitStack(quantity); |
| |
| if (this.inventory[slotId].stackSize == 0) |
| { |
| this.inventory[slotId] = null; |
| } |
| |
| this.onInventoryChanged(); |
| return itemstack; |
| } |
| } |
| else |
| { |
| return null; |
| } |
| } |
| |
| @Override |
| public ItemStack getStackInSlotOnClosing(int slotId) |
| { |
| if (this.inventory[slotId] != null) |
| { |
| ItemStack itemstack = this.inventory[slotId]; |
| this.inventory[slotId] = null; |
| return itemstack; |
| } |
| else |
| { |
| return null; |
| } |
| } |
| |
| @Override |
| public void setInventorySlotContents(int slotId, ItemStack stack) |
| { |
| this.inventory[slotId] = stack; |
| |
| if (stack != null && stack.stackSize > this.getInventoryStackLimit()) |
| { |
| stack.stackSize = this.getInventoryStackLimit(); |
| } |
| |
| this.onInventoryChanged(); |
| } |
| @Override |
| public String getInvName() |
| { |
| return this.isInvNameLocalized() ? this.customName : "container.bigchest"; |
| } |
| |
| @Override |
| public boolean isInvNameLocalized() |
| { |
| return this.customName != null && this.customName.length() > 0; |
| } |
| |
| public void setCustomGuiName(String name) |
| { |
| this.customName = name; |
| } |
| @Override |
| public int getInventoryStackLimit() |
| { |
| return 64; |
| } |
| @Override |
| public boolean isUseableByPlayer(EntityPlayer player) |
| { |
| return worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) == this && player.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5) < 64; |
| } |
| @Override |
| public void openChest() |
| { |
| |
| } |
| |
| @Override |
| public void closeChest() |
| { |
| |
| } |
| @Override |
| public boolean isItemValidForSlot(int slotId, ItemStack stack) |
| { |
| return true; |
| } |
| |
| } |
| |