Jump to content

Recommended Posts

Posted

In my mod, there's a block that when right clicked spawns the Monkeysaur entity:

package tlhpoe.fs.block;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import tlhpoe.fs.entity.boss.EntityMonkeysaur;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

public class BlockMonkeysaurAltar extends Block {
public IIcon iSide, iTop;

public BlockMonkeysaurAltar() {
	super(Material.rock);
}

@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int p_149691_2_) {
	if(side == 1)
		return iTop;
	return iSide;
}

@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister p_149651_1_) {
	this.iSide = Blocks.gold_block.getBlockTextureFromSide(0);
	this.iTop = p_149651_1_.registerIcon("fs:monkeysaurAltar");
	this.blockIcon = this.iTop;
}

@Override
public boolean onBlockActivated(World w, int x, int y, int z, EntityPlayer p_149727_5_, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) {
	if(!w.isRemote) {
		EntityMonkeysaur e = new EntityMonkeysaur(w);
		e.posX = x;
		e.posY = y;
		e.posZ = z;
		w.spawnEntityInWorld(e);
		w.setBlock(x, y, z, Blocks.air);
	}
	return true;
}
}

 

The problem is, the entity appears and I can't interact with it and it doesn't do anything. A few seconds later it disappears.

 

Here's the entity's code:

package tlhpoe.fs.entity.boss;

import net.minecraft.command.IEntitySelector;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAIAttackOnCollide;
import net.minecraft.entity.ai.EntityAIHurtByTarget;
import net.minecraft.entity.ai.EntityAILookIdle;
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.monster.EntityMob;
import net.minecraft.entity.monster.IMob;
import net.minecraft.world.World;

public class EntityMonkeysaur extends EntityMob implements IBossDisplayData, IMob {
private static final IEntitySelector attackEntitySelector = new IEntitySelector() {
	public boolean isEntityApplicable(Entity par1Entity) {
		return par1Entity instanceof EntityLivingBase && !(par1Entity instanceof EntityMonkeysaur);
	}
};

public EntityMonkeysaur(World par1World) {
	super(par1World);
	this.setSize(0.6F * 4, 1.8F * 4);
	this.tasks.addTask(0, new EntityAISwimming(this));
	this.tasks.addTask(1, new EntityAIAttackOnCollide(this, EntityLivingBase.class, 1.0D, false));
	this.tasks.addTask(7, new EntityAIWander(this, 1.0D));
	this.tasks.addTask(8, new EntityAIWatchClosest(this, EntityLivingBase.class, 8.0F));
	this.tasks.addTask(8, new EntityAILookIdle(this));
	this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, true));
	this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityLivingBase.class, 0, false, false, attackEntitySelector));
	this.experienceValue = 350;
}

@Override
protected void applyEntityAttributes() {
	super.applyEntityAttributes();
	this.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(64.0D);
	this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(200.0D);
	this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(10);
	this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.23000000417232513D);
}

@Override
public void setInWeb() {
}

@Override
protected void despawnEntity() {
	this.entityAge = 0;
}

@Override
protected void fall(float par1) {
}

@Override
protected boolean isAIEnabled() {
	return true;
}
}

Kain

Posted

I'm using 1.7.2, Minecraft stores its blocks in the Blocks class.

 

Here's where I do my entity registering:

package tlhpoe.fs.helper;

import net.minecraft.client.renderer.entity.Render;
import net.minecraft.entity.Entity;
import tlhpoe.fs.entity.EntityIceCreeper;
import tlhpoe.fs.entity.EntityWaterCreeper;
import tlhpoe.fs.entity.boss.EntityMonkeysaur;
import tlhpoe.fs.entity.render.RenderFSCreeper;
import tlhpoe.fs.entity.render.RenderMonkeysaur;
import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.common.registry.EntityRegistry;

public class EntityHelper {
public static void doServer() {
	doEntity(EntityIceCreeper.class, "iceCreeper", 0xFFFFFF, 0x00FFFF);
	doEntity(EntityWaterCreeper.class, "waterCreeper", 0x0F8FFF, 0x00B2FF);
	doEntity(EntityMonkeysaur.class, "monkeysaur", 0x663300, 0x472400);
}

public static void doClient() {
	doRender(EntityIceCreeper.class, new RenderFSCreeper("ice"));
	doRender(EntityWaterCreeper.class, new RenderFSCreeper("water"));
	doRender(EntityMonkeysaur.class, new RenderMonkeysaur());
}

private static void doEntity(Class<? extends Entity> clazz, String name, int bgColor, int spotColor) {
	int id = EntityRegistry.findGlobalUniqueEntityId();
	EntityRegistry.registerGlobalEntityID(clazz, name, id, bgColor, spotColor);
}

private static void doRender(Class<? extends Entity> clazz, Render render) {
	RenderingRegistry.registerEntityRenderingHandler(clazz, render);
}
}

 

I can spawn it just fine with the spawn egg.

Kain

Posted

Oh I thought you were using 1.6, my bad.

 

Hmm. Strange, as if its spawning a ghost entity.

 

Try looking at other onBlockActivated methods.

In BlockWorkbench, it activates when

 

(world.isRemote), try removing the !

Posted

If I remove the !, it spawns the entity client side and it just makes the game confused a little.

 

If I completely remove the if statement, same result.

Kain

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

    • Ignore shrimple, it doesn't work with Oculus. Also, enableShaders was alr true when it said that towards the end of the log. If you could also figure out why my tags are messed up that'd be cool too, but that's a later issue. https://drive.google.com/drive/folders/1ovEKDZECUCl7zZxGfpyQcS4s5PZPQyfa?usp=drive_link
    • accidental duplicate mesage cuz lag
    • https://gnomebot.dev/paste/231527759279685634/1372324909073563730/1372324908629102716 https://gnomebot.dev/paste/231527759279685634/1372320454861262908/1372320454299090996 seems like theres a registry sync error, not sure what that means though, however in an old pack i played on, i actually had a registry sync error happen whenever the world tried too save and it would suddenly stop loading chunks, is there a mod fix for this or some way too bypass registry syncing? is this a server problem? i have no issues with the pack on pc, only on my server.
    • i think the problem is the player animator library but i need it for one of my main mods is there any way i can fix this? The game crashed: rendering overlay Error: java.lang.IllegalArgumentException: Failed to create player model for default heres the crash report: https://pastebin.com/U5Wp8ysb
    • I have been an enthusiastic investor in crypt0currencies for several years, and my digital assets have been integral to my financial strategy. A few months ago, I encountered a distressing predicament when I lost access to my primary cryptocurrency walleet after clicking on an airdrop link that inadvertently connected to my walleet. The dread of potentially losing all my hard-earned funds was overwhelming, leaving me uncertain about where to seek assistance. In my pursuit of solutions, I stumbled upon ChainDigger Retrievers. From our initial consultation to the triumphant recovery of my assets, the team exhibited exceptional expertise. They provided comprehensive explanations of the recovery process, ensuring I was informed at every stage and offering reassurance during this tumultuous time. Their approach was not only meticulous but also compassionate, which significantly alleviated my anxiety. ChainDigger Retrievers unwavering commitment to resolving my issue was evident throughout the process. Leveraging their profound understanding of crypt0currency technology and digital forensics, they initiated an exhaustive investigation to trace the transactions linked to my compromised wallet. Their meticulous analysis and relentless determination were apparent as they left no stone unturned in their quest to recover my funds. After several days of diligent investigation, the team successfully recovered everything I had lost. They uncovered that the link I had clicked contained malware, which scammeers had used to infiltrate my walleet. This revelation was both alarming and enlightening, underscoring the inherent risks associated with crypt0currency transactions when proper precautions are not taken.Thanks to ChainDigger Retrievers, I not only regained everything but also acquired invaluable knowledge about safeguarding my investments. Their expertise and steadfast support transformed a daunting situation into a manageable one, and I am profoundly grateful for their assistance. I can now continue my investment journey with renewed confidence, knowing that I have a trustworthy ally in ChainDigger Retrievers. Their client satisfaction is truly commendable, and I wholeheartedly recommend their services to anyone facing similar challenges in the crypt0currency realm. With their help, I was able to turn a distressing time into a positive outcome, and I will forever be grateful for their support.  
  • Topics

  • Who's Online (See full list)

    • There are no registered users currently online
×
×
  • Create New...

Important Information

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