Jump to content

Recommended Posts

Posted

Following code only spawns a pig.

EntityRegistry.registerModEntity(RobotHelper.class, "robotHelper", 0, this, 64, 1, true);
EntityRegistry.registerEgg(RobotHelper.class, mainColor, subColor);

 

 

Following code spawns the entity but everytime i load the world from save the entity loads, stays there for 5 sec, then vanish, saving the map loading it again the entity again show up for 5 sec then vanish.

I'm overriding canDespawn and return false, i also tried setting enablePersistence() and forcing age to 0.

 

int i =EntityRegistry.instance().findGlobalUniqueEntityId();
EntityRegistry.registerGlobalEntityID(RobotHelper.class,"robotHelper",i);
        EntityRegistry.registerModEntity(RobotHelper.class, "robotHelper", i, this, 64, 1, true);
EntityRegistry.registerEgg(RobotHelper.class, mainColor, subColor);

 

 

Im sure im the one doing something wrong here, but im clueless at this point to why it is vanishing.

Posted

public class RobotHelper extends EntityCreature {

private static final DataParameter<Integer> PROFESSION = EntityDataManager.<Integer>createKey(RobotHelper.class, DataSerializers.VARINT);
    private int randomTickDivider;
    private boolean isMating;
    private boolean isPlaying;
    Village villageObj;
   

    private int timeUntilReset;
    /** addDefaultEquipmentAndRecipies is called if this is true */
    private boolean needsInitilization;
   
    
    /** Last player to trade with this villager, used for aggressivity. */
   
    private int careerId;
    /** This is the EntityVillager's career level value */
    private int careerLevel;
    private boolean isLookingForHome;
    private boolean areAdditionalTasksSet;
    private InventoryBasic inventory;

    

   

public RobotHelper(World worldIn) {
	this(worldIn, 0);
}




 public RobotHelper(World worldIn, int professionId)
    {

        super(worldIn);
        System.out.println("Constructed :" + professionId);

        this.inventory = new InventoryBasic("Items", false, ;
        this.setProfession(professionId);
        this.setSize(0.6F, 1.95F);
        ((PathNavigateGround)this.getNavigator()).setBreakDoors(true);
        this.setCanPickUpLoot(true);
        this.setCustomNameTag("ROBOT");
        this.setAlwaysRenderNameTag(true);
        //this.persistenceRequired = true;
        this.enablePersistence();
        this.entityAge = 0;
    }

  protected void entityInit()
    {
        super.entityInit();
        this.dataWatcher.register(PROFESSION, Integer.valueOf(0));
        this.entityAge = 0;
        
    }



 @Override
public void onEntityUpdate() {
	// TODO Auto-generated method stub
	 this.entityAge = 0;

	super.onEntityUpdate();
}

    protected void initEntityAI()
    {
    	super.initEntityAI();
        this.tasks.addTask(0, new EntityAISwimming(this));
        this.tasks.addTask(1, new EntityAIAvoidEntity(this, EntityZombie.class, 8.0F, 0.6D, 0.6D));
        //this.tasks.addTask(1, new EntityAITradePlayer(this));
        //this.tasks.addTask(1, new EntityAILookAtTradePlayer(this));
        
        //this.tasks.addTask(2, new EntityAIMoveIndoors(this));
        //this.tasks.addTask(3, new EntityAIRestrictOpenDoor(this));
        //this.tasks.addTask(4, new EntityAIOpenDoor(this, true));
        //this.tasks.addTask(5, new EntityAIMoveTowardsRestriction(this, 0.6D));
        
        
        //this.tasks.addTask(6, new EntityAIVillagerMate(this));
        //this.tasks.addTask(7, new EntityAIFollowGolem(this));
        
        
        this.tasks.addTask(9, new EntityAIWatchClosest2(this, EntityPlayer.class, 3.0F, 1.0F));
        //this.tasks.addTask(9, new EntityAIVillagerInteract(this));
        //this.tasks.addTask(9, new EntityAIWander(this, 0.6D));
        //this.tasks.addTask(10, new EntityAIWatchClosest(this, EntityLiving.class, 8.0F));
    }

    private void setAdditionalAItasks()
    {
        if (!this.areAdditionalTasksSet)
        {
            this.areAdditionalTasksSet = true;

            if (this.isChild())
            {
               // this.tasks.addTask(8, new EntityAIPlay(this, 0.32D));
            }
            else if (this.getProfession() == 0)
            {
               // this.tasks.addTask(6, new EntityAIHarvestFarmland(this, 0.6D));
            }
        }
    }


    public void writeEntityToNBT(NBTTagCompound tagCompound)
    {
        super.writeEntityToNBT(tagCompound);
        tagCompound.setInteger("Profession", this.getProfession());
        tagCompound.setInteger("Career", this.careerId);
        tagCompound.setInteger("CareerLevel", this.careerLevel);

      
        NBTTagList nbttaglist = new NBTTagList();

        for (int i = 0; i < this.inventory.getSizeInventory(); ++i)
        {
            ItemStack itemstack = this.inventory.getStackInSlot(i);

            if (itemstack != null)
            {
                nbttaglist.appendTag(itemstack.writeToNBT(new NBTTagCompound()));
            }
        }

        tagCompound.setTag("Inventory", nbttaglist);
    }

    /**
     * (abstract) Protected helper method to read subclass entity data from NBT.
     */
    public void readEntityFromNBT(NBTTagCompound tagCompund)
    {
        super.readEntityFromNBT(tagCompund);
        this.setProfession(tagCompund.getInteger("Profession"));
        this.careerId = tagCompund.getInteger("Career");
        this.careerLevel = tagCompund.getInteger("CareerLevel");


        NBTTagList nbttaglist = tagCompund.getTagList("Inventory", 10);

        for (int i = 0; i < nbttaglist.tagCount(); ++i)
        {
            ItemStack itemstack = ItemStack.loadItemStackFromNBT(nbttaglist.getCompoundTagAt(i));

            if (itemstack != null)
            {
                this.inventory.func_174894_a(itemstack);
            }
        }

        this.setCanPickUpLoot(true);
        this.setAdditionalAItasks();
        this.isDead = false;
        this.entityAge = 0;
    }
    
  
    
    protected boolean canDespawn()
    {
        return false;
    }

    protected SoundEvent getAmbientSound()
    {
        return SoundEvents.entity_villager_ambient;
    }

    protected SoundEvent getHurtSound()
    {
        return SoundEvents.entity_villager_hurt;
    }

    protected SoundEvent getDeathSound()
    {
        return SoundEvents.entity_villager_death;
    }

    public void setProfession(int professionId)
    {
        this.dataWatcher.set(PROFESSION, Integer.valueOf(professionId));
    }

    public int getProfession()
    {
        return Math.max(((Integer)this.dataWatcher.get(PROFESSION)).intValue() % 5, 0);
    }

}

 

 

Nothing in there really just part of the villager class

Posted

Following code only spawns a pig.

EntityRegistry.registerModEntity(RobotHelper.class, "robotHelper", 0, this, 64, 1, true);
EntityRegistry.registerEgg(RobotHelper.class, mainColor, subColor);

 

 

Following code spawns the entity but everytime i load the world from save the entity loads, stays there for 5 sec, then vanish, saving the map loading it again the entity again show up for 5 sec then vanish.

I'm overriding canDespawn and return false, i also tried setting enablePersistence() and forcing age to 0.

 

int i =EntityRegistry.instance().findGlobalUniqueEntityId();
EntityRegistry.registerGlobalEntityID(RobotHelper.class,"robotHelper",i);
        EntityRegistry.registerModEntity(RobotHelper.class, "robotHelper", i, this, 64, 1, true);
EntityRegistry.registerEgg(RobotHelper.class, mainColor, subColor);

 

 

Im sure im the one doing something wrong here, but im clueless at this point to why it is vanishing.

 

Same thing is happening to me. I have yet to figure out a solution.

Posted

Should add everything works fine until u save and reload the map, if you stay in the game after spawning a entity it stays visible, only when loading the map it vanishes. but you can still get pushed around by it, and collide with it, pushing it into a chest made it become visible, might be random

Posted

Stop using registerGlobalEntityID

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

im not using globalID, egg dont work without it, but i spawn in the entity with a item, and do not register it using the globalID.

 

This should show what i mean by vanishing..

Posted

im not using globalID,

 

Yes you are, its in your post:

int i =EntityRegistry.instance().findGlobalUniqueEntityId(); //GlobalID
EntityRegistry.registerGlobalEntityID(RobotHelper.class,"robotHelper",i); //GlobalID

 

egg dont work without it, but i spawn in the entity with a item, and do not register it using the globalID.

 

Yes they do, use the registerModEntity overloaded function that takes two color parameters.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

I posted the old way and the new way, new way will only spawn pig, dont matter if you use the function that create the egg as well as register it, or register the egg manually.

 

I was just listing both as i believe i was doing it wrong since the new way was not working correctly, I now know that is caused by a current bug in forge that is being corrected, https://github.com/MinecraftForge/MinecraftForge/pull/2587

 

Main problem now seems to be any entity or modded entity at least will vanish when a map is reloaded, the entity is still alive, can take damage, and will collide with the player, but is not visible until some update is triggered, like in the video i posted i use ender pearls to teleport threw the entity making me coolide with it causing some damage and the entity is then visible.

 

 

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I want to create block with entity, that will have height of 3 or more(configurable) and I tried to change first VoxelShape by increasing collision box on height I want and for changing block height on visual side i tried to configure BlockModelBuilder:  base.element() .from(0, 0, 0) .to(16f, 48f, 16f) .face(Direction.UP).texture("#top").end() .face(Direction.DOWN).texture("#bottom").end() .face(Direction.NORTH).texture("#side").end() .face(Direction.SOUTH).texture("#side").end() .face(Direction.WEST).texture("#side").end() .face(Direction.EAST).texture("#side").end() .end(); but, getting crash with next error: Position y out of range, must be within [-16, 32]. Found: %d [48.0]; Looks like game wont to block height modified by more than 32. Is there any way to fix that problem?
    • As long as the packets you are sending aren't lost, there's nothing wrong with what you're currently doing. Although, this sounds like something that would benefit from you making your own datapack registry instead of trying to arbitrarily sync static maps. Check out `DataPackRegistryEvent.NewRegistry`.
    • Hey all, I've been working a lot with datapacks lately, and I'm wondering what the most efficient way to get said data from server to client is.  I'm currently using packets, but given that a lot of the data I'm storing involves maps along the lines of Map<ResourceLocation, CustomDataType>, it can easily start to get messy if I need to transmit a lot of that data all at once. Recently I started looking into the ReloadableServerResources class, which is where Minecraft stores its built-ins.  I see you can access it via the server from the server's resources.managers, and it seems like this can be done even from the client to appropriately retrieve data from the server, unless I'm misunderstanding.  However, from what I can tell, this only works via built-in methods such as getRecipeManager() or getLootTables(), etc.  These are all SimpleJsonResourceReloadListeners, just like my datapack entries are, so it seems like it could be possible for me to access my datapack entries similarly?  But I don't see anywhere in ReloadableServerResources that stores loaded modded entries, so either I'm looking in the wrong place or it doesn't seem to be a thing. Are packets really the best way of doing this, or am I missing a method that would let me use ReloadableServerResources or something similar?
    • Hi, everyone! I'm new to minecraft modding stuff and want ask you some questions. 1. I checked forge references and saw there com.mojang and net.minecraft (not net.minecraftforge) and as I understand it's original game packages with all minecraft logic inside including renderers and so on, right? 2. Does it mean that forge has a limited set of instruments which doesn't cover all the aspects of the game? If make my question more specific then does forge provide such instruments that allow me totally change minecraft itself, like base mechanics and etc.? Or I have to use "original game packages" to implement such things? 3. I actively learning basic concepts with forge documentation and tutorials. So in my plans make different inventory system like in diabloids. Is that possible with forge? 4. It is last question related to the second one. So how deeply I can change minecraft with forge? I guess all my questions above because of that I haven't globally understanding what forge is and how it works inside and how it works with minecraft. It would be great if you provide some links or topics about it or explain it by yourself but I guess it's to big to be explained in that post at once. Anyway, thank you all for any help!
    • Im trying add to block a hole in center, just a usual block and in center of it on up side, there is should be a hole. I tried to add it via BlockModelBuilder, but its not working. Problem is that it only can change block size outside. I tried it to do with VoxelShape and its working, but its has been on server side and looks like its just changed collision shape, but for client, there is a texture covering this hole. I tried to use: base.renderType("cutout"); and removed some pixels from texture. I thought its should work, but game optimization makes block inside looks transparent. So, only custom model?
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

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