Jump to content

Machine Bug


Moritz

Recommended Posts

hello. I did create a machine with that you can create Modules.

Now i have a bug i saw at EE3 (Direwolf20MPLP), that you can not use the transmuationcrafting.

Now i have the same problem. I want to create a new Item in the same slot (in this case a diamond) and it transforms back into my Item^^ i have no idea how that happends^^.

 

Here My ModulMaker source! I am not on 1.6/1.5. I still work on 1.4. But the code is the same.

 

package speiger.src.tinychest.common.tileentity.machines.machine;

import cpw.mods.fml.common.FMLLog;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.liquids.LiquidStack;
import speiger.src.api.api.ICable;
import speiger.src.api.api.IMachine;
import speiger.src.api.api.modules.advanced.ModulMakerRecipeRegister;
import speiger.src.api.common.functions.WorldReading;
import speiger.src.api.common.tile.TileFacing;
import speiger.src.tinychest.common.config.TinyItems;
import speiger.src.tinychest.common.items.module.ItemEmptyModul;
import speiger.src.tinychest.common.items.module.ModulCore;

public class ModuleMaker extends TileFacing implements IInventory, IMachine
{
public int[] button = new int[3];
public int[] progressButton = new int[6];
public ItemStack[] modulStack = new ItemStack[8];
public int progress = 0;
public int maxProgress = 7200;
public int mode = 0;
public int progressmode = 0;
public int energy = 0;
public int maxEnergy = 100000;

private void updateButtons() 
{
	if(button[0] > 0)
	{
		mode = 1;
	}
	if(button[1] > 0)
	{
		mode = 2;
	}
	if(button[2] > 0)
	{
		mode = 3;
	}

	if(progressButton[0] > 0)
	{
		progressmode = 1;
	}
	if(progressButton[1] > 0)
	{
		progressmode = 2;
	}
	if(progressButton[2] > 0)
	{
		progressmode = 3;
	}
	if(progressButton[3] > 0)
	{
		progressmode = 4;
	}
	if(progressButton[4] > 0)
	{
		progressmode = 5;
	}
	if(progressButton[5] > 0)
	{
		progressmode = 6;
	}

}

@Override
public int getSizeInventory() 
{
	return this.modulStack.length;
}

    public ItemStack getStackInSlot(int par1)
    {
        return this.modulStack[par1];
    }

    public ItemStack decrStackSize(int par1, int par2)
    {
        if (this.modulStack[par1] != null)
        {
            ItemStack var3;

            if (this.modulStack[par1].stackSize <= par2)
            {
                var3 = this.modulStack[par1];
                this.modulStack[par1] = null;
                return var3;
            }
            else
            {
                var3 = this.modulStack[par1].splitStack(par2);

                if (this.modulStack[par1].stackSize == 0)
                {
                    this.modulStack[par1] = null;
                }

                return var3;
            }
        }
        else
        {
            return null;
        }
    }
   
    public ItemStack getStackInSlotOnClosing(int par1)
    {
        if (this.modulStack[par1] != null)
        {
            ItemStack var2 = this.modulStack[par1];
            this.modulStack[par1] = null;
            return var2;
        }
        else
        {
            return null;
        }
    }

    public void setInventorySlotContents(int par1, ItemStack par2ItemStack)
    {
        this.modulStack[par1] = par2ItemStack;

        if (par2ItemStack != null && par2ItemStack.stackSize > this.getInventoryStackLimit())
        {
            par2ItemStack.stackSize = this.getInventoryStackLimit();
        }
    }

    public String getInvName()
    {
        return "Module Maker";
    }

public int getInventoryStackLimit() 
{
	return 1;
}

public boolean isUseableByPlayer(EntityPlayer var1) 
{
	return true;
}

public void openChest() 
{
}

@Override
public void closeChest() 
{
}

@Override
public void updateEntity() 
{
	super.updateEntity();
	updateButtons();
	updateCable();
	createModul();
}

public void createModul()
{
	if(progressmode == 1)
	{
		createCleanModul();
	}
	if(progressmode == 2)
	{
		setModulKind();
	}


}

public void setModulKind() 
{

}

public void createCleanModul() 
{

	if(modulStack[0] != null && modulStack[0].getItem() instanceof ModulCore)
	{
		progress+= 10;
		FMLLog.getLogger().info("Progress: "+progress);
		if(progress >= getProgressFromMode())
		{
			progress = 0;
			ItemStack par1 = new ItemStack(Item.diamond, 1);
			modulStack[0] = null;
			modulStack[0] = par1.copy();




		}
	}

}

public int getProgressFromMode() 
{
	if(mode == 1)return maxProgress / 2;
	else if(mode == 2)return maxProgress;
	else return maxProgress*2;
}

public void updateCable()
{
	for(int i = 0;i<6;i++)
	{
		TileEntity tile = WorldReading.getTileEntity(worldObj, xCoord, yCoord, zCoord, i);
		if(tile != null && tile instanceof ICable)
		{
			ICable ic = (ICable) tile;
			ic.setPriorty(0);
		}
	}
}

@Override
public boolean needEnergie() 
{
	return energy < maxEnergy;
}

@Override
public int getMaxStoredEnergy() 
{
	return maxEnergy;
}

@Override
public int getStoredEnergy() 
{
	return energy;
}

@Override
public void sendEnergyToMachine(int i) 
{
	energy += i;
}

@Override
public int getTransferlimit() 
{
	return 128;
}

@Override
public int getEnergyOutOfMachine(int i)
{
	return 0;
}

@Override
public boolean hasLiquidContainer() 
{
	return false;
}

@Override
public boolean needsLiquid() 
{
	return false;
}

@Override
public boolean hasFinalLiquid() 
{
	return false;
}

@Override
public boolean hasLiquid() 
{
	return false;
}

@Override
public LiquidStack getLiquidID() 
{
	return null;
}

@Override
public int getStoredLiquid() 
{
	return 0;
}

@Override
public int getMaxLiquidLevel() 
{
	return 0;
}

@Override
public void setLiquidID(LiquidStack par1) 
{
}

@Override
public void sendLiquid(int i)
{
}

@Override
public int suckLiquidOutOfMachine(int i) 
{
	return 0;
}





}

 

Can you help me with that bug?

 

Link to comment
Share on other sites

Man, this is a forum, anyone can chose to answer or not.

 

                                progress = 0;
			ItemStack par1 = new ItemStack(Item.diamond, 1);
			modulStack[0] = null;
			modulStack[0] = par1.copy();

can't you just do instead:

setInventorySlotContents(0, new ItemStack(Item.diamond));

 

Link to comment
Share on other sites

Man, this is a forum, anyone can chose to answer or not.

 

                                progress = 0;
			ItemStack par1 = new ItemStack(Item.diamond, 1);
			modulStack[0] = null;
			modulStack[0] = par1.copy();

can't you just do instead:

setInventorySlotContents(0, new ItemStack(Item.diamond));

 

 

i already tried this way^^ The item still Transform back to the old Item!

 

Link to comment
Share on other sites

Ok i did find out what the problem is!

My buttoncode is the problem! Without that i can make the items without problems.

Now my Problem is i can not work without my Buttons^^.

I mean the RecipeList ist to complex to do it without buttons.

So the question is how do i fix it?

Do you need more source to find the error?

 

Link to comment
Share on other sites

Here is my Whole source.

 

Gui ModuleMaker


package speiger.src.tinychest.client.gui.machines.machine;

import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.StatCollector;

import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;

import cpw.mods.fml.common.FMLLog;

import speiger.src.tinychest.common.container.machines.machine.ContainerModulMaker;
import speiger.src.tinychest.common.tileentity.machines.machine.ModuleMaker;

public class GuiModuleMaker extends GuiContainer 
{
private ModuleMaker tile;

public GuiModuleMaker(InventoryPlayer par1, ModuleMaker par2) 
{
	super(new ContainerModulMaker(par1, par2));
	tile = par2;
	this.ySize = 232;
	this.xSize = 211;
}


protected void drawGuiContainerForegroundLayer(int par1, int par2)
    {
	this.fontRenderer.drawString("Fast", 38, 128, 0xffffff);
	this.fontRenderer.drawString("Med", 80, 128, 0xffffff);
	this.fontRenderer.drawString("Slow", 118, 128, 0xffffff);
        this.fontRenderer.drawString("Module Maker", 65, 6, 4210752);
        this.fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 8, this.ySize - 96 + 5, 4210752);
        this.fontRenderer.drawString("Clearing", 153, 10, 0xffffff);
        this.fontRenderer.drawString("Specify", 155, 30, 0xffffff);
        this.fontRenderer.drawString("Production", 146, 50, 0xffffff);
        this.fontRenderer.drawString("AdvProduct", 144, 70, 0xffffff);
        this.fontRenderer.drawString("Upgrade", 153, 90, 0xffffff);
        this.fontRenderer.drawString("Fuel", 164, 110, 0xffffff);
    }

    protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3)
    {
        int var4 = this.mc.renderEngine.getTexture("/speiger/src/tinychest/textures/ModuleMaker.png");
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        this.mc.renderEngine.bindTexture(var4);
        int var5 = (this.width - this.xSize) / 2;
        int var6 = (this.height - this.ySize) / 2;
        this.drawTexturedModalRect(var5, var6, 0, 0, this.xSize, this.ySize);
        int var7;
        


  
        if(tile.button[0] == 1)
        {
        	this.drawTexturedModalRect(32 + var5, 81 + var6 + 44, 222, 41, 35, 15);
       	}
       	if(tile.button[1] == 1)
       	{
       		this.drawTexturedModalRect(72 + var5, 81 + var6 + 44, 222, 41, 35, 15);
       	}
       	if(tile.button[2] == 1)
       	{
       		this.drawTexturedModalRect(112 + var5, 81 + var6 + 44, 222, 41, 35, 15);
        }
        
       	if(tile.progressButton[0] == 1)
       	{
       		this.drawTexturedModalRect(141 + var5, 6 + var6, 138, 234, 64, 15);
       	}
       	
       	if(tile.progressButton[1] == 1)
       	{
       		this.drawTexturedModalRect(141 + var5, 26 + var6, 138, 234, 64, 15);
       	}
        
       	if(tile.progressButton[2] == 1)
       	{
       		this.drawTexturedModalRect(141 + var5, 46 + var6, 138, 234, 64, 15);
       	}
       	
       	if(tile.progressButton[3] == 1)
       	{
       		this.drawTexturedModalRect(141 + var5, 66 + var6, 138, 234, 64, 15);
       	}
       	
       	if(tile.progressButton[4] == 1)
       	{
       		this.drawTexturedModalRect(141 + var5, 86 + var6, 138, 234, 64, 15);
       	}
       	
       	if(tile.progressButton[5] == 1)
       	{
       		this.drawTexturedModalRect(141 + var5, 106 + var6, 138, 234, 64, 15);
       	}
       	
       	
       	
       	
       	
        
    }

    
    public int getButtonprosition(int x, int y) 
    {
    	if(x>=33 && x<=64 && y>=125 && y<=139)return 1;
    	else if(x>=73 && x<=104 && y>=125 && y<=139)return 2;
    	else if(x>=113 && x<=144 && y>=125 && y<=139)return 3;
    	
    	else if(x>=141 && x<=204 && y>=6 && y<=20)return 4;
    	else if(x>=141 && x<=204 && y>=26 && y<=40)return 5;
    	else if(x>=141 && x<=204 && y>=46 && y<=60)return 6;
//    	else if(x>=141 && x<=204 && y>=66 && y<=80)return 7;
//    	else if(x>=141 && x<=204 && y>=86 && y<=100)return 8;
//    	else if(x>=141 && x<=204 && y>=106 && y<=120)return 9;
    	else return 0;
    }
    

    


@Override
protected void mouseClicked(int par1, int par2, int par3) 
{
	super.mouseClicked(par1, par2, par3);


	int cornerX = (width - xSize) / 2;
	int cornerY = (height - ySize) / 2;
	int prosition = getButtonprosition(par1 - cornerX, par2 - cornerY);
	if(prosition != 0)
	{
		tile.progress = 0;
		if(prosition == 1)
		{
			tile.button[0] = 1;
			tile.button[1] = 0;
			tile.button[2] = 0;
		}
		if(prosition == 2)
		{
			tile.button[0] = 0;
			tile.button[1] = 1;
			tile.button[2] = 0;
		}
		if(prosition == 3)
		{
			tile.button[0] = 0;
			tile.button[1] = 0;
			tile.button[2] = 1;
		}

		if(prosition == 4)
		{
			tile.progressButton[0] = 1;
			tile.progressButton[1] = 0;
			tile.progressButton[2] = 0;
			tile.progressButton[3] = 0;
			tile.progressButton[4] = 0;
			tile.progressButton[5] = 0;
		}
		if(prosition == 5)
		{
			tile.progressButton[0] = 0;
			tile.progressButton[1] = 1;
			tile.progressButton[2] = 0;
			tile.progressButton[3] = 0;
			tile.progressButton[4] = 0;
			tile.progressButton[5] = 0;
		}
		if(prosition == 6)
		{
			tile.progressButton[0] = 0;
			tile.progressButton[1] = 0;
			tile.progressButton[2] = 1;
			tile.progressButton[3] = 0;
			tile.progressButton[4] = 0;
			tile.progressButton[5] = 0;
		}
		if(prosition == 7)
		{
			tile.progressButton[0] = 0;
			tile.progressButton[1] = 0;
			tile.progressButton[2] = 0;
			tile.progressButton[3] = 1;
			tile.progressButton[4] = 0;
			tile.progressButton[5] = 0;
		}
		if(prosition == 
		{
			tile.progressButton[0] = 0;
			tile.progressButton[1] = 0;
			tile.progressButton[2] = 0;
			tile.progressButton[3] = 0;
			tile.progressButton[4] = 1;
			tile.progressButton[5] = 0;
		}

		if(prosition == 9)
		{
			tile.progressButton[0] = 0;
			tile.progressButton[1] = 0;
			tile.progressButton[2] = 0;
			tile.progressButton[3] = 0;
			tile.progressButton[4] = 0;
			tile.progressButton[5] = 1;
		}
	}
}

}

 

ContainerModuleMaker:

package speiger.src.tinychest.common.container.machines.machine;

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;
import speiger.src.tinychest.common.tileentity.machines.machine.ModuleMaker;

public class ContainerModulMaker extends Container 
{

public ContainerModulMaker(InventoryPlayer par1, ModuleMaker par2) 
{
	this.addSlotToContainer(new Slot(par2, 0, 79, 21));//Circuit Slot
	this.addSlotToContainer(new Slot(par2, 1, 79, 54)); //Modul Input
	this.addSlotToContainer(new Slot(par2, 2, 112, 54)); //OutputSlot
	this.addSlotToContainer(new Slot(par2, 3, 36, 10)); //Input Slot 1
	this.addSlotToContainer(new Slot(par2, 4, 36, 32)); //Input Slot 2
	this.addSlotToContainer(new Slot(par2, 5, 36, 54)); //Input Slot 3
	this.addSlotToContainer(new Slot(par2, 6, 36, 76)); //Input Slot 4
	this.addSlotToContainer(new Slot(par2, 7, 36, 98)); //Input Slot 5


        int var3;

        for (var3 = 0; var3 < 3; ++var3)
        {
            for (int var4 = 0; var4 < 9; ++var4)
            {
                this.addSlotToContainer(new Slot(par1, var4 + var3 * 9 + 9, 9 + var4 * 18, 151 + var3 * 18));
            }
        }

        for (var3 = 0; var3 < 9; ++var3)
        {
            this.addSlotToContainer(new Slot(par1, var3, 9 + var3 * 18, 209));
        }
}

@Override
public boolean canInteractWith(EntityPlayer var1)
{
	return true;
}

@Override
public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2) 
{
	return null;
}



}

 

TileEntity ModuleMaker

package speiger.src.tinychest.common.tileentity.machines.machine;

import cpw.mods.fml.common.FMLLog;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.FurnaceRecipes;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.liquids.LiquidStack;
import speiger.src.api.api.ICable;
import speiger.src.api.api.IMachine;
import speiger.src.api.api.modules.advanced.ModulMakerRecipeRegister;
import speiger.src.api.common.functions.WorldReading;
import speiger.src.api.common.tile.TileFacing;
import speiger.src.tinychest.common.config.TinyItems;
import speiger.src.tinychest.common.items.module.ItemEmptyModul;
import speiger.src.tinychest.common.items.module.ModulCore;

public class ModuleMaker extends TileFacing implements IInventory, IMachine
{
public int[] button = new int[3];
public int[] progressButton = new int[6];
public ItemStack[] modulStack = new ItemStack[8];
public int progress = 0;
public int maxProgress = 7200;
public int mode = 0;
public int progressmode = 0;
public int energy = 0;
public int maxEnergy = 100000;

private void updateButtons() 
{
	if(button[0] > 0)
	{
		mode = 1;
	}
	if(button[1] > 0)
	{
		mode = 2;
	}
	if(button[2] > 0)
	{
		mode = 3;
	}

	if(progressButton[0] > 0)
	{
		progressmode = 1;
	}
	if(progressButton[1] > 0)
	{
		progressmode = 2;
	}
	if(progressButton[2] > 0)
	{
		progressmode = 3;
	}
	if(progressButton[3] > 0)
	{
		progressmode = 4;
	}
	if(progressButton[4] > 0)
	{
		progressmode = 5;
	}
	if(progressButton[5] > 0)
	{
		progressmode = 6;
	}

}

@Override
public int getSizeInventory() 
{
	return this.modulStack.length;
}

    public ItemStack getStackInSlot(int par1)
    {
        return this.modulStack[par1];
    }

    public ItemStack decrStackSize(int par1, int par2)
    {
        if (this.modulStack[par1] != null)
        {
            ItemStack var3;

            if (this.modulStack[par1].stackSize <= par2)
            {
                var3 = this.modulStack[par1];
                this.modulStack[par1] = null;
                return var3;
            }
            else
            {
                var3 = this.modulStack[par1].splitStack(par2);

                if (this.modulStack[par1].stackSize == 0)
                {
                    this.modulStack[par1] = null;
                }

                return var3;
            }
        }
        else
        {
            return null;
        }
    }
   
    public ItemStack getStackInSlotOnClosing(int par1)
    {
        if (this.modulStack[par1] != null)
        {
            ItemStack var2 = this.modulStack[par1];
            this.modulStack[par1] = null;
            return var2;
        }
        else
        {
            return null;
        }
    }

    public void setInventorySlotContents(int par1, ItemStack par2ItemStack)
    {
        this.modulStack[par1] = par2ItemStack;

        if (par2ItemStack != null && par2ItemStack.stackSize > this.getInventoryStackLimit())
        {
            par2ItemStack.stackSize = this.getInventoryStackLimit();
        }
    }

    public String getInvName()
    {
        return "Module Maker";
    }

public int getInventoryStackLimit() 
{
	return 1;
}

public boolean isUseableByPlayer(EntityPlayer var1) 
{
	return true;
}

public void openChest() 
{
}

@Override
public void closeChest() 
{
}

@Override
public void updateEntity() 
{
	super.updateEntity();
	if(!worldObj.isRemote || worldObj.getWorldTime() % 10 == 0)return;

	updateButtons();
	updateCable();
	ItemStack par1 = new ItemStack(Item.diamond);
	if(modulStack[0] != null && canProgress())
	{
		modulStack[2] = par1.copy();
		modulStack[0] = null;


	}
}



public boolean canProgress() 
{
        if (this.modulStack[0] == null)
        {
            return false;
        }
        else
        {
            ItemStack var1 = new ItemStack(Item.diamond);
            if (this.modulStack[2] == null) return true;
            if (!this.modulStack[2].isItemEqual(var1)) return false;
            int result = modulStack[2].stackSize + var1.stackSize;
            return (result <= getInventoryStackLimit() && result <= var1.getMaxStackSize());
        }
}

public int getProgressFromMode() 
{
	if(mode == 1)return maxProgress / 2;
	else if(mode == 2)return maxProgress;
	else return maxProgress*2;
}

public void updateCable()
{
	for(int i = 0;i<6;i++)
	{
		TileEntity tile = WorldReading.getTileEntity(worldObj, xCoord, yCoord, zCoord, i);
		if(tile != null && tile instanceof ICable)
		{
			ICable ic = (ICable) tile;
			ic.setPriorty(0);
		}
	}
}

@Override
public boolean needEnergie() 
{
	return energy < maxEnergy;
}

@Override
public int getMaxStoredEnergy() 
{
	return maxEnergy;
}

@Override
public int getStoredEnergy() 
{
	return energy;
}

@Override
public void sendEnergyToMachine(int i) 
{
	energy += i;
}

@Override
public int getTransferlimit() 
{
	return 128;
}

@Override
public int getEnergyOutOfMachine(int i)
{
	return 0;
}

@Override
public boolean hasLiquidContainer() 
{
	return false;
}

@Override
public boolean needsLiquid() 
{
	return false;
}

@Override
public boolean hasFinalLiquid() 
{
	return false;
}

@Override
public boolean hasLiquid() 
{
	return false;
}

@Override
public LiquidStack getLiquidID() 
{
	return null;
}

@Override
public int getStoredLiquid() 
{
	return 0;
}

@Override
public int getMaxLiquidLevel() 
{
	return 0;
}

@Override
public void setLiquidID(LiquidStack par1) 
{
}

@Override
public void sendLiquid(int i)
{
}

@Override
public int suckLiquidOutOfMachine(int i) 
{
	return 0;
}





}

 

so my problem is that he creates ghost items.

I know from where the problem comes but i do not know how to fix it.

The problem activate every time when i asking is this button pressed or is it not (in form of the variable mode, progressmode, work) if i implement these variables he start to create Ghost items. so how can i fix it?

Link to comment
Share on other sites

From the Gui, send a packet to server when mouseClicked() is called, with enough data to change the tileentity state on the server side.

I would recommend using

this.mc.getNetHandler().addToSendQueue(packet);

With packet being constructed with your "prosition" data.

 

Then in a class implementing IPacketHandler, read the data and change the tileentity state.

You'll need to register channel and packet handling class in your @NetworkMod annotation.

Link to comment
Share on other sites

Well, this is going to be long.

Let's start from the beginning, shall we ?

 

For the server to know what the client is doing, (and vice-versa) information needs to be sent. You need to remember that client part is distinct from server part, because they can be, like, 1000 kilometres apart.

On your case, you have a client input (a click). You need to send this info to the server.

But rough info can't travel through the internet (which is the commonly used communicating system), as it would be slow and insecure.

You send packets containing the info.

How it is done:

You (as client here) write info into a DataOutputStream in a sequence (of Byte arrays), then put it into a new Packet.

You send the packet. (from your client, to the server, in your case)

*packet travels safely through the internet*

You receive the packet in your (server here) packet handler class. (IPacketHandler is our common backbone for receiving packets, so you get a call by onPacketData)

You (as server here) read info with a DataInputStream, in same sequence as it was written.

You (as server here) do the changes the data tells.

 

Do you understand till here ?

[You don't really need to understand what DataOutputStream and DataInputStream are doing to the packet, though you need to use them]

Link to comment
Share on other sites

Ok. I did read your text and i can see the differens between datainput/outputstream^^

Now a very important thing. I am still on 1.4.7 so do not forget that.

And i tried to implement a packethandler (i do not know if its working but the code is there)

But now is the problem how do i sync the Infos between my gui and my tile. Because the SyncTileEntities tutorial on forge is like: yeah you do need to sync sometimes manually but a specail explaining is not there.

 

Sry for saying it like that but i always say what i think! ^^

Link to comment
Share on other sites

i actually made that tutorial btw, and its intended for people who have experience with java,but if you need help i will explain in more details if you want

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Link to comment
Share on other sites

you might want to take a look at http://www.minecraftforge.net/wiki/Organising_packet_handlers, another tutorial i made

 

basicly make a class that implements IPacketHandling

 

register that class using

NetworkRegistry.instance().registerChannel(new ServerPacketHandler(), "channelName", Side.SERVER);

or for client:

NetworkRegistry.instance().registerChannel(new ClientPacketHandler(), "channelName", Side.CLIENT);

 

also, GotoLink said use this.mc.getNetHandler().addToSendQueue(packet);

its not bad, but i recommend PacketDispatcher.sendPacketToServer(packet);

its the same, except if you ever send a packet from somewhere else then a gui you wont have access to a Minecraft reference

and using PacketDispatcher server side has some convinient methods

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Link to comment
Share on other sites

Yeah that would maybe work but i do not get Anything done with it.

I tried to register a packetHandler and if i trie that then the game crashes and the game says Invalid Channel name. My Channel name is: "TinyModularThings"

 

Here are the classes^^.

 

xD if the forge forum would not block my PrimäryBrowserIP then i could read the answers better xD but that is not interessting now!

Link to comment
Share on other sites

Classes:

 

ModClass:

package speiger.src.tinychest;

import java.io.File;
import java.util.logging.Logger;

import net.minecraft.creativetab.CreativeTabs;
import speiger.src.api.api.modules.advanced.ModulRecipeRegister;
import speiger.src.tinychest.addons.AddonHelper;
import speiger.src.tinychest.common.config.TinyConfig;
import speiger.src.tinychest.common.config.TinyTileRegistry;
import speiger.src.tinychest.common.core.CreativeTapTinyChest;
import speiger.src.tinychest.common.core.TinyChestCore;
import speiger.src.tinychest.common.core.helpers.RecipeHelper;
import speiger.src.tinychest.common.lib.TinyChestRecipes;
import speiger.src.tinychest.common.lib.TinyChestReference;
import speiger.src.tinychest.common.packet.SpmodPackets;
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.LanguageRegistry;
import cpw.mods.fml.relauncher.Side;


@Mod(modid = TinyChestReference.TinyID, name = TinyChestReference.TinyName, version = TinyChestReference.TinyVersion, dependencies = "required-after:SpmodAPI")
@NetworkMod(clientSideRequired = true, serverSideRequired = false, channels = "TinyModularThings", packetHandler = SpmodPackets.class)
public class TinyChest 
{
@SidedProxy(clientSide = TinyChestReference.TinyClient, serverSide = TinyChestReference.TinyCore)
public static TinyChestCore core;

@Instance(TinyChestReference.TinyID)
public static TinyChest instance;

public static Logger tinyLogger = Logger.getLogger("TinyChestReference.TinyName");

public static CreativeTabs tinyChest = new CreativeTapTinyChest(CreativeTabs.getNextID(), TinyChestReference.TinyID);


@PreInit
    public void preInit(FMLPreInitializationEvent par1)
{

	NetworkRegistry.instance().registerGuiHandler(this, core);
	NetworkRegistry.instance().registerChannel(new SpmodPackets(), "TinyModularThings");
	instance = this;

	TinyConfig.loadTinyChests(new File(par1.getModConfigurationDirectory(), "Spmod/TinyChest.cfg"));
	LanguageRegistry.instance().addStringLocalization("itemGroup."+TinyChestReference.TinyID, "Tiny Chest");
    }



@Init
public void load(FMLInitializationEvent evt)
{

	ModulRecipeRegister.RegisterModulReicpeOutput(new RecipeHelper());
	TinyChestRecipes.loadTinyChests();
	TinyTileRegistry.registerTiles();
	core.registerTileRenders();
	core.preloadTexture();
}


@PostInit
public void modsLoaded(FMLPostInitializationEvent evt) 
{
	AddonHelper.loadAddons();
}

}

 

PacketClass:

package speiger.src.tinychest.common.packet;

import java.io.ByteArrayInputStream;
import java.io.DataInputStream;

import net.minecraft.network.INetworkManager;
import net.minecraft.network.packet.Packet250CustomPayload;
import cpw.mods.fml.common.network.IPacketHandler;
import cpw.mods.fml.common.network.Player;

public class SpmodPackets implements IPacketHandler {

@Override
public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player) 
{

}



}

Link to comment
Share on other sites

well basicly this is the flow of information

lets say i have a block that you can right click to open a gui, and in thsi gui there are buttons to change the values of the block (colors, meta, wtv you can think of)

 

what i want to do is in my gui, when a certain button is pressed (a button labeled "update" or wtv)

send a packet to the server containing every important information, in your case just send a integer that represent what action has been taken (btw i havnt actually read your post, just the few last one where GotoLink says:

On your case, you have a client input (a click). You need to send this info to the server.

so anyway, just feed the integer (or you could also send NOTHING if that teh only kind of packet that is send with thsi channel + the x, y, z coord of the TE (so that server side knows wtf you're talking about, but usually you want to send many different thigns with 1 channel)

on server side when you receive this packet

get the 3 coordinates, get a world ref, get that tile entity using the world ref  and apply the changes you want to the tile entity

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Link to comment
Share on other sites

I have tinkers construct installed (source) and because we have a nearly simmilar way of creating items i watched what he did^^.

 

So now i did a view changes. I Did not test really if it is write. But it does crash nothing!

 

Modfile

package speiger.src.tinychest;

import java.io.File;
import java.util.logging.Logger;

import net.minecraft.creativetab.CreativeTabs;
import speiger.src.api.api.modules.advanced.ModulRecipeRegister;
import speiger.src.tinychest.addons.AddonHelper;
import speiger.src.tinychest.common.config.TinyConfig;
import speiger.src.tinychest.common.config.TinyTileRegistry;
import speiger.src.tinychest.common.core.CreativeTapTinyChest;
import speiger.src.tinychest.common.core.TinyChestCore;
import speiger.src.tinychest.common.core.helpers.RecipeHelper;
import speiger.src.tinychest.common.lib.TinyChestRecipes;
import speiger.src.tinychest.common.lib.TinyChestReference;
import speiger.src.tinychest.common.packet.SpmodPackets;
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.LanguageRegistry;
import cpw.mods.fml.relauncher.Side;


@Mod(modid = TinyChestReference.TinyID, name = TinyChestReference.TinyName, version = TinyChestReference.TinyVersion, dependencies = "required-after:SpmodAPI")
@NetworkMod(clientSideRequired = true, serverSideRequired = false, channels = "TinyChest", packetHandler = SpmodPackets.class)
public class TinyChest 
{
@SidedProxy(clientSide = TinyChestReference.TinyClient, serverSide = TinyChestReference.TinyCore)
public static TinyChestCore core;

@Instance(TinyChestReference.TinyID)
public static TinyChest instance;

public static Logger tinyLogger = Logger.getLogger("TinyChestReference.TinyName");

public static CreativeTabs tinyChest = new CreativeTapTinyChest(CreativeTabs.getNextID(), TinyChestReference.TinyID);


@PreInit
    public void preInit(FMLPreInitializationEvent par1)
{

	NetworkRegistry.instance().registerGuiHandler(this, core);
	NetworkRegistry.instance().registerChannel(new SpmodPackets(), "TinyChest", Side.SERVER);
	instance = this;

	TinyConfig.loadTinyChests(new File(par1.getModConfigurationDirectory(), "Spmod/TinyChest.cfg"));
	LanguageRegistry.instance().addStringLocalization("itemGroup."+TinyChestReference.TinyID, "Tiny Chest");
    }



@Init
public void load(FMLInitializationEvent evt)
{

	ModulRecipeRegister.RegisterModulReicpeOutput(new RecipeHelper());
	TinyChestRecipes.loadTinyChests();
	TinyTileRegistry.registerTiles();
	core.registerTileRenders();
	core.preloadTexture();
}


@PostInit
public void modsLoaded(FMLPostInitializationEvent evt) 
{
	AddonHelper.loadAddons();
}

}

 

Gui

package speiger.src.tinychest.client.gui.machines.machine;

import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;

import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.network.packet.Packet250CustomPayload;
import net.minecraft.util.StatCollector;

import org.lwjgl.opengl.GL11;

import cpw.mods.fml.common.FMLLog;
import cpw.mods.fml.common.network.PacketDispatcher;

import speiger.src.tinychest.common.container.machines.machine.ContainerModuleMaker;
import speiger.src.tinychest.common.tileentity.machines.machine.ModuleMaker;

public class GuiModuleMaker extends GuiContainer 
{
private ModuleMaker tile;

public GuiModuleMaker(InventoryPlayer par1, ModuleMaker par2) 
{
	super(new ContainerModuleMaker(par1, par2));
	tile = par2;
	this.ySize = 232;
	this.xSize = 211;
}

protected void drawGuiContainerForegroundLayer(int par1, int par2)
    {
	this.fontRenderer.drawString("Fast", 38, 128, 0xffffff);
	this.fontRenderer.drawString("Work", 78, 106, 0xffffff);
	this.fontRenderer.drawString("Med", 80, 128, 0xffffff);
	this.fontRenderer.drawString("Slow", 118, 128, 0xffffff);
        this.fontRenderer.drawString("Module Maker", 65, 6, 4210752);
        this.fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 8, this.ySize - 96 + 5, 4210752);
        this.fontRenderer.drawString("Clearing", 153, 10, 0xffffff);
        this.fontRenderer.drawString("Specify", 155, 30, 0xffffff);
        this.fontRenderer.drawString("Production", 146, 50, 0xffffff);
        this.fontRenderer.drawString("AdvProduct", 144, 70, 0xffffff);
        this.fontRenderer.drawString("Upgrade", 153, 90, 0xffffff);
        this.fontRenderer.drawString("Fuel", 164, 110, 0xffffff);
    }

    protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3)
    {
        int var4 = this.mc.renderEngine.getTexture("/speiger/src/tinychest/textures/ModuleMaker.png");
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        this.mc.renderEngine.bindTexture(var4);
        int var5 = (this.width - this.xSize) / 2;
        int var6 = (this.height - this.ySize) / 2;
        this.drawTexturedModalRect(var5, var6, 0, 0, this.xSize, this.ySize);
        int var7;
        
       	if(tile.CanWork())
       	{
       		this.drawTexturedModalRect(72 + var5, 81 + var6 + 22, 222, 24, 35, 15);
       	}
       	
       	if(tile.work == 1)
       	{
       		this.drawTexturedModalRect(72 + var5, 81 + var6 + 22, 222, 41, 35, 15);
       	}

  
        if(tile.button[0] == 1)
        {
        	this.drawTexturedModalRect(32 + var5, 81 + var6 + 44, 222, 41, 35, 15);
       	}
       	if(tile.button[1] == 1)
       	{
       		this.drawTexturedModalRect(72 + var5, 81 + var6 + 44, 222, 41, 35, 15);
       	}
       	if(tile.button[2] == 1)
       	{
       		this.drawTexturedModalRect(112 + var5, 81 + var6 + 44, 222, 41, 35, 15);
        }
        
       	if(tile.progressButton[0] == 1)
       	{
       		this.drawTexturedModalRect(141 + var5, 6 + var6, 138, 234, 64, 15);
       	}
       	
       	if(tile.progressButton[1] == 1)
       	{
       		this.drawTexturedModalRect(141 + var5, 26 + var6, 138, 234, 64, 15);
       	}
        
       	if(tile.progressButton[2] == 1)
       	{
       		this.drawTexturedModalRect(141 + var5, 46 + var6, 138, 234, 64, 15);
       	}
       	
       	if(tile.progressButton[3] == 1)
       	{
       		this.drawTexturedModalRect(141 + var5, 66 + var6, 138, 234, 64, 15);
       	}
       	
       	if(tile.progressButton[4] == 1)
       	{
       		this.drawTexturedModalRect(141 + var5, 86 + var6, 138, 234, 64, 15);
       	}
       	
       	if(tile.progressButton[5] == 1)
       	{
       		this.drawTexturedModalRect(141 + var5, 106 + var6, 138, 234, 64, 15);
       	}
       	
       	
       	
       	
       	
        
    }

    
    public int getButtonprosition(int x, int y) 
    {
    	if(x>=33 && x<=64 && y>=125 && y<=139)return 1;
    	else if(x>=73 && x<=104 && y>=125 && y<=139)return 2;
    	else if(x>=113 && x<=144 && y>=125 && y<=139)return 3;
    	
    	else if(x>=141 && x<=204 && y>=6 && y<=20)return 4;
    	else if(x>=141 && x<=204 && y>=26 && y<=40)return 5;
    	else if(x>=141 && x<=204 && y>=46 && y<=60)return 6;
//    	else if(x>=141 && x<=204 && y>=66 && y<=80)return 7;
//    	else if(x>=141 && x<=204 && y>=86 && y<=100)return 8;
//    	else if(x>=141 && x<=204 && y>=106 && y<=120)return 9;
    	else if(x>=73 && x<=104 && y>=103 && y<=117)return 10;
    	else return 0;
    }
    

    


@Override
protected void mouseClicked(int par1, int par2, int par3) 
{
	super.mouseClicked(par1, par2, par3);



	int cornerX = (width - xSize) / 2;
	int cornerY = (height - ySize) / 2;

	int prosition = getButtonprosition(par1 - cornerX, par2 - cornerY);

	if(prosition != 0)
	{
		tile.progress = 0;
		tile.canWork = false;
		tile.work = 0;
		this.sendPacket(prosition);
		if(prosition == 1)
		{
			tile.button[0] = 1;
			tile.button[1] = 0;
			tile.button[2] = 0;
		}
		if(prosition == 2)
		{
			tile.button[0] = 0;
			tile.button[1] = 1;
			tile.button[2] = 0;
		}
		if(prosition == 3)
		{
			tile.button[0] = 0;
			tile.button[1] = 0;
			tile.button[2] = 1;
		}

		if(prosition == 4)
		{
			tile.progressButton[0] = 1;
			tile.progressButton[1] = 0;
			tile.progressButton[2] = 0;
			tile.progressButton[3] = 0;
			tile.progressButton[4] = 0;
			tile.progressButton[5] = 0;
		}
		if(prosition == 5)
		{
			tile.progressButton[0] = 0;
			tile.progressButton[1] = 1;
			tile.progressButton[2] = 0;
			tile.progressButton[3] = 0;
			tile.progressButton[4] = 0;
			tile.progressButton[5] = 0;
		}
		if(prosition == 6)
		{
			tile.progressButton[0] = 0;
			tile.progressButton[1] = 0;
			tile.progressButton[2] = 1;
			tile.progressButton[3] = 0;
			tile.progressButton[4] = 0;
			tile.progressButton[5] = 0;
		}
		if(prosition == 7)
		{
			tile.progressButton[0] = 0;
			tile.progressButton[1] = 0;
			tile.progressButton[2] = 0;
			tile.progressButton[3] = 1;
			tile.progressButton[4] = 0;
			tile.progressButton[5] = 0;
		}
		if(prosition == 
		{
			tile.progressButton[0] = 0;
			tile.progressButton[1] = 0;
			tile.progressButton[2] = 0;
			tile.progressButton[3] = 0;
			tile.progressButton[4] = 1;
			tile.progressButton[5] = 0;
		}

		if(prosition == 9)
		{
			tile.progressButton[0] = 0;
			tile.progressButton[1] = 0;
			tile.progressButton[2] = 0;
			tile.progressButton[3] = 0;
			tile.progressButton[4] = 0;
			tile.progressButton[5] = 1;
		}

		if(prosition == 10)
		{
			if(tile.work == 0 && tile.canWork)
			{
				tile.work = 1;
			}
			else
			{
				if(tile.work == 1)
				{
					tile.work = 0;
				}
			}
		}
	}
}

public void sendPacket(int prosition) 
{
	ByteArrayOutputStream bitout = new ByteArrayOutputStream(;
	DataOutputStream output = new DataOutputStream(bitout);

	try 
	{
		output.writeByte(1);
		output.writeInt(tile.worldObj.provider.dimensionId);
		output.writeInt(tile.xCoord);
		output.writeInt(tile.yCoord);
		output.writeInt(tile.zCoord);
		output.writeInt(prosition);
		FMLLog.getLogger().info("Send Data");
	}
	catch (Exception e) 
	{
		FMLLog.getLogger().info("Send Data");
		e.printStackTrace();
	}

	Packet250CustomPayload packet = new Packet250CustomPayload();
	packet.channel = "TinyChests";
	packet.data = bitout.toByteArray();
	packet.length = bitout.size();
	PacketDispatcher.sendPacketToServer(packet);
}

}

 

PacketHandler

package speiger.src.tinychest.common.packet;

import java.io.ByteArrayInputStream;
import java.io.DataInputStream;

import net.minecraft.network.INetworkManager;
import net.minecraft.network.packet.Packet250CustomPayload;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.DimensionManager;
import speiger.src.tinychest.common.tileentity.machines.machine.ModuleMaker;
import cpw.mods.fml.common.FMLLog;
import cpw.mods.fml.common.network.IPacketHandler;
import cpw.mods.fml.common.network.Player;

public class SpmodPackets implements IPacketHandler {

@Override
public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player) 
{
	if(packet.channel.equals("TinyChest"))
	{
		handlePacket(packet);
	}
}

void handlePacket(Packet250CustomPayload packet) 
{
	DataInputStream input = new DataInputStream(new ByteArrayInputStream(packet.data));
	byte packetID;
	int dimID;
	try 
	{
		FMLLog.getLogger().info("Test");
		packetID = input.readByte();
		dimID = input.readInt();

		World world = DimensionManager.getWorld(dimID);

		if(packetID == 1)//ModuleMaker
		{
			FMLLog.getLogger().info("Test2");
			int x = input.readInt();
			int y = input.readInt();
			int z = input.readInt();
			int prosition = input.readInt();
			TileEntity tile = world.getBlockTileEntity(x, y, z);
			if(tile != null && tile instanceof ModuleMaker)
			{
				ModuleMaker mod = (ModuleMaker) tile;
				mod.runTest();
			}
		}


	}
	catch (Exception e) 
	{
		System.out.println("[TinyChest] Error on Sending Packet");
		e.printStackTrace();
		return;
	}
}



}

 

It does crash nothing and something does he do but what he do i do not know^^

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • https://mclo.gs/4UC49Ao
    • Way back in the Forge 1.17 days, work started for adding JPMS (Java Platform Module Support) to ModLauncher and ForgeModLoader. This has been used internally by Forge and some libraries for a while now, but mods (those with mods.toml specifically) have not been able to take advantage of it. As of Forge 1.21.1 and 1.21.3, this is now possible!   What is JPMS and what does it mean for modders? JPMS is the Java Platform Module System, introduced in Java 9. It allows you to define modules, which are collections of packages and resources that can be exported or hidden from other modules. This allows for much more fine-tuned control over visibility, cleaner syntax for service declarations and support for sealed types across packages. For example, you might have a mod with a module called `com.example.mod` that exports `com.example.mod.api` and `com.example.mod.impl` to other mods, but hides `com.example.mod.internal` from them. This would allow you to have a clean API for other mods to use, while keeping your internal implementation details hidden from IDE hints, helping prevent accidental usage of internals that might break without prior notice. This is particularly useful if you'd like to use public records with module-private constructors or partially module-private record components, as you can create a sealed interface that only your record implements, having the interface be exported and the record hidden. It's also nice for declaring and using services, as you'll get compile-time errors from the Java compiler for typos and the like, rather than deferring to runtime errors. In more advanced cases, you can also have public methods that are only accessible to specific other modules -- handy if you want internal interactions between multiple of your own mods.   How do I bypass it? We understand there may be drama in implementing a system that prevents mods from accessing each other's internals when necessary (like when a mod is abandoned or you need to fix a compat issue) -- after all, we are already modding a game that doesn't have explicit support for Java mods yet. We have already thought of this and are offering APIs from day one to selectively bypass module restrictions. Let me be clear: Forge mods are not required to use JPMS. If you don't want to use it, you don't have to. The default behaviour is to have fully open, fully exported automatic modules. In Java, you can use the `Add-Opens` and `Add-Exports` manifest attributes to selectively bypass module restrictions of other mods at launch time, and we've added explicit support for these when loading your Forge mods. At compile-time, you can use existing solutions such as the extra-java-module-info Gradle plugin to deal with non-modular dependencies and add extra opens and exports to other modules. Here's an example on how to make the internal package `com.example.examplemod.internal` open to your mod in your build.gradle: tasks.named('jar', Jar) { manifest { attributes([ 'Add-Opens' : 'com.example.examplemod/com.example.examplemod.internal' 'Specification-Title' : mod_id, 'Specification-Vendor' : mod_authors // (...) ]) } } With the above in your mod's jar manifest, you can now reflectively access the classes inside that internal package. Multiple entries are separated with a space, as per Java's official spec. You can also use Add-Exports to directly call without reflection, however you'd need to use the Gradle plugin mentioned earlier to be able to compile. The syntax for Add-Exports is the same as Add-Opens, and instructions for the compile-time step with the Gradle plugin are detailed later in this post. Remember to prefer the opens and exports keywords inside module-info.java for sources you control. The Add-Opens/Add-Exports attributes are only intended for forcing open other mods.   What else is new with module support? Previously, the runtime module name was always forced to the first mod ID in your `mods.toml` file and all packages were forced fully open and exported. Module names are now distinguished from mod IDs, meaning the module name in your module-info.java can be different from the mod ID in your `mods.toml`. This allows you to have a more descriptive module name that doesn't have to be the same as your mod ID, however we strongly recommend including your mod ID as part of your module name to aid troubleshooting. The `Automatic-Module-Name` manifest attribute is now also honoured, allowing you to specify a module name for your mod without needing to create a `module-info.java` file. This is particularly useful for mods that don't care about JPMS features but want to have a more descriptive module name and easier integration with other mods that do use JPMS.   How do I use it? The first step is to create a `module-info.java` file in your mod's source directory. This file should be in the same package as your main mod class, and should look something like this: open module com.example.examplemod { requires net.minecraftforge.eventbus; requires net.minecraftforge.fmlcore; requires net.minecraftforge.forge; requires net.minecraftforge.javafmlmod; requires net.minecraftforge.mergetool.api; requires org.slf4j; requires logging; } For now, we're leaving the whole module open to reflection, which is a good starting point. When we know we want to close something off, we can remove the open modifier from the module and open or export individual packages instead. Remember that you need to be open to Forge (module name net.minecraftforge.forge), otherwise it can't call your mod's constructor. Next is fixing modules in Gradle. While Forge and Java support modules properly, Gradle does not put automatic modules on the module path by default, meaning that the logging module (from com.mojang:logging) is not found. To fix this, add the Gradle plugin and add a compile-time module definition for that Mojang library: plugins { // (...) id 'org.gradlex.extra-java-module-info' version "1.9" } // (...) extraJavaModuleInfo { failOnMissingModuleInfo = false automaticModule("com.mojang:logging", "logging") } The automatic module override specified in your build.gradle should match the runtime one to avoid errors. You can do the same for any library or mod dependency that is missing either a module-info or explicit Automatic-Module-Name, however be aware that you may need to update your mod once said library adds one. That's all you need to get started with module support in your mods. You can learn more about modules and how to use them at dev.java.
    • Faire la mise à jour grâce à ce lien m'a aider personnellement, merci à @Paint_Ninja. https://www.amd.com/en/support 
    • When I came across the 'Exit Code: I got a 1 error in my Minecraft mods, so I decided to figure out what was wrong. First, I took a look at the logs. In the mods folder (usually where you'd find logs or crash reports), I found the latest.log file or the corresponding crash report. I read it through carefully, looking for any lines with errors or warnings. Then I checked the Minecraft Forge support site, where you can often find info on what causes errors and how to fix them. I then disabled half of my mods and tried running the game. If the error disappeared, it meant that the problem was with the disabled mod. I repeated this several times to find the problem mod.
    • I have no idea - switch to a pre-configured modpack and use it as working base    
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.