Jump to content

Recommended Posts

Posted

Im trying to bind a different texture for my render based on variable stored in TileEntity, but the texture doesnt update(even when I place a block next to it, nothing changes). How can I force it to update?

 

Here is my code(some parts are complete mess, especially renderer,  used just for testing).

 

Block

 

  Reveal hidden contents

 

 

Renderer(complete mess here)

 

  Reveal hidden contents

 

 

Every code I try doesnt seem to work. :/

Posted
package net.woodworks.tileentity;

import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;

public class TileEntityTable extends TileEntity {

private int cloth;
private int rotation;

@Override
public void writeToNBT(NBTTagCompound compound)
{
	super.writeToNBT(compound);
	compound.setInteger("cloth", cloth);
	compound.setInteger("rotation", rotation);
}

@Override
public void readFromNBT(NBTTagCompound compound)
{
	super.readFromNBT(compound);
	cloth=compound.getInteger("cloth");
	rotation=compound.getInteger("rotation");
}



//Getter
public int getState()
{
	return cloth;
}

public int getRotation()
{
	return rotation;
}
//Setter
public void setState(int par1)
{
	cloth = par1;
	System.out.println("Setting state integer:" + par1);
}

public void setRotation(int par1)
{
	rotation = par1;
	System.out.println("Setting rotation integer:" + par1);
}
}

Posted

The cool thing is that vanilla handles 99% of it for you, just add this:

 

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

        public void onDataPacket(INetworkManager net, Packet132TileEntityData packet) {
                readFromNBT(packet.data);
        }

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
  On 1/15/2014 at 9:41 PM, Draco18s said:

The cool thing is that vanilla handles 99% of it for you, just add this:

 

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

        public void onDataPacket(INetworkManager net, Packet132TileEntityData packet) {
                readFromNBT(packet.data);
        }

 

Thank you! However I never made a mod where I would have to sync packets. So I really dont know how this is done. Where should I put this?

Posted
  On 1/15/2014 at 10:33 PM, DanteZg said:

  Quote

The cool thing is that vanilla handles 99% of it for you, just add this:

 

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

        public void onDataPacket(INetworkManager net, Packet132TileEntityData packet) {
                readFromNBT(packet.data);
        }

 

Thank you! However I never made a mod where I would have to sync packets. So I really dont know how this is done. Where should I put this?

 

Inside your tile entity class.  That's ALL you need to do in this case.

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
  On 1/15/2014 at 10:43 PM, Draco18s said:

  Quote

  Quote

The cool thing is that vanilla handles 99% of it for you, just add this:

 

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

        public void onDataPacket(INetworkManager net, Packet132TileEntityData packet) {
                readFromNBT(packet.data);
        }

 

Thank you! However I never made a mod where I would have to sync packets. So I really dont know how this is done. Where should I put this?

 

Inside your tile entity class.  That's ALL you need to do in this case.

 

Thats what I tought, however the still texture doesnt update/change. Even when I manually force a block to update.

Posted

Is the value that controls your texture saved to NBT?

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
  On 1/16/2014 at 12:07 AM, Draco18s said:

Is the value that controls your texture saved to NBT?

 

Yes, Its saved, everything else works, except that the textures stay the same. I havent finished all the textures, so when I run the game I get an error missing texture bla bla, it isnt possible that this could be causing this error? Aslo, you have my code above if you are interested in helping me out. Thank you btw.

Posted
  On 1/16/2014 at 12:15 AM, DanteZg said:
Yes, Its saved, everything else works, except that the textures stay the same. I havent finished all the textures, so when I run the game I get an error missing texture bla bla, it isnt possible that this could be causing this error? Aslo, you have my code above if you are interested in helping me out. Thank you btw.

 

If you're changing from one missing texture to another...

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

OK I have noticed that when I'm in singleplayer and after I quit and then rejoin the textures get updated. When I'm testing the server I get this error:

 

---- Minecraft Crash Report ----
// I just don't know what went wrong 

Time: 1/16/14 9:30 PM
Description: Ticking memory connection

java.lang.NullPointerException
at net.woodworks.blocks.BlockTable.onBlockActivated(BlockTable.java:166)
at net.minecraft.item.ItemInWorldManager.activateBlockOrUseItem(ItemInWorldManager.java:421)
at net.minecraft.network.NetServerHandler.handlePlace(NetServerHandler.java:556)
at net.minecraft.network.packet.Packet15Place.processPacket(Packet15Place.java:79)
at net.minecraft.network.MemoryConnection.processReadPackets(MemoryConnection.java:89)
at net.minecraft.network.NetServerHandler.networkTick(NetServerHandler.java:141)
at net.minecraft.network.NetworkListenThread.networkTick(NetworkListenThread.java:54)
at net.minecraft.server.integrated.IntegratedServerListenThread.networkTick(IntegratedServerListenThread.java:109)
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:691)
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:587)
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:129)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:484)
at net.minecraft.server.ThreadMinecraftServer.run(ThreadMinecraftServer.java:16)

 

  On 1/16/2014 at 4:06 AM, Draco18s said:

  Quote
Yes, Its saved, everything else works, except that the textures stay the same. I havent finished all the textures, so when I run the game I get an error missing texture bla bla, it isnt possible that this could be causing this error? Aslo, you have my code above if you are interested in helping me out. Thank you btw.

 

If you're changing from one missing texture to another...

 

I'm not :)

Posted

Okay I have figured out what have I done wrong and I have fixed that NullPointException, now the same thing happens on the server, when I setState to integer, the texture doesnt change until I log out and log in again. Please help me, this is the last thing holding me from releasing my mod.

Posted

Mmm~

Client-server disparity.

Solved by packets.

 

You're sure you have this in your TE?

 

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

        public void onDataPacket(INetworkManager net, Packet132TileEntityData packet) {
                readFromNBT(packet.data);
        }

 

And that right after you change the value you call world.notifyBlockChange()?

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
  On 1/17/2014 at 6:41 PM, Draco18s said:

Mmm~

Client-server disparity.

Solved by packets.

 

You're sure you have this in your TE?

 

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

        public void onDataPacket(INetworkManager net, Packet132TileEntityData packet) {
                readFromNBT(packet.data);
        }

 

And that right after you change the value you call world.notifyBlockChange()?

 

I have fixed that error with packets. Yeah here is my code:

	@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9)
{
	if(!world.isRemote){
		TileEntityTable par1tileEntity = (TileEntityTable)world.getBlockTileEntity(x, y, z);
			if (player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() == net.woodworks.common.WoodworksCommonProxy.itemModCloth && par1tileEntity.getState() == 0)
			{
				int par1ItemDamage = player.getCurrentEquippedItem().getItemDamage();
				par1tileEntity.setState(par1ItemDamage + 1);
				world.notifyBlockChange(x, y, z, this.blockID);
				player.inventory.decrStackSize(player.inventory.currentItem, 1);
				player.worldObj.playSoundAtEntity(player, "dig.cloth", 1.0F, 1.0F);
				return true;
			}
			else if(player.getCurrentEquippedItem().getItem() != net.woodworks.common.WoodworksCommonProxy.itemModCloth && par1tileEntity.getState() != 0){
				int par1ItemDamage = par1tileEntity.getState();
				dropItemStack(new ItemStack(net.woodworks.common.WoodworksCommonProxy.itemModCloth, 1, par1ItemDamage-1), world, x, y, z);
				par1tileEntity.setState(0);
				world.notifyBlockChange(x, y, z, this.blockID);
				player.worldObj.playSoundAtEntity(player, "dig.cloth", 1.0F, 1.0F);
				return true;
			}
			else if(player.getCurrentEquippedItem().getItem() == net.woodworks.common.WoodworksCommonProxy.itemModCloth && par1tileEntity.getState() != 0){
				int par1ItemDamage = player.getCurrentEquippedItem().getItemDamage();
				int par1State = par1tileEntity.getState();
				if(par1ItemDamage != par1State-1){
				player.inventory.decrStackSize(player.inventory.currentItem, 1);
				dropItemStack(new ItemStack(net.woodworks.common.WoodworksCommonProxy.itemModCloth, 1, par1State-1), world, x, y, z);
				par1tileEntity.setState(par1ItemDamage + 1);
				world.notifyBlockChange(x, y, z, this.blockID);
				player.worldObj.playSoundAtEntity(player, "dig.cloth", 1.0F, 1.0F);
				return true;
				}
			}
			else if(par1tileEntity.getState() == 1 && player.getCurrentEquippedItem().getItem() == Item.dyePowder){
				int par1ItemDamage = player.getCurrentEquippedItem().getItemDamage();
				player.inventory.decrStackSize(player.inventory.currentItem, 1);
				par1tileEntity.setState(par1ItemDamage +1);
				world.notifyBlockChange(x, y, z, this.blockID);
				player.worldObj.playSoundAtEntity(player, "dig.cloth", 1.0F, 1.0F);
				return true;
			}
	}
	return true;

}	

 

However the textures only change after you rejoin the world.

 

EDIT: I threw a bunch of this rerender methods(check to new code) and now it rerenders after clicking right click 2 times with the same item. Any ideas now? :D

 

	public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9)
{
	if(!world.isRemote){
		TileEntityTable par1tileEntity = (TileEntityTable)world.getBlockTileEntity(x, y, z);
			if (player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() == net.woodworks.common.WoodworksCommonProxy.itemModCloth && par1tileEntity.getState() == 0)
			{
				int par1ItemDamage = player.getCurrentEquippedItem().getItemDamage();
				par1tileEntity.setState(par1ItemDamage + 1);
				world.notifyBlockChange(x, y, z, this.blockID);
				player.worldObj.markBlockForRenderUpdate(x, y, z);
				player.inventory.decrStackSize(player.inventory.currentItem, 1);
				player.worldObj.playSoundAtEntity(player, "dig.cloth", 1.0F, 1.0F);
				return true;
			}
			else if(player.getCurrentEquippedItem().getItem() != net.woodworks.common.WoodworksCommonProxy.itemModCloth && par1tileEntity.getState() != 0){
				int par1ItemDamage = par1tileEntity.getState();
				dropItemStack(new ItemStack(net.woodworks.common.WoodworksCommonProxy.itemModCloth, 1, par1ItemDamage-1), world, x, y, z);
				par1tileEntity.setState(0);
				world.notifyBlockChange(x, y, z, this.blockID);
				player.worldObj.markBlockForRenderUpdate(x, y, z);
				player.worldObj.playSoundAtEntity(player, "dig.cloth", 1.0F, 1.0F);
				return true;
			}
			else if(player.getCurrentEquippedItem().getItem() == net.woodworks.common.WoodworksCommonProxy.itemModCloth && par1tileEntity.getState() != 0){
				int par1ItemDamage = player.getCurrentEquippedItem().getItemDamage();
				int par1State = par1tileEntity.getState();
				if(par1ItemDamage != par1State-1){
				player.inventory.decrStackSize(player.inventory.currentItem, 1);
				dropItemStack(new ItemStack(net.woodworks.common.WoodworksCommonProxy.itemModCloth, 1, par1State-1), world, x, y, z);
				par1tileEntity.setState(par1ItemDamage + 1);
				world.notifyBlockChange(x, y, z, this.blockID);
				player.worldObj.markBlockForRenderUpdate(x, y, z);
				player.worldObj.playSoundAtEntity(player, "dig.cloth", 1.0F, 1.0F);
				return true;
				}
			}
			else if(par1tileEntity.getState() == 1 && player.getCurrentEquippedItem().getItem() == Item.dyePowder){
				int par1ItemDamage = player.getCurrentEquippedItem().getItemDamage();
				player.inventory.decrStackSize(player.inventory.currentItem, 1);
				par1tileEntity.setState(par1ItemDamage +1);
				world.notifyBlockChange(x, y, z, this.blockID);
				player.worldObj.markBlockForRenderUpdate(x, y, z);
				player.worldObj.playSoundAtEntity(player, "dig.cloth", 1.0F, 1.0F);
				return true;
			}
	}
	world.markBlockForUpdate(x,y,z);
	world.notifyBlockChange(x, y, z, this.blockID);
	player.worldObj.markBlockForRenderUpdate(x, y, z);
	Minecraft.getMinecraft().renderGlobal.markBlockForRenderUpdate(x, y, z);
	return true;

}	

 

EDIT2: Got it to work! I will post my final code later tonight (I need to rewrite some things) so everyone with this problem can use it! Thank you for your help Draco!

 

EDIT3: Server crashes now!

 

EDIT4: Code works but it needs some serious rewriting, I'll be back in a few.

Posted

That code does not help solve the problem as there are NO references to packets in that function.

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.

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

    • wait, i just did that. why didn't it work? also it's the same. help me!!!!
    • Culprit has been located! It was Tough As Nails + (plus) which was among one of the mods *added* before re-entering, in an attempt to improve compatibility. It, for some reason or another, did not want to work!
    • "You can either try to load it with only the vanilla data pack ("safe mode"), or go back to the title screen and fix it manually." Hello! I encountered this error just now while attempting to re-enter my world for the first time. Notably, no mods were removed before encountering this error and, while being able to find this error elsewhere on the internet, in my scenario it is seemingly caused by a specific mod, of which I cannot isolate. Things I have tried: - Enter "Safe Mode" (fails) - Remove datapacks (no change) - Reverted to old save data (no change) Here is the server log: https://mclo.gs/9vJQEfN I use Modrinth mod loader so please let me know how to share my mod list, and if it is needed.
    • So, i'm hosting (or attempting to host) a port-forwarded modded server for 1.12.2. There's quite a few mods in this pack, but they all run and have no compatibility issues (besides something causing the game to crash if you go fullscreen, a problem ive given up trying to identify or fix). It can run on 6gb of ram or less, and works fine in singleplayer. All of my friends that want to join have the exact same mod/config/game setup as I do (I personally helped them set everything up). Just to be safe, we've all allocated 12 gigabytes of RAM to the installation, and I've also allocated 12GB to the server itself. I am able to join with no issue and it runs fine. However, when they try to join, it gets stuck in the 'logging in' screen before their game becomes unresponsive. When they close it, it gives them the exit code 805306369, which usually means not enough RAM, but this cant be the case. On my screen, in the server, it shows them joining, and then disconnecting, so I dont think its a port-forwarding issue. They can all run it just fine in singleplayer as well. The annoying bit about this particular issue is that it generates no crash log. Does anyone have any suggestions? Thanks! Here is my debug log, and his, starting from the same place. MINE: [132647] [Netty Client IO #5INFO] [FML] Attempting connection with missing mods [ctm, fusion] at SERVER 132653.817 [132653] [Client threadINFO] [minecraftGuiConnecting] Connecting to 0, 25565 132654.682 [132654] [Netty Client IO #9INFO] [STDOUT] [xaero.common.core.transformer.ClassNodeTransformertransform29] Transforming class brz net.minecraft.client.network.NetHandlerPlayClient 132654.684 [132654] [Netty Client IO #9INFO] [STDOUT] [xaero.map.core.transformer.ClassNodeTransformertransform29] Transforming class net.minecraft.client.network.NetHandlerPlayClient 132654.764 [132654] [Netty Client IO #9INFO] [FML] Server protocol version 2 132654.777 [132654] [Netty Client IO #9INFO] [FML] Attempting connection with missing mods [ctm, fusion] at SERVER 132656.193 [132656] [Client threadINFO] [FML] Injecting existing registry data into this client instance 132659.081 [132659] [Client threadINFO] [FML] Applying holder lookups 132659.082 [132659] [Client threadINFO] [FML] Holder lookups applied 132659.092 [132659] [Netty Client IO #9INFO] [FML] [Netty Client IO #9] Client side modded connection established HIS: [13:12:16] [Netty Client IO #0/INFO] [FML]: Attempting connection with missing mods [ctm, fusion] at SERVER 13:12:25.597 [13:12:25] [Client thread/INFO] [minecraft/GuiConnecting]: Connecting to (my IP address and the server port 25565) 13:12:26.805 [13:12:26] [Netty Client IO #1/INFO] [STDOUT]: [xaero.common.core.transformer.ClassNodeTransformer:transform:29]: Transforming class brz net.minecraft.client.network.NetHandlerPlayClient 13:12:26.808 [13:12:26] [Netty Client IO #1/INFO] [STDOUT]: [xaero.map.core.transformer.ClassNodeTransformer:transform:29]: Transforming class net.minecraft.client.network.NetHandlerPlayClient 13:12:26.936 [13:12:26] [Netty Client IO #1/INFO] [FML]: Server protocol version 2 13:12:27.114 [13:12:27] [Netty Client IO #1/INFO] [FML]: Attempting connection with missing mods [ctm, fusion] at SERVER 13:12:27.480 [13:12:27] [Client thread/INFO] [FML]: Injecting existing registry data into this client instance 13:12:30.669 [13:12:30] [Client thread/INFO] [FML]: Applying holder lookups 13:12:30.671 [13:12:30] [Client thread/INFO] [FML]: Holder lookups applied 13:13:04.700 Process crashed with exit code -805306369 P.S - Both mods "CTM" and "FUSION" are present in both our folders so idk what that's about.
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

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