-
Posts
197 -
Joined
-
Last visited
-
Days Won
1
Everything posted by That_Martin_Guy
-
It is up to date. I mentioned in the post an experiment I made where I returned NULL_AABB in those methods, instead of a new AxisAlignedBB with 0 as all of its parameters, which resulted in a NullPointerException. I did this experiment because I thought having this empty object had an unintended side effect where the block became visible when right clicked. I realize now, however, that it can't be because of that since it also becomes visible when receiving any block update (from a lever, for example). I thought I could "fix" this by making the hitbox null, but again, the hitbox is most likely not the problem. EDIT: Sorry for being unclear and editing my posts a lot, but I was pretty excited that someone would be able to help me (hopefully)
-
@Override public AxisAlignedBB getSelectedBoundingBox(IBlockState state, World worldIn, BlockPos pos) { return state.getValue(HIDDEN) ? NULL_AABB : FULL_BLOCK_AABB; } @Override public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { return state.getValue(HIDDEN) ? NULL_AABB : FULL_BLOCK_AABB; } If I have a new AxisAlignedBB with 0 as all of its parameters instead of NULL_AABB it works. EDIT: I had initally thought this made a problem where the block became visible when right clicked, but later realised it couldn't be because of this since it also becomes visible when receiving a block update.
-
I have a block of type BlockWire (which inherits from BlockHideable) that has a tile entity of type TileEntityWire (which in turn inherits from TileEntityHideable). The block mostly works like redstone, and should therefore be able to power redstone. My problem is that the wire doesn't update blocks properly. Redstone can only be turned on, while other wire blocks don't update at all. Also, if I click on the bottom on the block, it becomes visible (even though it shouldn't). I'm suspecting it is because BlockHideable sets the bounding box to AxisAligned(0, 0, 0, 0, 0, 0) instead of NULL_AABB, but if I return that the game crashes with a NullPointerException.
-
Having a tough time creating a crafting mechanic
That_Martin_Guy replied to That_Martin_Guy's topic in Modder Support
It saves correctly now, indeed. I'm still not sure how I would access my ItemStack output in the map with an Item array. -
Having a tough time creating a crafting mechanic
That_Martin_Guy replied to That_Martin_Guy's topic in Modder Support
ShapelessRecipes uses a normal List to iterate through its values, similar to how I did it before. No clue how I would replicate this with a map. When I tried to craft my item in-game it didn't give me it, so I assumed that it was because I get ItemArmor instead of ItemDiamondHelmet. I stand corrected however. -
Having a tough time creating a crafting mechanic
That_Martin_Guy replied to That_Martin_Guy's topic in Modder Support
Gosh that makes it so much easier! I still have a (relatively small) problem however. As you might know from previous code posted, I am using a diamond helmet in one of the recipes. My problem is that if I use ItemStack#getItem on a diamond helmet I don't actually get a diamond helmet object, but instead an ItemArmor object. One way to show this is with a simple print call: System.out.println(new ItemStack(Items.DIAMOND_HELMET).getItem()); . This will print net.minecraft.item.ItemArmor@4fa8bebb, not net.minecraft.item.ItemDiamondHelmet@123456. I could fix this by using registry names as the key instead of the object itself, but I would much prefer to use an object. Also, if you are curious, this is my updated DarkPortalCrafting class. -
Having a tough time creating a crafting mechanic
That_Martin_Guy replied to That_Martin_Guy's topic in Modder Support
I didn't include the package declaration and imports. A brainfart on my part, didn't realise you would need the whole file to get the right line numbers. This is the full class. 'Cause I went into this blindly, and am not familiar with Maps. I will look into it. -
Having a tough time creating a crafting mechanic
That_Martin_Guy replied to That_Martin_Guy's topic in Modder Support
Ah, great! The block now correctly stores items inside of it. I also noticed during testing that I never called DarkLightCrafting#init(), so I went ahead and added it to my main init method. When I did this, however, the game started to crash with an ArrayIndexOutOfBoundsException (full crash report here). Note that I renamed the Dark Light block to Dark Portal, and therefore updated most names related to it (including DarkPortalCrafting). Also note that I changed some things in that class, so it now looks like this. Also, why would you want to make simulate true? Isn't the point of using insertItem to actually store the item? -
Having a tough time creating a crafting mechanic
That_Martin_Guy replied to That_Martin_Guy's topic in Modder Support
Again, NBT data isn't my strong point, so sorry if I did anything stupid or missed something. I changed update() to .. IItemHandler stackHandlerCapability = this.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null); if(!this.world.isRemote) { if(burningItems.size() > 0) { for(int i = 0; i < burningItems.size(); i++) { System.out.println(burningItems.get(i).getEntityItem().toString()); stackHandlerCapability.insertItem(occupiedSlots++, burningItems.get(i).getEntityItem(), true); this.markDirty(); burningItems.get(i).setDead(); } } } //Print for checking if the tile entity saves items tossed into it. Currently mostly prints //Slot 0: 1xtile.air@0 Slot 2: 1xtile.air@0 System.out.println("Slot 0: " + stackHandlerCapability.getStackInSlot(0) + " Slot 1: " + stackHandlerCapability.getStackInSlot(1)); ItemStack output = DarkPortalCrafting.getOutput(stackHandlerCapability.getStackInSlot(0), stackHandlerCapability.getStackInSlot(1)); if(output != null) { System.out.println(output.toString()); for(int i = 0; i < playersInRange.size(); i++) { EntityPlayer currentPlayer = playersInRange.get(i); if(currentPlayer.getCapability(PlayerHostProvider.PLAYER_HOST_CAPABILITY, null).isHost()) { ItemHandlerHelper.giveItemToPlayer(currentPlayer, output); currentPlayer.playSound(SoundEvents.BLOCK_PORTAL_TRAVEL, 1.0f, 0.2f); } else { this.world.spawnEntity(new EntityLightningBolt(this.world, currentPlayer.posX, currentPlayer.posY, currentPlayer.posZ, false)); } this.world.setBlockToAir(this.pos); } } .. and writeToNBT() to public NBTTagCompound writeToNBT(NBTTagCompound compound) { super.writeToNBT(compound); compound.setTag("burnedItems", stackHandler.serializeNBT()); this.markDirty(); return compound; } . Still doesn't save. -
Having a tough time creating a crafting mechanic
That_Martin_Guy replied to That_Martin_Guy's topic in Modder Support
public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); stackHandler.deserializeNBT((NBTTagCompound) compound.getTag("burnedItems")); } Still doesn't save. Sorry if I'm doing anything stupid, but NBT tags aren't my strong point. -
Having a tough time creating a crafting mechanic
That_Martin_Guy replied to That_Martin_Guy's topic in Modder Support
@Override public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); compound.getTag("burnedItems"); } @Override public NBTTagCompound writeToNBT(NBTTagCompound compound) { super.writeToNBT(compound); compound.setTag("burnedItems", stackHandler.serializeNBT()); return compound; } Still doesn't save the item. -
I've been trying to come up with how this mechanic for a few days now, and I finally ended up with a concept that should be manageable. Sadly I got into some problems. The way I want this to work is that the player throws items into a fire-like block. The block stores the items in a tile entity, compares them to a list of recipes in a seperate class and, if it gets a match, destroy the block and give the player the crafted item. My problem is that my tile entity doesn't save the items it consumes, but instead constantly replaces them with air. I am also not certain that even if it did save, it would not be able to match one of the recipes. The relevant files are DarkLightCrafting (the file that stores and handles the recipes) and TileEntityDarkLight. This is honestly the biggest part of a mod that I've made yet, and I'm very dissapointed it doesn't work. Hopefully there is a solution to the problem.
-
My problem isn't detecting whether the itemstack is empty or not. My problem is that the held item isn't saved. If I give the mob a diamond, and then a stick, it should be able to hold both the diamond AND the stick. It doesn't save the diamond however, and when I give it the stick he will only be holding the stick. Since it doesn't save the stick either, it will almost immediatly be air again.
-
I have a unit that will equip two items the player gives it, compare the two to a recipe, and give the player an item if it matches. To do this I first place the player item in the mobs main hand, then the second item in the off hand, compare the two and drop the item and kill the entity if they match. This is the method I use for equipping the entity. For some reason it doesn't remember what I set the item as, however, and instead replaces it with air (which is why I check if the mob is holding air. The consequence of this is that the mob always puts the item in the main slot, essentially deleting the previously held item. This somewhat looks like a bug to me, since you check if the player is holding null, not air. Or is it something I'm doing wrong?
-
This is working now, thank you! The only clue I get is by adding a print to the first line in isPlayerHost. For some reason it isn't consistent. Most of the time it returns true, sometimes it returns false. Really strange. EDIT: After copy-pasting my working code and looking at a diff, I found the problem! This parameter used to be the player object I created. Since it wasn't initiated it always returned false. targetEntity isn't however, and therefore it returns true. Really shows how one line can screw up an entire class.
-
That worked, but there is a problem with the mob. It doesn't show the armor it's wearing, even though he does wear it (he drops it on death and takes reduced damage), and my custom AI doesn't work in this class, even though an almost identical version works for my other mob. If I put a print call in my predicate of the return condition it prints true.
-
I currently have an unspawnable human mob, and two variations of that mob which can (or should) be spawnable. One of them is a civilian, the other is a fighter. The civilian is working fine. Can be spawned using /summon, has the right texture, model, AI, etc. However, the fighter can't be spawned with /summon or with an egg. If I try to use the command it tells me that it was "unable to summon object" and gives me this error message (although the game doesn't crash). What is my problem? I think I registered both correctly, and the fighter does appear in the tab list of summonable entities. As you can see my project is on github. Feel free to browse it to find anything wrong with my code. Just note that ModEntity and EntityMobBase don't exist in my project, and I'm not sure why they are on github.