Jump to content

Help with Modding!!


Mavigno42

Recommended Posts

Just a heads up:  english is not my native language, I'm new to Java therefore to Minecraft modding too and I'm following as base the EE3 and MinecraftByExample Codes as well as McJty Wiki (http://wiki.mcjty.eu/modding/index.php/Main_Page);

OBS.: McJty's Code it's actually ported to 1.10.2 and I use it to understand the How's to make a TileEntity with GUI and a Inventory.

 

Right now I have two errors, at least that it´s all think I have. 

 

NUMBER 1: I've been struggling with localization. Basically it was all fine until I tried to upgrade my ItemBase.class (it's package "com.mavigno.modtest.common.items.base") so I would be able to add ItemVariants too my Mod, now nothing seems to be localized any more;

 

NUMBER 2: In the past couple weeks I've been trying to make a TIleEntity that can hold Items and have a GUI, like a Chest. I got everything set and ready, but the TileEntity won't save it's content on a world close.

 

Container related classes are in this package "com.mavigno.modtest.client.gui.container.base",

"com.mavigno.modtest.client.gui.GuiBasicInventory" is the class responsable for drawing the GUI,

everything related to how I'm handling TileEntities it's ih this package "com.mavigno.modtest.tileentity",

GuiHandler "com.mavigno.modtest.handler.GuiHandler".

 

IDE: IntellijIDEA 2017.1;

Forge Version: 1.11-13.19.1.2189;

Minecraft Version: 1.11;

Java: 1.8;

GitHub Access to the Code: https://github.com/Mavigno42/ModTest;

 

Anything out of common please point out, this Mod is attempt of trying to learn how to actually do it!

 

 

Link to comment
Share on other sites

1) https://github.com/Mavigno42/ModTest/tree/master/src/main/resources/assets/modtest/lang

You need to rename that file as en_us.lang as all resources must be in lower case.

 

2)

Part a: https://github.com/Mavigno42/ModTest/blob/master/src/main/java/com/mavigno/modtest/tileentity/base/TileEntityBasicInventory.java#L15

You don't need implements ICapabilityProvider, TileEntity already implements that interface.

Part b: https://github.com/Mavigno42/ModTest/blob/master/src/main/java/com/mavigno/modtest/tileentity/base/TileEntityBasicInventory.java#L17

Pretty sure you can't create the ItemHandler like this, as the SIZE value is coming from the constructor, but at the time that this field is initialized, the constructor has not yet been called.

  • Like 1

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

11 hours ago, Draco18s said:

1) https://github.com/Mavigno42/ModTest/tree/master/src/main/resources/assets/modtest/lang

You need to rename that file as en_us.lang as all resources must be in lower case.

 

2)

Part a: https://github.com/Mavigno42/ModTest/blob/master/src/main/java/com/mavigno/modtest/tileentity/base/TileEntityBasicInventory.java#L15

You don't need implements ICapabilityProvider, TileEntity already implements that interface.

Part b: https://github.com/Mavigno42/ModTest/blob/master/src/main/java/com/mavigno/modtest/tileentity/base/TileEntityBasicInventory.java#L17

Pretty sure you can't create the ItemHandler like this, as the SIZE value is coming from the constructor, but at the time that this field is initialized, the constructor has not yet been called.

1) I renamed the Lang file to en_us.lang, but it didn't change anything.2017-03-27_11_00_20.png.31e25fb0fbe2c7ad80de2a75cb761280.png

 

2) Changed some things, still doesn't work:

public class TileEntityBasicInventory extends TileEntityBase {

    protected NonNullList<ItemStack> tileEntityContents;
    protected StackHandler stackHandler;

    public TileEntityBasicInventory(String name, short numberOfSlots) {
        super(name, numberOfSlots);
        tileEntityContents = NonNullList.<ItemStack>func_191197_a(numberOfSlots, ItemStack.field_190927_a);
        stackHandler = new StackHandler(this, numberOfSlots);
    }

    @Override
    public void readFromNBT(NBTTagCompound compound) {
        super.readFromNBT(compound);
        ItemStackHelper.func_191283_b(compound, this.tileEntityContents);
    }

    @Override
    public NBTTagCompound writeToNBT(NBTTagCompound compound) {
        super.writeToNBT(compound);
        ItemStackHelper.func_191282_a(compound, this.tileEntityContents);
        return compound;
    }

    @Override
    public boolean hasCapability(Capability<?> capability, EnumFacing enumFacing) {
        if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
            return true;
        return super.hasCapability(capability, enumFacing);
    }

    @Override
    public <T> T getCapability(Capability<T> capability, EnumFacing enumFacing) {
        if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
            return (T) stackHandler;
        return super.getCapability(capability, enumFacing);
    }
}

StackHandler class

public class StackHandler extends ItemStackHandler {

    private final TileEntityBase tileEntityBase;

    public StackHandler(TileEntityBase tileEntityBase, int size) {
        super(size);
        this.tileEntityBase = tileEntityBase;
    }

    @Override
    protected void onContentsChanged(int slot)  {
        tileEntityBase.markDirty();
    }
}

 

The Log - (from World Start to World Close)

MinecraftLog.txt

 

I didn't Push the changes to the GitHub access by the way.

Link to comment
Share on other sites

There's a lot I can only infer, namely all those SRG function names. I assume you're calling the right methods, but I have no way to tell.

Are you on the latest MCP mapping?

Edited by Draco18s

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Update them.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

My lang file assignments omit my mod name from the middle . Try deleting "modtest:" from your test case to see if it works. Example:  tile.ruby_block.name=Block of Ruby

 

Also, my last lang filename (for mc 1.10.2) capitalized the US (imitating vanilla). Is that changing in 1.11+? I suppose I'll find out in a hurry when I do my next upgrade cycle.

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Link to comment
Share on other sites

4 minutes ago, jeffryfisher said:

Also, my last lang filename (for mc 1.10.2) capitalized the US (imitating vanilla). Is that changing in 1.11+? I suppose I'll find out in a hurry when I do my next upgrade cycle.

Yes.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

30 minutes ago, jeffryfisher said:

My lang file assignments omit my mod name from the middle . Try deleting "modtest:" from your test case to see if it works. Example:  tile.ruby_block.name=Block of Ruby

Tried that, it didn't work, and if did it would be very confusing since I'm handling the getUnlocalizedName. 

@Override
public String getUnlocalizedName(ItemStack itemStack) {
    if (hasSubtypes && itemStack.getMetadata() < VARIANTS.length)
        return String.format("item.%s:%s", Reference.MOD_ID, VARIANTS[itemStack.getMetadata()]);
    else
        return String.format("item.%s:%s", Reference.MOD_ID, ITEM_BASE_NAME);
}
Link to comment
Share on other sites

On 27/03/2017 at 0:34 PM, Draco18s said:

Update them.

Did the MCP update and updated my code to suit the change

public class TileEntityBasicInventory extends TileEntityBase {

    protected NonNullList<ItemStack> tileEntityContents;
    protected StackHandler stackHandler;

    public TileEntityBasicInventory(String name, short numberOfSlots) {
        super(name, numberOfSlots);
        tileEntityContents = NonNullList.<ItemStack>withSize(numberOfSlots, ItemStack.EMPTY);
        stackHandler = new StackHandler(this, numberOfSlots);
    }

    @Override
    public void readFromNBT(NBTTagCompound compound) {
        super.readFromNBT(compound);
        ItemStackHelper.loadAllItems(compound, this.tileEntityContents);
    }

    @Override
    public NBTTagCompound writeToNBT(NBTTagCompound compound) {
        super.writeToNBT(compound);
        ItemStackHelper.saveAllItems(compound, this.tileEntityContents);
        return compound;
    }

    @Override
    public boolean hasCapability(Capability<?> capability, EnumFacing enumFacing) {
        if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
            return true;
        return super.hasCapability(capability, enumFacing);
    }

    @Override
    public <T> T getCapability(Capability<T> capability, EnumFacing enumFacing) {
        if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
            return (T) stackHandler;
        return super.getCapability(capability, enumFacing);
    }
}

StackHandler

public class StackHandler extends ItemStackHandler {

    private final TileEntityBase tileEntityBase;

    public StackHandler(TileEntityBase tileEntityBase, int size) {
        super(size);
        this.tileEntityBase = tileEntityBase;
    }

    @Override
    protected void onContentsChanged(int slot)  {
        tileEntityBase.markDirty();
    }
}

 

Nothing changed :(

I actually had to redo my setup and create a new Repo and run setupDecompWorkspace... But the Gradle Idea setup wasn't perfect, I had to manually reassign the Source and Resources Directories.

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.



×
×
  • Create New...

Important Information

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