
MrDireball
Members-
Posts
34 -
Joined
-
Last visited
Everything posted by MrDireball
-
Even if Minecraft wasn't meant to mod, it still would have been better practice to cycle through an array at this point, or even better, use a dictionary. I've heard that they pretty much completely rewrote everything a few years ago, so I'm surprised that they didn't add mod support considering that Minecraft among the most modded video games in existence.
-
While looking at the code in EntityVillager, I found something that has caught my eye. In the canVillagerPickupItem method, rather than loop through a static array of items that it can pick up, it uses an if-statement with six ||s. The problem with this is that whatever the villager is allowed to pick up is hardcoded into the statement. With an array, you could just go to where the array is initialized and add it in. Is there any particular way why it was done like this? I know that the final result is still the same, but you could say that about pretty much any good or bad practice. private boolean canVillagerPickupItem(Item itemIn) { return itemIn == Items.BREAD || itemIn == Items.POTATO || itemIn == Items.CARROT || itemIn == Items.WHEAT || itemIn == Items.WHEAT_SEEDS || itemIn == Items.BEETROOT || itemIn == Items.BEETROOT_SEEDS; }
-
How to check if an instance of EntityAnimal is an adult?
MrDireball replied to MrDireball's topic in Modder Support
I wasn't actually looking through the code for the method, I made a variable for EntityAnimal and then typed the variable with a dot at the end and looked at all the suggestions. -
How to check if an instance of EntityAnimal is an adult?
MrDireball replied to MrDireball's topic in Modder Support
Ah, I was looking in EntityAnimal for it, it completely slipped my mind to check inside an interface that it implements. Thanks. -
How to check if an instance of EntityAnimal is an adult?
MrDireball posted a topic in Modder Support
So I want to make sure that when I add drops to the drop events of animals that they are adults, but I can't seem to find a method for checking. -
Much thanks to both of you.
-
Can't find very much documentation on that, could you please expand on that a bit?
-
So oak leaves for instance drop saplings and apples, but how could I override the method that decides which items to drop(It's called onBreak or onHarvest or something) so that I can give it custom drops?
-
What's the proper way to register a tileEntity?
MrDireball replied to MrDireball's topic in Modder Support
I just learned both Java and how to mod Minecraft a few days ago, so I don't actually know what a proxy is. I was just told somewhere to register TileEntities in a proxy. -
How to writeToNBT for more advanced objects?
MrDireball replied to MrDireball's topic in Modder Support
Ah, yes, I forgot to check whether it was null first. I also fixed the other error by setting itemStack to initialize to a stack of air rather than null. So although there doesn't seem to be any more errors, the problem with it not saving the value of itemStack after unloading and reloading still persists. DataBlock -
How to writeToNBT for more advanced objects?
MrDireball replied to MrDireball's topic in Modder Support
I'm trying to use that method of doing it, but I'm getting two errors. Code: First error, occurs upon placing block: -
How to writeToNBT for more advanced objects?
MrDireball replied to MrDireball's topic in Modder Support
I told it to read from and write to a file called "test.bat", but for some reason, it's still not working or even creating the file. -
How to writeToNBT for more advanced objects?
MrDireball replied to MrDireball's topic in Modder Support
Pardon my bad understanding, are you saying that I should create a new instance of NBTTagCompound or a new type that derives from NBTTagCompound? -
How to writeToNBT for more advanced objects?
MrDireball replied to MrDireball's topic in Modder Support
I'm checking it by right-clicking a block, and it swaps the item in the player's hand with the item in the DataTileEntity, which works fine until I reload, then whatever was in it is gone. So how can I get around the default setting? -
How to writeToNBT for more advanced objects?
MrDireball replied to MrDireball's topic in Modder Support
I have a member variable of the type ItemStack in my DataTileEntity class, and I'd like it to still have a reference to whatever it had a reference to before I relogged. But it is null everytime I load up the world again. -
How to writeToNBT for more advanced objects?
MrDireball replied to MrDireball's topic in Modder Support
Dangit, it's not saving the item. Is there anything that you can see that's clearly wrong with this code? I doubt I'm using the super right. -
How to writeToNBT for more advanced objects?
MrDireball replied to MrDireball's topic in Modder Support
What should I replace "id" with? "Minecraft:DIAMOND"? Here's what I translated this into: -
How to writeToNBT for more advanced objects?
MrDireball replied to MrDireball's topic in Modder Support
-
How to writeToNBT for more advanced objects?
MrDireball replied to MrDireball's topic in Modder Support
Could you give me a code example of that? -
Idiot me. If you look closely at line 9, you'll see that I accidentally set y to z, hence why they were falling from the sky just now, and presumably being teleported under the world before.
-
So the code below will save an integer to wherever (I just know that it's important to save it or things will get screwed up), but how do I save something such as an ItemStack to in a similar manner? Please tell me that I'm not going to have to break it down into simple data types to save it...
-
What's the proper way to register a tileEntity?
MrDireball replied to MrDireball's topic in Modder Support
I disabled the line of code that I had in Main, and nothing happened. Then I realized that I had put code in CommonProxy to register it, and apparently didn't need anything in Main. So I commented out the code in CommonProxy to see what would happen. I was able to place the block and interact with it and everything, and I saw no indication in-game that something was wrong, but errors were repeatedly logged in the console complaining about missing mapping or something. -
@Override public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { if (!world.isRemote) { if (side == state.getValue(FACING)) { //world.spawnEntity(new EntityItem(world, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(Items.DIAMOND))); EntityZombie mobEntity = new EntityZombie(world); mobEntity.setPosition(pos.getX(), pos.getZ(), pos.getZ()); world.spawnEntity(mobEntity); } } return true; }
-
So I've got some simple code that should spawn in a zombie in the onBlockActivated method of my block, but it doesn't seem to be doing anything, even though I could spawn in item entities just fine. EntityZombie mobEntity = new EntityZombie(world); mobEntity.setPosition(pos.getX(), pos.getZ(), pos.getZ()); world.spawnEntity(mobEntity); Also, if someone could tell me how to properly post code, that would be great.