Jump to content

TileEntity inventory without using IInventory?


memcallen

Recommended Posts

I don't know if this is the correct way to store items in nbt but heres my code:

package com.example.gammacraft.TileEntity;

import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;

public class MultiToolModifierTileEntity extends TileEntity {

public ItemStack[] inv;

public MultiToolModifierTileEntity() {
	inv=new ItemStack[10];
}

public Packet getDescriptionPacket() {
        NBTTagCompound nbtTag = new NBTTagCompound();
        this.writeToNBT(nbtTag);
        return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, nbtTag);
}

public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet) {
        readFromNBT(packet.func_148857_g());
}

public void writeToNBT(NBTTagCompound nbt){

	for(int i =1;i==inv.length;){
		NBTTagCompound NBT = new NBTTagCompound();
		inv[i].writeToNBT(NBT);
		nbt.setTag("ItemStack"+i,NBT);
		nbt.setTag("ItemStackData"+i, inv[i].stackTagCompound);
	}


}

public void readFromNBT(NBTTagCompound nbt){

	for(int i =1;i==inv.length;){
		NBTTagCompound itemstack = nbt.getCompoundTag("ItemStack"+i);
		NBTTagCompound data = nbt.getCompoundTag("ItemStackData"+i);

		inv[i]=ItemStack.loadItemStackFromNBT(itemstack);
		inv[i].stackTagCompound=data;

	}

}

}

 

I currently have it take the item in my hand and it puts the item in the ItemStack[] "inv"- thats the part that works. I can't make it save to NBT, for whatever reason. If you were wondering why I'm not using IInventory, it's because I don't want this block to be able to be automated-its my version of a crafting table.

The proud(ish) developer of Ancients

Link to comment
Share on other sites

Do you know how to loop?  At all?

 

This line is wrong, very very wrong.

 

for(int i =1;i==inv.length;)

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

for(a; b; c) { d }

is the same thing as

a;
while(b); {
  d;
  c;
}

 

Hint: where are  you changing the value of i?

 

Edit:

Whoops.  Made a mistake late last night.

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

whatever, I changed the code to this:

package com.example.gammacraft.TileEntity;

import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;

public class MultiToolModifierTileEntity extends TileEntity {

public ItemStack[] inv;

public MultiToolModifierTileEntity() {
	inv=new ItemStack[10];
}

public Packet getDescriptionPacket() {
        NBTTagCompound nbtTag = new NBTTagCompound();
        this.writeToNBT(nbtTag);
        return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, nbtTag);
}

public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet) {
        readFromNBT(packet.func_148857_g());
}

public void writeToNBT(NBTTagCompound nbt){

	for(int i =1;i==inv.length;i++){
		NBTTagCompound NBT = new NBTTagCompound();
		inv[i].writeToNBT(NBT);
		nbt.setTag("ItemStack"+i,NBT);
		nbt.setTag("ItemStackData"+i, inv[i].stackTagCompound);
	}


}

public void readFromNBT(NBTTagCompound nbt){

	for(int i =1;i==inv.length;i++){
		NBTTagCompound itemstack = nbt.getCompoundTag("ItemStack"+i);
		NBTTagCompound data = nbt.getCompoundTag("ItemStackData"+i);

		inv[i]=ItemStack.loadItemStackFromNBT(itemstack);
		inv[i].stackTagCompound=data;

	}

}

}

 

but it still doesn't save the stack.

The proud(ish) developer of Ancients

Link to comment
Share on other sites

Oh, I though the i++ was optional0

 

Optional in the sense that if you don't have it, the program can still function...for some definition of function.  It is possible to write a for loop thus:

 

for(;{
    //code
}

 

But you kind of have to know WTF you're doing to use it that way.  Also, the missing i++ is not your only problem.

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

ok I'm getting somewhere, I changed the for loops to for(int i = 0;i!=inv.length+1;i++){//do stuff}, and I added a try/catch around a line in the read func, but I'm getting an error with the function "func_150298_a" I googled it and I'm writing an  nbt tag to itself, but I can't see where or how. btw there is no error showing me where the line is thats causing the error.

 

stacktrace:

java.lang.NullPointerException
at net.minecraft.nbt.NBTTagCompound.func_150298_a(NBTTagCompound.java:309)
at net.minecraft.nbt.NBTTagCompound.write(NBTTagCompound.java:23)
at net.minecraft.nbt.NBTTagList.write(NBTTagList.java:35)
at net.minecraft.nbt.NBTTagCompound.func_150298_a(NBTTagCompound.java:314)
at net.minecraft.nbt.NBTTagCompound.write(NBTTagCompound.java:23)
at net.minecraft.nbt.NBTTagCompound.func_150298_a(NBTTagCompound.java:314)
at net.minecraft.nbt.NBTTagCompound.write(NBTTagCompound.java:23)
at net.minecraft.nbt.CompressedStreamTools.func_150663_a(CompressedStreamTools.java:146)
at net.minecraft.nbt.CompressedStreamTools.write(CompressedStreamTools.java:136)
at net.minecraft.world.chunk.storage.AnvilChunkLoader.writeChunkNBTTags(AnvilChunkLoader.java:197)
at net.minecraft.world.chunk.storage.AnvilChunkLoader.writeNextIO(AnvilChunkLoader.java:183)
at net.minecraft.world.storage.ThreadedFileIOBase.processQueue(ThreadedFileIOBase.java:30)
at net.minecraft.world.storage.ThreadedFileIOBase.run(ThreadedFileIOBase.java:23)
at java.lang.Thread.run(Unknown Source)

 

This doesn't crash me but I have no idea how to fix it.

 

EDIT:

the error only gets thrown when I take the item out of my block.

The proud(ish) developer of Ancients

Link to comment
Share on other sites

Good luck sorting through the onBlockActivated code...

 

package com.example.gammacraft.blocks.Machines;

import com.example.gammacraft.RandomFunctions;
import com.example.gammacraft.gammacraft;
import com.example.gammacraft.TileEntity.MultiToolModifierTileEntity;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;

public class MultiToolModifier extends BlockContainer {

public MultiToolModifier() {
	super(Material.iron);
	this.setBlockBounds(0F, 0F, 0F, 1F, 0.25F, 1F);
	this.setBlockName("MultiToolModifier");
	this.setCreativeTab(gammacraft.gammacraftcreativetab);
}

float pixel = 1F/16F;

@Override
public boolean onBlockActivated(World world,int x,int y,int z,EntityPlayer player,int side,float hx,float hy,float hz){
	MultiToolModifierTileEntity te = (MultiToolModifierTileEntity)world.getTileEntity(x, y, z);

		if(side==1){
			//slot 1
			if(withinBounds(hx,pixel*2,pixel*4)&&withinBounds(hz,pixel*4,pixel*6)){
				if(!world.isRemote)
				System.out.println("Button 1 is pressed");

				if(te.inv[0]!=null){
					player.inventory.mainInventory[player.inventory.currentItem]=te.inv[0];
					te.inv[0]=null;
				}else{
					te.inv[0]=player.inventory.mainInventory[player.inventory.currentItem];
					player.inventory.mainInventory[player.inventory.currentItem]=null;
				}

				return true;
			}
			//slot 2
			if(withinBounds(hx,pixel*2,pixel*4)&&withinBounds(hz,pixel*7,pixel*9)){
				if(!world.isRemote)
					System.out.println("Button 2 is pressed");

				if(te.inv[1]!=null){
					player.inventory.mainInventory[player.inventory.currentItem]=te.inv[1];
					te.inv[1]=null;
				}else{
					te.inv[1]=player.inventory.mainInventory[player.inventory.currentItem];
					player.inventory.mainInventory[player.inventory.currentItem]=null;
				}


					return true;
			}
			//slot 3
			if(withinBounds(hx,pixel*2,pixel*4)&&withinBounds(hz,pixel*10,pixel*12)){
				if(!world.isRemote)
					System.out.println("Button 3 is pressed");

				if(te.inv[2]!=null){
					player.inventory.mainInventory[player.inventory.currentItem]=te.inv[2];
					te.inv[2]=null;
				}else{
					te.inv[2]=player.inventory.mainInventory[player.inventory.currentItem];
					player.inventory.mainInventory[player.inventory.currentItem]=null;
				}

					return true;
			}
			//slot 4
			if(withinBounds(hx,pixel*5,pixel*7)&&withinBounds(hz,pixel*4,pixel*6)){
				if(!world.isRemote)
					System.out.println("Button 4 is pressed");

				if(te.inv[3]!=null){
					player.inventory.mainInventory[player.inventory.currentItem]=te.inv[3];
					te.inv[3]=null;
				}else{
					te.inv[3]=player.inventory.mainInventory[player.inventory.currentItem];
					player.inventory.mainInventory[player.inventory.currentItem]=null;
				}

					return true;
			}
			//slot 5
			if(withinBounds(hx,pixel*5,pixel*7)&&withinBounds(hz,pixel*7,pixel*9)){
				if(!world.isRemote)
					System.out.println("Button 5 is pressed");

				if(te.inv[4]!=null){
					player.inventory.mainInventory[player.inventory.currentItem]=te.inv[4];
					te.inv[4]=null;
				}else{
					te.inv[4]=player.inventory.mainInventory[player.inventory.currentItem];
					player.inventory.mainInventory[player.inventory.currentItem]=null;
				}

					return true;
			}
			//slot 6
			if(withinBounds(hx,pixel*5,pixel*7)&&withinBounds(hz,pixel*10,pixel*12)){
				if(!world.isRemote)
					System.out.println("Button 6 is pressed");

				if(te.inv[5]!=null){
					player.inventory.mainInventory[player.inventory.currentItem]=te.inv[5];
					te.inv[5]=null;
				}else{
					te.inv[5]=player.inventory.mainInventory[player.inventory.currentItem];
					player.inventory.mainInventory[player.inventory.currentItem]=null;
				}

					return true;
			}
			//slot 7
			if(withinBounds(hx,pixel*8,pixel*10)&&withinBounds(hz,pixel*4,pixel*6)){
				if(!world.isRemote)
					System.out.println("Button 7 is pressed");

				if(te.inv[6]!=null){
					player.inventory.mainInventory[player.inventory.currentItem]=te.inv[6];
					te.inv[6]=null;
				}else{
					te.inv[6]=player.inventory.mainInventory[player.inventory.currentItem];
					player.inventory.mainInventory[player.inventory.currentItem]=null;
				}

					return true;
			}
			//slot 8
			if(withinBounds(hx,pixel*8,pixel*10)&&withinBounds(hz,pixel*7,pixel*9)){
				if(!world.isRemote)
					System.out.println("Button 8 is pressed");

				if(te.inv[7]!=null){
					player.inventory.mainInventory[player.inventory.currentItem]=te.inv[7];
					te.inv[7]=null;
				}else{
					te.inv[7]=player.inventory.mainInventory[player.inventory.currentItem];
					player.inventory.mainInventory[player.inventory.currentItem]=null;
				}

					return true;
			}
			//slot 9
			if(withinBounds(hx,pixel*8,pixel*10)&&withinBounds(hz,pixel*10,pixel*12)){
				if(!world.isRemote)
					System.out.println("Button 9 is pressed");

				if(te.inv[8]!=null){
					player.inventory.mainInventory[player.inventory.currentItem]=te.inv[8];
					te.inv[8]=null;
				}else{
					te.inv[8]=player.inventory.mainInventory[player.inventory.currentItem];
					player.inventory.mainInventory[player.inventory.currentItem]=null;
				}

					return true;
			}
			//slot 10 (output)
			if(withinBounds(hx,pixel*12,pixel*14)&&withinBounds(hz,pixel*7,pixel*9)){
				if(!world.isRemote)
					System.out.println("Button 10 is pressed");

				if(te.inv[9]!=null){
					player.inventory.mainInventory[player.inventory.currentItem]=te.inv[9];
					te.inv[9]=null;
				}

					return true;
			}
		}

	return false;
}




@Override
public TileEntity createNewTileEntity(World var1, int var2) {
	return new MultiToolModifierTileEntity();
}

@SideOnly(Side.CLIENT)
public static IIcon sideIcon;
@SideOnly(Side.CLIENT)
public static IIcon bottom;
@SideOnly(Side.CLIENT)
public static IIcon top;

public void registerBlockIcons(IIconRegister i){
	sideIcon = i.registerIcon("gammacraft:FireJetSide");
	top = i.registerIcon("gammacraft:MultiToolModifierTop");
}

public IIcon getIcon(int side, int meta){
	if(side==1)return top;
	else return sideIcon;
}


public boolean withinBounds(float x, float min,float max){
	return x>min&&x<max;
}
}

 

EDIT:

you're lucky I decided to make a youtube video on how it works in the world. Should make it easier to figure out how it works.

The proud(ish) developer of Ancients

Link to comment
Share on other sites

...you're going to need to figure out for loops before you can even get to GL11 operations.

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

I don't even care anymore, I figured out for loops. I figured out GUIs I haven't figured out where to render it. I know how to render it. I've used GL11 and the tessellators before. Honestly, this topic isn't about for loops its about ItemStacks not saving in nbt, so please either answer my first question or don't answer at all.

The proud(ish) developer of Ancients

Link to comment
Share on other sites

this topic isn't about for loops its about ItemStacks not saving in nbt

 

Your items aren't saving because your for loop is fucked up.

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

I see a few of problems,

 

You're storing the ItemStack's NBTTagCompound twice.

You never call markDirty()

You never do null checks.

You do a lot of stuff on both Sides, which can cause one Side to have the wrong information.

You are setting the player's held Item, without making sure it's empty first.

Link to comment
Share on other sites

This is the Itemstack writeToNBT method:

 

    /**
     * Write the stack fields to a NBT object. Return the new NBT object.
     */
    public NBTTagCompound writeToNBT(NBTTagCompound p_77955_1_)
    {
        p_77955_1_.setShort("id", (short)Item.getIdFromItem(this.field_151002_e));
        p_77955_1_.setByte("Count", (byte)this.stackSize);
        p_77955_1_.setShort("Damage", (short)this.itemDamage);

        if (this.stackTagCompound != null)
        {
            p_77955_1_.setTag("tag", this.stackTagCompound);
        }

        return p_77955_1_;
    }

 

It checks and stores the stackTagCompound, which you store a second time in your writeToNBT:

 

			nbt.setTag("ItemStack"+i,NBT); // Stores the NBT.stackTagCompound Tag
		nbt.setTag("ItemStackData"+i, inv[i].stackTagCompound); // Duplicate Tag

 

 

 

markDirty() is a method on TileEntity. It ensures that the TileEntity is saved. Even if Minecraft would normally not save it, for example, when no blocks have changed.

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

    • [03Jun2024 15:23:40.010] [main/INFO] [cpw.mods.modlauncher.Launcher/MODLAUNCHER]: ModLauncher running: args [--username, LondonDumbden, --version, 1.20.1-forge-47.2.32, --gameDir, C:\Users\London Bunden\AppData\Roaming\.minecraft, --assetsDir, C:\Users\London Bunden\AppData\Roaming\.minecraft\assets, --assetIndex, 5, --uuid, da3510f9b4b4427bb78304c88f4c534a, --accessToken, ????????, --clientId, ZTIxMjA2NTctYmIxZS00ZWQzLWFkZDEtMmMxMGQzMjQyNjBj, --xuid, 2535420262661734, --userType, msa, --versionType, release, --quickPlayPath, C:\Users\London Bunden\AppData\Roaming\.minecraft\quickPlay\java\1717446216838.json, --launchTarget, forgeclient, --fml.forgeVersion, 47.2.32, --fml.mcVersion, 1.20.1, --fml.forgeGroup, net.minecraftforge, --fml.mcpVersion, 20230612.114412] [03Jun2024 15:23:40.017] [main/INFO] [cpw.mods.modlauncher.Launcher/MODLAUNCHER]: ModLauncher 10.0.9+10.0.9+main.dcd20f30 starting: java version 17.0.8 by Microsoft; OS Windows 11 arch amd64 version 10.0 [03Jun2024 15:23:42.057] [main/INFO] [net.minecraftforge.fml.loading.ImmediateWindowHandler/]: Loading ImmediateWindowProvider fmlearlywindow [03Jun2024 15:23:42.159] [main/INFO] [EARLYDISPLAY/]: Trying GL version 4.6 [03Jun2024 15:23:42.401] [main/INFO] [EARLYDISPLAY/]: Requested GL version 4.6 got version 4.6 [03Jun2024 15:23:42.494] [main/INFO] [mixin-transmog/]: Mixin Transmogrifier is definitely up to no good... [03Jun2024 15:23:42.524] [main/INFO] [mixin-transmog/]: crimes against java were committed [03Jun2024 15:23:42.630] [pool-2-thread-1/INFO] [EARLYDISPLAY/]: GL info: NVIDIA GeForce RTX 3070/PCIe/SSE2 GL version 4.6.0 NVIDIA 555.85, NVIDIA Corporation [03Jun2024 15:23:43.075] [main/INFO] [gg.essential.loader.stage1.EssentialLoaderBase/]: Starting Essential Loader (stage2) version 1.6.2 (285f951adc7537f49ae3ef9fc0d2fd3e) [stable] [03Jun2024 15:23:43.104] [main/INFO] [mixin-transmog/]: Original mixin transformation service successfully crobbed by mixin-transmogrifier! [03Jun2024 15:23:43.162] [main/INFO] [mixin/]: SpongePowered MIXIN Subsystem Version=0.8.5 Source=union:/C:/Users/London%20Bunden/AppData/Roaming/.minecraft/mods/Connector-1.0.0-beta.43+1.20.1.jar%23266%23270!/ Service=ModLauncher Env=CLIENT [03Jun2024 15:23:44.312] [main/WARN] [net.minecraftforge.fml.loading.moddiscovery.ModFileParser/LOADING]: Mod file C:\Users\London Bunden\AppData\Roaming\.minecraft\libraries\net\minecraftforge\fmlcore\1.20.1-47.2.32\fmlcore-1.20.1-47.2.32.jar is missing mods.toml file [03Jun2024 15:23:44.317] [main/WARN] [net.minecraftforge.fml.loading.moddiscovery.ModFileParser/LOADING]: Mod file C:\Users\London Bunden\AppData\Roaming\.minecraft\libraries\net\minecraftforge\javafmllanguage\1.20.1-47.2.32\javafmllanguage-1.20.1-47.2.32.jar is missing mods.toml file [03Jun2024 15:23:44.323] [main/WARN] [net.minecraftforge.fml.loading.moddiscovery.ModFileParser/LOADING]: Mod file C:\Users\London Bunden\AppData\Roaming\.minecraft\libraries\net\minecraftforge\lowcodelanguage\1.20.1-47.2.32\lowcodelanguage-1.20.1-47.2.32.jar is missing mods.toml file [03Jun2024 15:23:44.329] [main/WARN] [net.minecraftforge.fml.loading.moddiscovery.ModFileParser/LOADING]: Mod file C:\Users\London Bunden\AppData\Roaming\.minecraft\libraries\net\minecraftforge\mclanguage\1.20.1-47.2.32\mclanguage-1.20.1-47.2.32.jar is missing mods.toml file [03Jun2024 15:23:44.862] [main/WARN] [net.minecraftforge.jarjar.selection.JarSelector/]: Attempted to select two dependency jars from JarJar which have the same identification: Mod File:  and Mod File: . Using Mod File:  [03Jun2024 15:23:44.864] [main/WARN] [net.minecraftforge.jarjar.selection.JarSelector/]: Attempted to select a dependency jar for JarJar which was passed in as source: curios. Using Mod File: C:\Users\London Bunden\AppData\Roaming\.minecraft\mods\curios-forge-5.9.1+1.20.1.jar [03Jun2024 15:23:44.864] [main/INFO] [net.minecraftforge.fml.loading.moddiscovery.JarInJarDependencyLocator/]: Found 75 dependencies adding them to mods collection [03Jun2024 15:23:49.089] [main/INFO] [gg.essential.loader.stage2.util.KFFMerger/]: Found Kotlin-containing mod Jar[union:/C:/Users/London%20Bunden/AppData/Roaming/.minecraft/essential/libraries/forge_1.20.1/kotlin-for-forge-4.3.0-slim.jar%23280!/], checking whether we need to upgrade it.. [03Jun2024 15:23:49.091] [main/INFO] [gg.essential.loader.stage2.util.KFFMerger/]: Found outdated Kotlin core libs 0.0.0 (we ship 1.9.23) [03Jun2024 15:23:49.092] [main/INFO] [gg.essential.loader.stage2.util.KFFMerger/]: Found outdated Kotlin Coroutines libs 0.0.0 (we ship 1.8.0) [03Jun2024 15:23:49.092] [main/INFO] [gg.essential.loader.stage2.util.KFFMerger/]: Found outdated Kotlin Serialization libs 0.0.0 (we ship 1.6.3) [03Jun2024 15:23:49.095] [main/INFO] [gg.essential.loader.stage2.util.KFFMerger/]: Generating jar with updated Kotlin at C:\Users\LONDON~1\AppData\Local\Temp\kff-updated-kotlin-14765634657383373807-4.3.0-slim.jar [03Jun2024 15:23:49.974] [main/ERROR] [net.minecraftforge.fml.loading.LanguageLoadingProvider/LOADING]: Missing language kotlinforforge version [3,) wanted by Cobblemon-forge-1.5.2+1.20.1.jar [03Jun2024 15:23:49.989] [main/ERROR] [net.minecraftforge.fml.loading.ModSorter/LOADING]: Missing or unsupported mandatory dependencies:     Mod ID: 'curios', Requested by: 'radiantgear', Expected range: '[7,)', Actual version: '5.9.1+1.20.1'     Mod ID: 'minecraft', Requested by: 'radiantgear', Expected range: '[1.20.5,1.21)', Actual version: '1.20.1'     Mod ID: 'forge', Requested by: 'radiantgear', Expected range: '[50,)', Actual version: '47.2.32' [03Jun2024 15:23:50.434] [main/INFO] [dev.su5ed.sinytra.connector.service.hacks.ModuleLayerMigrator/]: Successfully made module authlib transformable [03Jun2024 15:23:51.112] [main/ERROR] [dev.su5ed.sinytra.connector.loader.ConnectorEarlyLoader/]: Skipping early mod setup due to previous error [03Jun2024 15:23:51.115] [main/INFO] [cpw.mods.modlauncher.LaunchServiceHandler/MODLAUNCHER]: Launching target 'forgeclient' with arguments [--version, 1.20.1-forge-47.2.32, --gameDir, C:\Users\London Bunden\AppData\Roaming\.minecraft, --assetsDir, C:\Users\London Bunden\AppData\Roaming\.minecraft\assets, --uuid, da3510f9b4b4427bb78304c88f4c534a, --username, LondonDumbden, --assetIndex, 5, --accessToken, ????????, --clientId, ZTIxMjA2NTctYmIxZS00ZWQzLWFkZDEtMmMxMGQzMjQyNjBj, --xuid, 2535420262661734, --userType, msa, --versionType, release, --quickPlayPath, C:\Users\London Bunden\AppData\Roaming\.minecraft\quickPlay\java\1717446216838.json]  
    • When I try to install the forge installer it comes with several files instead of just one in executable java format
    • 0 I have recently started with Java and the implementation of Minecraft mods. I am currently working on a mod for 1.20.4-49.0.31 I'm trying to get the content of each slot in the console to be displayed when the inventory is opened, which works. In addition, I wanted to do the same with chests (in this case containers). However, I get in the output that there is Air at every slot of the chest, even if the chest is filled. Does anyone have experience with similar problems and could help me? package net.kaan.sortingmod; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; import net.minecraft.client.gui.screens.inventory.InventoryScreen; import net.minecraft.client.gui.screens.inventory.ContainerScreen; import net.minecraft.client.gui.screens.inventory.FurnaceScreen; import net.minecraft.world.entity.player.Player; import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.inventory.InventoryMenu; import net.minecraft.world.item.ItemStack; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.client.event.ScreenEvent; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; @Mod(SortingMod.MODID) public class SortingMod { public static final String MODID = "sortingmod"; public SortingMod() { // Register the client setup method FMLJavaModLoadingContext.get().getModEventBus().addListener(this::doClientStuff); // Register this class for Forge events MinecraftForge.EVENT_BUS.register(this); } private void doClientStuff(final FMLClientSetupEvent event) { // Any client-side setup can be done here } @SubscribeEvent public void onScreenOpen(ScreenEvent.Opening event) { Screen screen = event.getScreen(); if (screen instanceof InventoryScreen) { System.out.println("Player opened their inventory."); assert Minecraft.getInstance().player != null; printInventoryItems(Minecraft.getInstance().player); } else if (screen instanceof ContainerScreen) { System.out.println("Player opened a chest."); printContainerItems((ContainerScreen) screen); } } private void printInventoryItems(Player player) { AbstractContainerMenu menu = player.inventoryMenu; for (int i = 0; i < menu.slots.size(); i++) { ItemStack stack = menu.getSlot(i).getItem(); if (!stack.isEmpty()) { System.out.println("Slot " + i + ": " + stack.getCount() + "x " + stack.getHoverName().getString()); } } } private void printContainerItems(ContainerScreen screen) { AbstractContainerMenu menu = screen.getMenu(); System.out.println(menu.slots.size()); for (int i = 0; i < menu.slots.size(); i++) { ItemStack stack = menu.getSlot(i).getItem(); System.out.println("Slot " + i + ": " + stack.getCount() + "x " + stack.getHoverName().getString()); } } }  
    • I am wanting to add an axe to my mod though I do not want it to have a recipe, the reason for this being that I want you to only be able to find it in a structure. I have looked on both here and elsewhere on the internet and have found nothing... How would this be done?    (Video for reference.)    
  • Topics

×
×
  • Create New...

Important Information

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