Jump to content

Recommended Posts

Posted

Hello. I'm making a mod and wanted to make an item that when you right click it,zombies wont attack you. Does anyone have any suggestions?

I'm back from being gone for... I think its been about a year. I'm pretty sure nobody remembers me, but hello anybody who does!

Posted

Depending upon the mob (if it is vanilla or not), you may be able to simply remove the AI tasks from its AI, or insert/overwrite with your own tasks.  This could be done with the EntityJoinWorld event.

 

Another method might be to handle the LivingSetAttackTargetEvent, cancelling the target/overwriting the target for that entity.  (Haven't played with this one myself...so..it _might_ be viable)

 

A bit of a hackier method would be to use a tick-handler and examine entities near players, and remove/reset their AI target.

 

There may well be other methods as well, as this is not something that I've looked into very much.

 

Edit:  these are methods that should work fine with vanilla entities.  Handling mod entities will be hit-and miss depending upon whether they call the appropriate events and/or use the vanilla AI system.

 

 

Posted

Depending upon the mob (if it is vanilla or not), you may be able to simply remove the AI tasks from its AI, or insert/overwrite with your own tasks.  This could be done with the EntityJoinWorld event.

 

Another method might be to handle the LivingSetAttackTargetEvent, cancelling the target/overwriting the target for that entity.  (Haven't played with this one myself...so..it _might_ be viable)

 

A bit of a hackier method would be to use a tick-handler and examine entities near players, and remove/reset their AI target.

 

There may well be other methods as well, as this is not something that I've looked into very much.

 

Edit:  these are methods that should work fine with vanilla entities.  Handling mod entities will be hit-and miss depending upon whether they call the appropriate events and/or use the vanilla AI system.

 

Can you please give me code how to use those methods to stop vanilla zombies from attacking the player. I would greatly appreciate that.

I'm back from being gone for... I think its been about a year. I'm pretty sure nobody remembers me, but hello anybody who does!

Posted

zombie.targetTasks.removeTask(zombie.targetTasks.taskEntries.get(1));

 

Let me know if it works, I didn't test it.  You'll have an issue if it is supposed to be a "toggle" as the EntityZombie constructor code puts it into the array second, and if you add it back with zombie.targetTasks.addTask(2, new EntityAINearestAttackableTarget(zombie, EntityPlayer.class, 0, true)); it will be third.  Adapt accordingly.

Posted

Giving me errors in Eclipse.

EntityZombie.targetTasks.removeTask(EntityZombie.targetTasks.taskEntries.get(1));

Errors:

Multiple markers at this line

- Cannot make a static reference to the non-static field

EntityZombie.targetTasks

- Cannot make a static reference to the non-static field

EntityZombie.targetTasks

I'm back from being gone for... I think its been about a year. I'm pretty sure nobody remembers me, but hello anybody who does!

Posted

Yeah, I missed that they weren't static...makes it a lot harder for me to test them now too...you'll have to get your item's right click target entity, check if it's a zombie, then run the code from my edit on the casted entity.

 

public boolean itemInteractionForEntity(ItemStack itemStack,EntityPlayer player,EntityLivingBase target) {
	if (target.worldObj.isRemote) return false;

	if (target instanceof EntityZombie && 
			((EntityZombie) target).targetTasks.taskEntries.get(1) instanceof EntityAINearestAttackableTarget)
	{
		((EntityZombie) target).targetTasks.removeTask((EntityAINearestAttackableTarget)((EntityZombie) target).targetTasks.taskEntries.get(1));
	}

	return false;
}

 

Posted

Third time's the charm.  I actually tested it this time.

 

 

@Override
public boolean itemInteractionForEntity(ItemStack itemStack,EntityPlayer player,EntityLivingBase target) {
	player.sendChatToPlayer(ChatMessageComponent.createFromText("Activated."));

	// Run locally only
	if (target.worldObj.isRemote) return false;

	player.sendChatToPlayer(ChatMessageComponent.createFromText("Testing for EntityZombie."));
	if (target instanceof EntityZombie)
	{
		player.sendChatToPlayer(ChatMessageComponent.createFromText("EntityZombie, testing task."));
		EntityZombie zombie = (EntityZombie) target;
		EntityAITaskEntry task = (EntityAITaskEntry) zombie.targetTasks.taskEntries.get(1);
		if (task.action instanceof EntityAINearestAttackableTarget)
		{
			player.sendChatToPlayer(ChatMessageComponent.createFromText("Task."));
			player.sendChatToPlayer(ChatMessageComponent.createFromText("Removing."));
			zombie.targetTasks.removeTask(task.action);

			player.sendChatToPlayer(ChatMessageComponent.createFromText("Tamed."));
		}
	}

	return false;
}

 

Posted

That will still allow a "tamed" zombie to attack villagers after the first right-click.  After the second right-click, they won't attack villagers either.  Cast the task.action and check the targetClass property against EntityPlayer.class to change this.  Sorry for the screwups, still a newb to this and this was actually my first dive into the AI.

Posted

It worked until this error came.

 

---- Minecraft Crash Report ----
// My bad.

Time: 1/16/14 3:42 PM
Description: Ticking memory connection

java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
at java.util.ArrayList.rangeCheck(Unknown Source)
at java.util.ArrayList.get(Unknown Source)
at rotten_flesh_mod.RottenFleshWandZombieTamer.itemInteractionForEntity(RottenFleshWandZombieTamer.java:29)
at net.minecraft.item.ItemStack.func_111282_a(ItemStack.java:421)
at net.minecraft.entity.player.EntityPlayer.interactWith(EntityPlayer.java:1257)
at net.minecraft.network.NetServerHandler.handleUseEntity(NetServerHandler.java:846)
at net.minecraft.network.packet.Packet7UseEntity.processPacket(Packet7UseEntity.java:36)
at net.minecraft.network.MemoryConnection.processReadPackets(MemoryConnection.java:89)
at net.minecraft.network.NetServerHandler.networkTick(NetServerHandler.java:141)
at net.minecraft.network.NetworkListenThread.networkTick(NetworkListenThread.java:54)
at net.minecraft.server.integrated.IntegratedServerListenThread.networkTick(IntegratedServerListenThread.java:109)
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:691)
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:587)
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:129)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:484)
at net.minecraft.server.ThreadMinecraftServer.run(ThreadMinecraftServer.java:583)


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

-- Head --
Stacktrace:
at java.util.ArrayList.rangeCheck(Unknown Source)
at java.util.ArrayList.get(Unknown Source)
at rotten_flesh_mod.RottenFleshWandZombieTamer.itemInteractionForEntity(RottenFleshWandZombieTamer.java:29)
at net.minecraft.item.ItemStack.func_111282_a(ItemStack.java:421)
at net.minecraft.entity.player.EntityPlayer.interactWith(EntityPlayer.java:1257)
at net.minecraft.network.NetServerHandler.handleUseEntity(NetServerHandler.java:846)
at net.minecraft.network.packet.Packet7UseEntity.processPacket(Packet7UseEntity.java:36)
at net.minecraft.network.MemoryConnection.processReadPackets(MemoryConnection.java:89)
at net.minecraft.network.NetServerHandler.networkTick(NetServerHandler.java:141)

-- Ticking connection --
Details:
Connection: net.minecraft.network.NetServerHandler@a88cdff
Stacktrace:
at net.minecraft.network.NetworkListenThread.networkTick(NetworkListenThread.java:54)
at net.minecraft.server.integrated.IntegratedServerListenThread.networkTick(IntegratedServerListenThread.java:109)
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:691)
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:587)
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:129)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:484)
at net.minecraft.server.ThreadMinecraftServer.run(ThreadMinecraftServer.java:583)

-- System Details --
Details:
Minecraft Version: 1.6.4
Operating System: Windows 8 (amd64) version 6.2
Java Version: 1.7.0_45, Oracle Corporation
Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 211564048 bytes (201 MB) / 562561024 bytes (536 MB) up to 1301282816 bytes (1241 MB)
JVM Flags: 0 total; 
AABB Pool Size: 1937 (108472 bytes; 0 MB) allocated, 1682 (94192 bytes; 0 MB) used
Suspicious classes: FML and Forge are installed
IntCache: cache: 3, tcache: 0, allocated: 3, tallocated: 63
FML: MCP v8.11 FML v6.99.19.964 Minecraft Forge 9.11.1.964 5 mods loaded, 5 mods active
mcp{8.09} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
FML{6.99.19.964} [Forge Mod Loader] (forge-1.6.4-9.11.1.964-mcp.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
Forge{9.11.1.964} [Minecraft Forge] (forge-1.6.4-9.11.1.964-mcp.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
examplemod{1.0} [Example Mod] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
rotten_flesh_mod{1.3} [Rotten Flesh Mod] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
Profiler Position: N/A (disabled)
Vec3 Pool Size: 765 (42840 bytes; 0 MB) allocated, 433 (24248 bytes; 0 MB) used
Player Count: 1 / 8; [EntityPlayerMP['Player343'/282, l='Test World', x=-38.45, y=63.79, z=12.70]]
Type: Integrated Server (map_client.txt)
Is Modded: Definitely; Client brand changed to 'fml,forge'

Note: For some reason this error just comes up at random and crashed the game.

I'm back from being gone for... I think its been about a year. I'm pretty sure nobody remembers me, but hello anybody who does!

Posted

This was my code orignally

 

public class RottenFleshWandZombieTamer extends Item{

public RottenFleshWandZombieTamer(int par1) {
	super(par1);
}
@Override
public boolean itemInteractionForEntity(ItemStack itemStack,EntityPlayer player,EntityLivingBase target) {
	player.sendChatToPlayer(ChatMessageComponent.createFromText("Activated."));

	// Run locally only
	if (target.worldObj.isRemote) return false;

	if (target instanceof EntityZombie)
	{
		player.sendChatToPlayer(ChatMessageComponent.createFromText("EntityZombie, testing task."));
		EntityZombie zombie = (EntityZombie) target;
		EntityAITaskEntry task = (EntityAITaskEntry) zombie.targetTasks.taskEntries.get(1);
	        if (task.action instanceof EntityAINearestAttackableTarget)
			{
				zombie.targetTasks.removeTask(task.action);

			}
		}

	}else{
		return false;
	}

	return false;
}
}

 

I changed it to this:

 

public class RottenFleshWandZombieTamer extends Item{

public RottenFleshWandZombieTamer(int par1) {
	super(par1);
}
@Override
public boolean itemInteractionForEntity(ItemStack itemStack,EntityPlayer player,EntityLivingBase target) {
	player.sendChatToPlayer(ChatMessageComponent.createFromText("Activated."));

	// Run locally only
	if (target.worldObj.isRemote) return false;

	if (target instanceof EntityZombie)
	{
		player.sendChatToPlayer(ChatMessageComponent.createFromText("EntityZombie, testing task."));
		EntityZombie zombie = (EntityZombie) target;
		if (zombie.targetTasks.taskEntries.size()!=0){
			EntityAITaskEntry task = (EntityAITaskEntry) zombie.targetTasks.taskEntries.get(1);
			if (task.action instanceof EntityAINearestAttackableTarget)
			{
				zombie.targetTasks.removeTask(task.action);

			}
		}

	}else{
		return false;
	}

	return false;
}
}

 

It still doesn't work and gives me the same error.

 

Please Help!!!

I'm back from being gone for... I think its been about a year. I'm pretty sure nobody remembers me, but hello anybody who does!

Posted

It's happening on the third click after the tasks targeting players and villagers have both been removed.  At that point, you only have one item left in the targetTasks list, and it's at index 0.  If you change your conditional to:

 

if (zombie.targetTasks.taskEntries.size() > 1){

 

Then it won't try to remove the task at index 1 when it doesn't exist.

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

    • [16Jan2025 00:33:16.640] [main/INFO] [cpw.mods.modlauncher.Launcher/MODLAUNCHER]: ModLauncher running: args [--launchTarget, forgeserver, --fml.forgeVersion, 47.3.22, --fml.mcVersion, 1.20.1, --fml.forgeGroup, net.minecraftforge, --fml.mcpVersion, 20230612.114412] [16Jan2025 00:33:16.649] [main/INFO] [cpw.mods.modlauncher.Launcher/MODLAUNCHER]: ModLauncher 10.0.9+10.0.9+main.dcd20f30 starting: java version 21.0.5 by Oracle Corporation; OS Windows 10 arch amd64 version 10.0 [16Jan2025 00:33:18.382] [main/INFO] [net.minecraftforge.fml.loading.ImmediateWindowHandler/]: ImmediateWindowProvider not loading because launch target is forgeserver [16Jan2025 00:33:18.395] [main/INFO] [com.teampotato.redirector.Redirector/]: Redirector CoreMod initialized successfully! [16Jan2025 00:33:18.403] [main/INFO] [mixin-transmog/]: Mixin Transmogrifier is definitely up to no good... [16Jan2025 00:33:18.440] [main/INFO] [mixin-transmog/]: crimes against java were committed [16Jan2025 00:33:18.481] [main/INFO] [mixin-transmog/]: Original mixin transformation service successfully crobbed by mixin-transmogrifier! [16Jan2025 00:33:18.551] [main/INFO] [mixin/]: SpongePowered MIXIN Subsystem Version=0.8.5 Source=union:/C:/Users/Admin/Desktop/1.20.1/mods/Connector-1.0.0-beta.46+1.20.1.jar%23209%23213!/ Service=ModLauncher Env=SERVER [16Jan2025 00:33:19.431] [main/WARN] [net.minecraftforge.fml.loading.moddiscovery.ModFileParser/LOADING]: Mod file C:\Users\Admin\Desktop\1.20.1\libraries\net\minecraftforge\fmlcore\1.20.1-47.3.22\fmlcore-1.20.1-47.3.22.jar is missing mods.toml file [16Jan2025 00:33:19.435] [main/WARN] [net.minecraftforge.fml.loading.moddiscovery.ModFileParser/LOADING]: Mod file C:\Users\Admin\Desktop\1.20.1\libraries\net\minecraftforge\javafmllanguage\1.20.1-47.3.22\javafmllanguage-1.20.1-47.3.22.jar is missing mods.toml file [16Jan2025 00:33:19.438] [main/WARN] [net.minecraftforge.fml.loading.moddiscovery.ModFileParser/LOADING]: Mod file C:\Users\Admin\Desktop\1.20.1\libraries\net\minecraftforge\lowcodelanguage\1.20.1-47.3.22\lowcodelanguage-1.20.1-47.3.22.jar is missing mods.toml file [16Jan2025 00:33:19.441] [main/WARN] [net.minecraftforge.fml.loading.moddiscovery.ModFileParser/LOADING]: Mod file C:\Users\Admin\Desktop\1.20.1\libraries\net\minecraftforge\mclanguage\1.20.1-47.3.22\mclanguage-1.20.1-47.3.22.jar is missing mods.toml file [16Jan2025 00:33:20.031] [main/WARN] [net.minecraftforge.jarjar.selection.JarSelector/]: Attempted to select two dependency jars from JarJar which have the same identification: Mod File:  and Mod File: . Using Mod File:  [16Jan2025 00:33:20.034] [main/INFO] [net.minecraftforge.fml.loading.moddiscovery.JarInJarDependencyLocator/]: Found 30 dependencies adding them to mods collection [16Jan2025 00:33:20.849] [main/INFO] [org.sinytra.connector.locator.DependencyResolver/]: Dependency resolution found 0 candidates to load [16Jan2025 00:33:22.698] [main/INFO] [org.sinytra.connector.service.hacks.ModuleLayerMigrator/]: Successfully made module authlib transformable [16Jan2025 00:33:24.980] [main/INFO] [mixin/]: Compatibility level set to JAVA_17 [16Jan2025 00:33:25.433] [main/INFO] [cpw.mods.modlauncher.LaunchServiceHandler/MODLAUNCHER]: Launching target 'forgeserver' with arguments [] [16Jan2025 00:33:25.536] [main/WARN] [mixin/]: Reference map 'v_slab_compat-common-refmap.json' for v_slab_compat-common.mixins.json could not be read. If this is a development environment you can ignore this message [16Jan2025 00:33:25.691] [main/INFO] [ModernFix/]: Loaded configuration file for ModernFix 5.20.0+mc1.20.1: 86 options available, 0 override(s) found [16Jan2025 00:33:25.695] [main/INFO] [ModernFix/]: Applying Nashorn fix [16Jan2025 00:33:25.749] [main/INFO] [ModernFix/]: Applied Forge config corruption patch [16Jan2025 00:33:25.913] [main/WARN] [mixin/]: Reference map '' for mixins.blueprintfix.json could not be read. If this is a development environment you can ignore this message [16Jan2025 00:33:26.131] [main/WARN] [mixin/]: Reference map 'mes-forge-refmap.json' for mes-forge.mixins.json could not be read. If this is a development environment you can ignore this message [16Jan2025 00:33:26.185] [main/WARN] [mixin/]: Reference map 'coroutil.refmap.json' for coroutil.mixins.json could not be read. If this is a development environment you can ignore this message [16Jan2025 00:33:26.224] [main/INFO] [Puzzles Lib/]: Loading 129 mods:     - amendments 1.20-1.2.12     - another_furniture 1.20.1-3.0.1     - architectury 9.2.14     - ash_api 3.0.2+1.20.1     - athena 3.1.1     - autochefsdelight 1.0.5+forge     - azurelib 2.0.41     - balm 7.3.9         \-- kuma_api 20.1.8     - barteringstation 8.0.0     - betteradvancements 0.3.2.161     - betterdungeons 1.20-Forge-4.0.4     - betterendisland 1.20-Forge-2.0.6     - betterfortresses 1.20-Forge-2.0.6     - betterjungletemples 1.20-Forge-2.0.5     - bettermineshafts 1.20-Forge-4.0.4     - betteroceanmonuments 1.20-Forge-3.0.4     - betterstrongholds 1.20-Forge-4.0.3     - biomesoplenty 19.0.0.93     - blue_skies 1.3.31     - blueprint 7.1.0     - blueprintfix 1.0.0         \-- mixinsquared 0.2.0-beta.6     - bookshelf 20.2.13     - bygonenether 1.3.2     - caelus 3.2.0+1.20.1     - carryon 2.1.2.7     - charmofundying 6.5.0+1.20.1         \-- spectrelib 0.13.15+1.20.1     - chefsdelight 1.0.3-forge-1.20.1     - citadel 2.6.0     - clientcrafting 1.20.1-1.8     - cloth_config 11.1.136     - clumps 12.0.0.4     - collective 7.87     - comforts 6.4.0+1.20.1     - connectorextras 1.9.2+1.20.1         |-- amecsapi 1.5.3+mc1.20-pre1         |-- connectorextras_architectury_bridge 1.9.2+1.20.1         |-- connectorextras_continuity_compat 1.9.2+1.20.1         |-- connectorextras_emi_bridge 1.9.2+1.20.1         |-- connectorextras_energy_bridge 1.9.2+1.20.1         |-- connectorextras_geckolib_fabric_compat 1.9.2+1.20.1         |-- connectorextras_jei_bridge 1.9.2+1.20.1         |-- connectorextras_kubejs_bridge 1.9.2+1.20.1         |-- connectorextras_modmenu_bridge 1.9.2+1.20.1             \-- modmenu 7.2.2         |-- connectorextras_rei_bridge 1.9.2+1.20.1         |-- connectorextras_terrablender_bridge 1.9.2+1.20.1         |-- forgeconfigapiport 8.0.0         \-- reach_entity_attributes 2.4.0     - connectormod 1.0.0-beta.46+1.20.1     - coroutil 1.20.1-1.3.7     - corpse 1.20.1-1.0.17     - crabbersdelight 1.1.4     - crawlondemand 1.20.x-1.0.0     - curios 5.11.0+1.20.1     - decorative_blocks 4.1.3     - diagonalfences 8.1.3         \-- diagonalblocks 8.0.2     - dragon_mounts_patches 1.0.0         \-- mixinextras 0.4.1     - dragonmounts 1.2.3-beta     - dungeons_arise 2.1.58-1.20.x     - dynamic_fps 3.7.7     - easyanvils 8.0.2     - easymagic 8.0.1     - elevatorid 1.20.1-lex-1.9     - endersdelight 1.0.3     - everycomp 1.20-2.7.7     - explorations 1.20.1-1.6.1     - extra_compat 1.5.22     - farmers_structures 1.0.0     - farmersdelight 1.20.1-1.2.6     - featurerecycler 1.0.1     - forge 47.3.22     - formations 1.0.3     - formationsnether 1.0.3     - formationsoverworld 1.0.4     - framework 0.7.8     - friendsandfoes 3.0.6     - galosphere 1.20.1-1.4.1     - geckoanimfix 1.0.0     - geckolib 4.7     - geophilic 2.1.0-mc1.20u1.20.2     - geophilic_reforged 1.2.0     - glitchcore 0.0.1.1     - goblintraders 1.9.3     - hearth_and_home 1.20.1-2.0.3     - hearths 1.0.0-mc1.20u1.20.1     - illagerinvasion 8.0.6     - immediatelyfast 1.3.3+1.20.4     - jei 15.20.0.104     - jeresources 1.4.0.247     - justenoughbreeding 1.5.0     - justenoughprofessions 3.0.1     - mes 1.3.1-1.20-forge     - minecraft 1.20.1     - modernfix 5.20.0+mc1.20.1     - moonlight 1.20-2.13.45     - mowziesmobs 1.6.4     - mr_blossom_blade 1.2     - nebs 1.8.0     - netherportalfix 13.0.1     - nethersdelight 1.20.1-4.0     - paintings 11.0.0.2     - palegarden 1.0.7     - pet_cemetery 2.0.0     - puzzleslib 8.1.25         \-- puzzlesaccessapi 8.0.7     - repurposed_structures 7.1.15+1.20.1-forge     - revampedwolf 1.20.1-5.0.0     - shieldexp 1.1.7a     - smarterfarmers 1.20-2.1.0     - sodiumoptionsmodcompat 1.0.0     - structorytowers 1.0.5     - structure_gel 2.16.2     - takesapillage 1.0.3     - temporalapi 1.6.7     - terrablender 3.0.1.7     - v_slab_compat 1.20-2.4     - villagersplus 3.1     - voidtotem 3.0.1     - waystones 14.1.6     - xaerominimap 24.7.1     - xaeroplus 2.25     - xaeroworldmap 1.39.2     - yungsapi 1.20-Forge-4.0.5     - yungsbridges 1.20-Forge-4.0.3     - zeta 1.0-24 [16Jan2025 00:33:26.258] [main/WARN] [mixin/]: Reference map '' for adapter.init.mixins.json could not be read. If this is a development environment you can ignore this message [16Jan2025 00:33:29.341] [main/INFO] [MixinExtras|Service/]: Initializing MixinExtras via com.llamalad7.mixinextras.service.MixinExtrasServiceImpl(version=0.4.1). [16Jan2025 00:33:31.153] [main/INFO] [net.minecraft.server.Bootstrap/]: ModernFix reached bootstrap stage (18.33 s after launch) [16Jan2025 00:33:31.418] [main/WARN] [mixin/]: @Final field delegatesByName:Ljava/util/Map; in modernfix-forge.mixins.json:perf.forge_registry_alloc.ForgeRegistryMixin from mod modernfix should be final [16Jan2025 00:33:31.421] [main/WARN] [mixin/]: @Final field delegatesByValue:Ljava/util/Map; in modernfix-forge.mixins.json:perf.forge_registry_alloc.ForgeRegistryMixin from mod modernfix should be final [16Jan2025 00:33:33.921] [main/INFO] [net.minecraft.server.Bootstrap/]: Vanilla bootstrap took 2759 milliseconds [16Jan2025 00:33:38.669] [main/WARN] [mixin/]: Static binding violation: PRIVATE @Overwrite method m_47505_ in modernfix-common.mixins.json:perf.remove_biome_temperature_cache.BiomeMixin from mod modernfix cannot reduce visibiliy of PUBLIC target method, visibility will be upgraded.
    • should the changes apply only to the listed ores, or do you want a more comprehensive overhaul of resource progression?
    • The information provided isn’t quite enough to pinpoint the issue. It would be helpful to know more about your setup. For instance, what screen recording software are you using, and is it set to capture the game window, full screen, or your entire desktop?
    • I had the same issue, so I ended up registering through gmail
    • I am trying to make an attack animation works for this entity, I have followed tutorials on youtube, looked into Geckolib's documentation but I can't find why it isn't working. The walking animation works, the mob recognizes the player and attack them. The model and animations were made in Blockbench.   public class RedSlimeEntity extends TensuraTamableEntity implements IAnimatable { private final AnimationFactory factory = GeckoLibUtil.createFactory(this); private boolean swinging; private long lastAttackTime; public RedSlimeEntity(EntityType<? extends RedSlimeEntity> type, Level worldIn) { super(type, worldIn); this.xpReward = 20; } public static AttributeSupplier.Builder createAttributes() { AttributeSupplier.Builder builder = Mob.createMobAttributes(); builder = builder.add(Attributes.MOVEMENT_SPEED, 0.1); builder = builder.add(Attributes.MAX_HEALTH, 50); builder = builder.add(Attributes.ARMOR, 0); builder = builder.add(Attributes.ATTACK_DAMAGE, 25); builder = builder.add(Attributes.FOLLOW_RANGE, 16); return builder; } public static void init() { } @Override protected void registerGoals() { this.goalSelector.addGoal(3, new FloatGoal(this)); this.goalSelector.addGoal(1, new RedSlimeAttackGoal(this, 1.2D, false)); this.goalSelector.addGoal(4, new WaterAvoidingRandomStrollGoal(this, 1.0D)); this.goalSelector.addGoal(5, new RandomLookAroundGoal(this)); this.goalSelector.addGoal(2, new RedSlimeAttackGoal.StopNearPlayerGoal(this, 1)); this.targetSelector.addGoal(2, new NearestAttackableTargetGoal<>(this, Player.class, true)); } private <E extends IAnimatable> PlayState predicate(AnimationEvent<E> event) { if (event.isMoving()) { event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.model.walk", true)); return PlayState.CONTINUE; } event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.model.idle", true)); return PlayState.CONTINUE; } private <E extends IAnimatable> PlayState attackPredicate(AnimationEvent<E> event) { if (this.swinging && event.getController().getAnimationState() == AnimationState.Stopped) { event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.model.attack", false)); this.swinging = false; return PlayState.CONTINUE; } return PlayState.STOP; } @Override public void swing(InteractionHand hand, boolean updateSelf) { super.swing(hand, updateSelf); this.swinging = true; } @Override public void registerControllers(AnimationData data) { data.addAnimationController(new AnimationController<>(this, "controller", 0, this::predicate)); data.addAnimationController(new AnimationController<>(this, "attackController", 0, this::attackPredicate)); } @Override public AnimationFactory getFactory() { return factory; } class RedSlimeAttackGoal extends MeleeAttackGoal { private final RedSlimeEntity entity; public RedSlimeAttackGoal(RedSlimeEntity entity, double speedModifier, boolean longMemory) { super(entity, speedModifier, longMemory); this.entity = entity; if (this.mob.getTarget() != null && this.mob.getTarget().isAlive()) { long currentTime = this.entity.level.getGameTime(); if (!this.entity.swinging && currentTime - this.entity.lastAttackTime > 20) { // 20 ticks = 1 second this.entity.swinging = true; this.entity.lastAttackTime = currentTime; } } } protected double getAttackReach(LivingEntity target) { return this.mob.getBbWidth() * 2.0F * this.mob.getBbWidth() * 2.0F + target.getBbWidth(); } @Override protected void checkAndPerformAttack(LivingEntity target, double distToEnt) { double reach = this.getAttackReach(target); if (distToEnt <= reach && this.getTicksUntilNextAttack() <= 0) { this.resetAttackCooldown(); this.entity.swinging = true; this.mob.doHurtTarget(target); } } public static class StopNearPlayerGoal extends Goal { private final Mob mob; private final double stopDistance; public StopNearPlayerGoal(Mob mob, double stopDistance) { this.mob = mob; this.stopDistance = stopDistance; } @Override public boolean canUse() { Player nearestPlayer = this.mob.level.getNearestPlayer(this.mob, stopDistance); if (nearestPlayer != null) { double distanceSquared = this.mob.distanceToSqr(nearestPlayer); return distanceSquared < (stopDistance * stopDistance); } return false; } @Override public void tick() { // Stop movement this.mob.getNavigation().stop(); } @Override public boolean canContinueToUse() { Player nearestPlayer = this.mob.level.getNearestPlayer(this.mob, stopDistance); if (nearestPlayer != null) { double distanceSquared = this.mob.distanceToSqr(nearestPlayer); return distanceSquared < (stopDistance * stopDistance); } return false; } } @Override public void tick() { super.tick(); if (this.mob.getTarget() != null && this.mob.getTarget().isAlive()) { if (!this.entity.swinging) { this.entity.swinging = true; } } } } @Override public @Nullable AgeableMob getBreedOffspring(ServerLevel serverLevel, AgeableMob ageableMob) { return null; } @Override public int getRemainingPersistentAngerTime() { return 0; } @Override public void setRemainingPersistentAngerTime(int i) { } @Override public @Nullable UUID getPersistentAngerTarget() { return null; } @Override public void setPersistentAngerTarget(@Nullable UUID uuid) { } @Override public void startPersistentAngerTimer() { } protected void playStepSound(BlockPos pos, BlockState blockIn) { this.playSound(SoundEvents.SLIME_SQUISH, 0.15F, 1.0F); } protected SoundEvent getAmbientSound() { return SoundEvents.SLIME_SQUISH; } protected SoundEvent getHurtSound(DamageSource damageSourceIn) { return SoundEvents.SLIME_HURT; } protected SoundEvent getDeathSound() { return SoundEvents.SLIME_DEATH; } protected float getSoundVolume() { return 0.2F; } }  
  • Topics

×
×
  • Create New...

Important Information

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