What is the Freeze Entity Mod?
Creepers and zombies and all other types of crazy entities roam the Minecraft world, making it sometimes impossible to survive. While fighting these entities, sometimes they respond too quickly, causing you more damage than the other way around. We at LearnToMod created a “freeze entity” mod that will help prevent those dangerous entities from attacking back when you attack them, increasing your chances of survival (we hope)!
The first thing we will do is create an “entity_damage_by entity” event in our main function. The first blank is where we place “hitEntity.” The reason we are using this event is because Minecraft considers the projectile an entity and we want the entity to be frozen if it is damaged by a projectile.
In the “hitEntity” function, add the info parameter and create two variables to get info’s entity and cause.
In hitEntity add an if block from the “logic” tab. This if statement will be checking if the cause of the damage to the entity is a projectile. If it is, it will freeze the entity. If not, the entity will be damaged, but not frozen.
In the if block, add a message block to notify the player that the entity is now frozen. Then create a sphere of red dust particles around the entityHit’s location to signify that the entity will be frozen. This particle sphere creates a better visual to notify the user.
To add the freeze effect on the damaged entity, place the “Give effect” block after the particle sphere block and change the effect to “slow.” Set the seconds to 20 and the amplifier to 200. This sets how long the potion will last and how strong the effect will be on the damaged entity.
After, place an after milliseconds event block that will call the “almostUnfrozen” function that will give the player a warning when the frozen effect is almost undone.
In the almostUnfrozen function, send a message to the player to notify them that the entity is almost unfrozen. Similar to in the hitEntity function, to make it more noticeable to the user that the entity is almost unfrozen, create another sphere particle of clouds around the entity’s location.
After, place the “do function ____ after _____ milliseconds” block again to call the function that will notify the player when the entity is officially unfrozen. This block will be called 10 more seconds after it was called which was already halfway through the potion effect, now making it the end of the length of the potion.
In the unfrozen function, send a message to the player to notify that the entity is unfrozen. This allows time for the player to run away if the entity is still not yet killed!