Résolu Probleme Custom Four
-
https://www.youtube.com/watch?v=BZciTSzWPwU&feature=youtu.be
Bon j’ai mis cette vidéo parceque moi même je ne sais pas trop expliqué le problème, c’est assez confus ^^’ tout ce que je peux dire c’est que sa fais n’importe quoi :s. Voila son tile entity si quelqu’un identifie le problème !
package com.google.Portuar.SpectralCraft.common.block.soulextruder; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.network.NetworkManager; import net.minecraft.network.Packet; import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.tileentity.TileEntity; import com.google.Portuar.SpectralCraft.common.block.RecipeSE; import com.google.Portuar.SpectralCraft.main.SpectralCraft_Item; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public class TileEntitySoulExtruder extends TileEntity implements ISidedInventory { private ItemStack[] furnaceItemStacks = new ItemStack[3]; private static final int[] slots_top = new int[] {0}; private static final int[] slots_bottom = new int[] {2, 1}; private static final int[] slots_sides = new int[] {1}; public EntityLiving entity; public int SE = 0, MaxSE = 1000, needSE = 0; public int progressBarSE = 100, progressBarSE_Full = 100; public int progressBarCraft = 300, progressBarCraft_Full = 300; private boolean makeSE, makeDust; Item slotItem = null; private RecipeSoulExtruder recipe = new RecipeSoulExtruder(); private RecipeSE recipeSE = new RecipeSE(); public static String name = "soulExtruder.container"; public static String inventory = "soulExtruder.inventory"; public int getSizeInventory() { return this.furnaceItemStacks.length; } public ItemStack getStackInSlot(int par1) { return this.furnaceItemStacks[par1]; } public ItemStack decrStackSize(int par1, int par2) { if (this.furnaceItemStacks[par1] != null) { ItemStack itemstack; if (this.furnaceItemStacks[par1].stackSize <= par2) { itemstack = this.furnaceItemStacks[par1]; this.furnaceItemStacks[par1] = null; return itemstack; } else { itemstack = this.furnaceItemStacks[par1].splitStack(par2); if (this.furnaceItemStacks[par1].stackSize == 0) { this.furnaceItemStacks[par1] = null; } return itemstack; } } else { return null; } } public ItemStack getStackInSlotOnClosing(int par1) { if (this.furnaceItemStacks[par1] != null) { ItemStack itemstack = this.furnaceItemStacks[par1]; this.furnaceItemStacks[par1] = null; return itemstack; } else { return null; } } public void setInventorySlotContents(int par1, ItemStack par2ItemStack) { this.furnaceItemStacks[par1] = par2ItemStack; if (par2ItemStack != null && par2ItemStack.stackSize > this.getInventoryStackLimit()) { par2ItemStack.stackSize = this.getInventoryStackLimit(); } } public int getInventoryStackLimit() { return 64; } public boolean isUseableByPlayer(EntityPlayer par1EntityPlayer) { return this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : par1EntityPlayer.getDistanceSq((double)this.xCoord + 0.5D, (double)this.yCoord + 0.5D, (double)this.zCoord + 0.5D) <= 64.0D; } public void readFromNBT(NBTTagCompound nbtTag) { super.readFromNBT(nbtTag); NBTTagList nbttaglist = nbtTag.getTagList("Items", 10); this.furnaceItemStacks = new ItemStack[this.getSizeInventory()]; for (int i = 0; i < nbttaglist.tagCount(); ++i) { NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); byte b0 = nbttagcompound1.getByte("Slot"); if (b0 >= 0 && b0 < this.furnaceItemStacks.length) { this.furnaceItemStacks[b0] = ItemStack.loadItemStackFromNBT(nbttagcompound1); } } } public void writeToNBT(NBTTagCompound nbtTag) { super.writeToNBT(nbtTag); NBTTagList nbttaglist = new NBTTagList(); for (int i = 0; i < this.furnaceItemStacks.length; ++i) { if (this.furnaceItemStacks* != null) { NBTTagCompound nbttagcompound1 = new NBTTagCompound(); nbttagcompound1.setByte("Slot", (byte)i); this.furnaceItemStacks*.writeToNBT(nbttagcompound1); nbttaglist.appendTag(nbttagcompound1); } } nbtTag.setTag("Items", nbttaglist); } /** * Overriden in a sign to provide the text. */ public Packet getDescriptionPacket() { NBTTagCompound nbttagcompound = new NBTTagCompound(); this.writeToNBT(nbttagcompound); return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 5, nbttagcompound); } public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { this.readFromNBT(pkt.func_148857_g()); } public boolean isSESource(ItemStack stack){ for(int i = 0; i < recipeSE.SESource.size(); i++){ if(stack != null && stack.getItem() == recipeSE.getSESource(i)){ return true; } } return false; } public boolean isChangeCraft(ItemStack stack){ for(int j = 0; j < recipe.itemSlot_2.size(); j++){ if(stack != null && stack.getItem() == recipe.getElementList_2(j)){ return true; } } return false; } public void energySource(Item i){ if(i == recipeSE.getSESource(0)){ this.addSE(20);} if(i == recipeSE.getSESource(1)){ this.addSE(100);} if(i == recipeSE.getSESource(2)){ this.addSE(10);} } public void addCraft(Item i){ if(i == recipe.getElementList_2(0)){ this.needSE = 20;} } public void addSE(int i){ this.SE = this.SE + i; } public void addEnergy(){ if(this.worldObj.isRemote){ for(int i = 0; i < recipeSE.SESource.size(); i++){ if(this.getStackInSlot(0) != null && this.getStackInSlot(0).getItem() == recipeSE.getSESource(i) && this.SE < 1000){ if(this.makeSE == false){ this.makeSE = true; this.slotItem = recipeSE.getSESource(i); } } if(this.getStackInSlot(0) == null || this.getStackInSlot(0).getItem() != this.slotItem){ this.makeSE = false; } if(this.makeSE == true){ this.progressBarSE–; if(this.progressBarSE < 0){ this.energySource(recipeSE.getSESource(i)); --this.furnaceItemStacks[0].stackSize; if (this.furnaceItemStacks[0].stackSize <= 0) { this.furnaceItemStacks[0] = null; } this.progressBarSE = 100; this.makeSE = false; } }else{ this.progressBarSE = 100; } } } } public void changeItem(){ if(this.worldObj.isRemote){ for(int i = 0; i < recipe.itemSlot_2.size(); i++){ if(this.getStackInSlot(1) != null && this.getStackInSlot(1).getItem() == recipe.getElementList_2(i)){ this.addCraft(recipe.getElementList_2(i)); if(this.SE >= this.needSE){ if(this.makeDust == false){ this.makeDust = true; } } if(this.makeDust == true){ this.progressBarCraft–; if(this.progressBarCraft < 0){ if(this.furnaceItemStacks[2] != null){ this.furnaceItemStacks[2].stackSize++; } else{ this.furnaceItemStacks[2] = new ItemStack(SpectralCraft_Item.spectralDust, 1); } this.addSE(-this.needSE); –this.furnaceItemStacks[1].stackSize; if (this.furnaceItemStacks[1].stackSize <= 0) { this.furnaceItemStacks[1] = null; } this.progressBarCraft = this.progressBarCraft_Full; this.makeDust = false; } }else{ this.progressBarCraft = this.progressBarCraft_Full; } } } } } public void updateEntity() { this.addEnergy(); this.changeItem(); System.out.println(SE); if(SE > 1000){ SE = 1000; } } @SideOnly(Side.CLIENT) public int getProgressBarSE() { return (int) Math.floor((this.progressBarSE_Full - this.progressBarSE) / (this.progressBarSE_Full / 18)); } @SideOnly(Side.CLIENT) public int getprogressBarCraft() { return (int) Math.floor((this.progressBarCraft_Full - this.progressBarCraft) / (this.progressBarCraft_Full / 18)); } @SideOnly(Side.CLIENT) public int getSETimeRemainingScaled() { return 50 - ((this.MaxSE - this.SE) / (this.MaxSE / 50)); } @Override public String getInventoryName() { // TODO Auto-generated method stub return null; } @Override public boolean hasCustomInventoryName() { // TODO Auto-generated method stub return false; } @Override public void openInventory() { // TODO Auto-generated method stub } @Override public void closeInventory() { // TODO Auto-generated method stub } @Override public boolean isItemValidForSlot(int p_94041_1_, ItemStack p_94041_2_) { // TODO Auto-generated method stub return false; } @Override public int[] getAccessibleSlotsFromSide(int p_94128_1_) { // TODO Auto-generated method stub return null; } @Override public boolean canInsertItem(int p_102007_1_, ItemStack p_102007_2_, int p_102007_3_) { // TODO Auto-generated method stub return false; } @Override public boolean canExtractItem(int p_102008_1_, ItemStack p_102008_2_, int p_102008_3_) { // TODO Auto-generated method stub return false; } }
-
public void changeItem(){ if(this.worldObj.isRemote){
Déjà ça c’est pas bon, tu devrais tout faire côté serveur, donc !this.worldObj.isRemote
Vérifie tout tes this.worldObj.isRemote, tu as l’air d’avoir fait la même erreur plusieurs fois.
-
Bah effet je sais mais quand je met le ! dans le gui rien ne se passe tout les “bar” ne update pas
-
Vérifie le container, si ça ne fonctionne pas c’est que tu n’envoie rien au client.
-
Je vois pas ou est l’erreur …
package com.google.Portuar.SpectralCraft.common.block.soulextruder; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.ICrafting; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public class ContainerSoulExtruder extends Container { private TileEntitySoulExtruder furnace; private int lastprogressBarSE; private int lastSE; private int lastprogressBarCraft; public static final int INPUT_1 = 0, INPUT_2 = 1, OUTPUT = 2; public ContainerSoulExtruder(InventoryPlayer par1InventoryPlayer, TileEntitySoulExtruder par2TileEntityFour) { this.furnace = par2TileEntityFour; this.addSlotToContainer(new Slot(par2TileEntityFour, INPUT_1, 8, 6)); this.addSlotToContainer(new Slot(par2TileEntityFour, INPUT_2, 80, 23)); this.addSlotToContainer(new SlotResult(par1InventoryPlayer.player, par2TileEntityFour, OUTPUT, 80, 45)); int i; for (i = 0; i < 3; ++i) { for (int j = 0; j < 9; ++j) { this.addSlotToContainer(new Slot(par1InventoryPlayer, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); } } for (i = 0; i < 9; ++i) { this.addSlotToContainer(new Slot(par1InventoryPlayer, i, 8 + i * 18, 142)); } } /** * Looks for changes made in the container, sends them to every listener. */ public void detectAndSendChanges() { super.detectAndSendChanges(); for (int i = 0; i < this.crafters.size(); ++i) { ICrafting icrafting = (ICrafting)this.crafters.get(i); if (this.lastprogressBarSE != this.furnace.progressBarSE) { icrafting.sendProgressBarUpdate(this, 0, this.furnace.progressBarSE); } if (this.lastSE != this.furnace.SE) { icrafting.sendProgressBarUpdate(this, 1, this.furnace.SE); } if (this.lastprogressBarCraft != this.furnace.progressBarCraft) { icrafting.sendProgressBarUpdate(this, 2, this.furnace.progressBarCraft); } } this.lastprogressBarSE = this.furnace.progressBarSE; this.lastSE = this.furnace.SE; this.lastprogressBarCraft = this.furnace.progressBarCraft; } @SideOnly(Side.CLIENT) public void updateprogressBarSE(int p_75137_1_, int p_75137_2_) { if (p_75137_1_ == 0) { this.furnace.progressBarSE = p_75137_2_; } if (p_75137_1_ == 1) { this.furnace.SE = p_75137_2_; } if (p_75137_1_ == 2) { this.furnace.progressBarCraft = p_75137_2_; } } public void addCraftingToCrafters(ICrafting p_75132_1_) { super.addCraftingToCrafters(p_75132_1_); p_75132_1_.sendProgressBarUpdate(this, 0, this.furnace.progressBarSE); p_75132_1_.sendProgressBarUpdate(this, 1, this.furnace.SE); p_75132_1_.sendProgressBarUpdate(this, 2, this.furnace.progressBarCraft); } public boolean canInteractWith(EntityPlayer par1EntityPlayer) { return this.furnace.isUseableByPlayer(par1EntityPlayer); } /** * Called when a player shift-clicks on a slot. You must override this or you will crash when someone does that. */ public ItemStack transferStackInSlot(EntityPlayer player, int par2) { ItemStack itemstack = null; Slot slot = (Slot)this.inventorySlots.get(par2); if (slot != null && slot.getHasStack()) { ItemStack itemstack1 = slot.getStack(); itemstack = itemstack1.copy(); if (par2 == OUTPUT) { if (!this.mergeItemStack(itemstack1, OUTPUT+1, OUTPUT+36+1, true)) { return null; } slot.onSlotChange(itemstack1, itemstack); } else if (par2 != INPUT_1 && par2 != INPUT_2) { if (furnace.isSESource(itemstack1) == true) { if (!this.mergeItemStack(itemstack1, INPUT_1, INPUT_1+1, false)) { return null; } } else if (furnace.isChangeCraft(itemstack1) == true) { if (!this.mergeItemStack(itemstack1, INPUT_2, INPUT_2+1, false)) { return null; } } else if (par2 >= OUTPUT+1 && par2 < OUTPUT+28) { if (!this.mergeItemStack(itemstack1, OUTPUT+28, OUTPUT+37, false)) { return null; } } else if (par2 >= OUTPUT+28 && par2 < OUTPUT+37 && !this.mergeItemStack(itemstack1, OUTPUT+1, OUTPUT+28, false)) { return null; } } else if (!this.mergeItemStack(itemstack1, OUTPUT+1, OUTPUT+37, false)) { return null; } if (itemstack1.stackSize == 0) { slot.putStack((ItemStack)null); } else { slot.onSlotChanged(); } if (itemstack1.stackSize == itemstack.stackSize) { return null; } slot.onPickupFromSlot(player, itemstack1); } return itemstack; } }
-
Ta fonction public void updateprogressBarSE(int p_75137_1_, int p_75137_2_)
devrait s’appeler
public void updateProgressBar(int p_75137_1_, int p_75137_2_)
Sinon elle n’override pas la version qui se trouve dans Container.java … -
Tout fonctionne parfaitement merci !