Jump to content

Vinther

Members
  • Posts

    15
  • Joined

  • Last visited

Converted

  • Gender
    Undisclosed
  • Personal Text
    I am new!

Vinther's Achievements

Tree Puncher

Tree Puncher (2/8)

2

Reputation

  1. Okay, cool! I have not yet learned what those are, and wouldn't have thought to do so any time soon. I will look into them right away. Thanks for the help!
  2. I'm very curious about how you suppose I would make it non-final, when it is not possible to override member fields in an extending class. And when you say it can be done anyway, I must say I think you don't understand what I'm saying. Maybe I'm not explaining well enough. I am not trying to add different boxes together to form a multi-part shape. I want to "subtract" parts of the bounding box, making a raytrace pass through it. I have certainly made a fair bit of research already, but if you know of something that I've missed, please point me in the right direction.
  3. What do you mean? I can make Entity.boundingBox not be final, without base edits? Or are you saying I could do what I'm asking even when it is final? I don't think so. I'll try to clarify. What I'm trying to do is to write a custom collider class that extends AxisAlignedBB and overrides some of its methods, and assign it as the boundingBox of my entity. This way I could for example use boolean operations with intersecting bounding boxes, to create complex collider shapes. How would I do this without editing base classes, when boundingBox is final?
  4. I have no idea how that kind of stuff works, though. The whole process is a bit intimidating to me. But I'll look into it.
  5. Ok, I hear you. But hey! Could we just make the field non-final then? That might actually work as well, and wouldn't break anything, would it?
  6. Haha! I guess I am a bit lazy, although the specific thing I had in mind cannot really be done with multiple entities, and it would actually allow for more complex colliders than AABB's, which I think would be beneficial for everyone. Also I was thinking this could be done in the process of upgrading to 1.8, at which point everyone will need to update anyway. But yea, it might be a bit much of a hassle.
  7. Hmm. I was afraid it would turn out to be more complex than I thought. To me it seems like you could just do a simple find&replace from 'boundingBox' to 'getBoundingBox()'. Since the field is final it can never be assigned anywhere, so you wouldn't even need to check for that. Guess there's more to it, huh?
  8. Yep, a boolean flag and initializing in update works fine. It's just not as clean as I would like it, but it's fine. Thanks again!
  9. I'm sorry if this isn't possible for whatever reason I just don't realize, but it bugs me that boundingBox is currently a 'final' field, and I think it would be much better and more flexible if it was changed to use getter/setter methods. What made me think of this is that I recently had a cool (in my opinion at least ) idea, involving a custom collider class extending AxisAlignedBB, which would allow a much more complex hitbox for my large, animated entity. What do you guys think?
  10. I can't be entirely sure as I've not messed around with this kind of stuff enough, but I would say it's most likely using only one instance of the renderer for all TileEntities of the same type. So you should store any animation state data in the entity itself.
  11. Oh.. Silly me. Thank you! But TileEntity doesn't seem to have a good place to init stuff.
  12. I do this, right before the call to renderAll(). Minecraft.getMinecraft().renderEngine.bindTexture(texture); And I load the texture like this, saving the texture as a member of the renderer class. private static final ResourceLocation texture = new ResourceLocation(MyMod.MODID, "textures/blocks/texture.png");
  13. Ah, of course... This is my entity class. It hardly does anything but I guess that might be the problem. package com.vinther.mymod.entity; import net.minecraft.entity.Entity; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.World; public class MyEntity extends Entity { public MyEntity(World world) { super(world); this.setSize(1f, 1f); } @Override protected void entityInit() {} public void onEntityUpdate() { super.onEntityUpdate(); System.out.println(this.posX +", "+ this.posY +", "+ this.posZ); } public boolean canBeCollidedWith() { return true; } @Override protected void readEntityFromNBT(NBTTagCompound p_70037_1_) {} @Override protected void writeEntityToNBT(NBTTagCompound p_70014_1_) {} public AxisAlignedBB getCollisionBox(Entity entity) { return AxisAlignedBB.getBoundingBox(this.posX - this.width / 2f, this.posY - this.height / 2f, this.posZ - this.width / 2f, this.posX + this.width / 2f, this.posY + this.height / 2f, this.posZ + this.width / 2f); } } And this is the TileEntity where I try to instantiate it. package com.vinther.mymod.tileentity; import com.vinther.mymod.MyMod; import com.vinther.mymod.entity.MyEntity; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.entity.Entity; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.World; public class MyTileEntity extends TileEntity { public MyTileEntity() { MyEntity entity = new MyEntity(worldObj); worldObj.spawnEntityInWorld(entity); // This line throws NullPointerException } ... }
  14. I have written a simple custom entity extending the Entity base class, and am trying to spawn instances of this entity from one of my custom TileEntities. I have registered my entity in the preInit method of the main mod class like this: int uniqueId = EntityRegistry.findGlobalUniqueEntityId(); EntityRegistry.registerGlobalEntityID(MyEntity.class, "myEntity", uniqueId); EntityRegistry.registerModEntity(MyEntity.class, "myEntity", uniqueId, this, 80, 3, false); But when try to instantiate it using Entity.createEntityByName it always returns null, and if I create an instance myself using "new MyEntity..." and then pass it to World.spawnEntityInWorld, I still get a NullPointerException. How should I go about this? Is there something I'm missing?
×
×
  • Create New...

Important Information

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