Synchro entre plusieurs joueurs non faites (partielle)



  • Bonjour, je reviens avec un problème sur la synchro des clients ^^ En fait faisant une machine qui vend des items, je cherche à stocker les données côté serveur et côté client dans le tile entity. Pour la personne qui crée la machine pas de soucis tout est bien afficher en revanche pour une autre personne déjà présente les infos ne sont pas afficher, enfin si partiellement grâce à l'aide de AymericRed j'ai rajouté le

        @Override
        public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt) 
        {
        readFromNBT(pkt.getNbtCompound());
        }
    

    Mais je n'ai qu'une partie qui s'affiche (cf. image), c'est à dire le nom …

    Le problème est que je ne vois pas pourquoi les autres données ne sont pas synchronisées ^^ Et du coup je ne sais pas ou je dois regarder pour ce genre d'infos, je vous met mes classes et merci à ceux qui m'aideront ^^

    Le gui de création de la machine :

    package fr.fifou.economy.gui;
    
    import java.awt.Color;
    import java.io.IOException;
    
    import net.minecraft.client.gui.GuiButton;
    import net.minecraft.client.gui.GuiTextField;
    import net.minecraft.client.gui.inventory.GuiContainer;
    import net.minecraft.client.resources.I18n;
    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.entity.player.InventoryPlayer;
    import net.minecraft.init.Blocks;
    import net.minecraft.server.MinecraftServer;
    import net.minecraft.util.ResourceLocation;
    import net.minecraft.util.math.BlockPos;
    import net.minecraft.util.text.TextComponentString;
    import net.minecraft.util.text.TextComponentTranslation;
    import net.minecraft.util.text.TextFormatting;
    import net.minecraft.world.World;
    import net.minecraftforge.fml.client.config.GuiButtonExt;
    import net.minecraftforge.fml.common.FMLCommonHandler;
    
    import org.lwjgl.opengl.GL11;
    
    import fr.fifou.economy.ModEconomy;
    import fr.fifou.economy.blocks.tileentity.TileEntityBlockSeller;
    import fr.fifou.economy.blocks.tileentity.TileEntityBlockVault;
    import fr.fifou.economy.containers.ContainerSeller;
    import fr.fifou.economy.packets.PacketCardChange;
    import fr.fifou.economy.packets.PacketSellerCreated;
    
    public class GuiSeller extends GuiContainer
    {
    private TileEntityBlockSeller tile;
    
    public GuiSeller(InventoryPlayer playerInventory, TileEntityBlockSeller tile) 
    {
    super(new ContainerSeller(playerInventory, tile));
    this.tile = tile;
    
    }
    
    private static final ResourceLocation background = new ResourceLocation(ModEconomy.MODID ,"textures/gui/screen/gui_seller.png");
    protected int xSize = 176;
    protected int ySize = 168;
    protected int guiLeft;
    protected int guiTop;
    
    private GuiButtonExt validate;
    private GuiButtonExt five;
    private GuiButtonExt ten;
    private GuiButtonExt twenty;
    private GuiButtonExt fifty;
    private GuiButtonExt hundreed;
    private GuiButtonExt twoHundreed;
    private GuiButtonExt fiveHundreed;
    private GuiButtonExt unlimitedStack;
    
    private static int cost;
    private boolean admin = false;
    
    @Override
    public void updateScreen() 
    {
    super.updateScreen();
    
    }
    
    @Override
    public void initGui() 
    {
    super.initGui();
    World worldIn = mc.world;
    EntityPlayer player = mc.player;
    if(tile.getCreated() == false)
    {
    this.buttonList.add(this.validate = new GuiButtonExt(1, width / 2 + 46, height / 2 - 33, 35, 20, I18n.format("title.validate")));
    this.buttonList.add(this.five = new GuiButtonExt(2, width / 2 - 122, height / 2 - 66, 35, 20, "5"));
    this.buttonList.add(this.ten = new GuiButtonExt(3, width / 2- 122, height / 2 -47, 35, 20, "10"));
    this.buttonList.add(this.twenty = new GuiButtonExt(4, width / 2 - 122, height / 2 - 28, 35, 20, "20"));
    this.buttonList.add(this.fifty = new GuiButtonExt(5, width / 2 - 122, height / 2 -9, 35, 20, "50"));
    this.buttonList.add(this.hundreed = new GuiButtonExt(6, width / 2 - 122, height / 2 + 10, 35, 20, "100"));
    this.buttonList.add(this.twoHundreed = new GuiButtonExt(7, width / 2 - 122, height / 2 +29, 35, 20, "200"));
    this.buttonList.add(this.fiveHundreed = new GuiButtonExt(8, width / 2 - 122, height / 2 + 48, 35, 20, "500"));
    this.buttonList.add(this.unlimitedStack = new GuiButtonExt(9, width /2 + 2, height / 2 + 83, 80, 13, I18n.format("title.unlimited")));
    
    }
    }
    
    @Override
    protected void actionPerformed(GuiButton button) throws IOException 
    {
    super.actionPerformed(button);
    World worldIn = mc.world;
    EntityPlayer playerIn = mc.player;
    if(tile != null)
    {
    if(button == this.unlimitedStack)
    {
    if(this.admin == false)
    {
    this.admin = true;
    tile.setAdmin(true);
    playerIn.sendMessage(new TextComponentString(I18n.format("title.unlimitedStack")));
    }
    else if(this.admin == true)
    {
    this.admin = false;
    tile.setAdmin(false);
    playerIn.sendMessage(new TextComponentString(I18n.format("title.limitedStack")));
    }
    System.out.println(this.admin);
    }
    if(button == this.five)
    {
    tile.setCost(5);
    this.cost = 5;
    }
    else if(button == this.ten)
    {
    tile.setCost(10);
    this.cost = 10;
    }
    else if(button == this.twenty)
    {
    tile.setCost(20);
    this.cost = 20;
    }
    else if(button == this.fifty)
    {
    tile.setCost(50);
    this.cost = 50;
    }
    else if(button == this.hundreed)
    {
    tile.setCost(100);
    this.cost = 100;
    }
    else if(button == this.twoHundreed)
    {
    tile.setCost(200);
    this.cost = 200;
    }
    else if(button == this.fiveHundreed)
    {
    tile.setCost(500);
    this.cost = 500;
    }
    else if(button == this.validate)
    {
    if(!(tile.getCost() == 0)) // IF TILE HAS NOT A COST OF 0 THEN WE PASS TO THE OTHER
    {
    if(!tile.getStackInSlot(0).getDisplayName().equals("Air")) // IF SLOT 0 IS NOT BLOCKS.AIR, WE PASS
    {
    if(this.admin == false) //ADMIN HASN'T SET : UNLIMITED STACK
    {
    tile.setAdmin(false);
    tile.setCreated(true); // CLIENT SET CREATED AT TRUE
    final int x = tile.getPos().getX(); // GET X
    final int y = tile.getPos().getY(); // GET Y
    final int z = tile.getPos().getZ(); // GET Z
    int amount = tile.getStackInSlot(0).getCount(); // GET COUNT IN TILE THANKS TO STACK IN SLOT
    String name = tile.getStackInSlot(0).getDisplayName(); // GET ITEM NAME IN TILE THANKS TO STACK IN SLOT
    tile.setAmount(amount); //CLIENT SET AMOUNT
    tile.setItem(name); // CLIENT SET ITEM NAME
    playerIn.closeScreen(); // CLOSE SCREEN
    ModEconomy.network.sendToServer(new PacketSellerCreated(true, this.cost, name, amount, x,y,z, false)); // SEND SERVER PACKET FOR CREATED, COST, NAME, AMOUNT, X,Y,Z ARE TILE COORDINATES
    tile.markDirty();
    }
    else if(this.admin == true) //ADMIN HAS SET : UNLIMITED STACK
    {
    tile.setAdmin(true);
    tile.setCreated(true); // CLIENT SET CREATED AT TRUE
    final int x = tile.getPos().getX(); // GET X
    final int y = tile.getPos().getY(); // GET Y
    final int z = tile.getPos().getZ(); // GET Z
    int amount = tile.getStackInSlot(0).getCount(); // GET COUNT IN TILE THANKS TO STACK IN SLOT
    String name = tile.getStackInSlot(0).getDisplayName(); // GET ITEM NAME IN TILE THANKS TO STACK IN SLOT
    tile.setAmount(amount); //CLIENT SET AMOUNT
    tile.setItem(name); // CLIENT SET ITEM NAME
    playerIn.closeScreen(); // CLOSE SCREEN
    ModEconomy.network.sendToServer(new PacketSellerCreated(true, this.cost, name, amount, x,y,z, true)); // SEND SERVER PACKET FOR CREATED, COST, NAME, AMOUNT, X,Y,Z ARE TILE COORDINATES
    tile.markDirty();
    }
    
    }
    else // PROVIDE PLAYER TO SELL AIR
    {
    playerIn.sendMessage(new TextComponentString(I18n.format("title.sellAir")));
    }
    }
    else // IT MEANS THAT PLAYER HAS NOT SELECTED A COST
    {
    playerIn.sendMessage(new TextComponentString(I18n.format("title.noCost")));
    }
    }
    }
    
    }
    
    @Override
    public boolean doesGuiPauseGame() 
    {
    return false;
    }
    
    @Override
    protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) 
    {
    fontRenderer.drawString(new TextComponentTranslation(I18n.format("title.block_seller")).getFormattedText(), 8, 5, Color.DARK_GRAY.getRGB());
    fontRenderer.drawString(new TextComponentTranslation("Inventory").getFormattedText(), 8, 73, Color.DARK_GRAY.getRGB());
    }
    
    @Override
    protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) 
    {
      this.drawDefaultBackground();
          GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); 
          this.mc.getTextureManager().bindTexture(background); 
          int k = (this.width - this.xSize) / 2; 
          int l = (this.height - this.ySize) / 2;
          this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); 
    }
    }
    

    Le gui d'achat

    package fr.fifou.economy.gui;
    
    import java.awt.Color;
    import java.awt.Graphics;
    import java.awt.image.BufferedImage;
    import java.io.IOException;
    import java.util.UUID;
    import javax.imageio.ImageIO;
    
    import net.minecraft.client.Minecraft;
    import net.minecraft.client.gui.FontRenderer;
    import net.minecraft.client.gui.GuiButton;
    import net.minecraft.client.gui.GuiScreen;
    import net.minecraft.client.gui.inventory.GuiContainer;
    import net.minecraft.client.renderer.GlStateManager;
    import net.minecraft.client.renderer.OpenGlHelper;
    import net.minecraft.client.renderer.RenderHelper;
    import net.minecraft.client.renderer.entity.RenderManager;
    import net.minecraft.client.resources.I18n;
    import net.minecraft.entity.EntityLivingBase;
    import net.minecraft.entity.item.EntityItem;
    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.entity.player.InventoryPlayer;
    import net.minecraft.item.Item;
    import net.minecraft.item.ItemStack;
    import net.minecraft.util.ResourceLocation;
    import net.minecraft.util.text.TextComponentString;
    import net.minecraft.util.text.TextComponentTranslation;
    import net.minecraft.util.text.TextFormatting;
    import net.minecraft.world.World;
    import net.minecraftforge.fml.client.config.GuiButtonExt;
    
    import org.lwjgl.opengl.GL11;
    
    import fr.fifou.economy.ModEconomy;
    import fr.fifou.economy.blocks.tileentity.TileEntityBlockSeller;
    import fr.fifou.economy.containers.ContainerSeller;
    import fr.fifou.economy.items.ItemCreditcard;
    import fr.fifou.economy.packets.PacketCardChange;
    import fr.fifou.economy.packets.PacketCardChangeAdmin;
    import fr.fifou.economy.packets.PacketCardChangeSeller;
    import fr.fifou.economy.packets.PacketSellerCreated;
    import fr.fifou.economy.packets.PacketSellerFundsTotal;
    
    public class GuiSellerBuy extends GuiScreen
    {
    private TileEntityBlockSeller tile;
    
    public GuiSellerBuy(TileEntityBlockSeller tile) 
    {
    this.tile = tile;
    
    }
    
    private static final ResourceLocation background = new ResourceLocation(ModEconomy.MODID ,"textures/gui/screen/gui_item.png");
    protected int xSize = 256;
    protected int ySize = 124;
    protected int guiLeft;
    protected int guiTop;
    
    private GuiButtonExt slot1;
    private GuiButtonExt takeFunds;
    private String owner = "";
    private String itemName = "";
    private int cost;
    private int amount;
    private int fundsTotalRecovery;
    
    @Override
    public void updateScreen() 
    {
    super.updateScreen();
    amount = tile.getAmount();
    fundsTotalRecovery = tile.getFundsTotal();
    tile.setFundsTotal(fundsTotalRecovery);
    tile.setAmount(amount);
    tile.markDirty();
    }
    
    @Override
    public void initGui() 
    {
    this.guiLeft = (this.width - this.xSize) / 2;
       this.guiTop = (this.height - this.ySize) / 2;
    World worldIn = mc.world;
    EntityPlayer player = mc.player;
    if(tile != null)
    {
    this.owner = tile.getOwnerName();
    this.itemName = tile.getItem();
    this.cost = tile.getCost();
    this.buttonList.add(this.slot1 = new GuiButtonExt(1, width / 2 - 50, height / 2 + 27, 100, 20, I18n.format("title.buy")));
    String sellerOwner = tile.getOwner();
    String worldPlayer = player.getUniqueID().toString();
    if(sellerOwner.equals(worldPlayer))
    {
    this.buttonList.add(this.takeFunds = new GuiButtonExt(2, width / 2 + 20, height / 2 - 74, 100, 13, I18n.format("title.recover")));
    }
    
    }
    }
    
    @Override
    public boolean doesGuiPauseGame() 
    {
    return false;
    }
    
    @Override
    protected void actionPerformed(GuiButton button) throws IOException 
    {
    super.actionPerformed(button);
    
    World worldIn = mc.world;
    EntityPlayer player = mc.player;
    if(tile != null) // WE CHECK IF TILE IS NOT NULL FOR AVOID CRASH
    {
    if(button == this.slot1) //IF PLAYER BUY
    {
    for(int i = 0; i < player.inventory.getSizeInventory(); i++) // WE CHECK FOR THE CREDIT CARD IN PLAYER'S INVENTORY
    {
    if(player.inventory.getStackInSlot(i) != null) //IF SLOT "i" IS NOT NULL
    {
    if(player.inventory.getStackInSlot(i).getItem() instanceof ItemCreditcard) // AND THE ITEM IS THE CREDIT CARD
    {
    ItemStack hasCardIS = player.inventory.getStackInSlot(i); // WE CREATE A NEW ITEM STACK WITH THE CARD IN SLOT
    if(hasCardIS.hasTagCompound() && hasCardIS.getTagCompound().hasKey("Owner")) // CHECK IF CARD HAS OWNER
    {
    String playerCardO = hasCardIS.getTagCompound().getString("OwnerUUID"); // GET THE OWNER UUID IN CARD'S NBT
    String playerInWorld = player.getUniqueID().toString(); // GET THE PLAYER UUID IN WORLD
    
    if(playerCardO.equals(playerInWorld)) // IF THEY ARE THE SAME WE PASS
    {
    if(hasCardIS.getTagCompound().getInteger("Funds") >= tile.getCost()) //IF FUNDS IN CARD ARE SUPERIOR OR EQUAL TO THE COST WE PASS
    {
    if(hasCardIS.getTagCompound().getBoolean("Linked") == true)
    {
    if(tile.getAmount() >= 1)
    {
    boolean admin = tile.getAdmin();
    if(admin == false)
    {
    int fundTotal = tile.getFundsTotal(); // WE GET THE TOTAL FUNDS
    tile.setFundsTotal(fundTotal + tile.getCost()); // CLIENT ADD TOTAL FUNDS + THE COST OF THE ITEM
    final int x = tile.getPos().getX(); // GET X COORDINATES
    final int y = tile.getPos().getY(); // GET Y COORDINATES
    final int z = tile.getPos().getZ(); // GET Z COORDINATES
    final int cost = tile.getCost(); // GET COST OF THE TILE ENTITY
    int amount = tile.getAmount(); // GET AMOUNT OF THE TILE ENTITY
    tile.setAmount(amount -1); // CLIENT SET AMOUNT MINUS ONE EACH TIME HE BUY
    ModEconomy.network.sendToServer(new PacketSellerFundsTotal((fundTotal + tile.getCost()), x,y,z, amount, false)); //SENDING PACKET TO LET SERVER KNOW CHANGES WITH TOTAL FUNDS, COORDINATES AND AMOUNT
    ModEconomy.network.sendToServer(new PacketCardChangeSeller(cost)); // SENDING ANOTHER PACKET TO UPDATE CLIENT'S CARD IN SERVER KNOWLEDGE
    tile.markDirty();
    }
    else if(admin == true)
    {
    int fundTotal = tile.getFundsTotal(); // WE GET THE TOTAL FUNDS
    tile.setFundsTotal(fundTotal + tile.getCost()); // CLIENT ADD TOTAL FUNDS + THE COST OF THE ITEM
    final int x = tile.getPos().getX(); // GET X COORDINATES
    final int y = tile.getPos().getY(); // GET Y COORDINATES
    final int z = tile.getPos().getZ(); // GET Z COORDINATES
    final int cost = tile.getCost(); // GET COST OF THE TILE ENTITY
    int amount = tile.getAmount(); // GET AMOUNT OF THE TILE ENTITY
    tile.setAmount(amount); // CLIENT SET AMOUNT MINUS ONE EACH TIME HE BUY
    ModEconomy.network.sendToServer(new PacketSellerFundsTotal((fundTotal + tile.getCost()), x,y,z, amount, false)); //SENDING PACKET TO LET SERVER KNOW CHANGES WITH TOTAL FUNDS, COORDINATES AND AMOUNT
    ModEconomy.network.sendToServer(new PacketCardChangeSeller(cost)); // SENDING ANOTHER PACKET TO UPDATE CLIENT'S CARD IN SERVER KNOWLEDGE
    tile.markDirty();
    }
    }
    }
    else // ELSE WE SEND HIM A MESSAGE TO TELL HE DON'T HAVE THE UPGRADE
    {
    player.sendMessage(new TextComponentString(I18n.format("title.noUpgrade")));
    }
    }
    else // ELSE WE SEND HIM A MESSAGE TO TELL THEY DON'T HAVE ENOUGH FUNDS
    {
    player.sendMessage(new TextComponentString(I18n.format("title.noEnoughFunds")));
    }
    }
    else // ELSE WE SEND HIM A MESSAGE TO TELL HIM IT'S NOT HIS CARD
    {
    player.sendMessage(new TextComponentString(I18n.format("title.noSameCardBuy")));
    }
    }
    }
    }
    }
    }
    else if(button == this.takeFunds)
    {
    for(int i = 0; i < player.inventory.getSizeInventory(); i++) // WE CHECK FOR THE CREDIT CARD IN PLAYER'S INVENTORY
    {
    if(player.inventory.getStackInSlot(i) != null) //IF SLOT "i" IS NOT NULL
    {
    if(player.inventory.getStackInSlot(i).getItem() instanceof ItemCreditcard) // AND THE ITEM IS THE CREDIT CARD
    {
    ItemStack hasCardIS = player.inventory.getStackInSlot(i); // WE CREATE A NEW ITEM STACK WITH THE CARD IN SLOT
    if(hasCardIS.hasTagCompound() && hasCardIS.getTagCompound().hasKey("Owner"))
    {
    final int x = tile.getPos().getX(); // GET X COORDINATES
    final int y = tile.getPos().getY(); // GET Y COORDINATES
    final int z = tile.getPos().getZ(); // GET Z COORDINATES
    tile.setFundsTotal(0);
    tile.markDirty();
    ModEconomy.network.sendToServer(new PacketSellerFundsTotal(fundsTotalRecovery, x,y,z, amount, true)); //SENDING PACKET TO LET SERVER KNOW CHANGES WITH TOTAL FUNDS, COORDINATES AND AMOUNT
    }
    }
    }
    }
    }
    }
    }
    
    @Override
    public void drawScreen(int mouseX, int mouseY, float partialTicks)
    {
    this.drawDefaultBackground();
    // added
           this.mc.getTextureManager().bindTexture(background);
           int i = this.guiLeft;
           int j = this.guiTop;
           this.drawTexturedModalRect(i, j, 0, 0, this.xSize, this.ySize);
    this.fontRenderer.drawString(TextFormatting.BOLD + I18n.format("title.seller") + owner, (this.width / 2 - 120), (this.height / 2 - 50), 0x000);
    this.fontRenderer.drawString(TextFormatting.BOLD + I18n.format("title.item") + itemName, (this.width / 2 - 120), (this.height / 2 - 40), 0x000);
    this.fontRenderer.drawString(TextFormatting.BOLD + I18n.format("title.cost") + cost, (this.width / 2 - 120), (this.height / 2 - 30), 0x000);
    this.fontRenderer.drawString(TextFormatting.BOLD + I18n.format("title.amount") + amount, (this.width / 2 - 120), (this.height / 2 - 20), 0x000);
    this.fontRenderer.drawString(TextFormatting.BOLD + I18n.format("title.fundsToRecover") + fundsTotalRecovery, (this.width / 2 - 120), (this.height / 2 - 10), 0x000);
    super.drawScreen(mouseX, mouseY, partialTicks);
       }
    
    }
    

    Le tile entity :

    package fr.fifou.economy.blocks.tileentity;
    
    import javax.annotation.Nullable;
    
    import net.minecraft.item.ItemStack;
    import net.minecraft.nbt.NBTTagCompound;
    import net.minecraft.network.NetworkManager;
    import net.minecraft.network.play.server.SPacketUpdateTileEntity;
    import net.minecraft.tileentity.TileEntity;
    import net.minecraft.util.EnumFacing;
    import net.minecraftforge.common.capabilities.Capability;
    import net.minecraftforge.items.CapabilityItemHandler;
    import net.minecraftforge.items.ItemStackHandler;
    
    public class TileEntityBlockSeller extends TileEntity 
    {
    ItemStackHandler inventory_seller = new ItemStackHandler(1); //STACK HANDLER FOR ONE SLOT = 0 
    private String owner = ""; 
    private String ownerName = "";
    private int funds_total;
    private int cost;
    private boolean created;
    private int amount;
    private String item = "";
    private boolean admin;
    
    public TileEntityBlockSeller()
    {
    
    }
    
    public ItemStackHandler getHandler()
    {
    return inventory_seller;
    
    }
    
    public TileEntityBlockSeller(String ownerUUID, String ownerName, int costS, int amountS, String itemS ,int fundsTotalS, boolean createdS, boolean adminS)
    {
    this.owner = ownerUUID; //STORE OWNER UUID
    this.ownerName = ownerName;
    this.cost = costS; //STORE COST
    this.amount = amountS; //STORE AMOUNT
    this.item = itemS; //STORE ITEM NAME
    this.funds_total = fundsTotalS; //STORE FUNDS TOTAL
    this.created = createdS; //STORE CREATED BOOLEAN
    this.admin = adminS;
    }
    
        public SPacketUpdateTileEntity getUpdatePacket()
        {
            return new SPacketUpdateTileEntity(this.pos, 1, this.getUpdateTag());
        }
    
        public NBTTagCompound getUpdateTag()
        {
            return this.writeToNBT(new NBTTagCompound());
        }
    
        @Override
        public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt) 
        {
        readFromNBT(pkt.getNbtCompound());
        }
    
    public ItemStack getStackInSlot(int slot)
    {
    return inventory_seller.getStackInSlot(slot);
    }
    
    public ItemStack removeStackInSlot(int slot)
    {
    return inventory_seller.getStackInSlot(slot).splitStack(1);
    }
    
    public void setAdmin(Boolean adminS)
    {
    this.admin = adminS;
    }
    
    public boolean getAdmin()
    {
    return this.admin;
    }
    
        public void setOwner(String string)
        {
            this.owner = string;
        }
    
        public String getOwner()
        {
            return this.owner;
        }
    
        public void setOwnerName(String stringName)
        {
        this.ownerName = stringName;
        }
    
        public String getOwnerName()
        {
        return this.ownerName;
        }
    
        public void setCost(int costS)
        {
        this.cost = costS;
        }
    
        public int getCost()
        {
            return this.cost;
        }
    
        public void setFundsTotal(int fundsS)
        {
        this.funds_total = fundsS;
        }
    
        public int getFundsTotal()
        {
        return this.funds_total;
        }
        public void setCreated(boolean createdS)
        {
        this.created = createdS;
        }
    
        public boolean getCreated()
        {
            return this.created;
        }
    
        public void setItem(String itemS)
        {
        this.item = itemS;
        }
    
        public String getItem()
        {
        return this.item;
        }
    
        public void setAmount(int amountS)
        {
        this.amount = amountS;
        }
    
        public int getAmount()
        {
        return this.amount;
        }
    
    @Override
    public NBTTagCompound writeToNBT(NBTTagCompound compound) 
    {
    compound.setTag("inventory", inventory_seller.serializeNBT());
    compound.setString("ownerS", this.owner);
    compound.setString("ownerName", this.ownerName);
    compound.setInteger("cost", this.cost);
    compound.setInteger("amount", this.amount);
    compound.setString("item", this.item);
    compound.setInteger("funds_total", this.funds_total);
    compound.setBoolean("created", this.created);
    compound.setBoolean("admin", this.admin);
    return super.writeToNBT(compound);
    }
    
    @Override
    public void readFromNBT(NBTTagCompound compound) 
    {
    super.readFromNBT(compound);
    inventory_seller.deserializeNBT(compound.getCompoundTag("inventory"));
    this.owner = compound.getString("ownerS");
    this.ownerName = compound.getString("ownerName");
    this.cost = compound.getInteger("cost");
    this.amount = compound.getInteger("amount");
    this.item = compound.getString("item");
    this.funds_total = compound.getInteger("funds_total");
    this.created = compound.getBoolean("created");
    this.admin = compound.getBoolean("admin");
    }
    }
    
    

    Si vous avez besoins des packets, demandez moi 😉 Merci.



  • Après la réception de ton packet, essayes de faire "tontileentity.markDirty()" et normalement ça sera bon. Si ça ne marche toujours pas envoies le code du packet.


  • Administrateurs

    Salut,
    Ou world.markBlockForUpdate.

    (elle est où la balise de version ?)
    EDIt : ho, je viens de voir qu'il y a une option pour forcer le fait de mettre un préfixe de version, je viens l'activer.



  • @robin4002:

    Ou world.markBlockForUpdate.

    (elle est où la balise de version ?)

    Le problème c'est qu'il n'y a pas cette fonction selon les versions justement ^^



  • @robin4002:

    Salut,
    Ou world.markBlockForUpdate.

    (elle est où la balise de version ?)
    EDIt : ho, je viens de voir qu'il y a une option pour forcer le fait de mettre un préfixe de version, je viens l'activer.

    Merci à chaque fois j'oublie punaise ! Pourtant je sais qu'il faut la mettre ^^

    Après la réception du packet, c'est à dire dans le tile entity ? oO


  • Administrateurs

    Tu ne risques plus de l'oublier maintenant car cela fera une erreur si elle manque.

    C'est world.markBlockForUpdateRange(pos, pos) en 1.12 il me semble.
    Oui dans le tile entity.

    EDIT : perdu : https://github.com/kevin68/The-Spotlight-Mod/blob/master/src/fr/mcnanotech/kevin_68/thespotlightmod/TileEntitySpotLight.java#L220
    this.world.notifyBlockUpdate(getPos(), state, state, 3);



  • D'acc tant mieux car c'est vrai que c'est important, désoler de l'avoir oublier 😞

    D'acc je teste ce à la fin du tile entity du coup 🙂


    Toujours pas /:

    EDIT EDIT: C'était

    @Override
    public void markDirty() 
    {
    IBlockState state = this.world.getBlockState(getPos());
        this.world.notifyBlockUpdate(getPos(), state, state, 3);
    }
    ``` en 1.12, je n'ai que extends tileentity ^^ Du coup ca marche :)
    Merci à vous !