Jump to content

[1.8] Custom Item Inventory, don't save the Items. (SOLVED)


Recommended Posts

Posted

I have the problem that my Item Inventory don't save the Items that i drag in or shift click, after re-opening the gui they are not saved.

but when i use this method in right clicking the item while sneaking:

new InventoryKeyring(player.getHeldItem()).setInventorySlotContents(0, new ItemStack(Items.diamond, 4));

it saves the diamonds, but when i take the diamond and re open the gui the diamond is still there.

 

Seems for me like a Client/Server Problem, how can i fix that?

or maybe a problem at the method when clicking on a slot to put a item or take a item

My files:

 

Container

 

package youngertu.fairytail.inventory;

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.ItemArmor;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import scala.tools.nsc.backend.icode.BBFlags;
import youngertu.fairytail.items.ItemKeyRing;

public class ContainerKeyring extends Container
{
private ItemStack bookStack;

/** The Item Inventory for this Container */
private final InventoryKeyring inventory;

private static final int
ARMOR_START = InventoryKeyring.INV_SIZE, // INV_SIZE = 10, so slots 0 to 9 are the custom inventory, armor starts at the next slot (i.e. 10)
ARMOR_END = ARMOR_START+3, // 4 slots total, e.g. 10-13 (10, 11, 12, 13)
INV_START = ARMOR_END+1, // start at next slot after armor, e.g. 14
INV_END = INV_START+26, // 27 vanilla inventory slots total (i.e. the first one plus 26 more)
HOTBAR_START = INV_END+1, // start at next slot after inventory
HOTBAR_END = HOTBAR_START+8; // 9 slots total (i.e. the first one plus 8 more)

public ContainerKeyring(EntityPlayer player, InventoryPlayer inv, InventoryKeyring bag)
{
	int i = 0;
	inventory = bag;

	// CUSTOM INVENTORY SLOTS
	for (i = 0; i < InventoryKeyring.INV_SIZE; ++i) {
		addSlotToContainer(new SlotKeyring(inventory, i, 80 + (18*(i%5)), 8 + (18 * (int)(i/5))));
	}

	// PLAYER INVENTORY - uses default locations for standard inventory texture file
	for (i = 0; i < 3; ++i) {
		for (int j = 0; j < 9; ++j) {
			addSlotToContainer(new Slot(inv, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
		}
	}

	// PLAYER ACTION BAR - uses default locations for standard action bar texture file
	for (i = 0; i < 9; ++i) {
		addSlotToContainer(new Slot(inv, i, 8 + i * 18, 142));
	}
}

@Override
public boolean canInteractWith(EntityPlayer player) {
	return inventory.isUseableByPlayer(player);
}

@Override
public ItemStack transferStackInSlot(EntityPlayer player, int index)
{
	ItemStack itemstack = null;
	Slot slot = (Slot) this.inventorySlots.get(index);

	if (slot != null && slot.getHasStack())
	{
		ItemStack itemstack1 = slot.getStack();
		itemstack = itemstack1.copy();

		// If item is in our custom Inventory or an ARMOR slot
		if (index < INV_START)
		{
			if (!this.mergeItemStack(itemstack1, INV_START, HOTBAR_END+1, true))
			{
				return null;
			}

			slot.onSlotChange(itemstack1, itemstack);
		}

		else
		{

			if (itemstack1.getItem() instanceof ItemArmor)
			{
				int type = ((ItemArmor) itemstack1.getItem()).armorType;
				if (!this.mergeItemStack(itemstack1, ARMOR_START + type, ARMOR_START + type + 1, false))
				{
					return null;
				}
			}


			else if (index >= INV_START)
			{

				if (!this.mergeItemStack(itemstack1, 0, ARMOR_START, false))
				{
					return null;
				}
			}
		}

		if (itemstack1.stackSize == 0) {
			slot.putStack((ItemStack) null);
		} else {
			slot.onSlotChanged();
		}

		if (itemstack1.stackSize == itemstack.stackSize) {
			return null;
		}

		slot.onPickupFromSlot(player, itemstack1);
	}

	return itemstack;
}

@Override
public ItemStack slotClick(int slot, int button, int flag, EntityPlayer player) {
	if (slot >= 0 && getSlot(slot) != null && getSlot(slot).getStack() == player.getHeldItem()) {
		return null;
	}
	return super.slotClick(slot, button, flag, player);
}

/**
 * Vanilla method fails to account for stack size limits of one, resulting in only one
 * item getting placed in the slot and the rest disappearing into thin air; vanilla
 * method also fails to check whether stack is valid for slot
 */
@Override
protected boolean mergeItemStack(ItemStack stack, int start, int end, boolean backwards)
{
	boolean flag1 = false;
	int k = (backwards ? end - 1 : start);
	Slot slot;
	ItemStack itemstack1;

	if (stack.isStackable())
	{
		while (stack.stackSize > 0 && (!backwards && k < end || backwards && k >= start))
		{
			slot = (Slot) inventorySlots.get(k);
			itemstack1 = slot.getStack();

			if (!slot.isItemValid(stack)) {
				k += (backwards ? -1 : 1);
				continue;
			}

			if (itemstack1 != null && itemstack1.getItem() == stack.getItem() &&
					(!stack.getHasSubtypes() || stack.getItemDamage() == itemstack1.getItemDamage()) &&
					ItemStack.areItemStackTagsEqual(stack, itemstack1))
			{
				int l = itemstack1.stackSize + stack.stackSize;

				if (l <= stack.getMaxStackSize() && l <= slot.getSlotStackLimit()) {
					stack.stackSize = 0;
					itemstack1.stackSize = l;
					inventory.markDirty();
					flag1 = true;
				} else if (itemstack1.stackSize < stack.getMaxStackSize() && l < slot.getSlotStackLimit()) {
					stack.stackSize -= stack.getMaxStackSize() - itemstack1.stackSize;
					itemstack1.stackSize = stack.getMaxStackSize();
					inventory.markDirty();
					flag1 = true;
				}
			}

			k += (backwards ? -1 : 1);
		}
	}

	if (stack.stackSize > 0)
	{
		k = (backwards ? end - 1 : start);

		while (!backwards && k < end || backwards && k >= start) {
			slot = (Slot) inventorySlots.get(k);
			itemstack1 = slot.getStack();

			if (!slot.isItemValid(stack)) {
				k += (backwards ? -1 : 1);
				continue;
			}

			if (itemstack1 == null) {
				int l = stack.stackSize;

				if (l <= slot.getSlotStackLimit()) {
					slot.putStack(stack.copy());
					stack.stackSize = 0;
					inventory.markDirty();
					flag1 = true;
					break;
				} else {
					putStackInSlot(k, new ItemStack(stack.getItem(), slot.getSlotStackLimit(), stack.getItemDamage()));
					stack.stackSize -= slot.getSlotStackLimit();
					inventory.markDirty();
					flag1 = true;
				}
			}

			k += (backwards ? -1 : 1);
		}
	}

	return flag1;
}

}

 

 

Inventory:

 

package youngertu.fairytail.inventory;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import youngertu.fairytail.items.keys.KeyBase;

public class InventoryKeyring extends AbstractInventory
{
private String name = "Key Ring";

/** The key used to store and retrieve the inventory from NBT */
private static final String SAVE_KEY = "InventoryKeyring";

/** Defining your inventory size this way is handy */
public static final int INV_SIZE = 18;

/** Provides NBT Tag Compound to reference */
private final ItemStack invStack;

public InventoryKeyring(ItemStack stack) {
	inventory = new ItemStack[iNV_SIZE];
	this.invStack = stack;
	if (!invStack.hasTagCompound()) {
		invStack.setTagCompound(new NBTTagCompound());
	}
	readFromNBT(invStack.getTagCompound());
}

@Override
public String getName() {
	return name;
}

@Override
public boolean hasCustomName() {
	return name.length() > 0;
}

@Override
public int getInventoryStackLimit() {
	return 1;
}

/**
 * For inventories stored in ItemStacks, it is critical to implement this method
 * in order to write the inventory to the ItemStack's NBT whenever it changes.
 */
@Override
public void markDirty() {
	for (int i = 0; i < getSizeInventory(); ++i) {
		if (getStackInSlot(i) != null && getStackInSlot(i).stackSize == 0)
			inventory[i] = null;
	}
	writeToNBT(invStack.getTagCompound());
}

@Override
public boolean isUseableByPlayer(EntityPlayer player) {
	return true;
}

@Override
public boolean isItemValidForSlot(int slot, ItemStack stack) {
	return (stack.getItem() instanceof KeyBase);
}

@Override
protected String getNbtKey() {
	return SAVE_KEY;
}
}

 

 

 

GuiHandler

 

public class GuiHandler implements IGuiHandler
{
@Override
public Object getServerGuiElement(int guiId, EntityPlayer player, World world, int x, int y, int z) {
	switch(guiId) {

	case FairyTail.GUI_KEYRING_INV: return new ContainerKeyring(player, player.inventory, new InventoryKeyring(player.getHeldItem())); 
	default: return null;
	}

	/*if (guiId == FairyTail.GUI_KEYRING_INV)  {
		System.out.println("RETURNED KEYRING INV");
		return new ContainerKeyring(player, player.inventory, new InventoryKeyring(player.getHeldItem()));
	} else {
		return null;
	}*/
}

@Override
public Object getClientGuiElement(int guiId, EntityPlayer player, World world, int x, int y, int z) {
	switch(guiId) {
	case FairyTail.GUI_KEYRING_INV: return new GuiKeyring(player, player.inventory, new InventoryKeyring(player.getHeldItem()));
	default: return null;
	}
	/*if (guiId == FairyTail.GUI_KEYRING_INV)  {
		return new GuiKeyring(player, player.inventory, new InventoryKeyring(player.getHeldItem()));
	} else {
		return null;
	}*/
}

}

 

"My Crew is World Wide." 「ヤング • エルトウ」

Posted

Well you are never saving your data to the itemstacks'nbt.

override onContainerClosed and save your inventory to the itemstacks nbt there

 

it is saving, because when i open it again there is a diamond. but im not able to add or take something.

"My Crew is World Wide." 「ヤング • エルトウ」

Posted

I think the diamond is there because you are adding it everytime you create a new inventory..?

new InventoryKeyring(player.getHeldItem()).setInventorySlotContents(0, new ItemStack(Items.diamond, 4));

Posted

I think the diamond is there because you are adding it everytime you create a new inventory..?

new InventoryKeyring(player.getHeldItem()).setInventorySlotContents(0, new ItemStack(Items.diamond, 4));

 

thats possible, i'll try out what you said before.

"My Crew is World Wide." 「ヤング • エルトウ」

Posted

Well you are never saving your data to the itemstacks'nbt.

override onContainerClosed and save your inventory to the itemstacks nbt there

 

but then you didn't saw this:

/**
 * For inventories stored in ItemStacks, it is critical to implement this method
 * in order to write the inventory to the ItemStack's NBT whenever it changes.
 */
@Override
public void markDirty() {
	for (int i = 0; i < getSizeInventory(); ++i) {
		if (getStackInSlot(i) != null && getStackInSlot(i).stackSize == 0)
			inventory[i] = null;
	}
	writeToNBT(invStack.getTagCompound());
}

 

there is a other reason i think, but why?

 

EDIT: When i try to shift-click the Diamond the game crashes.

 

EDIT 2: this method is only for TileEntities i'll try to writeNBTTag and readNBTTag

"My Crew is World Wide." 「ヤング • エルトウ」

Posted

1) That is not what Mark Dirty is supposed to be doing.

2) That function utterly deletes the entire contained inventory.  Good jorb.

3) Never, ever, EVER call

writeToNBT

yourself.

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.

Posted

1) That is not what Mark Dirty is supposed to be doing.

2) That function utterly deletes the entire contained inventory.  Good jorb.

3) Never, ever, EVER call

writeToNBT

yourself.

 

I just followed the Tutorial of coolAlias seems that this doesn't work for 1.8 or im not able to get it to work.

 

I think i'll start the tutorial from begining.

"My Crew is World Wide." 「ヤング • エルトウ」

Posted

I posted this under the topic of coolAlias Tutorial and here are the problems that i detected:

 

Changed everything but still no difference, the Item Inventory is still not saved. Also when I try to set Items to the Inventory in the Item Right-Click Method it is saving the Item but when i take the item and open the inventory again it is still there.

 

here my 2 classes inventory and container:

 

Container

 

package youngertu.fairytail.inventory;

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.ItemArmor;
import net.minecraft.item.ItemStack;
import youngertu.fairytail.items.keys.KeyBase;

public class ContainerKeyRing extends Container
{
/** The Item Inventory for this Container */
private final InventoryKeyRing inventory;

private static final int
ARMOR_START = InventoryKeyRing.INV_SIZE, // INV_SIZE = 10, so slots 0 to 9 are the custom inventory, armor starts at the next slot (i.e. 10)
ARMOR_END = ARMOR_START+3, // 4 slots total, e.g. 10-13 (10, 11, 12, 13)
INV_START = ARMOR_END+1, // start at next slot after armor, e.g. 14
INV_END = INV_START+26, // 27 vanilla inventory slots total (i.e. the first one plus 26 more)
HOTBAR_START = INV_END+1, // start at next slot after inventory
HOTBAR_END = HOTBAR_START+8; // 9 slots total (i.e. the first one plus 8 more)

public ContainerKeyRing(EntityPlayer player, InventoryPlayer inv, InventoryKeyRing bag)
{
	int i = 0;
	inventory = bag;

	// CUSTOM INVENTORY SLOTS
	for (i = 0; i < InventoryKeyRing.INV_SIZE; ++i) {
		addSlotToContainer(new SlotKeyRing(inventory, i, 80 + (18*(i%5)), 8 + (18 * (int)(i/5))));
	}

	// PLAYER INVENTORY - uses default locations for standard inventory texture file
	for (i = 0; i < 3; ++i) {
		for (int j = 0; j < 9; ++j) {
			addSlotToContainer(new Slot(inv, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
		}
	}

	// PLAYER ACTION BAR - uses default locations for standard action bar texture file
	for (i = 0; i < 9; ++i) {
		addSlotToContainer(new Slot(inv, i, 8 + i * 18, 142));
	}
}

@Override
public boolean canInteractWith(EntityPlayer player) {
	return inventory.isUseableByPlayer(player);
}


@Override
public ItemStack transferStackInSlot (EntityPlayer player, int par2) {
	ItemStack itemstack = null;
	Slot slot = this.inventorySlots.get(par2);

	if (slot != null && slot.getHasStack()) {
		ItemStack itemstack1 = slot.getStack();
		itemstack = itemstack1.copy();

		if (par2 < INV_START) {
			if (!mergeItemStack(itemstack1, INV_START, HOTBAR_END + 1, true)) return null;

			slot.onSlotChange(itemstack1, itemstack);
		} else if (itemstack1.getItem() instanceof KeyBase) {
			if (!mergeItemStack(itemstack1, 0, InventoryKeyRing.INV_SIZE, false)) return null;
		} else if (par2 >= INV_START && par2 < HOTBAR_START) {
			if (!mergeItemStack(itemstack1, HOTBAR_START, HOTBAR_START + 1, false)) return null;
		} else if (par2 >= HOTBAR_START && par2 < HOTBAR_END + 1) if (!mergeItemStack(itemstack1, INV_START, INV_END + 1, false)) return null;

		if (itemstack1.stackSize == 0)
			slot.putStack((ItemStack) null);
		else
			slot.onSlotChanged();

		if (itemstack1.stackSize == itemstack.stackSize) return null;

		slot.onPickupFromSlot(player, itemstack1);
	}

	return itemstack;
}

@Override
public ItemStack slotClick(int slot, int button, int flag, EntityPlayer player) {
	if (slot >= 0 && getSlot(slot) != null && getSlot(slot).getStack() == player.getHeldItem()) {
		return null;
	}
	return super.slotClick(slot, button, flag, player);
}

@Override
protected boolean mergeItemStack (ItemStack stack, int start, int end, boolean backwards) {
	boolean flag1 = false;
	int k = (backwards ? end - 1 : start);
	Slot slot;
	ItemStack itemstack1;

	if (stack.isStackable()) while (stack.stackSize > 0 && (!backwards && k < end || backwards && k >= start)) {
		slot = inventorySlots.get(k);
		itemstack1 = slot.getStack();

		if (!slot.isItemValid(stack)) {
			k += (backwards ? -1 : 1);
			continue;
		}

		if (itemstack1 != null && itemstack1.getItem() == stack.getItem() && (!stack.getHasSubtypes() || stack.getItemDamage() == itemstack1.getItemDamage()) && ItemStack.areItemStackTagsEqual(stack, itemstack1)) {
			int l = itemstack1.stackSize + stack.stackSize;

			if (l <= stack.getMaxStackSize() && l <= slot.getSlotStackLimit()) {
				stack.stackSize = 0;
				itemstack1.stackSize = l;
				inventory.markDirty();
				flag1 = true;
			} else if (itemstack1.stackSize < stack.getMaxStackSize() && l < slot.getSlotStackLimit()) {
				stack.stackSize -= stack.getMaxStackSize() - itemstack1.stackSize;
				itemstack1.stackSize = stack.getMaxStackSize();
				inventory.markDirty();
				flag1 = true;
			}
		}

		k += (backwards ? -1 : 1);
	}

	if (stack.stackSize > 0) {
		k = (backwards ? end - 1 : start);

		while (!backwards && k < end || backwards && k >= start) {
			slot = inventorySlots.get(k);
			itemstack1 = slot.getStack();

			if (!slot.isItemValid(stack)) {
				k += (backwards ? -1 : 1);
				continue;
			}

			if (itemstack1 == null) {
				int l = stack.stackSize;

				if (l <= slot.getSlotStackLimit()) {
					slot.putStack(stack.copy());
					stack.stackSize = 0;
					inventory.markDirty();
					flag1 = true;
					break;
				} else {
					putStackInSlot(k, new ItemStack(stack.getItem(), slot.getSlotStackLimit(), stack.getItemDamage()));
					stack.stackSize -= slot.getSlotStackLimit();
					inventory.markDirty();
					flag1 = true;
				}
			}

			k += (backwards ? -1 : 1);
		}
	}

	return flag1;
}
}

 

 

Inventory

 

package youngertu.fairytail.inventory;

import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import youngertu.fairytail.items.keys.KeyBase;

public class InventoryKeyRing extends AbstractInventory
{
private String name = "Key Ring";

/** The key used to store and retrieve the inventory from NBT */
private static final String SAVE_KEY = "KeyRingInventory";

/** Defining your inventory size this way is handy */
public static final int INV_SIZE = 18;

/** Provides NBT Tag Compound to reference */
private final ItemStack invStack;

public InventoryKeyRing(ItemStack stack) {
inventory = new ItemStack[iNV_SIZE];
this.invStack = stack;
if (!invStack.hasTagCompound()) {
invStack.setTagCompound(new NBTTagCompound());
}
readFromNBT(invStack.getTagCompound());
}

@Override
public String getName() {
return name;
}

@Override
public boolean hasCustomName() {
return name.length() > 0;
}

@Override
public int getInventoryStackLimit() {
return 1;
}

/**
* For inventories stored in ItemStacks, it is critical to implement this method
* in order to write the inventory to the ItemStack's NBT whenever it changes.
*/
@Override
public void markDirty()
{
for (int i = 0; i < getSizeInventory(); ++i)
{
if (getStackInSlot(i) != null && getStackInSlot(i).stackSize == 0)
{
setInventorySlotContents(i, null);
}
}
writeToNBT(invStack.getTagCompound());
}

@Override
public boolean isUseableByPlayer(EntityPlayer player) {
return true;
}

@Override
public boolean isItemValidForSlot(int slot, ItemStack stack) {
return stack.getItem() instanceof KeyBase;
}

@Override
protected String getNbtKey() {
return SAVE_KEY;
}

public void copy (AbstractInventory inv) {
for (int i = 0; i < inv.getSizeInventory(); ++i) {
ItemStack stack = inv.getStackInSlot(i);
inventory = (stack == null ? null : stack.copy());
}
markDirty();
}

@Override
public ItemStack removeStackFromSlot(int slot) {
ItemStack stack = getStackInSlot(slot);
setInventorySlotContents(slot, null);
return stack;
}
}

 

 

thanks for your help coolAlias, maybe i understanded something wrong and this is the reason for not saving the items.

 

EDIT: I added some debug lines and everything works fine, the NBTWriting is successful, but instead of readingNBT when opening the Inventory it writes to NBT, why?

 

EDIT 2: Fixed ReadingNBT by putting into openInventory but it still writesNBT after opening the Inventory and reading the NBT and this several times 10 times i think.

 

EDIT 3: writeNBT is called on Client Side when opening the inventory, but Server Side when putting Item in Slot. Reading NBT is only called on Server Side.

 

When opening the Inventory the writeNBT method is called by markDirty, and how i said before on client side, there is something wrong but i couldn't find it.

 

EDIT 4: I outcommented the method markDirty to put my Code into onContainerClosed but it doesn't want to work.

"My Crew is World Wide." 「ヤング • エルトウ」

Posted

I still do not understand that mark dirty function.

 

CoolAlias might have to hop in and help you, because from here it looks like that method is erasing the inventory contents, not saving them.

 

Similarly, it isn't calling super().

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.

Posted

I still do not understand that mark dirty function.

 

CoolAlias might have to hop in and help you, because from here it looks like that method is erasing the inventory contents, not saving them.

 

Similarly, it isn't calling super().

 

I looked into a Open Source Mod and it seems that this markDirty method is wrong, he uses onContainerClosed i'll try the same, im currently working on that.

"My Crew is World Wide." 「ヤング • エルトウ」

Posted

Fixed that by adding this into the Container:

 

@Override
public void onContainerClosed(EntityPlayer player){
	World world = player.worldObj;

	if (!world.isRemote){
		ItemStack stack = player.getCurrentEquippedItem();
		inventory.writeToNBT(stack.getTagCompound());
	}

	super.onContainerClosed(player);
}

"My Crew is World Wide." 「ヤング • エルトウ」

Posted

Well you are never saving your data to the itemstacks'nbt.

override onContainerClosed and save your inventory to the itemstacks nbt there

 

At the end you were right, sorry and thanks ^^

"My Crew is World Wide." 「ヤング • エルトウ」

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.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • As long as the packets you are sending aren't lost, there's nothing wrong with what you're currently doing. Although, this sounds like something that would benefit from you making your own datapack registry instead of trying to arbitrarily sync static maps. Check out `DataPackRegistryEvent.NewRegistry`.
    • Hey all, I've been working a lot with datapacks lately, and I'm wondering what the most efficient way to get said data from server to client is.  I'm currently using packets, but given that a lot of the data I'm storing involves maps along the lines of Map<ResourceLocation, CustomDataType>, it can easily start to get messy if I need to transmit a lot of that data all at once. Recently I started looking into the ReloadableServerResources class, which is where Minecraft stores its built-ins.  I see you can access it via the server from the server's resources.managers, and it seems like this can be done even from the client to appropriately retrieve data from the server, unless I'm misunderstanding.  However, from what I can tell, this only works via built-in methods such as getRecipeManager() or getLootTables(), etc.  These are all SimpleJsonResourceReloadListeners, just like my datapack entries are, so it seems like it could be possible for me to access my datapack entries similarly?  But I don't see anywhere in ReloadableServerResources that stores loaded modded entries, so either I'm looking in the wrong place or it doesn't seem to be a thing. Are packets really the best way of doing this, or am I missing a method that would let me use ReloadableServerResources or something similar?
    • Hi, everyone! I'm new to minecraft modding stuff and want ask you some questions. 1. I checked forge references and saw there com.mojang and net.minecraft (not net.minecraftforge) and as I understand it's original game packages with all minecraft logic inside including renderers and so on, right? 2. Does it mean that forge has a limited set of instruments which doesn't cover all the aspects of the game? If make my question more specific then does forge provide such instruments that allow me totally change minecraft itself, like base mechanics and etc.? Or I have to use "original game packages" to implement such things? 3. I actively learning basic concepts with forge documentation and tutorials. So in my plans make different inventory system like in diabloids. Is that possible with forge? 4. It is last question related to the second one. So how deeply I can change minecraft with forge? I guess all my questions above because of that I haven't globally understanding what forge is and how it works inside and how it works with minecraft. It would be great if you provide some links or topics about it or explain it by yourself but I guess it's to big to be explained in that post at once. Anyway, thank you all for any help!
    • Im trying add to block a hole in center, just a usual block and in center of it on up side, there is should be a hole. I tried to add it via BlockModelBuilder, but its not working. Problem is that it only can change block size outside. I tried it to do with VoxelShape and its working, but its has been on server side and looks like its just changed collision shape, but for client, there is a texture covering this hole. I tried to use: base.renderType("cutout"); and removed some pixels from texture. I thought its should work, but game optimization makes block inside looks transparent. So, only custom model?
    • I Made this modpack myself and When i Open a world with embeddium enabeld no chuncks are loading in and when i have the mod brute force rendering culling eanbled the game will not start     This is the Modlist:   Chef's Delight [Forge] (by redstone3game) Yung Structures Addon for Loot Integrations (by someaddon) Macaw's Paths and Pavings (by sketch_macaw) My Nether's Delight (by soytutta) Client Crafting (by someaddon) Integrated Stronghold (by CraisinLord) Delightful (by brnbrd) Immersive Aircraft [Fabric/Forge] (by Conczin) Mysterious Mountain Lib (by sz0999312) Infinity Buttons (by LarsMans) SuperMartijn642's Core Lib (by SuperMartijn642) Clumps (by Jaredlll08) Embeddium (by FiniteReality) Cosmetic Armor Reworked (by LainMI) Creeper Overhaul (by joosh_7889) Balm (by BlayTheNinth) HT's TreeChop (by hammertater) Fastload (by StockiesLad) ImmediatelyFast (by RaphiMC) Integrated Dungeons and Structures (by CraisinLord) Mobtimizations - Entity Performance Fixes (by Corosus) Handcrafted (by terrariumearth) SuperMartijn642's Config Lib (by SuperMartijn642) Dramatic Doors (by FizzWare) Allurement (by TeamAbnormals) Xaero's World Map (by xaero96) Panda's Extra Details (by ThePandaOliver) Geophilic – Vanilla Biome Overhauls (by bebebea_loste) Auroras (by Verph) Naturalist (by Starfish_Studios) Iron Chests (by ProgWML6) Corpse (by henkelmax) FastSuite (by Shadows_of_Fire) Controlling (by Jaredlll08) Ash API (by Trikzon) Eating Animation [Neo/Forge] (by matyrobbrt) Macaw's Doors (by sketch_macaw) ForgeEndertech (by EnderLanky) Philip's Ruins (by philipmoddev) Resourceful Config (by ThatGravyBoat) ModernFix (by embeddedt) Quark (by Vazkii) Illager Invasion [Forge & Fabric] (by Fuzs) Integrated API (by CraisinLord) Redirector [Modern] (by pOtAto__bOy) Macaw's Fences and Walls (by sketch_macaw) Diagonal Windows [Forge & Fabric] (by Fuzs) Waystones (by BlayTheNinth) [EMF] Entity Model Features [Fabric & Forge] (by Traben) FerriteCore ((Neo)Forge) (by malte0811) CodeChicken Lib 1.8.+ (by covers1624) Macaw's Roofs (by sketch_macaw) Server Country Flags (by khajiitos) Bookshelf (by DarkhaxDev) Comforts (Fabric/Forge/Quilt) (by TheIllusiveC4) Enchantment Descriptions (by DarkhaxDev) Entity Culling Fabric/Forge (by tr7zw) Embeddium++ (by SrRapero720) Embeddium (Rubidium) Extra (by dimadencep) Smooth Boot (Reloaded) (by AbdElAziz333) Dungeons and Taverns (by Nova_Wostra) Placeables (by ItzSkay) CoroUtil (by Corosus) Small Ships [Fabric & Forge] (by talhanation) Trade Cycling (by henkelmax) Better Fps - Render Distance[Forge] (by someaddon) Better Villages - Forge (by jtl_elisa) PandaLib (by ThePandaOliver) Curios API (Forge/NeoForge) (by TheIllusiveC4) Stoneworks [Forge & Fabric] (by Fuzs) Pastel Shaders (by ElocinDev) Integrated Villages (by CraisinLord) More Axolotl Variants API (by AkashiiKun69) Potato Shader (by RRe36) Better Archeology (by Pandarix) Block Runner [Forge & Fabric] (by Fuzs) Cloth Config API (Fabric/Forge/NeoForge) (by shedaniel) Kiwi 🥝 (Neo/Forge) (by Snownee) Macaw's Lights and Lamps (by sketch_macaw) Loot Integrations (by someaddon) Farmers Structures (by BlackAuresArt) Wilderness (by ketok) Corpse x Curios API Compat (by Project8gbDeRam) Friends&Foes (Forge/NeoForge) (Copper Golem,Glare,Crab,Moobloom,Iceologer,Rascal,Tuff Golem,Wildfire,Illusioner) (by Faboslav) More Mob Variants (by nyuppo) Better Than Mending (by legobmw99) Remove Reloading Screen (by dimadencep) Simply Swords [Fabric & Forge] (by sweenuss) Better Brightness Slider (by LaidBackSloth) Krypton Reforged (by Txni) AppleSkin (by squeek502) Supplementaries Squared (by plantspookable) Horse Expert (by Fuzs) YUNG's Menu Tweaks (Forge) (by YUNGNICKYOUNG) Pet Cemetery (by TeamAbnormals) Leaky - Item Lag Fix[Forge/Fabric] (by someaddon) Tectonic (by Apollo) Saturn (by AbdElAziz333) Searchables (by Jaredlll08) Inventory HUD+ (by dmitrylovin) Moonlight Lib (by MehVahdJukaar) Explorify – Dungeons & Structures (by bebebea_loste) Placebo (by Shadows_of_Fire) Overflowing Bars [Forge & Fabric] (by Fuzs) Citadel (by sbom_xela) Alex's Mobs - Naturalist Compat (by Kanadeyoru) Forge CIT (by tfarecnim) Create (by simibubi) Starlight (Forge) (by Spottedleaf) [ETF] Entity Texture Features - [Fabric & Forge] (by Traben) Advanced Chimneys (by EnderLanky) Corn Delight[Forge] (by sz0999312) Trials Chambers [1.20.1 Backport] (by Jusey1z) MVS - Moog's Voyager Structures (by finndog_123) Macaw's Paintings (by sketch_macaw) Alternate Current (by SpaceWalkerRS) Hopo Better Ruined Portals (Fabric/Forge/NeoForge) (by hoponopono) Alex's Delight (by Baisylia) Macaw's Biomes O' Plenty (by Samlegamer_) Resourceful Lib (by ThatGravyBoat) FindMe (by Buuz135) Macaw's Bridges (by sketch_macaw) YUNG's Better Witch Huts (Forge) (by YUNGNICKYOUNG) MNS - Moog's Nether Structures (by finndog_123) Mowzie's Mobs (by bobmowzie) FastWorkbench (by Shadows_of_Fire) Transparent (by Trikzon) Artifacts (by ochotonida) Passable Foliage 🌳 (Neo/Forge) (by Snownee) Supplementaries (by MehVahdJukaar) Atmospheric (by TeamAbnormals) Alex's Caves (by sbom_xela) Alex's Caves Delight (by FixerLink1) Ocean's Delight (by scouter567) Brute force Rendering Culling (by RogoShum) fix GPU memory leak[Forge/Fabric] (by someaddon) Burnt: Better Vanilla Fire (by pxlbnk) YDM's Weapon Master (by YourDailyModderx) Curios Compat Layer for Accessories (by Blodhgarm) MES - Moog's End Structures (by finndog_123) Pale Garden and Creaking (by MinoBanana) YUNG's Better Jungle Temples (Forge) (by YUNGNICKYOUNG) AddonsLib (by Samlegamer_) Athena (by CodexAdrian) MakeUp - Ultra Fast | Shaders (by XavierFST) Xaero's Minimap (by xaero96) Macaw's Trapdoors (by sketch_macaw) Translocators 1.8.+ (by covers1624) Additional Structures (by XxRexRaptorxX) AI Improvements (by QueenOfMissiles) Autochef's Delight (by Snownee) Iron Furnaces (by XenoMustache) Iris/Oculus & GeckoLib Compat (by ElocinDev) Connectivity (by someaddon) Easy Magic [Forge & Fabric] (by Fuzs) Blueprint (by TeamAbnormals) VillagersPlus (FORGE) (by finallion_13) Panda's Falling Tree's (by ThePandaOliver) Xaero's Minimap & World Map - Waystones Compatibility [Forge] (by ArcaneAlloy) ServerCore (by Wesley8081) MrCrayfish's Furniture Mod: Refurbished (by MrCrayfish) Just Enough Items (JEI) (by mezz) Farmer's Delight (by vectorwing) Old fisherman swamp house (by SuperWarioModTeam) YUNG's Better Nether Fortresses (Forge) (by YUNGNICKYOUNG) Lithostitched (by Apollo) FastFurnace (by Shadows_of_Fire) DrDestens MCShaders (by DrDesten) Server Performance - Smooth Chunk Save[Forge/Fabric] (by someaddon) Noisium (by Steveplays28) Puzzles Lib [Forge & Fabric] (by Fuzs) YUNG's Bridges (Forge) (by YUNGNICKYOUNG) Alex's Mobs (by sbom_xela) Regions Unexplored (forge/fabric) (by UHQ_GAMES) Architectury API (by shedaniel) Radium Reforged (by Asek3) Separated Leaves (by LarsMans) CullLessLeaves Reforged (Unofficial) (by ccr4ft3r) Just Enough Effect Descriptions (JEED) (by MehVahdJukaar) FastBoot (by dnlayu) Framework (by MrCrayfish) Chipped (by terrariumearth) MSS - Moog's Soaring Structures (by finndog_123) GeckoLib (by Gecko) CB Multipart (by covers1624) GlitchCore (by TheAdubbz) Realm RPG: Fallen Adventurers (by nocubeyt) Zume (by Nolij) Library Ferret - Forge (by jtl_elisa) Recipe Essentials[Forge/Fabric] (by someaddon) Macaw's Stairs (by sketch_macaw) Accessories (by Blodhgarm) What Are They Up To (Watut) (by Corosus) GroovyModLoader (GML) (by matyrobbrt) Fruits Delight (by lcy0x1) Just Enough Breeding (JEBr) (by Christofmeg) Farmer's Respite (by lumpazl) YUNG's API (Forge) (by YUNGNICKYOUNG) Underground Villages (by Mrbysco) Easy Anvils [Forge & Fabric] (by Fuzs) Cupboard (by someaddon) Diagonal Walls (by Fuzs) Large Ore Deposits (by EnderLanky) More Axolotl Variants Mod (by AkashiiKun69) Zeta (by Vazkii) TerraBlender (Forge) (by TheAdubbz) Biomes O' Plenty (by Forstride) Bocchium (by pOtAto__bOy) FramedBlocks (by XFactHD) Patchouli (by Vazkii) Quark Delight (by nocubeyt) Just Enough Resources (JER) (by way2muchnoise) Amendments (by plantspookable) Simple Hats (by fonnymunkey) Oculus (by Asek3) OpenBlocks Elevator (by vsngarcia) YUNG's Better Mineshafts (Forge) (by YUNGNICKYOUNG) Skin Layers 3D (Fabric/Forge) (by tr7zw) Mouse Tweaks (by YaLTeR) YUNG's Extras (Forge) (by YUNGNICKYOUNG)
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

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