This repository has been archived on 2023-11-26. You can view files and clone it, but cannot push or open issues or pull requests.
RelicCraft/src/main/java/com/thebrokenrail/reliccraft/mixin/MixinEntity.java

34 lines
958 B
Java

package com.thebrokenrail.reliccraft.mixin;
import com.thebrokenrail.reliccraft.block.TeleportationRestrictorBlock;
import net.minecraft.entity.Entity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@SuppressWarnings("unused")
@Mixin(Entity.class)
public class MixinEntity implements TeleportationRestrictorBlock.TeleportingEntity {
@Unique
private int teleportCooldown = 0;
@Override
public void resetTeleportCooldown() {
teleportCooldown = 5;
}
@Inject(at = @At("HEAD"), method = "tick")
public void tick(CallbackInfo info) {
if (teleportCooldown > 0) {
teleportCooldown--;
}
}
@Override
public boolean cannotTeleport() {
return teleportCooldown > 0;
}
}