-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Gracefully handle Local and Global sytem to work with Entity Awarenes…
…s System... I think
- Loading branch information
Showing
9 changed files
with
37 additions
and
236 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 7 additions & 93 deletions
100
src/main/java/org/arsparadox/mobtalkerredux/command/MobFreezer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,101 +1,15 @@ | ||
package org.arsparadox.mobtalkerredux.command; | ||
|
||
import net.minecraft.server.level.ServerLevel; | ||
import net.minecraft.world.entity.Mob; | ||
import net.minecraft.world.entity.ai.attributes.AttributeModifier; | ||
import net.minecraft.world.entity.ai.attributes.Attributes; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.UUID; | ||
import org.arsparadox.mobtalkerredux.vn.view.DialogueScreen; | ||
|
||
public class MobFreezer { | ||
private static final Map<UUID, Boolean> frozenMobs = new HashMap<>(); | ||
private static final UUID MOVEMENT_SPEED_MODIFIER = UUID.fromString("708396DC-7DEA-4EDD-B915-A3B97ADFF457"); | ||
|
||
/** | ||
* Freezes a mob in place, disabling AI and movement | ||
* @param mob The mob to freeze | ||
* @return true if the mob was frozen, false if already frozen | ||
*/ | ||
public static boolean freezeMob(Mob mob) { | ||
if (mob == null || frozenMobs.containsKey(mob.getUUID())) { | ||
return false; | ||
} | ||
|
||
// Store current AI state | ||
frozenMobs.put(mob.getUUID(), mob.isNoAi()); | ||
|
||
// Disable AI | ||
mob.setNoAi(true); | ||
|
||
// Stop all current goals | ||
// mob.goalSelector.removeAllGoals(); | ||
// mob.targetSelector.removeAllGoals(); | ||
|
||
// Freeze movement speed | ||
mob.getAttribute(Attributes.MOVEMENT_SPEED).addTransientModifier( | ||
new AttributeModifier(MOVEMENT_SPEED_MODIFIER, "Freeze movement", -1.0D, AttributeModifier.Operation.MULTIPLY_TOTAL) | ||
); | ||
|
||
// Stop any current movement/path | ||
mob.getNavigation().stop(); | ||
mob.setDeltaMovement(0, mob.getDeltaMovement().y, 0); // Preserve Y movement for gravity | ||
|
||
return true; | ||
} | ||
|
||
/** | ||
* Freezes a mob by UUID if it exists in the world | ||
* @param level The server level to search in | ||
* @param uuid The UUID of the mob to freeze | ||
* @return true if the mob was found and frozen | ||
*/ | ||
public static boolean freezeMobByUUID(ServerLevel level, UUID uuid) { | ||
if (level.getEntity(uuid) instanceof Mob mob) { | ||
return freezeMob(mob); | ||
} | ||
return false; | ||
} | ||
|
||
/** | ||
* Unfreezes a previously frozen mob | ||
* @param mob The mob to unfreeze | ||
* @return true if the mob was unfrozen, false if it wasn't frozen | ||
*/ | ||
public static boolean unfreezeMob(Mob mob) { | ||
if (mob == null || !frozenMobs.containsKey(mob.getUUID())) { | ||
return false; | ||
} | ||
|
||
// Restore original AI state | ||
mob.setNoAi(frozenMobs.remove(mob.getUUID())); | ||
|
||
// Remove movement speed modifier | ||
mob.getAttribute(Attributes.MOVEMENT_SPEED) | ||
.removeModifier(MOVEMENT_SPEED_MODIFIER); | ||
|
||
// The mob's AI goals will be reinstated automatically when needed | ||
return true; | ||
} | ||
|
||
/** | ||
* Unfreezes a mob by UUID if it exists in the world | ||
* @param level The server level to search in | ||
* @param uuid The UUID of the mob to unfreeze | ||
* @return true if the mob was found and unfrozen | ||
*/ | ||
public static boolean unfreezeMobByUUID(ServerLevel level, UUID uuid) { | ||
if (level.getEntity(uuid) instanceof Mob mob) { | ||
return unfreezeMob(mob); | ||
} | ||
return false; | ||
public static void freezeMob(DialogueScreen ds) { | ||
ds.mob.setNoAi(true); | ||
ds.mob.setNoGravity(true); | ||
} | ||
|
||
/** | ||
* Checks if a mob is currently frozen | ||
*/ | ||
public static boolean isFrozen(UUID uuid) { | ||
return frozenMobs.containsKey(uuid); | ||
public static void unfreezeMob(DialogueScreen ds) { | ||
ds.mob.setNoAi(false); | ||
ds.mob.setNoGravity(false); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
107 changes: 0 additions & 107 deletions
107
src/main/java/org/arsparadox/mobtalkerredux/vn/model/TextureLoader.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.