Jump to content

Making Entities?


atrain99

Recommended Posts

Can somebody explain (without making me look at MC's source, as I don't understand any of it), what I need to do to make my robot entity move around and have an inventory/gui/container/whatever?

I can just about do the rest, and if I can't, I'll just make something up. :P

package net.minecraft.src.GreenEnergy.Solar.Bot;

import net.minecraft.src.EntityAIWander;
import net.minecraft.src.EntityCreature;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.IInventory;
import net.minecraft.src.ItemStack;
import net.minecraft.src.NBTTagCompound;
import net.minecraft.src.World;
import net.minecraft.src.universalelectricity.extend.IDisableable;

public class EntitySolarBot extends EntityCreature implements IInventory, IDisableable{

private float moveSpeed;
private int batteryRemaining;
private ItemStack[] containingItems = new ItemStack[2];
private int disableTimer = 0;
private int updateTimer = 0;
public EntitySolarBot(World par1World) {
	super(par1World);
	this.setSize(0.6F, 0.5F);
	this.moveSpeed = 0.125F;
	this.tasks.addTask(0, new EntityAIWander(this, this.moveSpeed));
	this.batteryRemaining = 0;
}

@Override
protected void entityInit() {
	if(this.worldObj.canBlockSeeTheSky((int)this.lastTickPosX, (int) this.lastTickPosY, (int) this.lastTickPosZ)){
		this.batteryRemaining += 40;
		this.onDisable(40);
	}

}
protected boolean isAIEnabled()
    {
        return true;
    }
public void onEntityUpdate(){
	if(this.worldObj.canBlockSeeTheSky((int)this.lastTickPosX, (int) this.lastTickPosY, (int) this.lastTickPosZ) && !this.isDisabled()){
		chargeElectricalItem();
	}
	this.batteryRemaining--;

}

private void chargeElectricalItem() {
	// TODO Auto-generated method stub

}

@Override
public void readEntityFromNBT(NBTTagCompound var1) {


}

@Override
public void writeEntityToNBT(NBTTagCompound var1) {


}

@Override
public int getSizeInventory() {
	return 2;
}


public ItemStack getStackInSlot(int par1) { return this.containingItems[par1]; }

@Override
public ItemStack decrStackSize(int par1, int par2)
{
	if (this.containingItems[par1] != null)
        {
            ItemStack var3;
            if (this.containingItems[par1].stackSize <= par2)
            {
                var3 = this.containingItems[par1];
                this.containingItems[par1] = null;
                return var3;
            }
            else
            {
                var3 = this.containingItems[par1].splitStack(par2);
                if (this.containingItems[par1].stackSize == 0)
                {
                    this.containingItems[par1] = null;
                }
                return var3;
            }
        }
        else
        {
            return null;
        }
}

@Override
public ItemStack getStackInSlotOnClosing(int par1)
{
	if (this.containingItems [par1] != null)
        {
            ItemStack var2 = this.containingItems[par1];
            this.containingItems[par1] = null;
            return var2;
        }
        else
        {
            return null;
        }
}

@Override
public void setInventorySlotContents(int var1, ItemStack var2) {
	// TODO Auto-generated method stub

}

@Override
public String getInvName() {
	return "Battery Bot";
}

@Override
public int getInventoryStackLimit() {
	// TODO Auto-generated method stub
	return 0;
}

@Override
public void onInventoryChanged() {
	// TODO Auto-generated method stub

}

@Override
public boolean isUseableByPlayer(EntityPlayer var1) {
	return true;
}

@Override
public void openChest() {
	// TODO Auto-generated method stub

}

@Override
public void closeChest() {


}

@Override
public int getMaxHealth() {
	return 6;
}

@Override
public void onDisable(int duration) {
	this.disableTimer  += duration;

}

@Override
public boolean isDisabled() {
	return disableTimer == 0;
}
@Override
public boolean isMovementCeased(){
	return this.isDisabled() && (this.batteryRemaining != 0);
}

}

 

So, what would happen if I did push that shiny red button over there? ... Really? ... Can I try it? ... Damn.

Link to comment
Share on other sites

Just roam around and do the solar panel physics to charge batteries. How would I do the opening of a gui from an entity? Would it be in an entityActivated()?

So, what would happen if I did push that shiny red button over there? ... Really? ... Can I try it? ... Damn.

Link to comment
Share on other sites

Just roam around and do the solar panel physics to charge batteries. How would I do the opening of a gui from an entity? Would it be in an entityActivated()?

 

Have you tried decompiling 1.3? The code obviously won't be directly copy/pasteable, but Villagers now open a GUI with a Container.

Link to comment
Share on other sites

Just roam around and do the solar panel physics to charge batteries. How would I do the opening of a gui from an entity? Would it be in an entityActivated()?

 

Have you tried decompiling 1.3? The code obviously won't be directly copy/pasteable, but Villagers now open a GUI with a Container.

 

I retried putting UE into there and I just ran into tons of errors messages. :D

 

Also, 1.3 seems to have world.isRemote and I think that variable is pretty useless considering the fact that it's ALWAYS remote/SMP?

Link to comment
Share on other sites

Just roam around and do the solar panel physics to charge batteries. How would I do the opening of a gui from an entity? Would it be in an entityActivated()?

 

Have you tried decompiling 1.3? The code obviously won't be directly copy/pasteable, but Villagers now open a GUI with a Container.

 

I retried putting UE into there and I just ran into tons of errors messages. :D

 

Also, 1.3 seems to have world.isRemote and I think that variable is pretty useless considering the fact that it's ALWAYS remote/SMP?

 

Actually, as I predicted, Mojang didn't come through with the SSP/SMP merger. Instead of the client being a dummy, they just made the client speak in Packetese. By that, I mean all communication in SSP is now dealt through packets. This means the client can now function as an SMP server, but it doesn't actually make SSP mods SMP like we we were promised/lead to assume.

Link to comment
Share on other sites

Actually they never said SSP mods would be SMP capable (which would be impossible without logic in the mod to know on which side to run on), rather they said that SMP mods would be SSP capable, which is true.

So I have to write a SSP and SMP?!?!

:(

 

So, what would happen if I did push that shiny red button over there? ... Really? ... Can I try it? ... Damn.

Link to comment
Share on other sites

Actually they never said SSP mods would be SMP capable (which would be impossible without logic in the mod to know on which side to run on), rather they said that SMP mods would be SSP capable, which is true.

So I have to write a SSP and SMP?!?!

:(

 

Yup. Both in minecraft.jar clent

Is it easy?

Is there some secret?

What needs to change from server to client?

So, what would happen if I did push that shiny red button over there? ... Really? ... Can I try it? ... Damn.

Link to comment
Share on other sites

Actually you write just SMP, the SSP part is the SMP part + graphical stuff now.  Unlike before where they were two different code basis.  So yes, it is a lot easier.

Oh. So no weird packet sending/recieving? Or do I just do the sending?

So, what would happen if I did push that shiny red button over there? ... Really? ... Can I try it? ... Damn.

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.



×
×
  • Create New...

Important Information

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