I feel stupid again. I have fixed the errors. How do you use get enchantment helper to see if there is an enchantment (silk touch) on the pickaxe. I meant I can check this on the block harvest event. So this is all inside of the block break event because, it seems to be different.
@SubscribeEvent
public void BlockEvent(BreakEvent event)
{
if (event.world.isRemote = false)
{
if (event.block instanceof BlockMobSpawner)
{
event.world.getTileEntity(event.x, event.y, event.z);
ItemStack test1 = event.getPlayer().getCurrentEquippedItem();
if(test1 != null)
{
if (test1.getItem().getHarvestLevel(test1, "pickaxe") > 0)
{
}
}
}
}
}
How do you use get enchantment helper to see if there is an enchantment (silk touch) on the pickaxe.
The same way you did in your previous code, using EnchantmentHelper#getSilkTouchModifier. In HarvestDropsEvent, you should use BlockEvent.HarvestDropsEvent#isSilkTouching instead.
if (event.world.isRemote = false)
You're assigning false to the isRemote field instead of comparing its value to false. Did your IDE not warn you about this?
You should generally avoid using the == (equality) operator to compare booleans, either use the boolean value directly if you expect it to be true or invert it with the ! (not) operator if you expect it to be false.
Try to use meaningful variable names that describe the purpose of the variable. Instead of test1, call it something like heldItem (because it contains the player's held item).
if (test1 != null)
{
if (test1.getItem().getHarvestLevel(test1, "pickaxe") > 0)
{
These could be merged into a single if statement.
Rollback Post to RevisionRollBack
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
this is what I am stuck on. I don't know what to do with the parameter. event.harvester isn't a thing for block break.
EnchantmentHelper.getSilkTouchModifier(event.)
ok I fixed the one line into one if statement it would have worked anyways. I changed the name of test1 to heldItem. I also fixed if(world.isremote = false) to if(!world.isremote).
What do you want me to do with the tile entity store it to the hashmap or a variable to later be put there?
My current Hashmap setup doesn't have the dimension in the arguments I want to put it there should I? If the dimension is the key for retreiving the data then how am I suppose to put the data if there is no key in the arguments or does it auto put it there so confused on this part. This is why I like to make my own definitions so I am not on a form asking questions wondering how it works.
private TIntObjectMap<Map> feildSpawner = new TIntObjectHashMap<Map<ChunkPosition, TileEntity>>();
In your BlockEvent.BreakEvent handler, do the following:
Check if ... the TileEntity at the block's position (World#getTileEntity) was an instance of TileEntityMobSpawner
...
Get the TileEntity at the block's position and store it in the Map, using the block's position as the key.
My current Hashmap setup doesn't have the dimension in the arguments I want to put it there should I? If the dimension is the key for retreiving the data then how am I suppose to put the data if there is no key in the arguments or does it auto put it there so confused on this part. This is why I like to make my own definitions so I am not on a form asking questions wondering how it works.
The dimension ID is the key of the TIntObjectMap. You can think of a TIntObjectMap<Foo> as a Map<Integer, Foo>, except it uses primitive int keys rather than object Integer keys.
private TIntObjectMap<Map> feildSpawner = new TIntObjectHashMap<Map<ChunkPosition, TileEntity>>();
You should specify the generic type arguments of Map, i.e. TIntObjectMap<Map<ChunkPosition, TileEntity>> rather than TIntObjectMap<Map>.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
Get the Map<blockpos, tileentity=""> for the dimension the block was broken in from the TIntObjectMap. If it doesn't exist, create a new HashMap<blockpos, tileentity=""> and store it in the TIntObjectMap, using the dimension ID as the key.
Get the TileEntity at the block's position and store it in the Map, using the block's position as the key.
This is where I keep getting confused at. Ok let's say I get the Tintobjectmap how do I get the dimension id if it's not there I think this itself will make it crash the game. Create a new hash map if it doesn't exist what so not only your getting data from Tintobjectmap but, if it doesn't exsist just make a new hash map which isn't the tinobjectmap. Well you did say the outer map was the hash map so this would make sense but, it wouldn't when I am getting the tintobjectmap for the dimension id. Ok so let's assume your right and I don't know what I am doing which is true. so how am I suppose to make a new one if it doesn't exist? Set it to a variable and if it returns null ( wait it's public void and public void is required). So if it's null then write a new one. Well if it's null it should crash before it gets the chance to write a new one? so the key is the first thing to put the feild.put in but, what's it's value suppose to be TileEntity data?
So by create a hashmap you mean only the hashmap or another entire thing or add a thing to the hashmap?
So for tile entity the key is BlockPos (aka ChunkPosition) The value is Tile Entity I am assuming? what do I write from the tile entity? Do I set the map of tileentity to a varible and use that?
O about the silk touch. I did get it working but, it crashed because, there were two arguments in one event I don't know why it doesn't take (BreakEvent event, player)
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
I know it can't be copied and pasted that's why I am going to use your code as a reference but, either way I got an error from your method. Your method of
int dimensionID = event.world.provider.dimensionId;
if (!feild.containsKey(dimensionID)) { // If the map for this dimension doesn't exist yet, create it
feild.put(dimensionID, new HashMap<>());
}
here is what it is saying on the .put where the error is.
The method put(int, Map<chunkposition,tileentity>) in the type TIntObjectMap<map<chunkposition,tileentity>> is not applicable for the arguments (int, HashMap<object,object>)
Here is my entire class so far please don't give up on me.
package com.EvilNotch.SilkSpawners;
import java.util.HashMap;
import java.util.Map;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import gnu.trove.map.TIntObjectMap;
import gnu.trove.map.hash.TIntObjectHashMap;
import net.minecraft.block.BlockMobSpawner;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityMobSpawner;
import net.minecraft.world.ChunkPosition;
import net.minecraft.world.World;
import net.minecraft.world.WorldProvider;
import net.minecraftforge.event.world.BlockEvent.BreakEvent;
import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent;
public class SilkSpawners {
@SideOnly(Side.SERVER)
private static final TIntObjectMap<Map<ChunkPosition, TileEntity>> feild = new TIntObjectHashMap<>();
// WorldProvider#dimensionId field
// (first is chunkposition tileentity ("key") )
//String name = countryNames.get("IT");
@SubscribeEvent
public void BlockEvent(BreakEvent event, boolean isSilkTouching)
{
if (!event.world.isRemote)
{
if (event.block instanceof BlockMobSpawner)
{
if (event.world.getTileEntity(event.x, event.y, event.z) instanceof TileEntityMobSpawner);
{
ItemStack heldItem = event.getPlayer().getCurrentEquippedItem();
if (heldItem != null && heldItem.getItem().getHarvestLevel(heldItem, "pickaxe") > 0)
{
int dimensionID = event.world.provider.dimensionId;
if (!feild.containsKey(dimensionID)) { // If the map for this dimension doesn't exist yet, create it
feild.put(dimensionID, new HashMap<>());
}
}
}
}
}
}
// world.getProvider().getDimensionId() world.getTileEntity()
@SubscribeEvent
public void yourPlayerHarvestEvent(HarvestDropsEvent event1)
{
if(!event1.world.isRemote)
{
if (event1.block instanceof BlockMobSpawner)
{
ItemStack heldItem1 = event1.harvester.getCurrentEquippedItem();
if (heldItem1 != null && heldItem1.getItem().getHarvestLevel(heldItem1, "pickaxe") > 0)
{
event1.drops.add(new ItemStack(Blocks.bedrock, 1));
event1.world.removeTileEntity(event1.x, event1.y, event1.z);
event1.drops.clear();
// if nesassary feild.clear();
}
}
}
}
}
Since I cannot get the hash map working A because, it's giving me the error for putting the thing into hashmap like you had it and B there is no block position for 1.7.10 I am storing the tileentitydata in a variable. I however keep getting stuck writing the nbt data as your method doesn't work and .writetonbt has a parameter that I can't seem to find then it errors. Yes I tried using chunk position however those methods below don't exist either
final World world = event.getWorl
final BlockPos pos = event.getPos();
So the point is I think I can get away with a variable and then setting it to null after the function has complete for each block break and the harvest drops event it will be null. However I can't seem to find a working function in 1.7 to write to nbt and have spent hours looking without success.
package com.EvilNotch.SilkSpawners;
import java.util.HashMap;
import java.util.Map;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import gnu.trove.map.TIntObjectMap;
import gnu.trove.map.hash.TIntObjectHashMap;
import net.minecraft.block.Block;
import net.minecraft.block.BlockMobSpawner;
import net.minecraft.block.BlockSand;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityMobSpawner;
import net.minecraft.world.ChunkPosition;
import net.minecraft.world.World;
import net.minecraft.world.WorldProvider;
import net.minecraftforge.event.world.BlockEvent.BreakEvent;
import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent;
public class SilkSpawners {
public static TileEntity var1;
//@SideOnly(Side.SERVER)
// private static TIntObjectMap<Map<ChunkPosition, TileEntity>> feild = new TIntObjectHashMap<>();
// WorldProvider#dimensionId field
// (first is chunkposition tileentity ("key") )
//String name = countryNames.get("IT");
@SubscribeEvent
public void BlockEvent(BreakEvent event)
{
if (!event.world.isRemote)
{
if (event.block instanceof BlockMobSpawner)
{
if (event.world.getTileEntity(event.x, event.y, event.z) instanceof TileEntityMobSpawner);
{
ItemStack heldItem = event.getPlayer().getCurrentEquippedItem();
if (heldItem != null && heldItem.getItem().getHarvestLevel(heldItem, "pickaxe") > 0)
{
var1 = event.world.getTileEntity(event.x, event.y, event.z);
}
}
}
}
}
// world.getProvider().getDimensionId() world.getTileEntity()
@SubscribeEvent
public void yourPlayerHarvestEvent(HarvestDropsEvent event1)
{
if(!event1.world.isRemote)
{
if (event1.block instanceof BlockMobSpawner)
{
ItemStack heldItem1 = event1.harvester.getCurrentEquippedItem();
if (heldItem1 != null && heldItem1.getItem().getHarvestLevel(heldItem1, "pickaxe") > 0)
{
Block block = Blocks.mob_spawner;
final NBTTagCompound tileData = var1.writeToNBT(p_145841_1_); // Write the TileEntity to NBT
final ItemStack droppedItem = new ItemStack(block); // Create an ItemStack of the Block
droppedItem.setTagInfo("BlockEntityTag", tileData); // Store the TileEntity data in the ItemStack
event1.drops.add(droppedItem); // Add the ItemStack to the drops list
event1.world.removeTileEntity(event1.x, event1.y, event1.z);
event1.drops.clear();
var1 = null; //resets var1 to null and is ready for the next instance
// if nesassary feild.clear();
}
}
}
}
}
The method put(int, Map<chunkposition,tileentity>) in the type TIntObjectMap<map<chunkposition,tileentity>> is not applicable for the arguments (int, HashMap<object,object>)
If you're not targeting Java 8, you need to fully specify the generic type arguments instead of leaving them empty and letting the compiler infer them. This means using HashMap<ChunkPosition, TileEntity> instead of just HashMap<>.
You need to create an NBTTagCompound to pass to TileEntity#writeToNBT, this is where the data will be written to. This method returns void in 1.7.10, so you need to create the compound tag, call the method and then use the tag in separate statements.
The getter methods I'm using were added in a more recent version of Minecraft. In 1.7.10, you need to access the fields directly instead.
Rollback Post to RevisionRollBack
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
ok I got the nbt to itemsStack however when placed down it becomes a pig again rather then a skele spawner. is this because my refusal to use hashmap or am I missing something here? If you find no issues then I am going to try your hashmaps again.
1.7.10 doesn't read TileEntity data from the ItemStack's "BlockEntityTag" tag when placing blocks, so you'll need to do this yourself.
Subscribe to BlockEvent.PlaceEvent and check if the player is placing a mob spawner with the BlockEntityTag tag. If this is the case, get the TileEntity at the position and call TileEntity#readFromNBT with the BlockEntityTag tag.
Rollback Post to RevisionRollBack
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
This makes sense I think I can figure this out and will post to here if I have any more questions/issues.
Edit I know this code isn't writing any nbt tags to itemstacks but, I was testing metadata and nie. It kept returning 0 So This is where I need help on and I will work on making it work by itself later.
So here lies my issue nie contains metadata for each blockmobspawner ItemStack. I think the tileentites themselves are vanilla. However when in item stack they have a metadata. When I try to get this metadata it inputs 0 for varmetadata. So does the spawners have metadata as blocks? If only with nie as the itemstack has metadata then how do I get it to write metadata from nbt to nies version of the spawner? Or if it does exsist in the block in some way what is wrong with my code? Do they really place an entity inside of the spawner? How could I add support for nie with the metadata so it shows the model.
Having issues with what you told me to do. How do I get the blockentitytag if the block just got placed? does it still have the item stack in that event? What methods do you want me to read the nbt. varible .readtonbt? If you tileentity mob spawner read nbt I don't know how to do that it says cannot make static reference.
Tried updating it to 1.8.9 and 1.8.9 is junk. I couldn't even call event .block. when it wasn't that junk and I fixed it then, it told me that the nibble was out of bounds even though it worked perfect for 1.7.10.
It looks like NEI creates its own spawner ItemBlock that uses the entity's global ID as its metadata and replaces the vanilla ItemBlock with it. This only supports entities that extend EntityLiving and have a global ID. These restrictions don't apply to spawners themselves, so you'll need to fall back to using NBT for some entities.
The vanilla spawner block doesn't use metadata.
To support NEI, you'll need to modify your HarvestDropsEvent handler to do the following:
Check if NEI is loaded.
Get the entity name from MobSpawnerBaseLogic#getEntityNameToSpawn.
Get the entity class from EntityList#stringToClassMapping, using the entity name as the key.
Check if the entity class extends EntityLiving by calling Class#isAssignableFrom on EntityLiving.class and passing the entity class as an argument.
Create an instance of the entity by calling EntityList#createEntityByName with the name and World.
Get the entity's global ID by calling EntityList#getEntityID with the entity instance.
If these conditions are met and the global ID is greater than 0, use the global ID as the metadata of the ItemStack you add to the drops list. Otherwise write the TileEntity to NBT and store it in the ItemStack's NBT.
In your PlaceEvent handler, get the held item from BlockEvent.PlaceEvent#itemInHand and the TileEntity from World#getTileEntity. Only call TileEntity#readFromNBT if the "BlockEntityTag" tag exists, let NEI handle the metadata-based spawners.
In 1.8.9+, most events use private fields with public getter methods for proper encapsulation. Most places that previously used a Block and metadata value now use an IBlockState instead (e.g. use the BlockEvent#getState method instead of the BlockEvent#block field). This page introduces block states.
I'm not sure what nibble you're talking about. If it's not directly related to this topic, I suggest creating a new thread for it and I may answer you there.
I wouldn't recommend updating to 1.8.9, it's several versions out of date. If you're going to update, update to the latest version (1.10.2).
Rollback Post to RevisionRollBack
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
1.1.02 or whatever It is called I don't like it because, of it's features from 1.9 otherwise I would play it. That involves the swing cap on wepons. I would have to use forge asm to change the ItemSword , ItemAxe, to the old ways and hope it doesn't have the spawn cap / same properties and that is over my head for now.
Also the latest version with forge you already wrote if I were to compile a version I would compile your mod and play that. Of course I couldn't claim rights to this mod.
if the "BlockEntityTag" tag exists,
This is what I was asking about. How do I detect this? From an ItemStack and if so how?
This is what I was asking about. How do I detect this? From an ItemStack and if so how?
Use ItemStack#hasTagCompound to check if an ItemStack has a stack compound tag, then use ItemStack#getTagCompound to get it. You can then use NBTTagCompound#hasKey(String, int) to check if the compound tag has a key (the first argument) with the specified tag type (the second argument, use the constants from Constants.NBT).
Rollback Post to RevisionRollBack
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
i am trying to do this as well how would i fix this error
Cannot make a static reference to the non-static method getEntityNameToSpawn() from the type MobSpawnerBaseLogic
You must have a solid understanding of Java and OO programming in general before you can make a mod. If you did have this understanding, you'd be able to understand what the error message is telling you.
Rollback Post to RevisionRollBack
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
since the code only fires up on the server side and server worlds can this be on client mod as well?
I feel stupid again. I have fixed the errors. How do you use get enchantment helper to see if there is an enchantment (silk touch) on the pickaxe. I meant I can check this on the block harvest event. So this is all inside of the block break event because, it seems to be different.
The same way you did in your previous code, using EnchantmentHelper#getSilkTouchModifier. In HarvestDropsEvent, you should use BlockEvent.HarvestDropsEvent#isSilkTouching instead.
You're assigning false to the isRemote field instead of comparing its value to false. Did your IDE not warn you about this?
You should generally avoid using the == (equality) operator to compare booleans, either use the boolean value directly if you expect it to be true or invert it with the ! (not) operator if you expect it to be false.
You're calling World#getTileEntity and then doing nothing with the result. Why?
Try to use meaningful variable names that describe the purpose of the variable. Instead of test1, call it something like heldItem (because it contains the player's held item).
These could be merged into a single if statement.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
this is what I am stuck on. I don't know what to do with the parameter. event.harvester isn't a thing for block break.
ok I fixed the one line into one if statement it would have worked anyways. I changed the name of test1 to heldItem. I also fixed if(world.isremote = false) to if(!world.isremote).
What do you want me to do with the tile entity store it to the hashmap or a variable to later be put there?
My current Hashmap setup doesn't have the dimension in the arguments I want to put it there should I? If the dimension is the key for retreiving the data then how am I suppose to put the data if there is no key in the arguments or does it auto put it there so confused on this part. This is why I like to make my own definitions so I am not on a form asking questions wondering how it works.
Did you try looking at the BreakEvent class? It has a field called player containing the player who broke the block.
The dimension ID is the key of the TIntObjectMap. You can think of a TIntObjectMap<Foo> as a Map<Integer, Foo>, except it uses primitive int keys rather than object Integer keys.
You should specify the generic type arguments of Map, i.e. TIntObjectMap<Map<ChunkPosition, TileEntity>> rather than TIntObjectMap<Map>.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
This is where I keep getting confused at. Ok let's say I get the Tintobjectmap how do I get the dimension id if it's not there I think this itself will make it crash the game. Create a new hash map if it doesn't exist what so not only your getting data from Tintobjectmap but, if it doesn't exsist just make a new hash map which isn't the tinobjectmap. Well you did say the outer map was the hash map so this would make sense but, it wouldn't when I am getting the tintobjectmap for the dimension id. Ok so let's assume your right and I don't know what I am doing which is true. so how am I suppose to make a new one if it doesn't exist? Set it to a variable and if it returns null ( wait it's public void and public void is required). So if it's null then write a new one. Well if it's null it should crash before it gets the chance to write a new one? so the key is the first thing to put the feild.put in but, what's it's value suppose to be TileEntity data?
So by create a hashmap you mean only the hashmap or another entire thing or add a thing to the hashmap?
So for tile entity the key is BlockPos (aka ChunkPosition) The value is Tile Entity I am assuming? what do I write from the tile entity? Do I set the map of tileentity to a varible and use that?
O about the silk touch. I did get it working but, it crashed because, there were two arguments in one event I don't know why it doesn't take (BreakEvent event, player)
I'm struggling to explain this to you and running out of patience, so I've implemented this for 1.10.2 here. The comments should explain how it works.
This can't be directly copy-pasted for 1.7.10, I suggest you try to understand my code and write it for 1.7.10 yourself.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
I know it can't be copied and pasted that's why I am going to use your code as a reference but, either way I got an error from your method. Your method of
here is what it is saying on the .put where the error is.
The method put(int, Map<chunkposition,tileentity>) in the type TIntObjectMap<map<chunkposition,tileentity>> is not applicable for the arguments (int, HashMap<object,object>)
Here is my entire class so far please don't give up on me.
Since I cannot get the hash map working A because, it's giving me the error for putting the thing into hashmap like you had it and B there is no block position for 1.7.10 I am storing the tileentitydata in a variable. I however keep getting stuck writing the nbt data as your method doesn't work and .writetonbt has a parameter that I can't seem to find then it errors. Yes I tried using chunk position however those methods below don't exist either
So the point is I think I can get away with a variable and then setting it to null after the function has complete for each block break and the harvest drops event it will be null. However I can't seem to find a working function in 1.7 to write to nbt and have spent hours looking without success.
If you're not targeting Java 8, you need to fully specify the generic type arguments instead of leaving them empty and letting the compiler infer them. This means using HashMap<ChunkPosition, TileEntity> instead of just HashMap<>.
You need to create an NBTTagCompound to pass to TileEntity#writeToNBT, this is where the data will be written to. This method returns void in 1.7.10, so you need to create the compound tag, call the method and then use the tag in separate statements.
The getter methods I'm using were added in a more recent version of Minecraft. In 1.7.10, you need to access the fields directly instead.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
ok I got the nbt to itemsStack however when placed down it becomes a pig again rather then a skele spawner. is this because my refusal to use hashmap or am I missing something here? If you find no issues then I am going to try your hashmaps again.
Here is my code
http://pastebin.com/esRH9etM
So harvested block skele is in the before block placed back down.
Before block placed after harvested skele
After block placed then harvested
1.7.10 doesn't read TileEntity data from the ItemStack's "BlockEntityTag" tag when placing blocks, so you'll need to do this yourself.
Subscribe to BlockEvent.PlaceEvent and check if the player is placing a mob spawner with the BlockEntityTag tag. If this is the case, get the TileEntity at the position and call TileEntity#readFromNBT with the BlockEntityTag tag.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
This makes sense I think I can figure this out and will post to here if I have any more questions/issues.
Edit I know this code isn't writing any nbt tags to itemstacks but, I was testing metadata and nie. It kept returning 0 So This is where I need help on and I will work on making it work by itself later.
So here lies my issue nie contains metadata for each blockmobspawner ItemStack. I think the tileentites themselves are vanilla. However when in item stack they have a metadata. When I try to get this metadata it inputs 0 for varmetadata. So does the spawners have metadata as blocks? If only with nie as the itemstack has metadata then how do I get it to write metadata from nbt to nies version of the spawner? Or if it does exsist in the block in some way what is wrong with my code? Do they really place an entity inside of the spawner? How could I add support for nie with the metadata so it shows the model.
Having issues with what you told me to do. How do I get the blockentitytag if the block just got placed? does it still have the item stack in that event? What methods do you want me to read the nbt. varible .readtonbt? If you tileentity mob spawner read nbt I don't know how to do that it says cannot make static reference.
Tried updating it to 1.8.9 and 1.8.9 is junk. I couldn't even call event .block. when it wasn't that junk and I fixed it then, it told me that the nibble was out of bounds even though it worked perfect for 1.7.10.
It looks like NEI creates its own spawner ItemBlock that uses the entity's global ID as its metadata and replaces the vanilla ItemBlock with it. This only supports entities that extend EntityLiving and have a global ID. These restrictions don't apply to spawners themselves, so you'll need to fall back to using NBT for some entities.
The vanilla spawner block doesn't use metadata.
To support NEI, you'll need to modify your HarvestDropsEvent handler to do the following:
If these conditions are met and the global ID is greater than 0, use the global ID as the metadata of the ItemStack you add to the drops list. Otherwise write the TileEntity to NBT and store it in the ItemStack's NBT.
In your PlaceEvent handler, get the held item from BlockEvent.PlaceEvent#itemInHand and the TileEntity from World#getTileEntity. Only call TileEntity#readFromNBT if the "BlockEntityTag" tag exists, let NEI handle the metadata-based spawners.
In 1.8.9+, most events use private fields with public getter methods for proper encapsulation. Most places that previously used a Block and metadata value now use an IBlockState instead (e.g. use the BlockEvent#getState method instead of the BlockEvent#block field). This page introduces block states.
I'm not sure what nibble you're talking about. If it's not directly related to this topic, I suggest creating a new thread for it and I may answer you there.
I wouldn't recommend updating to 1.8.9, it's several versions out of date. If you're going to update, update to the latest version (1.10.2).
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
1.1.02 or whatever It is called I don't like it because, of it's features from 1.9 otherwise I would play it. That involves the swing cap on wepons. I would have to use forge asm to change the ItemSword , ItemAxe, to the old ways and hope it doesn't have the spawn cap / same properties and that is over my head for now.
Also the latest version with forge you already wrote if I were to compile a version I would compile your mod and play that. Of course I couldn't claim rights to this mod.
This is what I was asking about. How do I detect this? From an ItemStack and if so how?
Use ItemStack#hasTagCompound to check if an ItemStack has a stack compound tag, then use ItemStack#getTagCompound to get it. You can then use NBTTagCompound#hasKey(String, int) to check if the compound tag has a key (the first argument) with the specified tag type (the second argument, use the constants from Constants.NBT).
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
i am trying to do this as well how would i fix this error
Cannot make a static reference to the non-static method getEntityNameToSpawn() from the type MobSpawnerBaseLogic
You must have a solid understanding of Java and OO programming in general before you can make a mod. If you did have this understanding, you'd be able to understand what the error message is telling you.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
So how do we get the thing you wanted us to when it isn't under the event if we can't make public static reference?