Jump to content

Recommended Posts

Posted

How can i make a player invisible to mobs on wearing an specific armor set, by the way the player is not been attacked by them.

 

I've tried this, but the mobs still attack the player:

player.addPotionEffect((new PotionEffect(Potion.invisibility.id, 2, 0)));

 

Thanks for helping.

Posted

I'm not sure if this would be the most efficient way, but:

 

1. Setup an entity tick event

2. Check if entity is a mob

3. Check if mob has a target (the player)

4. Remove if it does

Kain

Posted

I'm not sure if this would be the most efficient way, but:

 

1. Setup an entity tick event

2. Check if entity is a mob

3. Check if mob has a target (the player)

4. Remove if it does

 

There is LivingSetAttackTargetEvent.

 

Ok, but, could you give me some steps to do it? code examples?

Posted

Hi

 

This has some useful code

http://www.minecraftforum.net/topic/1419836-131-forge-4x-events-howto/

 

 

Not sure how you would cancel the event, it doesn't seem to be cancelable like normal events, unless I'm missing something.

 

You could perhaps use

 

@ForgeSubscribe
public void entityTarget(LivingSetAttackTargetEvent event)
{
  
  if (event.target != null
     && event.target instanceof EntityPlayer) {
    event.entityLiving.setAttackTarget(null);
  }
}

 

Not sure if that will work since the call to setAttackTarget is reentrant, i.e. will trigger another LivingSetAttackTargetEvent.  Also, setting target to null like this might perhaps cause a crash.

 

And, probably, the mobs will just stand around doing nothing instead of ignoring the player.

 

But it's worth a try :-)

 

-TGG

Posted

What TGG said, though if you check properly the second post to the set living attack target event should process just fine. Btw, checking instanceof automatically null checks for you:

if (event.target instanceof EntityPlayer) {
((EntityLiving) event.entity).setAttackTarget(null);
}

That will make the mobs mostly just stand around doing nothing, even if you attack them. If you want them to fight back, you should add the following check to the check for instanceof EntityPlayer:

&& event.entityLiving.func_94060_bK() != event.target)

Note also that this only works on mobs that are using the AI system - spiders, for example, will still attack you.

Posted

Hi

 

This has some useful code

http://www.minecraftforum.net/topic/1419836-131-forge-4x-events-howto/

 

 

Not sure how you would cancel the event, it doesn't seem to be cancelable like normal events, unless I'm missing something.

 

You could perhaps use

 

@ForgeSubscribe
public void entityTarget(LivingSetAttackTargetEvent event)
{
  
  if (event.target != null
     && event.target instanceof EntityPlayer) {
    event.entityLiving.setAttackTarget(null);
  }
}

 

Not sure if that will work since the call to setAttackTarget is reentrant, i.e. will trigger another LivingSetAttackTargetEvent.  Also, setting target to null like this might perhaps cause a crash.

 

And, probably, the mobs will just stand around doing nothing instead of ignoring the player.

 

But it's worth a try :-)

 

-TGG

 

What TGG said, though if you check properly the second post to the set living attack target event should process just fine. Btw, checking instanceof automatically null checks for you:

if (event.target instanceof EntityPlayer) {
((EntityLiving) event.entity).setAttackTarget(null);
}

That will make the mobs mostly just stand around doing nothing, even if you attack them. If you want them to fight back, you should add the following check to the check for instanceof EntityPlayer:

&& event.entityLiving.func_94060_bK() != event.target)

Note also that this only works on mobs that are using the AI system - spiders, for example, will still attack you.

 

Ok, thanks, it works.

 

Now i have another problem:

 

If the player is firstly invisible, then the mobs don't attack him, but if the mobs are attacking him and the player becomes invisible, the mobs still attack him.

 

This is my code:

/**
 * Only works with AI mobs: Zombies, Skeletons and Creepers.
 * @param event
 */
@SubscribeEvent
public void onEntitySetTarget(LivingSetAttackTargetEvent event)
{
	if (Loader.isModLoaded("SKC-Camouflage"))
	{
		if (event.target != null && event.target instanceof EntityPlayer && event.entityLiving.func_94060_bK() != event.target)
    	{
			if (event.target.isInvisible())
			{
				((EntityLiving) event.entity).setAttackTarget(null);
			}
    	}
	}
    }

Posted

Hi

 

This has some useful code

http://www.minecraftforum.net/topic/1419836-131-forge-4x-events-howto/

 

 

Not sure how you would cancel the event, it doesn't seem to be cancelable like normal events, unless I'm missing something.

 

You could perhaps use

 

@ForgeSubscribe
public void entityTarget(LivingSetAttackTargetEvent event)
{
  
  if (event.target != null
     && event.target instanceof EntityPlayer) {
    event.entityLiving.setAttackTarget(null);
  }
}

 

Not sure if that will work since the call to setAttackTarget is reentrant, i.e. will trigger another LivingSetAttackTargetEvent.  Also, setting target to null like this might perhaps cause a crash.

 

And, probably, the mobs will just stand around doing nothing instead of ignoring the player.

 

But it's worth a try :-)

 

-TGG

 

What TGG said, though if you check properly the second post to the set living attack target event should process just fine. Btw, checking instanceof automatically null checks for you:

if (event.target instanceof EntityPlayer) {
((EntityLiving) event.entity).setAttackTarget(null);
}

That will make the mobs mostly just stand around doing nothing, even if you attack them. If you want them to fight back, you should add the following check to the check for instanceof EntityPlayer:

&& event.entityLiving.func_94060_bK() != event.target)

Note also that this only works on mobs that are using the AI system - spiders, for example, will still attack you.

 

Ok, thanks, it works.

 

Now i have another problem:

 

If the player is firstly invisible, then the mobs don't attack him, but if the mobs are attacking him and the player becomes invisible, the mobs still attack him.

 

This is my code:

/**
 * Only works with AI mobs: Zombies, Skeletons and Creepers.
 * @param event
 */
@SubscribeEvent
public void onEntitySetTarget(LivingSetAttackTargetEvent event)
{
	if (Loader.isModLoaded("SKC-Camouflage"))
	{
		if (event.target != null && event.target instanceof EntityPlayer && event.entityLiving.func_94060_bK() != event.target)
    	{
			if (event.target.isInvisible())
			{
				((EntityLiving) event.entity).setAttackTarget(null);
			}
    	}
	}
    }

That's because the mob already has a target, so it won't set a new. So you'll have to deal with it, or find a solution for it.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Posted

You could subscribe to LivingAttackEvent as well, checking if the player is invisible and getting the source of the source of damage (yes, you read that right), checking if that is an EntityLiving and then setting their current target to null. Obviously that won't work for everything - creepers, for instance - but it should cover most. Otherwise, you could get all of the living entities nearby the player when they turn invisible and set their targets to null at that time, if their current target is the player turning invisible. Probably simpler to just deal with some mobs still attacking.

Posted

You could subscribe to LivingAttackEvent as well, checking if the player is invisible and getting the source of the source of damage (yes, you read that right), checking if that is an EntityLiving and then setting their current target to null. Obviously that won't work for everything - creepers, for instance - but it should cover most. Otherwise, you could get all of the living entities nearby the player when they turn invisible and set their targets to null at that time, if their current target is the player turning invisible. Probably simpler to just deal with some mobs still attacking.

 

Ok, but where's the ".setCurrentTarget()" (or similar) method is located?

 

Posted

Ok, but where's the ".setCurrentTarget()" (or similar) method is located?

You can't be serious... haven't you been paying attention to the thread at all? EntityLiving#setAttackTarget has been featured in probably every single bit of code that has been used in the examples.

 

:'( Sorry for that stupid question, but i've just got up.

 

Ok, did it and the mobs (only tested zombies) don't attack me. But if i touch them then minecraft crashes.

 

[12:56:51] [server thread/ERROR]: Encountered an unexpected exception
net.minecraft.util.ReportedException: Ticking entity
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:745) ~[MinecraftServer.class:?]
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:650) ~[MinecraftServer.class:?]
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:120) ~[integratedServer.class:?]
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:528) [MinecraftServer.class:?]
at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:787) [MinecraftServer$2.class:?]
Caused by: java.lang.ClassCastException: net.minecraft.entity.player.EntityPlayerMP cannot be cast to net.minecraft.entity.EntityLiving
at com.sackcastellon.core.event.MinecraftForgeEvents.onEntityAttack(MinecraftForgeEvents.java:50) ~[MinecraftForgeEvents.class:?]
at cpw.mods.fml.common.eventhandler.ASMEventHandler_6_MinecraftForgeEvents_onEntityAttack_LivingAttackEvent.invoke(.dynamic) ~[?:?]
at cpw.mods.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:51) ~[ASMEventHandler.class:?]
at cpw.mods.fml.common.eventhandler.EventBus.post(EventBus.java:122) ~[EventBus.class:?]
at net.minecraftforge.common.ForgeHooks.onLivingAttack(ForgeHooks.java:274) ~[ForgeHooks.class:?]
at net.minecraft.entity.player.EntityPlayer.attackEntityFrom(EntityPlayer.java:1132) ~[EntityPlayer.class:?]
at net.minecraft.entity.player.EntityPlayerMP.attackEntityFrom(EntityPlayerMP.java:564) ~[EntityPlayerMP.class:?]
at net.minecraft.entity.monster.EntityMob.attackEntityAsMob(EntityMob.java:140) ~[EntityMob.class:?]
at net.minecraft.entity.monster.EntityZombie.attackEntityAsMob(EntityZombie.java:333) ~[EntityZombie.class:?]
at net.minecraft.entity.ai.EntityAIAttackOnCollide.updateTask(EntityAIAttackOnCollide.java:175) ~[EntityAIAttackOnCollide.class:?]
at net.minecraft.entity.ai.EntityAITasks.onUpdateTasks(EntityAITasks.java:131) ~[EntityAITasks.class:?]
at net.minecraft.entity.EntityLiving.updateAITasks(EntityLiving.java:633) ~[EntityLiving.class:?]
at net.minecraft.entity.EntityLivingBase.onLivingUpdate(EntityLivingBase.java:2023) ~[EntityLivingBase.class:?]
at net.minecraft.entity.EntityLiving.onLivingUpdate(EntityLiving.java:451) ~[EntityLiving.class:?]
at net.minecraft.entity.monster.EntityMob.onLivingUpdate(EntityMob.java:39) ~[EntityMob.class:?]
at net.minecraft.entity.monster.EntityZombie.onLivingUpdate(EntityZombie.java:236) ~[EntityZombie.class:?]
at net.minecraft.entity.EntityLivingBase.onUpdate(EntityLivingBase.java:1856) ~[EntityLivingBase.class:?]
at net.minecraft.entity.EntityLiving.onUpdate(EntityLiving.java:270) ~[EntityLiving.class:?]
at net.minecraft.entity.monster.EntityMob.onUpdate(EntityMob.java:47) ~[EntityMob.class:?]
at net.minecraft.entity.monster.EntityZombie.onUpdate(EntityZombie.java:328) ~[EntityZombie.class:?]
at net.minecraft.world.World.updateEntityWithOptionalForce(World.java:2286) ~[World.class:?]
at net.minecraft.world.WorldServer.updateEntityWithOptionalForce(WorldServer.java:705) ~[WorldServer.class:?]
at net.minecraft.world.World.updateEntity(World.java:2246) ~[World.class:?]
at net.minecraft.world.World.updateEntities(World.java:2096) ~[World.class:?]
at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:536) ~[WorldServer.class:?]
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:739) ~[MinecraftServer.class:?]
... 4 more
[12:56:51] [server thread/ERROR]: This crash report has been saved to: C:\Users\Juanjo hijo\AppData\Roaming\Modding\forge-1.7.2-10.12.0.1024-src\.\crash-reports\crash-2014-03-24_12.56.51-server.txt
[12:56:51] [server thread/INFO]: Stopping server
[12:56:51] [server thread/INFO]: Saving players
---- Minecraft Crash Report ----
// Quite honestly, I wouldn't worry myself about that.

Time: 24/03/14 12:56
Description: Ticking entity

java.lang.ClassCastException: net.minecraft.entity.player.EntityPlayerMP cannot be cast to net.minecraft.entity.EntityLiving
at com.sackcastellon.core.event.MinecraftForgeEvents.onEntityAttack(MinecraftForgeEvents.java:50)
at cpw.mods.fml.common.eventhandler.ASMEventHandler_6_MinecraftForgeEvents_onEntityAttack_LivingAttackEvent.invoke(.dynamic)
at cpw.mods.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:51)
at cpw.mods.fml.common.eventhandler.EventBus.post(EventBus.java:122)
at net.minecraftforge.common.ForgeHooks.onLivingAttack(ForgeHooks.java:274)
at net.minecraft.entity.player.EntityPlayer.attackEntityFrom(EntityPlayer.java:1132)
at net.minecraft.entity.player.EntityPlayerMP.attackEntityFrom(EntityPlayerMP.java:564)
at net.minecraft.entity.monster.EntityMob.attackEntityAsMob(EntityMob.java:140)
at net.minecraft.entity.monster.EntityZombie.attackEntityAsMob(EntityZombie.java:333)
at net.minecraft.entity.ai.EntityAIAttackOnCollide.updateTask(EntityAIAttackOnCollide.java:175)
at net.minecraft.entity.ai.EntityAITasks.onUpdateTasks(EntityAITasks.java:131)
at net.minecraft.entity.EntityLiving.updateAITasks(EntityLiving.java:633)
at net.minecraft.entity.EntityLivingBase.onLivingUpdate(EntityLivingBase.java:2023)
at net.minecraft.entity.EntityLiving.onLivingUpdate(EntityLiving.java:451)
at net.minecraft.entity.monster.EntityMob.onLivingUpdate(EntityMob.java:39)
at net.minecraft.entity.monster.EntityZombie.onLivingUpdate(EntityZombie.java:236)
at net.minecraft.entity.EntityLivingBase.onUpdate(EntityLivingBase.java:1856)
at net.minecraft.entity.EntityLiving.onUpdate(EntityLiving.java:270)
at net.minecraft.entity.monster.EntityMob.onUpdate(EntityMob.java:47)
at net.minecraft.entity.monster.EntityZombie.onUpdate(EntityZombie.java:328)
at net.minecraft.world.World.updateEntityWithOptionalForce(World.java:2286)
at net.minecraft.world.WorldServer.updateEntityWithOptionalForce(WorldServer.java:705)
at net.minecraft.world.World.updateEntity(World.java:2246)
at net.minecraft.world.World.updateEntities(World.java:2096)
at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:536)
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:739)
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:650)
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:120)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:528)
at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:787)


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- Head --
Stacktrace:
at com.sackcastellon.core.event.MinecraftForgeEvents.onEntityAttack(MinecraftForgeEvents.java:50)
at cpw.mods.fml.common.eventhandler.ASMEventHandler_6_MinecraftForgeEvents_onEntityAttack_LivingAttackEvent.invoke(.dynamic)
at cpw.mods.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:51)
at cpw.mods.fml.common.eventhandler.EventBus.post(EventBus.java:122)
at net.minecraftforge.common.ForgeHooks.onLivingAttack(ForgeHooks.java:274)
at net.minecraft.entity.player.EntityPlayer.attackEntityFrom(EntityPlayer.java:1132)
at net.minecraft.entity.player.EntityPlayerMP.attackEntityFrom(EntityPlayerMP.java:564)
at net.minecraft.entity.monster.EntityMob.attackEntityAsMob(EntityMob.java:140)
at net.minecraft.entity.monster.EntityZombie.attackEntityAsMob(EntityZombie.java:333)
at net.minecraft.entity.ai.EntityAIAttackOnCollide.updateTask(EntityAIAttackOnCollide.java:175)
at net.minecraft.entity.ai.EntityAITasks.onUpdateTasks(EntityAITasks.java:131)
at net.minecraft.entity.EntityLiving.updateAITasks(EntityLiving.java:633)
at net.minecraft.entity.EntityLivingBase.onLivingUpdate(EntityLivingBase.java:2023)
at net.minecraft.entity.EntityLiving.onLivingUpdate(EntityLiving.java:451)
at net.minecraft.entity.monster.EntityMob.onLivingUpdate(EntityMob.java:39)
at net.minecraft.entity.monster.EntityZombie.onLivingUpdate(EntityZombie.java:236)
at net.minecraft.entity.EntityLivingBase.onUpdate(EntityLivingBase.java:1856)
at net.minecraft.entity.EntityLiving.onUpdate(EntityLiving.java:270)
at net.minecraft.entity.monster.EntityMob.onUpdate(EntityMob.java:47)
at net.minecraft.entity.monster.EntityZombie.onUpdate(EntityZombie.java:328)
at net.minecraft.world.World.updateEntityWithOptionalForce(World.java:2286)
at net.minecraft.world.WorldServer.updateEntityWithOptionalForce(WorldServer.java:705)
at net.minecraft.world.World.updateEntity(World.java:2246)

-- Entity being ticked --
Details:
Entity Type: Zombie (net.minecraft.entity.monster.EntityZombie)
Entity ID: 4
Entity Name: Zombie
Entity's Exact location: -1321,83, 56,00, 925,34
Entity's Block location: World: (-1322,56,925), Chunk: (at 6,3,13 in -83,57; contains blocks -1328,0,912 to -1313,255,927), Region: (-3,1; contains chunks -96,32 to -65,63, blocks -1536,0,512 to -1025,255,1023)
Entity's Momentum: 0,00, -0,08, 0,00
Stacktrace:
at net.minecraft.world.World.updateEntities(World.java:2096)
at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:536)

-- Affected level --
Details:
Level name: New World
All players: 1 total; [EntityPlayerMP['Player4'/6, l='New World', x=-1320,69, y=56,00, z=925,46]]
Chunk stats: ServerChunkCache: 646 Drop: 0
Level seed: 4740230574978669681
Level generator: ID 01 - flat, ver 0. Features enabled: false
Level generator options: 2;7,3x1,52x24;2;
Level spawn location: World: (-1359,4,966), Chunk: (at 1,0,6 in -85,60; contains blocks -1360,0,960 to -1345,255,975), Region: (-3,1; contains chunks -96,32 to -65,63, blocks -1536,0,512 to -1025,255,1023)
Level time: 141224 game time, 13000 day time
Level dimension: 0
Level storage version: 0x04ABD - Anvil
Level weather: Rain time: 80681 (now: false), thunder time: 91378 (now: false)
Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: true
Stacktrace:
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:739)
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:650)
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:120)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:528)
at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:787)

-- System Details --
Details:
Minecraft Version: 1.7.2
Operating System: Windows 7 (amd64) version 6.1
Java Version: 1.7.0_25, Oracle Corporation
Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 169809664 bytes (161 MB) / 448659456 bytes (427 MB) up to 878051328 bytes (837 MB)
JVM Flags: 0 total; 
AABB Pool Size: 188 (10528 bytes; 0 MB) allocated, 55 (3080 bytes; 0 MB) used
IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
FML: MCP v9.01-pre FML v7.2.116.1024 Minecraft Forge 10.12.0.1024 7 mods loaded, 7 mods active
mcp{8.09} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
FML{7.2.116.1024} [Forge Mod Loader] (forgeSrc-1.7.2-10.12.0.1024.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
Forge{10.12.0.1024} [Minecraft Forge] (forgeSrc-1.7.2-10.12.0.1024.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
SKC-Core{1.1.1.0} [sKC Core] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
SKC-BetterWood{1.1.0.0} [better Wood] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
SKC-Camouflage{1.1.0.0} [Camouflage] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
SKC-CraftableHorseArmor{1.1.1.0} [Craftable Horse Armor] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
Profiler Position: N/A (disabled)
Vec3 Pool Size: 149 (8344 bytes; 0 MB) allocated, 92 (5152 bytes; 0 MB) used
Player Count: 1 / 8; [EntityPlayerMP['Player4'/6, l='New World', x=-1320,69, y=56,00, z=925,46]]
Type: Integrated Server (map_client.txt)
Is Modded: Definitely; Client brand changed to 'fml,forge'
#@!@# Game crashed! Crash report saved to: #@!@# .\crash-reports\crash-2014-03-24_12.56.51-server.txt
[12:56:51] [Client Shutdown Thread/INFO]: Stopping server
[12:56:51] [Client Shutdown Thread/INFO]: Saving players
AL lib: (EE) alc_cleanup: 1 device not closed

Posted

You don't know how to prevent class cast exceptions? It crashed because whatever code you ran is indiscriminately casting every single entity it comes across as an EntityLiving, when the entity may very well not be one, such as the EntityPlayerMP in your crash log.

 

Solution: instanceof

 

EntityLiving and EntityPlayer are both subclasses of EntityLivingBase, but you cannot cast one to the other unless it is an X instanceof Y (you can cast both to EntityLivingBase, if that's what you need, though.) SO, put an 'if' in there to catch that and use logic.

 

Posted

EntityLiving and EntityPlayer are both subclasses of EntityLivingBase, but you cannot cast one to the other unless it is an X instanceof Y (you can cast both to EntityLivingBase, if that's what you need, though.) SO, put an 'if' in there to catch that and use logic.

That has nothing to do with the topic, he is trying to use a method in EntityLiving, not EntityLivingBase, so he needs to check if the entity in question is an instanceof EntityLiving before casting. Stop confusing people with random comments.

Posted

EntityLiving and EntityPlayer are both subclasses of EntityLivingBase, but you cannot cast one to the other unless it is an X instanceof Y (you can cast both to EntityLivingBase, if that's what you need, though.) SO, put an 'if' in there to catch that and use logic.

That has nothing to do with the topic, he is trying to use a method in EntityLiving, not EntityLivingBase, so he needs to check if the entity in question is an instanceof EntityLiving before casting. Stop confusing people with random comments.

 

I don't find your attitude helpful. Perhaps you could keep your snide comments out of the fora.

Posted

EntityLiving and EntityPlayer are both subclasses of EntityLivingBase, but you cannot cast one to the other unless it is an X instanceof Y (you can cast both to EntityLivingBase, if that's what you need, though.) SO, put an 'if' in there to catch that and use logic.

That has nothing to do with the topic, he is trying to use a method in EntityLiving, not EntityLivingBase, so he needs to check if the entity in question is an instanceof EntityLiving before casting. Stop confusing people with random comments.

I don't find your attitude helpful. Perhaps you could keep your snide comments out of the fora.

How is clarifying a statement that confuses the issue at hand being snide or unhelpful? I've seen you give people some excellent advice on challenging questions in other threads, but there have been several cases where you've been either plain wrong or providing extraneous information that diverts from the main point; in the latter cases, I feel it is indeed helpful to point it out and provide either clarification or correction as needed. When I say "stop confusing people with random statements", I'm referring to the latter; for the former, it is helpful to fact-check before posting replies to make sure the information you provide is accurate. If you consider that snide, well, that's your call.

Posted

EntityLiving and EntityPlayer are both subclasses of EntityLivingBase, but you cannot cast one to the other unless it is an X instanceof Y (you can cast both to EntityLivingBase, if that's what you need, though.) SO, put an 'if' in there to catch that and use logic.

That has nothing to do with the topic, he is trying to use a method in EntityLiving, not EntityLivingBase, so he needs to check if the entity in question is an instanceof EntityLiving before casting. Stop confusing people with random comments.

I don't find your attitude helpful. Perhaps you could keep your snide comments out of the fora.

How is clarifying a statement that confuses the issue at hand being snide or unhelpful? I've seen you give people some excellent advice on challenging questions in other threads, but there have been several cases where you've been either plain wrong or providing extraneous information that diverts from the main point; in the latter cases, I feel it is indeed helpful to point it out and provide either clarification or correction as needed. When I say "stop confusing people with random statements", I'm referring to the latter; for the former, it is helpful to fact-check before posting replies to make sure the information you provide is accurate. If you consider that snide, well, that's your call.

Your remarks were and continue to be out of band for these fora. Your tutorials are nice, but all you do is self-advertise your ability to learn from tutorials. So, when all you have to add is "hey, look at my totorial," you really don't have any place suggesting I change my posting habits to suit you.

Now, please grow the hell up and stop this quibbling. It gains nothing and bores me.

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



×
×
  • Create New...

Important Information

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