Jump to content

Fences dont register when testing with world.isRemote


Tschallacka

Recommended Posts

I have made an item as a worldstripper to harvest structures with and now I've hit upon a peculiar problem.

 

When I hit a fence any code in world.isRemote does not get evaluated. Is there any reason why world.isRemote does not evaluate when hitting a fence with an item? All other blocks get captured properly when being hit, but the fences just dont evaluate in world.isRemote. if I remove the world.isRemote it works fine, but I don't want that because I want it to be able to execute clientside only.

 

public boolean onItemUse(ItemStack itemstack, EntityPlayer player, World world, int x, int y, int z, int targetSide, float targetX, float targetY, float targetZ)
    {
    	final int metadata = itemstack.getItemDamage();
    	
    	if(metadata == 0) {
	    	if(world.isRemote) {
	    		Block block = world.getBlock(x, y, z);
	    		String name = block.blockRegistry.getNameForObject(block);
	    		int[] store = {world.getBlockMetadata(x, y, z),x,y,z};
	    		MagicCookie.log.warn("Aquired block with worldstripper : "+name + "("+store[0]+")");			    	
			    ItemWorldStripper.blocks.put(x+"/"+y+"/"+z+"="+name, store);
	    		}
		    world.setBlockToAir(x, y, z);
    	}
}

How much wood could a woodchuck chuck if a wood chuck could chuck wood - Guybrush Treepwood

 

I wrote my own mod ish... still a few bugs to fix. http://thaumcraft.duckdns.org/downloads/MagicCookies-1.0.6.4.jar

Link to comment
Share on other sites

I have made an item as a worldstripper to harvest structures with and now I've hit upon a peculiar problem.

 

When I hit a fence any code in world.isRemote does not get evaluated. Is there any reason why world.isRemote does not evaluate when hitting a fence with an item? All other blocks get captured properly when being hit, but the fences just dont evaluate in world.isRemote. if I remove the world.isRemote it works fine, but I don't want that because I want it to be able to execute clientside only.

 

public boolean onItemUse(ItemStack itemstack, EntityPlayer player, World world, int x, int y, int z, int targetSide, float targetX, float targetY, float targetZ)
    {
    	final int metadata = itemstack.getItemDamage();
    	
    	if(metadata == 0) {
	    	if(world.isRemote) {
	    		Block block = world.getBlock(x, y, z);
	    		String name = block.blockRegistry.getNameForObject(block);
	    		int[] store = {world.getBlockMetadata(x, y, z),x,y,z};
	    		MagicCookie.log.warn("Aquired block with worldstripper : "+name + "("+store[0]+")");			    	
			    ItemWorldStripper.blocks.put(x+"/"+y+"/"+z+"="+name, store);
	    		}
		    world.setBlockToAir(x, y, z);
    	}
}

 

world.isRemote is telling you whether it is the client's world or not. Use !world.isRemote (this means the world is the server). NEVER try to make something client-side that isn't textures or something of the like.

Link to comment
Share on other sites

Thats the thing, like i mentioned it, I want it to be clientside only. What i do is add the information to a hashmap and then put it in an output. Prefably i have this running clientside so I can use it on my server without having to dive into the server files.

 

It all works beatifully, except for fences. Walls, torches etc... All get registered, but the fences never trigger on the remote world.

 

Im just interested why that is. Im suspecting the leashing code interfering somehow. But that doesn't explain for me why it does work server side but not clientside.

How much wood could a woodchuck chuck if a wood chuck could chuck wood - Guybrush Treepwood

 

I wrote my own mod ish... still a few bugs to fix. http://thaumcraft.duckdns.org/downloads/MagicCookies-1.0.6.4.jar

Link to comment
Share on other sites

Thats the thing, like i mentioned it, I want it to be clientside only. What i do is add the information to a hashmap and then put it in an output. Prefably i have this running clientside so I can use it on my server without having to dive into the server files.

 

It all works beatifully, except for fences. Walls, torches etc... All get registered, but the fences never trigger on the remote world.

 

Im just interested why that is. Im suspecting the leashing code interfering somehow. But that doesn't explain for me why it does work server side but not clientside.

 

Ok, what exactly are you trying to do? This world.setBlockToAir(x, y, z); can NEVER be run on the client!

Link to comment
Share on other sites

Thats the thing, like i mentioned it, I want it to be clientside only. What i do is add the information to a hashmap and then put it in an output. Prefably i have this running clientside so I can use it on my server without having to dive into the server files.

 

It all works beatifully, except for fences. Walls, torches etc... All get registered, but the fences never trigger on the remote world.

 

Im just interested why that is. Im suspecting the leashing code interfering somehow. But that doesn't explain for me why it does work server side but not clientside.

 

Ok, what exactly are you trying to do? This world.setBlockToAir(x, y, z); can NEVER be run on the client!

He never ran it on the client. He ran it on both sides.

EDIT: That was really dumb.

Maker of the Craft++ mod.

Link to comment
Share on other sites

Thats the thing, like i mentioned it, I want it to be clientside only. What i do is add the information to a hashmap and then put it in an output. Prefably i have this running clientside so I can use it on my server without having to dive into the server files.

 

It all works beatifully, except for fences. Walls, torches etc... All get registered, but the fences never trigger on the remote world.

 

Im just interested why that is. Im suspecting the leashing code interfering somehow. But that doesn't explain for me why it does work server side but not clientside.

 

You are absolutely right, the bracket was farther right than I am used to looking. Shouldn't that method only be run server-side though? I would think that telling both the client and server to remove it would cause issues.

 

Ok, what exactly are you trying to do? This world.setBlockToAir(x, y, z); can NEVER be run on the client!

He never ran it on the client. He ran it on both sides.

Link to comment
Share on other sites

Usefull guys. If I was interested in a discussion about the merit of clientside vs serverside i would have posted a different question.

 

What I'm interested in is why a fence does not trigger the in itemuse when clientside but all other blocks do.

How much wood could a woodchuck chuck if a wood chuck could chuck wood - Guybrush Treepwood

 

I wrote my own mod ish... still a few bugs to fix. http://thaumcraft.duckdns.org/downloads/MagicCookies-1.0.6.4.jar

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.

Announcements



×
×
  • Create New...

Important Information

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