Jump to content

ZetaHunter

Members
  • Posts

    39
  • Joined

  • Last visited

Posts posted by ZetaHunter

  1. MrArcane111, I followed this http://www.minecraftforge.net/wiki/Server_Command and it worked perfectly fine for me, and I am using 1.7.2.

     

    I don't see what else to discuss here even, follow the tutorial, the end.

    But since I am in good mood,  I will share my sample command code with you.

    package com.zetaworx.proboblyawesome.handler;
    
    import java.util.ArrayList;
    import java.util.List;
    
    import net.minecraft.command.ICommand;
    import net.minecraft.command.ICommandSender;
    import net.minecraft.util.ChatComponentText;
    
    public class CommandHandle implements ICommand
    {
    private List<String> aliases;
    public CommandHandle()
    {
    	this.aliases = new ArrayList<String>();
    	this.aliases.add("probobly");
    	this.aliases.add("awesome");
    	this.aliases.add("proboblyawesome");
    }
    
    @Override
    public String getCommandName()
    {
    	return "pa";
    }
    
    @Override
    public String getCommandUsage(ICommandSender icommandsender)
    {
    	return "pa <text/help>";
    }
    
    @Override
    public List<String> getCommandAliases()
    {
    	return this.aliases;
    }
    
    @Override
    public void processCommand(ICommandSender icommandsender, String[] astring)
    {
    	if(astring.length == 0)
    	{
    		icommandsender.addChatMessage(new ChatComponentText("Invalid Arguments. Usage: " + this.getCommandUsage(icommandsender)));
    		return;
    	}
    	if (astring[0] == "help")
    	{
    		icommandsender.addChatMessage(new ChatComponentText("Usage: " + this.getCommandUsage(icommandsender)));
    		return;
    	} else {
    	ChatComponentText msg = new ChatComponentText("Output: [");
    	for (int i = 0;i < astring.length; ++i)
    	{
    		msg.appendText(" " + astring[i]);
    	}
    	msg.appendText(" ]");
    	icommandsender.addChatMessage(msg);	
    	}
    }
    
    @Override
    public boolean canCommandSenderUseCommand(ICommandSender icommandsender)
    {
    return true;
    }
    
    @Override
    public List<?> addTabCompletionOptions(ICommandSender icommandsender,
    String[] astring)
    {
    return null;
    }
    
    @Override
    public boolean isUsernameIndex(String[] astring, int i)
    {
    return false;
    }
    
    @Override
    public int compareTo(Object o)
    {
    return 0;
    }
    }
    

     

    and this in your mod file

        @EventHandler
        public void serverLoad(FMLServerStartingEvent event)
        {
        	event.registerServerCommand(new CommandHandle());
        }
    

     

    my command is using ICommand interface which is what CommandBase is extending from, but for time being I didn't need CommandBase functions so I didn't use it.

     

    Ps. my command also shows how to send user a chat message.

  2. I have an item which I intend to make multi purpose, I have a gui and the gui will have a list of possible modes,

    I want to make it possible for other mods to add their own modes to the modes list.

    I suppose just a

    Map<int, Object> modes;

    Map<String, int> alliases;

    and some basic get set add remove function set would be fine aswell though.

  3. I suggest you to take a deeper look into how addExpirence and addExpirenceLevel is realised.

            for (this.experienceTotal += par1; this.experience >= 1.0F; this.experience /= (float)this.xpBarCap())
            {
                this.experience = (this.experience - 1.0F) * (float)this.xpBarCap();
                this.addExperienceLevel(1);
            }
    

    is designed to increase level when the bar is full, but not the other way around.

    You might want to make your own function lets say 'public boolean drainExpirence(EntityPlayer player, int exp);'

    which would return true or false whatever draining succeeded (if user has no exp what's the point to drain it?).

    you need the EntityPlayer player so you can access the actual player, since the addExpirence was made in EntityPlayer  you will need the reference to the player to work with.

  4. So I want to have my own instance of NamespacedRegistry.

    But when I tried to do so, it didn't work because constructor like this

    new FMLControlledNamespacedRegistry<Mode>("Mode", MAX_MODE_ID, MIN_MODE_ID, Mode.class,'\u0003');
    

    is not visible for some reason, I suppose I will have to create my own copy of FMLControlledNamespacedRegistry?

    Since the whole thing is closely connected to MC Block and Item management, and no one seems to have thought of making it usable for other stuff. I might be wrong though, feel free to correct me.

     

    Also the Mode class is just a small class with couple string get functions for now. (empty otherwise)

    I want to make it possible to easily register modes for other modders in future.

    Also I am not quite sure what's up with \u0003 too, but I just increment it from \u0002 that ItemRegistry had.

     

    Any help on this? I know this is quite unexplored direction but still...

  5. I might misunderstand you, but your problem is that you are defining and initializing the variable MyItem in the function.

    And than trying to access MyItem from some other mod related class but you can't because it doesn't see it?

     

    If that is so, your mistake was putting definition of the MyItem inside function.

    All that is inside function, stays inside.

    You have to define the variable outside the function boundary to make it visible to other classes.

     

    If you are afraid that if flag1 is false and item dosen't get created, and other classes that utilize it fail to find it and error crash on you.

    Just init it with null first and than when time comes just check

     if (AwesomeMod.MyItem != null) {/*item exists.*/}

  6. This might be caused by two reasons I could see here.

     

    One: The file servers that gradlew is using were down on the moment.

    (This dosen't have to be neceseraly Forge File's, but rather other libs that MC requires.)

     

    Two: Your system is preventing gradlew and/or 1.6.4 src installer from communicating with network at all.

    (Check your firewall and antivirus.)

     

    Feel free to pastebin your install log if any.

     

    Ps. I tried installing fresh Forge 1.7.2 Rev1061 src, seems to work perfectly fine.

    It's most likely your client side issue, do pastebin your log.

  7. Thanks for the reply, appreciate it, but only for mobs I used setVelocity.

    Which when I replaced with addVelocity (which isn't clientSideOnly)

    Worked better than before, I could see why now.

    But it still didn't resolve the issue for the player, it used addVelocity in first place.

    I will now try writing packet manager to send a packet to server about this stuff.

    And see if that resolves anything at all.

  8. All that would be is just a block with a predefined scheme of structure.

    An on click event handler that then places blocks are it whatever way you want them to, although can't write you an example since I am on forge 1.7.2.

    But it would just be an iteration over an array of positions/ids, or just manual line by line code.

    It's quite simple really.

     

  9. I have resumed modding, and decide to update my mod to 1.7.2, after updating most of the stuff, while testing I find out that a staff item I had, which fired an entity which then affected entity's in area had partially got broken.

    The part which I loved the most, the ability to leap up into air is broken, It still works on other living entities.

    But player? Nope.

    So I tried addVelocity, setVelocity, manualy change motionX,Y,Z.

    None of those worked on my player.

    Here's an extract of my entity's action on detonation. I took out the other 3 type's of action's for sake of size of code.

    public void specialAttack(MovingObjectPosition var1, int type) {
    
    	EntityLivingBase p = this.getThrower();
    
    	if (p == null) {
    		this.setDead();
    		return;
    	}
    
    
    	switch (type) {
    	case 4:
    		pool = AxisAlignedBB.getAABBPool().getAABB(
    				var1.hitVec.xCoord - getRadius(),
    				var1.hitVec.yCoord - getRadius(),
    				var1.hitVec.zCoord - getRadius(),
    				var1.hitVec.xCoord + getRadius(),
    				var1.hitVec.yCoord + getRadius(),
    				var1.hitVec.zCoord + this.size);
    		entl = this.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, pool);
    		if ((entl != null) && (entl.size() > 0))
    			for (EntityLivingBase el : entl)
    				if ((el != null) && (el != p))
    					try {
    						double xdir = el.posX - this.getThrower().posX;
    						double zdir = el.posZ - this.getThrower().posZ;
    						double motionX = xdir * 0.1F;
    						double motionY = 5F;
    						double motionZ = zdir * 0.1F;
    						el.setVelocity(motionX, motionY, motionZ);
    					} catch (Throwable ex) {
    					}
    		if (var1.typeOfHit == MovingObjectType.ENTITY) {
    			if (!(var1.entityHit instanceof EntityLivingBase))
    				break;
    			EntityLivingBase el = (EntityLivingBase) var1.entityHit;
    			if ((el != null) && (el != p))
    				try {
    					double xdir = el.posX - this.getThrower().posX;
    					double zdir = el.posZ - this.getThrower().posZ;
    					motionX = xdir * 0.1F;
    					motionY = 0.1F;
    					motionZ = zdir * 0.1F;
    					el.setVelocity(motionX, motionY, motionZ);
    				} catch (Throwable ex) {
    				}
    		}
    
    		if (p != null && p instanceof EntityPlayer){
    
    
    			if ((p.getDistanceToEntity(this) < 3) && ((p.rotationPitch > 70) && (p.rotationPitch < 110))) {
    				double ydir = p.posY - this.posY;
    				Vec3 dir = p.getLookVec();
    				dir.yCoord = 0;
    				dir.normalize();
    				((EntityPlayer)p).addVelocity(0, 100, 0);
    				FMLLog.info("Current motion:" + p.motionX + " " + p.motionY + " " + p.motionZ);
    			}
    			}
    		break;
    	case 5:
    		specialAttack(var1, 4);
    
    		break;
    	default:
    		break;
    	}
    	this.setDead();
    }[
    /code]
    So if anyone know's why changing motion dosen't affect player, please do tell me.

  10. Hello, I am having a problem with my entity's collision box, specificly it lets players go thru the entity, I dont want that.

    I tried every possible way I saw in the vanilla minecraft logic... sadly couldnt get it to work.

    Here is my code,

     

     

    /**

    *

    */

    package com.zetaworx.tardis.block;

     

    import java.util.Iterator;

     

    import com.google.common.io.ByteArrayDataInput;

    import com.google.common.io.ByteArrayDataOutput;

    import com.zetaworx.tardis.lib.Vector3;

     

    import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData;

     

    import net.minecraft.block.Block;

    import net.minecraft.entity.Entity;

    import net.minecraft.entity.EntityLiving;

    import net.minecraft.nbt.NBTTagCompound;

    import net.minecraft.util.AxisAlignedBB;

    import net.minecraft.util.DamageSource;

    import net.minecraft.world.World;

     

    /**

    * @author ZetaHunter

    *

    */

    public class EntityTardis extends EntityLiving implements IEntityAdditionalSpawnData {

     

    public String owner;

    //public AxisAlignedBB boundingBox;

    /**

    * @param par1World

    */

    public EntityTardis(World par1World) {

    super(par1World);

    this.height = 3;

    this.width = 2;

    }

     

        public AxisAlignedBB getCollisionBox(Entity par1Entity)

        {

            return par1Entity.boundingBox;

        }

     

    public boolean attackEntityFrom(DamageSource par1DamageSource, int par2)

        {

            if (this.isEntityInvulnerable())

            {

                return false;

            }

            else

            {

            if (this.owner != null) {

            System.out.println(this.owner);

            }

                //this.setDead();

                return true;

            }

        }

     

    // @Override

    //    public AxisAlignedBB getBoundingBox()

    //    {

    //        return AxisAlignedBB.getBoundingBox(-1, 0, -1, 1, 2, 1);

    //    }

     

    @Override

        public boolean canBeCollidedWith()

        {

            return true;

        }

     

    public EntityTardis(World w, double x, double y, double z, String owner) {

    this(w);

    this.owner = owner;

    this.setPosition(x, y, z);

    }

     

    public void onUpdate() {

    this.activePotionsMap.clear();

    this.extinguish();

    }

     

    @Override

    protected void entityInit() {

    }

     

    @Override

    public void readEntityFromNBT(NBTTagCompound var1) {

    super.readEntityFromNBT(var1);

    this.owner = var1.getString("owner");

    }

     

    @Override

    public void writeEntityToNBT(NBTTagCompound var1) {

    super.writeEntityToNBT(var1);

    var1.setString("owner", this.owner);

    }

     

    @Override

    public void writeSpawnData(ByteArrayDataOutput data) {

    data.writeUTF(this.owner);

    }

     

    @Override

    public void readSpawnData(ByteArrayDataInput data) {

    this.owner = data.readUTF();

    }

     

    //Some cruel fun part :3

    public boolean nuke(World worldObj, Vector3 position, Entity explosionSource, int callCount)

    {

    if (!worldObj.isRemote)

    {

    if (callCount == 1)

    {

    for (int x = (int)-getRadius(); x < getRadius(); x++)

    {

    for (int y = (int)-getRadius(); y < getRadius(); y++)

    {

    for (int z = (int)-getRadius(); z < getRadius(); z++)

    {

    Vector3 targetPosition = Vector3.add(position, new Vector3(x, y, z));

    double dist = position.distanceTo(targetPosition);

     

    if (dist < getRadius())

    {

    int blockID = targetPosition.getBlockID(worldObj);

     

    if (blockID > 0)

    {

    if ((blockID != Block.bedrock.blockID))

    {

    if ((dist < getRadius() + 5.0F))

    {

    targetPosition.setBlockWithNotify(worldObj, 0);

    }

    }

    }

    }

    }

    }

    }

    Iterator<?> entities = worldObj.getEntitiesWithinAABB(EntityLiving.class, AxisAlignedBB.getAABBPool().addOrModifyAABBInPool(

    position.x - getRadius(), position.y - getRadius(), position.z - getRadius(), position.x + getRadius(), position.y + getRadius(), position.z + getRadius())).iterator();

    while (entities.hasNext()) {

    //System.out.println(entities.next().toString());

    EntityLiving entity = (EntityLiving) entities.next();

    entity.performHurtAnimation();

    entity.attackEntityFrom(DamageSource.outOfWorld, 150);

    }

    return false;

    }

     

    }

     

    if (callCount > getRadius())

    {

    return false;

    }

     

    return true;

    }

     

    public float getRadius()

    {

    return 10.0F;

    }

     

    @Override

    public int getMaxHealth() {

    return 1;

    }

    }

     

     

     

    Currently everything but the collision box works perfectly so I dont see point posting any other source's.

    But if needed I will.

     

    Before I tried to make the block do what I planed, but it was causing even more trouble...

  11. I do belive making a custom fire block will be alot easier, as in how you plan doing this in a tickHandler anyway?

    In the case of custom fire you simple override the updateTick (in which case fire block has it overrided already anyway) as this is fire it has its own ticking

    you could for example if want it to spread do super.updateTick(), or just override it if dont want spreading of ur own fire...

    also for this to work, you simply set the block, and then schudle the update of the block...

     

  12. yes this may look a bit confusing but how it works is anything that goes to "xxx" is of type string

    recipes for component indification use characters, and that is writen with singe quotes like this 'x'

    I had this problem couple times, its anoying but whatcha gonna do...

  13. That is a bit of problem if you need a specifc air block instance, but if you want to check if its an air or not, world class provides function just for that

    World.java > 431 Line.

    Heres cutout of it.

     

     

        /**
         * Returns true if the block at the specified coordinates is empty
         */
        public boolean isAirBlock(int par1, int par2, int par3)
        {
            int id = getBlockId(par1, par2, par3);
            return id == 0 || Block.blocksList[id] == null || Block.blocksList[id].isAirBlock(this, par1, par2, par3);
        }
    

     

     

     

    Hope I helped in any way,

    one way you could do this is check every users location via server tick event and check as whatever they are in specifc biom and are in air or whatever and then just do what ever you wanted with them.

    Just an idea....

×
×
  • Create New...

Important Information

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