This commit is contained in:
@ -0,0 +1,26 @@
|
||||
package wtf.hak.survivalfabric.mixin;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.text.Text;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import wtf.hak.survivalfabric.utils.DimensionTeams;
|
||||
import wtf.hak.survivalfabric.utils.Messages;
|
||||
|
||||
@Mixin(ServerWorld.class)
|
||||
public class ServerWorldMixin {
|
||||
|
||||
@Inject(method = "onDimensionChanged", at = {@At("HEAD")})
|
||||
public void onDimensionChange(Entity entity, CallbackInfo ci) {
|
||||
if(entity instanceof ServerPlayerEntity) {
|
||||
ServerPlayerEntity player = (ServerPlayerEntity)entity;
|
||||
String dimension = Messages.getDimensionFormatted(player.getServerWorld().getRegistryKey().getValue().toTranslationKey());
|
||||
player.sendMessage(Text.literal(dimension), false);
|
||||
DimensionTeams.assignCorrectTeam(player, player.getServerWorld().getRegistryKey().getValue().toTranslationKey());
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user