Fix leashes
This commit is contained in:
@@ -1,6 +1,12 @@
|
|||||||
package com.kasetoatz.fastghast;
|
package com.kasetoatz.fastghast;
|
||||||
|
|
||||||
import net.fabricmc.api.ModInitializer;
|
import net.fabricmc.api.ModInitializer;
|
||||||
|
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
|
||||||
|
import net.minecraft.entity.Leashable;
|
||||||
|
import net.minecraft.entity.passive.HappyGhastEntity;
|
||||||
|
import net.minecraft.network.packet.s2c.play.PositionFlag;
|
||||||
|
|
||||||
|
import java.util.EnumSet;
|
||||||
|
|
||||||
import static com.kasetoatz.fastghast.config.Config.load;
|
import static com.kasetoatz.fastghast.config.Config.load;
|
||||||
|
|
||||||
@@ -10,5 +16,13 @@ public class Fastghast implements ModInitializer
|
|||||||
public void onInitialize()
|
public void onInitialize()
|
||||||
{
|
{
|
||||||
load();
|
load();
|
||||||
|
ServerTickEvents.END_SERVER_TICK.register((server) -> {
|
||||||
|
server.getWorlds().forEach(world -> world.iterateEntities().forEach(entity -> {
|
||||||
|
if (entity instanceof Leashable leashed && leashed.isLeashed() && leashed.getLeashHolder() instanceof HappyGhastEntity ghast && leashed.getDistanceToCenter(ghast) > 8)
|
||||||
|
{
|
||||||
|
entity.teleport(world, ghast.getX(), ghast.getY(), ghast.getZ(), EnumSet.noneOf(PositionFlag.class), entity.getYaw(), entity.getPitch(), false);
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -7,7 +7,6 @@
|
|||||||
"authors": [],
|
"authors": [],
|
||||||
"contact": {},
|
"contact": {},
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"icon": "assets/fastghast/icon.png",
|
|
||||||
"environment": "*",
|
"environment": "*",
|
||||||
"entrypoints": {
|
"entrypoints": {
|
||||||
"main": [
|
"main": [
|
||||||
|
Reference in New Issue
Block a user