Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

I made a Container, but it does not do what i want it to do.

 

When I place an item in a slot, quit the world and then load the world, The item in that slot is gone.

It will not take it either. When I place the item inside, The cursor will still have the item, but the slot too.

 

Container and Gui are not different then my other containers and GUIs, those work perfectly!

Only the Guihandler is slightly different.

 

btw, it is a container for a mob.

 

public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) { 
	switch(id){
	case 6:
		EntityTest test = getUnitMouseOver2(5, 0, player);
		System.out.println("calling Container");
		return new ContainerTest(player.inventory, test.inventory, test);
	}

	return null;
}

@Override
public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) {
	switch(id){
	case 6:
		EntityTest test = getUnitMouseOver2(5, 0, player);
		System.out.println("calling Gui");
		return new GuiTest(player.inventory, test.inventory, test);
	}

	return null;

}

public static MovingObjectPosition getMouseOver(double distance, float f)
    {
    	Minecraft mc = FMLClientHandler.instance().getClient();
    	
        if (mc.renderViewEntity != null)
        {
            if (mc.theWorld != null)
            {
                double var2 = distance;
                MovingObjectPosition mouseOver = mc.renderViewEntity.rayTrace(var2, f);
                Vec3 var6 = mc.renderViewEntity.getPosition(f);

                double var4 = var2;
                if (mouseOver != null)
                {
                    var4 = mouseOver.hitVec.distanceTo(var6);
                }

                Vec3 var7 = mc.renderViewEntity.getLook(f);
                Vec3 var8 = var6.addVector(var7.xCoord * var2, var7.yCoord * var2, var7.zCoord * var2);
                Entity pointedEntity = null;
                float var9 = 1.0F;
                List var10 = mc.theWorld.getEntitiesWithinAABBExcludingEntity(mc.renderViewEntity, mc.renderViewEntity.boundingBox.addCoord(var7.xCoord * var2, var7.yCoord * var2, var7.zCoord * var2).expand((double)var9, (double)var9, (double)var9));
                double var11 = var4;
                Iterator var13 = var10.iterator();

                while (var13.hasNext())
                {
                    Entity var14 = (Entity)var13.next();

                    if (var14.canBeCollidedWith())
                    {
                        float var15 = var14.getCollisionBorderSize();
                        AxisAlignedBB var16 = var14.boundingBox.expand((double)var15, (double)var15, (double)var15);
                        MovingObjectPosition var17 = var16.calculateIntercept(var6, var8);

                        if (var16.isVecInside(var6))
                        {
                            if (0.0D < var11 || var11 == 0.0D)
                            {
                                pointedEntity = var14;
                                var11 = 0.0D;
                            }
                        }
                        else if (var17 != null)
                        {
                            double var18 = var6.distanceTo(var17.hitVec);

                            if (var18 < var11 || var11 == 0.0D)
                            {
                                pointedEntity = var14;
                                var11 = var18;
                            }
                        }
                    }
                }

                if (pointedEntity != null && (var11 < var4 || mouseOver == null))
                {
                   mouseOver = new MovingObjectPosition(pointedEntity);
                }
                
                return mouseOver;
            }
        }
        return null;
    }

public static EntityTest getUnitMouseOver2(double distance, float f, EntityPlayer player){
    	MovingObjectPosition mouseOver = getMouseOver(distance, f);
    	if(mouseOver != null && mouseOver.entityHit != null && mouseOver.entityHit instanceof EntityTest){
    		return (EntityTest) mouseOver.entityHit;
    	}else
    		return null;
    }

 

Interact part of the entity:

public boolean interact(EntityPlayer par1EntityPlayer)
{
	if(par1EntityPlayer.isSneaking() && !this.worldObj.isRemote) {
		par1EntityPlayer.openGui(Core.instance, 6, par1EntityPlayer.worldObj, (int)par1EntityPlayer.posX, (int)par1EntityPlayer.posY, (int)par1EntityPlayer.posZ);
	}
	return super.interact(par1EntityPlayer);
}

Coding, Testing, Smiling, Publishing!

  • Author

Broken? How do you mean?

I can just use it. When the outcome entity of the methode is not null, it'll print out text. and it did.

Why is it broken?

 

Coding, Testing, Smiling, Publishing!

  • Author

Okay, I will say ´this´ in the interact methode.

I know how to get the entityID.

But how do I pass the entityID?

Coding, Testing, Smiling, Publishing!

  • Author

Now, I have a very diferent problem.

 

Caused by: java.lang.NullPointerException
at net.minecraft.item.ItemStack.getAttributeModifiers(ItemStack.java:884) ~[itemStack.class:?]
at net.minecraft.entity.EntityLivingBase.writeEntityToNBT(EntityLivingBase.java:503) ~[EntityLivingBase.class:?]
at net.minecraft.entity.EntityLiving.writeEntityToNBT(EntityLiving.java:313) ~[EntityLiving.class:?]
at mefa.Entities.EntityTest.writeEntityToNBT(EntityTest.java:94) ~[EntityTest.class:?]
at net.minecraft.entity.Entity.writeToNBT(Entity.java:1562) ~[Entity.class:?]

//
//OR
//

java.lang.NullPointerException: Ticking entity
at net.minecraft.item.ItemStack.getAttributeModifiers(ItemStack.java:884)
at net.minecraft.entity.EntityLivingBase.onUpdate(EntityLivingBase.java:1812)
at net.minecraft.entity.EntityLiving.onUpdate(EntityLiving.java:250)
at net.minecraft.world.World.updateEntityWithOptionalForce(World.java:2254)
at net.minecraft.world.WorldServer.updateEntityWithOptionalForce(WorldServer.java:697)
at net.minecraft.world.World.updateEntity(World.java:2214)
at net.minecraft.world.World.updateEntities(World.java:2064)
at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:528)

Coding, Testing, Smiling, Publishing!

  • Author

seems like my EntityTest does not like the world.getEntitybyID(int i)

 

My other, let's say 'real' entity, likes it a lot.

Thanks for helping!

Coding, Testing, Smiling, Publishing!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.