Player spawn in Overworld fix

This commit is contained in:
paulevsGitch 2021-01-13 13:34:43 +03:00
parent e09d1d2235
commit 56591633ec
12 changed files with 370 additions and 41 deletions

View file

@ -1,34 +1,57 @@
package ru.betterend.mixin.common;
import java.util.Map;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import com.google.common.collect.Maps;
import com.mojang.authlib.GameProfile;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.registry.RegistryKey;
import net.minecraft.world.World;
import ru.betterend.interfaces.TeleportingEntity;
@Mixin(ServerPlayerEntity.class)
public abstract class ServerPlayerEntityMixin implements TeleportingEntity {
public abstract class ServerPlayerEntityMixin extends PlayerEntity implements TeleportingEntity {
private static final Map<ServerPlayerEntity, Long> COOLDOWN = Maps.newHashMap();
private long beCooldown;
public ServerPlayerEntityMixin(World world, BlockPos pos, float yaw, GameProfile profile) {
super(world, pos, yaw, profile);
}
@Shadow
private RegistryKey<World> spawnPointDimension;
@Inject(method = "tick", at = @At("TAIL"))
public void be_baseTick(CallbackInfo info) {
if (hasCooldown()) {
this.beCooldown--;
ServerPlayerEntity key = (ServerPlayerEntity) (Object) this;
long value = COOLDOWN.getOrDefault(key, 0L) - 1;
COOLDOWN.put(key, value);
}
}
@Shadow
private void moveToSpawn(ServerWorld world) {}
@Override
public long beGetCooldown() {
return this.beCooldown;
ServerPlayerEntity key = (ServerPlayerEntity) (Object) this;
return COOLDOWN.getOrDefault(key, 0L);
}
@Override
public void beSetCooldown(long time) {
this.beCooldown = time;
ServerPlayerEntity key = (ServerPlayerEntity) (Object) this;
COOLDOWN.put(key, time);
}
@Override