Jump to content

Remove TileEntity and the Item in Slot


themaw

Recommended Posts

Is there an optimization method if I want to have a large scale removal?

private void clean(EntityPlayer theplayer,World world){
		int start = 500;
		//start is the range of clean
		int x = theplayer.serverPosX-start;

		int y = theplayer.serverPosY-128;

		int z = theplayer.serverPosZ-start;

		int count = 0;

		for(int i1 = 0;i1<start*2;i1++){

			for(int i2 = 0;i2<300;i2++){

				for(int i3 = 0;i3<start*2;i3++){

					TileEntity tile = world.getTileEntity(x+i1, y+i2, z+i3);

					if(tile!=null){

						System.out.println(tile.toString());

						world.removeTileEntity(x+i1, y+i2, z+i3);

						++count;

					}

				}

			}

		}

		System.out.println("Clean "+count+" TileEntities By Player "+theplayer.getDisplayName());

	}

 

Edited by themaw
Link to comment
Share on other sites

Remove tile entity does not do what you want, in any way, shape, or form.

 

You want to remove an item from a tile entity's inventory? Use getCapability() to get its inventory and remove the item from the IItemStackHandler instance.

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

2 hours ago, Draco18s said:

Remove tile entity does not do what you want, in any way, shape, or form.

 

You want to remove an item from a tile entity's inventory? Use getCapability() to get its inventory and remove the item from the IItemStackHandler instance.

Thank you so much!:D:D:D

Because of you, I finally implemented a tool today to remove TileEntity from a region.

I successfully made a tool for the player's archive to eliminate the wrong TileEntity.

Although I didn't use getCapability(), I just remembered that I didn't transform TileEntity into IInventory.

Here is my void code:

	private void cleantileentity(EntityPlayer theplayer, World world) {

		

		int start = info.tileentitycleanrange;

		int x = theplayer.serverPosX-start;

		int y = theplayer.serverPosY-128;

		int z = theplayer.serverPosZ-start;

		int count = 0;

		for(int i1 = 0;i1<start*2;i1++){

			for(int i2 = 0;i2<300;i2++){

				for(int i3 = 0;i3<start*2;i3++){

					TileEntity tile = world.getTileEntity(x+i1, y+i2, z+i3);

					if(tile!=null){

						if(tile instanceof IInventory){

							IInventory tile2 = (IInventory)tile;

							for(int i4=0;i4<tile2.getSizeInventory();i4++){

								if(tile2.getStackInSlot(i4)!=null){

									tile2.setInventorySlotContents(i4, null);

								}

							}

						System.out.println("Remove TileEntity with item in "+tile.toString()+"x:"+(x+i1)+" y:"+(y+i2)+" z:"+(z+i3));

						}

						world.removeTileEntity(x+i1, y+i2, z+i3);

						System.out.println("Remove TileEntity in "+tile.toString()+"x:"+(x+i1)+" y:"+(y+i2)+" z:"+(z+i3));

						++count;

					}

				}

			}

		}

		System.out.println("Clean "+count+" TileEntites By Player "+theplayer.getDisplayName());

	}

 

Link to comment
Share on other sites

IInventory is only for vanilla containers. That won't work with mods.

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

On 16-2-2018 at 9:33 AM, Draco18s said:

IInventory is only for vanilla containers. That won't work with mods.

nope he is on 1.7.10

 

and WHY remove the tileEntity that could end up badly because the other mod still thinks there is a tile on that block

Edited by loordgek
Link to comment
Share on other sites

  • Guest locked this topic
Guest
This topic is now closed to further replies.


  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • ChemsXpress (https://chemsxpress.com): ChemsXpress is a platform specializing in the distribution of research chemicals and related products. It offers a wide range of substances for scientific and laboratory use, catering to researchers and professionals. BubatzLand (https://bubatzland.com): BubatzLand focuses on providing high-quality cannabis products. The site offers a variety of strains, edibles, and related accessories, aiming to serve the needs of cannabis enthusiasts and medicinal users. HalluShroom (https://hallushroom.com): HalluShroom specializes in the sale of psychedelic mushrooms and related products. It caters to individuals interested in exploring the benefits and experiences associated with psilocybin and other psychedelic substances. HighAsch (https://highasch.com): HighAsch offers a diverse range of cannabis products, including flowers, concentrates, and edibles. The site aims to provide premium-quality products to both recreational and medicinal users. KetaminHaus (https://ketaminhaus.com): KetaminHaus provides ketamine and related products for research and therapeutic use. The platform focuses on ensuring the availability of high-quality, safe, and effective ketamine for various applications. KokainLabor (https://kokainlabor.com): KokainLabor offers cocaine and other related substances. The site targets individuals seeking high-purity products for personal or research purposes, emphasizing quality and safety. MDPHPWelt (https://mdphpwelt.com): MDPHPWelt specializes in the distribution of MDPHP and other similar research chemicals. It aims to supply researchers with high-quality substances for scientific and experimental use. NembutaLabor (https://nembutalabor.com): NembutaLabor provides Nembutal (pentobarbital) and related products. The site focuses on supplying these substances for research and veterinary purposes, ensuring high standards of quality and safety. NembutalQuelle (https://nembutalquelle.com): NembutalQuelle is dedicated to offering Nembutal and similar barbiturates. It caters to researchers and professionals who require these substances for scientific, medical, or veterinary applications. JBSaves Ltda Brazil (https://jbsavesltdabrazil.com): JBSaves Ltda Brazil is involved in the food and agricultural industry, providing a variety of products and services related to food processing, distribution, and agricultural practices. Bello Alimentos Ltda (https://belloalimentosltda.com): Bello Alimentos Ltda offers a wide range of food products. The site focuses on high-quality, nutritious, and safe food items, catering to consumers and businesses in the food industry. São Salvador Alimentos (https://saosalvadoralimentoss.com): São Salvador Alimentos specializes in the production and distribution of food products. The site provides a variety of options aimed at meeting the dietary needs and preferences of diverse consumers. WietWereld (https://wietwereld.com): WietWereld is a platform dedicated to the cannabis community. It offers information, products, and resources related to cannabis cultivation, consumption, and culture. 14. BeuhParadise (https://beuhparadis.com): BeuhParadise offers a range of cannabis products, including flowers, edibles, and concentrates. The site aims to provide high-quality cannabis products to recreational and medicinal users, emphasizing purity and potency. 15. WietWereld (https://wietwereld.com): WietWereld is a comprehensive resource for cannabis enthusiasts. It provides products, cultivation guides, and community forums for those interested in cannabis culture and cultivation. GrasOase (https://grasoase.com): GrasOase specializes in cannabis products and accessories. The site offers a variety of strains, seeds, and related items for cannabis users, focusing on quality and customer satisfaction. https://chemsxpress.com/ https://bubatzland.com/ https://hallushroom.com/ https://highasch.com/ https://ketaminhaus.com/ https://kokainlabor.com/ https://mdphpwelt.com/ https://nembutalabor.com/ https://nembutalquelle.com/ https://jbsavesltdabrazil.com/ https://belloalimentosltda.com/ https://saosalvadoralimentoss.com/ https://wietwereld.com https://beuhparadis.com https://wietwereld.com https://grasoase.com/
    • For Example I have an Main Mod that adds new Content to Minecraft. But I'm using custom Classes etc. and I want it so that is an api integrated in the Main Mod but can be download seperately like an Module. Is this possible? If you need more Information just comment what you need to know ^^
    • Delete the config of this mod (config folder) and test it again   If there is no change, try other builds  
    • Add the full crash-report or latest.log (logs-folder) with sites like https://paste.ee/ and paste the link to it here
  • Topics

×
×
  • Create New...

Important Information

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