Jump to content

Recommended Posts

Posted

Hi guy's, today I made a mob. If I spawn him, he has like two textures, very weird. I also wanted him to wear an armor and an item. I thought about it, and removed the armor code. But he still was there two times.. Could you please take a look into ma' code?

Thanks, Dary

 

EntityCreator.java

package netcrafter.mods.aoto.util;

import net.minecraft.client.renderer.entity.Render;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.EnumCreatureType;
import net.minecraft.entity.projectile.EntityEgg;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraftforge.fml.client.registry.RenderingRegistry;
import net.minecraftforge.fml.common.registry.EntityRegistry;
import netcrafter.mods.aoto.Main;

public class EntityCreator {

public static final void createEntity(Class entityClass, Render renderer, String name, EnumCreatureType type, boolean doesSpawn, int probability, int minSpawn, int maxSpawn, BiomeGenBase[] biomes, int solidColor, int spotColor, boolean hasSpawnEgg) {
	int id = EntityRegistry.findGlobalUniqueEntityId();

	EntityRegistry.registerGlobalEntityID(entityClass, name, id);
	EntityRegistry.registerModEntity(entityClass, name, id, Main.instance, 64, 1, true);
	RenderingRegistry.registerEntityRenderingHandler(entityClass, renderer);

	if(doesSpawn) { EntityRegistry.addSpawn(name, probability, minSpawn, maxSpawn, type, biomes); }		
	if(hasSpawnEgg) { EntityList.entityEggs.put(Integer.valueOf(id), new EntityList.EntityEggInfo(id, solidColor, spotColor)); }
}

public static final void createEntityItem(Class entityClass, Render renderer, String name) {
	int id = EntityRegistry.findGlobalUniqueEntityId();

	EntityRegistry.registerGlobalEntityID(entityClass, name, id);
	EntityRegistry.registerModEntity(entityClass, name, id, Main.instance, 64, 1, true);
	RenderingRegistry.registerEntityRenderingHandler(entityClass, renderer);

}


}

 

CommonProxy.java

package netcrafter.mods.aoto.proxy;

import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.entity.RenderSnowball;
import net.minecraft.entity.EnumCreatureType;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.registry.GameRegistry;
import netcrafter.mods.aoto.Main;
import netcrafter.mods.aoto.crafting.AOTOCrafting;
import netcrafter.mods.aoto.entity.boss.EntityForestGuardian;
import netcrafter.mods.aoto.entity.boss.EntityKingSteve;
import netcrafter.mods.aoto.entity.mob.EntityTreeMinion;
import netcrafter.mods.aoto.entity.projectile.EntityTreeRoot;
import netcrafter.mods.aoto.init.AOTOBlocks;
import netcrafter.mods.aoto.init.AOTOItems;
import netcrafter.mods.aoto.render.entity.RenderForestGuardian;
import netcrafter.mods.aoto.render.entity.RenderKingSteve;
import netcrafter.mods.aoto.render.entity.RenderTreeMinion;
import netcrafter.mods.aoto.util.EntityCreator;
import netcrafter.mods.aoto.util.WorldGenRegister;
import netcrafter.mods.aoto.world.gen.feature.ForestGen;

public class CommonProxy {

    public void preInit(FMLPreInitializationEvent e) {
    	//Creating and registering items and blocks
	AOTOItems.createItems();
	AOTOBlocks.createBlocks();
    }

    public void init(FMLInitializationEvent e) {
    	//Register crafting recipes
        AOTOCrafting.initCrafting();
        
        //Create and register entities
        EntityCreator.createEntityItem(EntityTreeRoot.class, new RenderSnowball(Minecraft.getMinecraft().getRenderManager(), AOTOItems.tree_root, Minecraft.getMinecraft().getRenderItem()), "TreeRoot");
        EntityCreator.createEntity(EntityKingSteve.class, new RenderKingSteve(), "KingSteve", EnumCreatureType.MONSTER, false, 0, 0, 0, null, 0xF2FF00, 0x020B12, true);
        EntityCreator.createEntity(EntityForestGuardian.class, new RenderForestGuardian(), "ForestGuardian", EnumCreatureType.MONSTER, false, 0, 0, 0, null, 0xC219A3, 0x19C238, true);
        EntityCreator.createEntity(EntityTreeMinion.class, new RenderTreeMinion(), "TreeMinion", EnumCreatureType.MONSTER, false, 0, 0, 0, null, 0xA85236, 0x6E260E, true);
        
        //Register world generators
        WorldGenRegister.registerGenerators();
    }

    public void postInit(FMLPostInitializationEvent e) {

    }

public void registerRenders() {

}

}

 

EntityKingSteve.java

package netcrafter.mods.aoto.entity.boss;

import java.util.Random;

import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityCreature;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAIArrowAttack;
import net.minecraft.entity.ai.EntityAIAttackOnCollide;
import net.minecraft.entity.ai.EntityAIHurtByTarget;
import net.minecraft.entity.ai.EntityAILookIdle;
import net.minecraft.entity.ai.EntityAIMoveTowardsTarget;
import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
import net.minecraft.entity.ai.EntityAISwimming;
import net.minecraft.entity.ai.EntityAIWander;
import net.minecraft.entity.ai.EntityAIWatchClosest;
import net.minecraft.entity.boss.IBossDisplayData;
import net.minecraft.entity.effect.EntityLightningBolt;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.item.EntityXPOrb;
import net.minecraft.entity.monster.EntityGuardian;
import net.minecraft.entity.monster.EntityMob;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.MathHelper;
import net.minecraft.world.DifficultyInstance;
import net.minecraft.world.World;
import netcrafter.mods.aoto.Reference;
import netcrafter.mods.aoto.entity.mob.EntityTreeMinion;
import netcrafter.mods.aoto.entity.projectile.EntityTreeRoot;
import netcrafter.mods.aoto.init.AOTOItems;

public class EntityKingSteve extends EntityMob implements IBossDisplayData {

private int attackCounter = 0;
    private int deathTicks = 0;
    private int regenTime = 0;

public EntityKingSteve(World worldIn) {
	super(worldIn);
	this.setSize(1.5F, 7.0F);
	this.tasks.addTask(1, new EntityAIAttackOnCollide(this, EntityPlayer.class, 2.0D, true));
	this.tasks.addTask(2, new EntityAIMoveTowardsTarget(this, 1.0D, (float) 2.0D));
    this.tasks.addTask(3, new EntityAIWander(this, 1.0D));
    this.tasks.addTask(4, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
    this.tasks.addTask(5, new EntityAILookIdle(this));
    this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false));
    this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, true));
}
    
    @Override
    protected void applyEntityAttributes() {
        super.applyEntityAttributes();
        this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(360.0F);
        this.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(35.0D);
        this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.26D);
        this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(15.0D);
        this.getEntityAttribute(SharedMonsterAttributes.knockbackResistance).setBaseValue(2.0D);
    }
    
    protected void func_180481_a(DifficultyInstance p_180481_1_) {
        super.func_180481_a(p_180481_1_);
        this.setCurrentItemOrArmor(0, new ItemStack(AOTOItems.long_diamond_sword));
        this.setCurrentItemOrArmor(1, new ItemStack(AOTOItems.beard));
    }

@Override
    protected String getLivingSound() {
        return Reference.MOD_ID + ":mob.forestguardian.living";
    }

    @Override
    protected String getHurtSound() {
        return Reference.MOD_ID + ":mob.forestguardian.hurt";
    }

    @Override
    protected String getDeathSound() {
        return Reference.MOD_ID + ":mob.forestguardian.death";
    }
    
    /** Calls this method if the mob is dead */
    @SuppressWarnings("unchecked")
    @Override
    protected void onDeathUpdate() {
    	//Increments deathTicks every tick
    	++this.deathTicks;

    	//Creates a huge explosion if the value of deathTicks is between 180 and 200
        if (this.deathTicks >= 180 && this.deathTicks <= 200) {
            final float f = (this.rand.nextFloat() - 0.5F) * 1.5F;
            final float f1 = (this.rand.nextFloat() - 0.5F) * 2.0F;
            final float f2 = (this.rand.nextFloat() - 0.5F) * 1.5F;
            //Spawns the explosion into the world
            this.worldObj.spawnParticle(EnumParticleTypes.EXPLOSION_HUGE, this.posX + f, this.posY + 2.0D + f1, this.posZ + f2, 0.0D, 0.0D, 0.0D);
        }

        int i;
        int j;

        if (!this.worldObj.isRemote) {
        	
        	if (this.deathTicks > 150 && this.deathTicks % 5 == 0) {
                i = 30;

                while (i > 0) {
                    j = EntityXPOrb.getXPSplit(i);
                    i -= j;
                    //Spawns xp orbs while i is bigger than zero
                    this.worldObj.spawnEntityInWorld(new EntityXPOrb(this.worldObj, this.posX, this.posY, this.posZ, j));
                }
            }

        }

        //Rotates the mob
        this.moveEntity(0.0D, 0.10000000149011612D, 0.0D);
        this.renderYawOffset = this.rotationYaw += 20.0F;

        //Checks if the death ticks reached 200
        if (this.deathTicks == 200 && !this.worldObj.isRemote) {
            i = 20;

            while (i > 0) {
                j = EntityXPOrb.getXPSplit(i);
                i -= j;
                //Spawns xp orbs while i is bigger than 0
                this.worldObj.spawnEntityInWorld(new EntityXPOrb(this.worldObj, this.posX, this.posY, this.posZ, j));
            }

            //Drops an item
            this.entityDropItem(new ItemStack(AOTOItems.gem, 1, 1), 0.5F);
            
            //Spawns a lighting bolt into the world
            this.worldObj.addWeatherEffect(new EntityLightningBolt(worldObj, this.posX + 6, this.posY + 6, this.posZ));
            
            //Sets this mob dead
            super.setDead();
        }
    }

    @Override
    protected void dropFewItems(boolean par1, int par2) {
    	final ItemStack var2 = new ItemStack(AOTOItems.crown);
        EnchantmentHelper.addRandomEnchantment(this.rand, var2, 5);
        this.entityDropItem(var2, 0.0F);
    }
    
    @Override
    public EntityItem entityDropItem(ItemStack par1ItemStack, float par2) {
        final EntityItem entityitem = new EntityItem(this.worldObj, this.posX, this.posY + par2, this.posZ, par1ItemStack);
        entityitem.motionY = -2.0D;
        entityitem.setPickupDelay(60);
        if (this.captureDrops) {
            this.capturedDrops.add(entityitem);
        }else{
            this.worldObj.spawnEntityInWorld(entityitem);
        }
        return entityitem;
    }
    
    @Override
    public void onLivingUpdate() {
    	
    	if(regenTime++ > 10) {
    		regenTime = 0;
    		this.heal(4);
    	}   	
    	super.onLivingUpdate();
    }

}

 

RenderKingSteve.java

package netcrafter.mods.aoto.render.entity;

import net.minecraft.client.Minecraft;
import net.minecraft.client.model.ModelBiped;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.client.renderer.entity.RenderBiped;
import net.minecraft.client.renderer.entity.RenderLiving;
import net.minecraft.client.renderer.entity.layers.LayerBipedArmor;
import net.minecraft.client.renderer.entity.layers.LayerHeldItem;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.boss.BossStatus;
import net.minecraft.entity.boss.IBossDisplayData;
import net.minecraft.util.ResourceLocation;
import netcrafter.mods.aoto.Reference;
import netcrafter.mods.aoto.entity.boss.EntityKingSteve;
import netcrafter.mods.aoto.entity.mob.EntityTreeMinion;
import netcrafter.mods.aoto.model.ModelKingSteve;
import netcrafter.mods.aoto.model.ModelTreeMinion;

public class RenderKingSteve extends RenderBiped {

    public RenderKingSteve() {
    	
    	super(Minecraft.getMinecraft().getRenderManager(), new ModelKingSteve(), 0);
    	
	this.addLayer(new LayerHeldItem(this));
	LayerBipedArmor layerbipedarmor = new LayerBipedArmor(this) {
		protected void func_177177_a() {
			this.field_177186_d = new ModelBiped(1.0F);
			this.field_177189_c = new ModelBiped(0.5F);
		}
	};

        this.addLayer(layerbipedarmor);

    }

    @Override
    protected ResourceLocation getEntityTexture(Entity par1Entity) {
        return new ResourceLocation(Reference.MOD_ID, "textures/models/king_steve.png");
    }
    
private void renderEntity(EntityKingSteve entity, double x, double y, double z, float yaw, float partialTickTime) {
    super.doRender(entity, x, y, z, yaw, partialTickTime);
    }

    @Override
    public void doRender(EntityLiving par1EntityLiving, double par2, double par4, double par6, float par8, float par9) {
        BossStatus.setBossStatus((IBossDisplayData) par1EntityLiving, false);
        super.doRender(par1EntityLiving, par2, par4, par6, par8, par9);
    }
    
}

 

ModelKingSteve.java

package netcrafter.mods.aoto.model;

import net.minecraft.client.model.ModelBiped;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;

public class ModelKingSteve extends ModelBiped {

    ModelRenderer head;
    ModelRenderer body;
    ModelRenderer rightarm;
    ModelRenderer leftarm;
    ModelRenderer rightleg;
    ModelRenderer leftleg;
  
  public ModelKingSteve() {
    textureWidth = 64;
    textureHeight = 32;
    
      head = new ModelRenderer(this, 0, 0);
      head.addBox(-4F, -8F, -4F, 8, 8, ;
      head.setRotationPoint(0F, 0F, 0F);
      head.setTextureSize(64, 32);
      head.mirror = true;
      setRotation(head, 0F, 0F, 0F);
      body = new ModelRenderer(this, 16, 16);
      body.addBox(-4F, 0F, -2F, 8, 12, 4);
      body.setRotationPoint(0F, 0F, 0F);
      body.setTextureSize(64, 32);
      body.mirror = true;
      setRotation(body, 0F, 0F, 0F);
      rightarm = new ModelRenderer(this, 40, 16);
      rightarm.addBox(-3F, -2F, -2F, 4, 12, 4);
      rightarm.setRotationPoint(-5F, 2F, 0F);
      rightarm.setTextureSize(64, 32);
      rightarm.mirror = true;
      setRotation(rightarm, 0F, 0F, 0F);
      leftarm = new ModelRenderer(this, 40, 16);
      leftarm.addBox(-1F, -2F, -2F, 4, 12, 4);
      leftarm.setRotationPoint(5F, 2F, 0F);
      leftarm.setTextureSize(64, 32);
      leftarm.mirror = true;
      setRotation(leftarm, 0F, 0F, 0F);
      rightleg = new ModelRenderer(this, 0, 16);
      rightleg.addBox(-2F, 0F, -2F, 4, 12, 4);
      rightleg.setRotationPoint(-2F, 12F, 0F);
      rightleg.setTextureSize(64, 32);
      rightleg.mirror = true;
      setRotation(rightleg, 0F, 0F, 0F);
      leftleg = new ModelRenderer(this, 0, 16);
      leftleg.addBox(-2F, 0F, -2F, 4, 12, 4);
      leftleg.setRotationPoint(2F, 12F, 0F);
      leftleg.setTextureSize(64, 32);
      leftleg.mirror = true;
      setRotation(leftleg, 0F, 0F, 0F);
  }
  
  public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) {
    super.render(entity, f, f1, f2, f3, f4, f5);
    setRotationAngles(f, f1, f2, f3, f4, f5, entity);
    head.render(f5);
    body.render(f5);
    rightarm.render(f5);
    leftarm.render(f5);
    rightleg.render(f5);
    leftleg.render(f5);
  }
  
  private void setRotation(ModelRenderer model, float x, float y, float z) {
    model.rotateAngleX = x;
    model.rotateAngleY = y;
    model.rotateAngleZ = z;
  }
  
  public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) {
    super.setRotationAngles(f, f1, f2, f3, f4, f5, entity);
  }

}

 

Well now, that I pasted the model, maybe it renders it two times, because it is already a modelbiped?

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

×
×
  • Create New...

Important Information

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