34 lines
958 B
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;
|
||
|
}
|
||
|
}
|