Jump to content

[1.7.2] [SOLVED] Container is not responding to server


Casual Dutchman

Recommended Posts

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!

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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