Table d'enchantement personnalisée avec mes propres enchantement
-
Bonjour, j’ai différents problèmes avec ma table de programming, le principe est que c’est comme une table d’enchantement mais en utilisant 3 items, toujours les mêmes, à la place des levels Et que ca utilise des methods, extends enchantement, à la place des enchantement pour que dans cette machine il n’y aie que mes methods et que les methods n’apparaissent pas dans la table d’enchantement.
Mes problèmes:
-
Je voudrais que ma machine utilise des methods et pas des enchantements
-
Je voudrais qu’elle affiche leur noms
-
Je voudrais que quand on clique sur une des methods elle s’ajoute à l’items
-
Je voudrais que les items programmés soit pourvu d’une lueur semblable à selle des enchants mais vertes
-
Je voudrais que si les items soi enchantés ET programmés la lueur soit bleue
-
Je voudrais trouver un moyen d’enlever enchantLevels[] qui me fais chier
-
J’ai un peu copier coller de la table d’enchant, je voudrais que vous m’aidiez à trouvez et enlever les trucs inutiles et de m’aider à renommer correctement les field dégueulasses
Code:
Le block:public class BlockProgrammingTable extends BlockContainer implements ITileEntityProvider { public BlockProgrammingTable() { super(Material.rock); } @Override public TileEntity createNewTileEntity(World world, int metadata) { return new TileEntityProgrammingTable(); } @Override public boolean hasTileEntity(int metadata) { return true; } public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { { //player.triggerAchievement(AchievementMod.achievementBinaryMachine); if (world.isRemote) { return true; } else { TileEntity tile = world.getTileEntity(x, y, z); if(tile instanceof TileEntityProgrammingTable) { player.openGui(BinaryMod.instance, 0, world, x, y, z); return true; } return false; } } } public void breakBlock(World world, int x, int y, int z, Block block, int metadata) { TileEntity tileentity = world.getTileEntity(x, y, z); if(tileentity instanceof IInventory) { IInventory inv = (IInventory)tileentity; for(int i1 = 0; i1 < inv.getSizeInventory(); ++i1) { ItemStack itemstack = inv.getStackInSlot(i1); if(itemstack != 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; itemstack.stackSize > 0; world.spawnEntityInWorld(entityitem)) { int j1 = world.rand.nextInt(21) + 10; if(j1 > itemstack.stackSize) { j1 = itemstack.stackSize; } itemstack.stackSize -= j1; entityitem = new EntityItem(world, (double)((float)x + f), (double)((float)y + f1), (double)((float)z + f2), new ItemStack(itemstack.getItem(), j1, itemstack.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(itemstack.hasTagCompound()) { entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy()); } } } } world.func_147453_f(x, y, z, block); } super.breakBlock(world, x, y, z, block, metadata); } }
La tileEntity:
public class TileEntityProgrammingTable extends TileEntity implements IInventory { private ItemStack[] contents = new ItemStack[4]; private String customName; @Override public void writeToNBT(NBTTagCompound compound) { if(func_145921_b()) { compound.setString("CustomName", customName); } } @Override public void readFromNBT(NBTTagCompound compound) { if(compound.hasKey("CustomName")) { customName = compound.getString("CustomName"); } } public String func_145919_a() { return this.func_145921_b() ? this.customName : "container.program"; } public boolean func_145921_b() { return customName != null && customName.length() > 0; } public void setName(String name) { customName = name; } @Override public int getSizeInventory() { return this.contents.length; } @Override public ItemStack getStackInSlot(int slotIndex) { return this.contents[slotIndex]; } @Override public ItemStack decrStackSize(int slotIndex, int amount) { if(this.contents[slotIndex] != null) { ItemStack itemstack; if(this.contents[slotIndex].stackSize <= amount) { itemstack = this.contents[slotIndex]; this.contents[slotIndex] = null; this.markDirty(); return itemstack; } else { itemstack = this.contents[slotIndex].splitStack(amount); if(this.contents[slotIndex].stackSize == 0) { this.contents[slotIndex] = null; } this.markDirty(); return itemstack; } } else { return null; } } @Override public ItemStack getStackInSlotOnClosing(int slotIndex) { if(this.contents[slotIndex] != null) { ItemStack itemstack = this.contents[slotIndex]; this.contents[slotIndex] = null; return itemstack; } else { return null; } } @Override public void setInventorySlotContents(int slotIndex, ItemStack stack) { this.contents[slotIndex] = stack; if(stack != null && stack.stackSize > this.getInventoryStackLimit()) { stack.stackSize = this.getInventoryStackLimit(); } this.markDirty(); } @Override public String getInventoryName() { return this.hasCustomInventoryName() ? this.customName : "gui.programming_table"; } @Override public boolean hasCustomInventoryName() { return false; } public void setCustomName(String customName) { this.customName = customName; } @Override public int getInventoryStackLimit() { return 64; } @Override public boolean isUseableByPlayer(EntityPlayer player) { return this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : player.getDistanceSq((double)this.xCoord + 0.5D, (double)this.yCoord + 0.5D, (double)this.zCoord + 0.5D) <= 64.0D; } @Override public void openInventory() {} @Override public void closeInventory() {} @Override public boolean isItemValidForSlot(int slot, ItemStack stack) { return slot == 1 && stack.getItem() != ItemMod.screen ? false : (slot == 2 && stack.getItem() != ItemMod.informatical_gear ? false : (slot == 3 && stack.getItem() != ItemMod.giga_informatical_plant ? false : true)); } }
Le container:
public class ContainerProgrammingTable extends Container { private TileEntityProgrammingTable tileTable; private World worldPointer; private int posX; private int posY; private int posZ; private Random rand = new Random(); public long nameSeed; public int enchantLevels[] = new int[3]; public ContainerProgrammingTable(TileEntityProgrammingTable tile, InventoryPlayer inventory, int x, int y, int z, World world) { this.tileTable = tile; this.addSlotToContainer(new Slot(tile, 0, 23, 10)); // Lancez votre jeu en debug pour calibrer vos slots this.addSlotToContainer(new Slot(tile, 1, 10, 33)); this.addSlotToContainer(new Slot(tile, 2, 36, 33)); this.addSlotToContainer(new Slot(tile, 3, 23, 56)); } public void onCraftMatrixChanged(IInventory p_75130_1_) { if (p_75130_1_ == this.tileTable) { ItemStack itemstack = p_75130_1_.getStackInSlot(0); int i; if (itemstack != null && itemstack.isItemEnchantable()) { this.nameSeed = this.rand.nextLong(); if (!this.worldPointer.isRemote) { i = 0; int j; float power = 0; for (j = -1; j <= 1; ++j) { for (int k = -1; k <= 1; ++k) { if ((j != 0 || k != 0) && this.worldPointer.isAirBlock(this.posX + k, this.posY, this.posZ + j) && this.worldPointer.isAirBlock(this.posX + k, this.posY + 1, this.posZ + j)) { power += ForgeHooks.getEnchantPower(worldPointer, posX + k * 2, posY, posZ + j * 2); power += ForgeHooks.getEnchantPower(worldPointer, posX + k * 2, posY + 1, posZ + j * 2); if (k != 0 && j != 0) { power += ForgeHooks.getEnchantPower(worldPointer, posX + k * 2, posY, posZ + j ); power += ForgeHooks.getEnchantPower(worldPointer, posX + k * 2, posY + 1, posZ + j ); power += ForgeHooks.getEnchantPower(worldPointer, posX + k, posY, posZ + j * 2); power += ForgeHooks.getEnchantPower(worldPointer, posX + k, posY + 1, posZ + j * 2); } } } } for (j = 0; j < 3; ++j) { this.enchantLevels[j] = EnchantmentHelper.calcItemStackEnchantability(this.rand, j, (int)power, itemstack); } this.detectAndSendChanges(); } } else { for (i = 0; i < 3; ++i) { this.enchantLevels* = 0; } } } } public ItemStack transferStackInSlot(EntityPlayer player, int quantity) { ItemStack itemstack = null; Slot slot = (Slot)this.inventorySlots.get(quantity); if(slot != null && slot.getHasStack()) { ItemStack itemstack1 = slot.getStack(); itemstack = itemstack1.copy(); if(quantity < this.tileTable.getSizeInventory()) { if(!this.mergeItemStack(itemstack1, this.tileTable.getSizeInventory(), this.inventorySlots.size(), true)) { return null; } } else if(!this.mergeItemStack(itemstack1, 0, this.tileTable.getSizeInventory(), false)) { return null; } if(itemstack1.stackSize == 0) { slot.putStack((ItemStack)null); } else { slot.onSlotChanged(); } } return itemstack; } @Override public boolean canInteractWith(EntityPlayer player) { return tileTable.isUseableByPlayer(player); } }
La GUI:
public class GuiProgrammingTable extends GuiContainer { public static final ResourceLocation texture = new ResourceLocation(Reference.MOD_ID, "textures/gui/container/programming_table.png"); private TileEntityProgrammingTable tileTable; private IInventory playerInv; private ContainerProgrammingTable container; private static final ModelBook field_147072_E = new ModelBook(); private Random field_147074_F = new Random(); ItemStack field_147077_B; public int field_147073_u; public float field_147071_v; public float field_147069_w; public float field_147082_x; public float field_147081_y; public float field_147080_z; public float field_147076_A; public GuiProgrammingTable(TileEntityProgrammingTable tile, InventoryPlayer inventory, int x, int y, int z, World world) { super(new ContainerProgrammingTable(tile, inventory, x, y, z, world)); this.container = (ContainerProgrammingTable)this.inventorySlots; this.tileTable = tile; this.playerInv = inventory; this.allowUserInput = false; this.ySize = 150; this.xSize = 175; } protected void mouseClicked(int p_73864_1_, int p_73864_2_, int p_73864_3_) { super.mouseClicked(p_73864_1_, p_73864_2_, p_73864_3_); int l = (this.width - this.xSize) / 2; int i1 = (this.height - this.ySize) / 2; for (int j1 = 0; j1 < 3; ++j1) { int k1 = p_73864_1_ - (l + 60); int l1 = p_73864_2_ - (i1 + 14 + 19 * j1); if (k1 >= 0 && l1 >= 0 && k1 < 108 && l1 < 19 && this.container.enchantItem(this.mc.thePlayer, j1)) { this.mc.playerController.sendEnchantPacket(this.container.windowId, j1); } } } public void updateScreen() { super.updateScreen(); this.func_147068_g(); } protected void drawGuiContainerForegroundLayer(int x, int y) { String tileName = this.tileTable.hasCustomInventoryName() ? this.tileTable.getInventoryName() : I18n.format(this.tileTable.getInventoryName()); this.fontRendererObj.drawString(tileName, (this.xSize - this.fontRendererObj.getStringWidth(tileName)) / 2, 5, 0x00ff00); String invName = this.playerInv.hasCustomInventoryName() ? this.playerInv.getInventoryName() : I18n.format(this.playerInv.getInventoryName()); this.fontRendererObj.drawString(invName, (this.xSize - this.fontRendererObj.getStringWidth(invName)) / 2, this.ySize - 96 + 2, 0x00ff00); } protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(texture); int k = (this.width - this.xSize) / 2; int l = (this.height - this.ySize) / 2; this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); GL11.glPushMatrix(); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glPushMatrix(); GL11.glLoadIdentity(); ScaledResolution scaledresolution = new ScaledResolution(this.mc, this.mc.displayWidth, this.mc.displayHeight); GL11.glViewport((scaledresolution.getScaledWidth() - 320) / 2 * scaledresolution.getScaleFactor(), (scaledresolution.getScaledHeight() - 240) / 2 * scaledresolution.getScaleFactor(), 320 * scaledresolution.getScaleFactor(), 240 * scaledresolution.getScaleFactor()); GL11.glTranslatef(-0.34F, 0.23F, 0.0F); Project.gluPerspective(90.0F, 1.3333334F, 9.0F, 80.0F); float f1 = 1.0F; GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); RenderHelper.enableStandardItemLighting(); GL11.glTranslatef(0.0F, 3.3F, -16.0F); GL11.glScalef(f1, f1, f1); float f2 = 5.0F; GL11.glScalef(f2, f2, f2); GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F); this.mc.getTextureManager().bindTexture(texture); GL11.glRotatef(20.0F, 1.0F, 0.0F, 0.0F); float f3 = this.field_147076_A + (this.field_147080_z - this.field_147076_A) * p_146976_1_; GL11.glTranslatef((1.0F - f3) * 0.2F, (1.0F - f3) * 0.1F, (1.0F - f3) * 0.25F); GL11.glRotatef(-(1.0F - f3) * 90.0F - 90.0F, 0.0F, 1.0F, 0.0F); GL11.glRotatef(180.0F, 1.0F, 0.0F, 0.0F); float f4 = this.field_147069_w + (this.field_147071_v - this.field_147069_w) * p_146976_1_ + 0.25F; float f5 = this.field_147069_w + (this.field_147071_v - this.field_147069_w) * p_146976_1_ + 0.75F; f4 = (f4 - (float)MathHelper.truncateDoubleToInt((double)f4)) * 1.6F - 0.3F; f5 = (f5 - (float)MathHelper.truncateDoubleToInt((double)f5)) * 1.6F - 0.3F; if (f4 < 0.0F) { f4 = 0.0F; } if (f5 < 0.0F) { f5 = 0.0F; } if (f4 > 1.0F) { f4 = 1.0F; } if (f5 > 1.0F) { f5 = 1.0F; } GL11.glEnable(GL12.GL_RESCALE_NORMAL); field_147072_E.render((Entity)null, 0.0F, f4, f5, f3, 0.0F, 0.0625F); GL11.glDisable(GL12.GL_RESCALE_NORMAL); RenderHelper.disableStandardItemLighting(); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glViewport(0, 0, this.mc.displayWidth, this.mc.displayHeight); GL11.glPopMatrix(); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glPopMatrix(); RenderHelper.disableStandardItemLighting(); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); EnchantmentNameParts.instance.reseedRandomGenerator(this.container.nameSeed); for (int i1 = 0; i1 < 3; ++i1) { String s = EnchantmentNameParts.instance.generateNewRandomName(); this.zLevel = 0.0F; this.mc.getTextureManager().bindTexture(texture); int j1 = this.container.enchantLevels[i1]; GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); if (j1 == 0) { this.drawTexturedModalRect(k + 60, l + 14 + 19 * i1, 0, 185, 108, 19); } else { String s1 = "" + j1; FontRenderer fontrenderer = this.mc.standardGalacticFontRenderer; int k1 = 6839882; if (container.getSlot(1).getHasStack() && container.getSlot(2).getHasStack() && container.getSlot(3).getHasStack()) { this.drawTexturedModalRect(k + 60, l + 14 + 19 * i1, 0, 185, 108, 19); fontrenderer.drawSplitString(s, k + 62, l + 16 + 19 * i1, 104, (k1 & 16711422) >> 1); fontrenderer = this.mc.fontRenderer; k1 = 4226832; fontrenderer.drawStringWithShadow(s1, k + 62 + 104 - fontrenderer.getStringWidth(s1), l + 16 + 19 * i1 + 7, k1); } else { int l1 = p_146976_2_ - (k + 60); int i2 = p_146976_3_ - (l + 14 + 19 * i1); if (l1 >= 0 && i2 >= 0 && l1 < 108 && i2 < 19) { this.drawTexturedModalRect(k + 60, l + 14 + 19 * i1, 0, 204, 108, 19); k1 = 16777088; } else { this.drawTexturedModalRect(k + 60, l + 14 + 19 * i1, 0, 166, 108, 19); } fontrenderer.drawSplitString(s, k + 62, l + 16 + 19 * i1, 104, k1); fontrenderer = this.mc.fontRenderer; k1 = 8453920; fontrenderer.drawStringWithShadow(s1, k + 62 + 104 - fontrenderer.getStringWidth(s1), l + 16 + 19 * i1 + 7, k1); } } } } public void func_147068_g() { ItemStack itemstack = this.inventorySlots.getSlot(0).getStack(); if (!ItemStack.areItemStacksEqual(itemstack, this.field_147077_B)) { this.field_147077_B = itemstack; do { this.field_147082_x += (float)(this.field_147074_F.nextInt(4) - this.field_147074_F.nextInt(4)); } while (this.field_147071_v <= this.field_147082_x + 1.0F && this.field_147071_v >= this.field_147082_x - 1.0F); } ++this.field_147073_u; this.field_147069_w = this.field_147071_v; this.field_147076_A = this.field_147080_z; boolean flag = false; for (int i = 0; i < 3; ++i) { if (this.container.enchantLevels* != 0) { flag = true; } } if (flag) { this.field_147080_z += 0.2F; } else { this.field_147080_z -= 0.2F; } if (this.field_147080_z < 0.0F) { this.field_147080_z = 0.0F; } if (this.field_147080_z > 1.0F) { this.field_147080_z = 1.0F; } float f1 = (this.field_147082_x - this.field_147071_v) * 0.4F; float f = 0.2F; if (f1 < -f) { f1 = -f; } if (f1 > f) { f1 = f; } this.field_147081_y += (f1 - this.field_147081_y) * 0.9F; this.field_147071_v += this.field_147081_y; } }
-
-
- c’est à dire ?
- c’est à dire ?
- Qu’est-ce qui t’en empêche ?
- tu peux mettre l’effet de minecraft et rendre ton item un peu vert, sinon il faut utiliser un rendu spécial pour ton item
- même chose
- c’est à dire ?
- Où est-ce que tu bloques ?
-
@‘SCAREX’:
- c’est à dire ?
- c’est à dire ?
- Qu’est-ce qui t’en empêche ?
- tu peux mettre l’effet de minecraft et rendre ton item un peu vert, sinon il faut utiliser un rendu spécial pour ton item
- même chose
- c’est à dire ?
- Où est-ce que tu bloques ?
- J’ai une liste de metods qui est une copie de enchantement mais avec un autre nom et j’aimerais qu’elle les utilise à la place des enchant de base
- J’aimerais que ça puise dans la liste aléatoirement 3 methods à afficher
- Je ne sais pas le faire
- Comment?
- Idem
- Vu que j’ai fait le 7, il y a une int[] qui s’appelle enchantLevels[] et qui m’emmerde je veux l’enlever mes les fonctions l’utilise inutillement
- Ils y a plain de fonctions inutiles qui utilisent des variables inutiles pour faire des trucs avec les levels d’xp mais moi j’ai pas besoin de ça si tu te réfère à la description
-
- Où est-ce que tu bloques ?
- Où est-ce que tu bloques ?
- Est-ce que tu sais exécuter quelque chose lorsque l’on clique sur un élément ? Si oui je vois pas ce qui est compliqué : ajouter le tag nbt à l’item
- Tu veux faire quelle méthode ?
- idem
- Alors pourquoi ne pas supprimer ses appels ?
- Alors supprime tout ce dont tu n’as pas besoin
-
J’y arrive pas et je sais pas comment faire un peut pour tout
Envoyé de mon SM-G360F en utilisant Tapatalk
-
Alors essaie de regarder tout le code et de le comprendre