Update to BCLib 0.3.0

This commit is contained in:
paulevsGitch 2021-07-20 00:39:58 +03:00
parent 1a52251af0
commit b2431153dc
294 changed files with 7484 additions and 1440 deletions

View file

@ -16,6 +16,7 @@ import java.util.List;
public class ItemStackMixin {
@Inject(method = "getTooltipLines", at = @At("RETURN"))
private void be_getTooltip(Player entity, TooltipFlag tooltipContext, CallbackInfoReturnable<List<Component>> info) {
ItemTooltipCallback.EVENT.invoker().getTooltip(entity, ItemStack.class.cast(this), tooltipContext, info.getReturnValue());
ItemTooltipCallback.EVENT.invoker()
.getTooltip(entity, ItemStack.class.cast(this), tooltipContext, info.getReturnValue());
}
}

View file

@ -11,7 +11,6 @@ import com.mojang.blaze3d.vertex.VertexFormat;
import com.mojang.math.Matrix4f;
import com.mojang.math.Quaternion;
import com.mojang.math.Vector3f;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.renderer.DimensionSpecialEffects;
@ -21,7 +20,6 @@ import net.minecraft.client.renderer.LevelRenderer;
import net.minecraft.client.renderer.RenderBuffers;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.resources.ResourceLocation;
import org.lwjgl.opengl.GL11;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@ -101,7 +99,10 @@ public class LevelRendererMixin {
FogRenderer.levelFogColor();
RenderSystem.enableTexture();
RenderSystem.enableBlend();
RenderSystem.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
RenderSystem.blendFunc(
GlStateManager.SourceFactor.SRC_ALPHA,
GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA
);
float blindA = 1F - BackgroundInfo.blindness;
blind02 = blindA * 0.2F;
@ -111,26 +112,62 @@ public class LevelRendererMixin {
matrices.pushPose();
matrices.mulPose(new Quaternion(0, time, 0, false));
RenderSystem.setShaderTexture(0, HORIZON);
be_renderBuffer(matrices, matrix4f, horizon, DefaultVertexFormat.POSITION_TEX, 0.77F, 0.31F, 0.73F, 0.7F * blindA);
be_renderBuffer(
matrices,
matrix4f,
horizon,
DefaultVertexFormat.POSITION_TEX,
0.77F,
0.31F,
0.73F,
0.7F * blindA
);
matrices.popPose();
matrices.pushPose();
matrices.mulPose(new Quaternion(0, -time, 0, false));
RenderSystem.setShaderTexture(0, NEBULA_1);
be_renderBuffer(matrices, matrix4f, nebulas1, DefaultVertexFormat.POSITION_TEX, 0.77F, 0.31F, 0.73F, blind02);
be_renderBuffer(
matrices,
matrix4f,
nebulas1,
DefaultVertexFormat.POSITION_TEX,
0.77F,
0.31F,
0.73F,
blind02
);
matrices.popPose();
matrices.pushPose();
matrices.mulPose(new Quaternion(0, time2, 0, false));
RenderSystem.setShaderTexture(0, NEBULA_2);
be_renderBuffer(matrices, matrix4f, nebulas2, DefaultVertexFormat.POSITION_TEX, 0.77F, 0.31F, 0.73F, blind02);
be_renderBuffer(
matrices,
matrix4f,
nebulas2,
DefaultVertexFormat.POSITION_TEX,
0.77F,
0.31F,
0.73F,
blind02
);
matrices.popPose();
RenderSystem.setShaderTexture(0, STARS);
matrices.pushPose();
matrices.mulPose(axis3.rotation(time));
be_renderBuffer(matrices, matrix4f, stars3, DefaultVertexFormat.POSITION_TEX, 0.77F, 0.31F, 0.73F, blind06);
be_renderBuffer(
matrices,
matrix4f,
stars3,
DefaultVertexFormat.POSITION_TEX,
0.77F,
0.31F,
0.73F,
blind06
);
matrices.popPose();
matrices.pushPose();
@ -143,7 +180,16 @@ public class LevelRendererMixin {
if (a > 0) {
if (a > 1) a = 1;
RenderSystem.setShaderTexture(0, FOG);
be_renderBuffer(matrices, matrix4f, fog, DefaultVertexFormat.POSITION_TEX, BackgroundInfo.fogColorRed, BackgroundInfo.fogColorGreen, BackgroundInfo.fogColorBlue, a);
be_renderBuffer(
matrices,
matrix4f,
fog,
DefaultVertexFormat.POSITION_TEX,
BackgroundInfo.fogColorRed,
BackgroundInfo.fogColorGreen,
BackgroundInfo.fogColorBlue,
a
);
}
RenderSystem.disableTexture();

View file

@ -33,7 +33,10 @@ public abstract class LocalPlayerMixin extends AbstractClientPlayer {
public void be_aiStep(CallbackInfo info) {
ItemStack itemStack = getItemBySlot(EquipmentSlot.CHEST);
if (itemStack.getItem() instanceof FallFlyingItem && ElytraItem.isFlyEnabled(itemStack) && tryToStartFallFlying()) {
connection.send(new ServerboundPlayerCommandPacket(LocalPlayer.class.cast(this), ServerboundPlayerCommandPacket.Action.START_FALL_FLYING));
connection.send(new ServerboundPlayerCommandPacket(
LocalPlayer.class.cast(this),
ServerboundPlayerCommandPacket.Action.START_FALL_FLYING
));
}
}
}

View file

@ -36,11 +36,17 @@ public class MinecraftClientMixin {
private void be_getEndMusic(CallbackInfoReturnable<Music> info) {
if (!(this.screen instanceof WinScreen) && this.player != null) {
if (this.player.level.dimension() == Level.END) {
if (this.gui.getBossOverlay().shouldPlayMusic() && MHelper.lengthSqr(this.player.getX(), this.player.getZ()) < 250000) {
if (this.gui.getBossOverlay().shouldPlayMusic() && MHelper.lengthSqr(
this.player.getX(),
this.player.getZ()
) < 250000) {
info.setReturnValue(Musics.END_BOSS);
}
else {
Music sound = this.level.getBiomeManager().getNoiseBiomeAtPosition(this.player.blockPosition()).getBackgroundMusic().orElse(Musics.END);
Music sound = this.level.getBiomeManager()
.getNoiseBiomeAtPosition(this.player.blockPosition())
.getBackgroundMusic()
.orElse(Musics.END);
info.setReturnValue(sound);
}
info.cancel();

View file

@ -12,7 +12,11 @@ public abstract class ModelLoaderMixin {
@ModifyVariable(method = "loadModel", ordinal = 2, at = @At(value = "INVOKE"))
public ResourceLocation be_switchModel(ResourceLocation id) {
if (GeneratorOptions.changeChorusPlant() && id.getNamespace().equals("minecraft") && id.getPath().startsWith("blockstates/") && id.getPath().contains("chorus") && !id.getPath().contains("custom_")) {
if (GeneratorOptions.changeChorusPlant() && id.getNamespace().equals("minecraft") && id.getPath()
.startsWith(
"blockstates/") && id
.getPath()
.contains("chorus") && !id.getPath().contains("custom_")) {
id = new ResourceLocation(id.getPath().replace("chorus", "custom_chorus"));
}
return id;

View file

@ -1,13 +1,11 @@
package ru.betterend.mixin.client;
import net.minecraft.client.Minecraft;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.client.resources.sounds.AbstractSoundInstance;
import net.minecraft.client.resources.sounds.SoundInstance;
import net.minecraft.client.sounds.MusicManager;
import net.minecraft.sounds.Music;
import net.minecraft.util.Mth;
import net.minecraft.world.level.Level;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@ -52,7 +50,8 @@ public abstract class MusicTrackerMixin {
if (currentMusic instanceof AbstractSoundInstance) {
((AbstractSoundInstanceAccessor) currentMusic).setVolume(volume);
}
minecraft.getSoundManager().updateSourceVolume(currentMusic.getSource(), currentMusic.getVolume() * volume);
minecraft.getSoundManager()
.updateSourceVolume(currentMusic.getSource(), currentMusic.getVolume() * volume);
long t = System.currentTimeMillis();
if (volume == 1 && time == 0) {
time = t;
@ -91,7 +90,9 @@ public abstract class MusicTrackerMixin {
}
private boolean be_shouldChangeSound(Music musicSound) {
return currentMusic != null && !musicSound.getEvent().getLocation().equals(this.currentMusic.getLocation()) && musicSound.replaceCurrentMusic();
return currentMusic != null && !musicSound.getEvent()
.getLocation()
.equals(this.currentMusic.getLocation()) && musicSound.replaceCurrentMusic();
}
private boolean be_checkNullSound(Music musicSound) {

View file

@ -72,7 +72,8 @@ public abstract class AnvilMenuMixin extends ItemCombinerMenu implements AnvilSc
slotsChanged(inputSlots);
access.execute((world, blockPos) -> {
BlockState anvilState = world.getBlockState(blockPos);
if (!player.getAbilities().instabuild && anvilState.is(BlockTags.ANVIL) && player.getRandom().nextDouble() < 0.1) {
if (!player.getAbilities().instabuild && anvilState.is(BlockTags.ANVIL) && player.getRandom()
.nextDouble() < 0.1) {
BlockState landingState = EndAnvilBlock.applyDamage(anvilState);
if (landingState == null) {
world.removeBlock(blockPos, false);
@ -97,7 +98,9 @@ public abstract class AnvilMenuMixin extends ItemCombinerMenu implements AnvilSc
be_recipes = recipeManager.getRecipesFor(AnvilRecipe.TYPE, inputSlots, player.level);
if (be_recipes.size() > 0) {
int anvilLevel = this.anvilLevel.get();
be_recipes = be_recipes.stream().filter(recipe -> anvilLevel >= recipe.getAnvilLevel()).collect(Collectors.toList());
be_recipes = be_recipes.stream()
.filter(recipe -> anvilLevel >= recipe.getAnvilLevel())
.collect(Collectors.toList());
if (be_recipes.size() > 0) {
if (be_currentRecipe == null || !be_recipes.contains(be_currentRecipe)) {
be_currentRecipe = be_recipes.get(0);

View file

@ -61,10 +61,23 @@ public abstract class ChorusFlowerBlockMixin extends Block {
if (i < 5) {
this.placeGrownFlower(world, up, i + 1);
if (GeneratorOptions.changeChorusPlant()) {
BlocksHelper.setWithoutUpdate(world, pos, plant.defaultBlockState().setValue(ChorusPlantBlock.UP, true).setValue(ChorusPlantBlock.DOWN, true).setValue(VanillaBlockProperties.ROOTS, true));
BlocksHelper.setWithoutUpdate(
world,
pos,
plant.defaultBlockState()
.setValue(ChorusPlantBlock.UP, true)
.setValue(ChorusPlantBlock.DOWN, true)
.setValue(VanillaBlockProperties.ROOTS, true)
);
}
else {
BlocksHelper.setWithoutUpdate(world, pos, plant.defaultBlockState().setValue(ChorusPlantBlock.UP, true).setValue(ChorusPlantBlock.DOWN, true));
BlocksHelper.setWithoutUpdate(
world,
pos,
plant.defaultBlockState()
.setValue(ChorusPlantBlock.UP, true)
.setValue(ChorusPlantBlock.DOWN, true)
);
}
info.cancel();
}

View file

@ -52,7 +52,8 @@ public abstract class ChorusPlantBlockMixin extends Block {
BlockState plant = info.getReturnValue();
if (ctx.canPlace() && plant.is(Blocks.CHORUS_PLANT) && world.getBlockState(pos.below()).is(TagAPI.END_GROUND)) {
if (GeneratorOptions.changeChorusPlant()) {
info.setReturnValue(plant.setValue(VanillaBlockProperties.ROOTS, true).setValue(BlockStateProperties.DOWN, true));
info.setReturnValue(plant.setValue(VanillaBlockProperties.ROOTS, true)
.setValue(BlockStateProperties.DOWN, true));
}
else {
info.setReturnValue(plant.setValue(BlockStateProperties.DOWN, true));
@ -67,7 +68,8 @@ public abstract class ChorusPlantBlockMixin extends Block {
if (plant.is(Blocks.CHORUS_PLANT)) {
if (blockGetter.getBlockState(blockPos.below()).is(TagAPI.END_GROUND)) {
if (GeneratorOptions.changeChorusPlant()) {
info.setReturnValue(plant.setValue(BlockStateProperties.DOWN, true).setValue(VanillaBlockProperties.ROOTS, true));
info.setReturnValue(plant.setValue(BlockStateProperties.DOWN, true)
.setValue(VanillaBlockProperties.ROOTS, true));
}
else {
info.setReturnValue(plant.setValue(BlockStateProperties.DOWN, true));
@ -98,7 +100,8 @@ public abstract class ChorusPlantBlockMixin extends Block {
if (plant.is(Blocks.CHORUS_PLANT)) {
if (world.getBlockState(pos.below()).is(TagAPI.END_GROUND)) {
if (GeneratorOptions.changeChorusPlant()) {
plant = plant.setValue(BlockStateProperties.DOWN, true).setValue(VanillaBlockProperties.ROOTS, true);
plant = plant.setValue(BlockStateProperties.DOWN, true)
.setValue(VanillaBlockProperties.ROOTS, true);
}
else {
plant = plant.setValue(BlockStateProperties.DOWN, true);

View file

@ -28,15 +28,24 @@ public class ChorusPlantFeatureMixin {
final Random random = featureConfig.random();
final BlockPos blockPos = featureConfig.origin();
final WorldGenLevel structureWorldAccess = featureConfig.level();
if (structureWorldAccess.isEmptyBlock(blockPos) && structureWorldAccess.getBlockState(blockPos.below()).is(EndBlocks.CHORUS_NYLIUM)) {
if (structureWorldAccess.isEmptyBlock(blockPos) && structureWorldAccess.getBlockState(blockPos.below())
.is(EndBlocks.CHORUS_NYLIUM)) {
ChorusFlowerBlock.generatePlant(structureWorldAccess, blockPos, random, MHelper.randRange(8, 16, random));
BlockState bottom = structureWorldAccess.getBlockState(blockPos);
if (bottom.is(Blocks.CHORUS_PLANT)) {
if ((GeneratorOptions.changeChorusPlant())) {
BlocksHelper.setWithoutUpdate(structureWorldAccess, blockPos, bottom.setValue(VanillaBlockProperties.ROOTS, true).setValue(PipeBlock.DOWN, true));
BlocksHelper.setWithoutUpdate(
structureWorldAccess,
blockPos,
bottom.setValue(VanillaBlockProperties.ROOTS, true).setValue(PipeBlock.DOWN, true)
);
}
else {
BlocksHelper.setWithoutUpdate(structureWorldAccess, blockPos, bottom.setValue(PipeBlock.DOWN, true));
BlocksHelper.setWithoutUpdate(
structureWorldAccess,
blockPos,
bottom.setValue(PipeBlock.DOWN, true)
);
}
}
info.setReturnValue(true);

View file

@ -17,7 +17,11 @@ import ru.betterend.world.generator.GeneratorOptions;
public class DimensionTypeMixin {
@Inject(method = "defaultEndGenerator", at = @At("HEAD"), cancellable = true)
private static void be_replaceGenerator(Registry<Biome> biomeRegistry, Registry<NoiseGeneratorSettings> chunkGeneratorSettingsRegistry, long seed, CallbackInfoReturnable<ChunkGenerator> info) {
info.setReturnValue(new NoiseBasedChunkGenerator(new BetterEndBiomeSource(biomeRegistry, seed), seed, () -> chunkGeneratorSettingsRegistry.getOrThrow(NoiseGeneratorSettings.END)));
info.setReturnValue(new NoiseBasedChunkGenerator(
new BetterEndBiomeSource(biomeRegistry, seed),
seed,
() -> chunkGeneratorSettingsRegistry.getOrThrow(NoiseGeneratorSettings.END)
));
}
@Inject(method = "createDragonFight", at = @At("HEAD"), cancellable = true)

View file

@ -66,7 +66,11 @@ public abstract class EnchantmentMenuMixin extends AbstractContainerMenu {
int j;
for (j = -1; j <= 1; ++j) {
for (int k = -1; k <= 1; ++k) {
if ((j != 0 || k != 0) && world.isEmptyBlock(blockPos.offset(k, 0, j)) && world.isEmptyBlock(blockPos.offset(k, 1, j))) {
if ((j != 0 || k != 0) && world.isEmptyBlock(blockPos.offset(
k,
0,
j
)) && world.isEmptyBlock(blockPos.offset(k, 1, j))) {
if (world.getBlockState(blockPos.offset(k * 2, 0, j * 2)).is(TagAPI.BOOKSHELVES)) {
++i;
}
@ -111,7 +115,8 @@ public abstract class EnchantmentMenuMixin extends AbstractContainerMenu {
if (this.costs[j] > 0) {
List<EnchantmentInstance> list = this.getEnchantmentList(itemStack, j, this.costs[j]);
if (list != null && !list.isEmpty()) {
EnchantmentInstance enchantmentLevelEntry = (EnchantmentInstance) list.get(this.random.nextInt(list.size()));
EnchantmentInstance enchantmentLevelEntry = (EnchantmentInstance) list.get(this.random.nextInt(
list.size()));
enchantClue[j] = Registry.ENCHANTMENT.getId(enchantmentLevelEntry.enchantment);
levelClue[j] = enchantmentLevelEntry.level;
}

View file

@ -72,7 +72,10 @@ public class EndDragonFightMixin {
BlockPos center = GeneratorOptions.getPortalPos().above(5);
for (Direction dir : BlocksHelper.HORIZONTAL) {
BlockPos central = center.relative(dir, 4);
List<EndCrystal> crystalList = level.getEntitiesOfClass(EndCrystal.class, new AABB(central.below(255).south().west(), central.above(255).north().east()));
List<EndCrystal> crystalList = level.getEntitiesOfClass(
EndCrystal.class,
new AABB(central.below(255).south().west(), central.above(255).north().east())
);
int count = crystalList.size();
for (int n = 0; n < count; n++) {

View file

@ -54,14 +54,21 @@ public class EndPodiumFeatureMixin {
private FeaturePlaceContext<NoneFeatureConfiguration> be_setPosOnGround(FeaturePlaceContext<NoneFeatureConfiguration> featurePlaceContext) {
WorldGenLevel world = featurePlaceContext.level();
BlockPos pos = be_updatePos(featurePlaceContext.origin(), world);
return new FeaturePlaceContext<NoneFeatureConfiguration>(world, featurePlaceContext.chunkGenerator(), featurePlaceContext.random(), pos, featurePlaceContext.config());
return new FeaturePlaceContext<NoneFeatureConfiguration>(
world,
featurePlaceContext.chunkGenerator(),
featurePlaceContext.random(),
pos,
featurePlaceContext.config()
);
}
private BlockPos be_updatePos(BlockPos blockPos, WorldGenLevel world) {
if (GeneratorOptions.useNewGenerator()) {
BlockPos pos = GeneratorOptions.getPortalPos();
if (pos.equals(BlockPos.ZERO)) {
int y = world.getChunk(0, 0, ChunkStatus.FULL).getHeight(Types.WORLD_SURFACE, blockPos.getX(), blockPos.getZ());
int y = world.getChunk(0, 0, ChunkStatus.FULL)
.getHeight(Types.WORLD_SURFACE, blockPos.getX(), blockPos.getZ());
if (y < 1) {
y = 65;
}

View file

@ -15,7 +15,10 @@ import ru.betterend.effects.EndStatusEffects;
public abstract class EnderManMixin {
@Inject(method = "isLookingAtMe", at = @At("HEAD"), cancellable = true)
private void be_isLookingAtMe(Player player, CallbackInfoReturnable<Boolean> info) {
if (player.isCreative() || player.hasEffect(EndStatusEffects.END_VEIL) || EnchantmentHelper.getItemEnchantmentLevel(EndEnchantments.END_VEIL, player.getItemBySlot(EquipmentSlot.HEAD)) > 0) {
if (player.isCreative() || player.hasEffect(EndStatusEffects.END_VEIL) || EnchantmentHelper.getItemEnchantmentLevel(
EndEnchantments.END_VEIL,
player.getItemBySlot(EquipmentSlot.HEAD)
) > 0) {
info.setReturnValue(false);
}
}

View file

@ -58,7 +58,13 @@ public abstract class EntityMixin implements TeleportingEntity {
Entity entity = getType().create(destination);
if (entity != null) {
entity.restoreFrom(Entity.class.cast(this));
entity.moveTo(teleportTarget.pos.x, teleportTarget.pos.y, teleportTarget.pos.z, teleportTarget.yRot, entity.getXRot());
entity.moveTo(
teleportTarget.pos.x,
teleportTarget.pos.y,
teleportTarget.pos.z,
teleportTarget.yRot,
entity.getXRot()
);
entity.setDeltaMovement(teleportTarget.speed);
//TODO: check if this works as intended in 1.17
@ -79,7 +85,12 @@ public abstract class EntityMixin implements TeleportingEntity {
@Inject(method = "findDimensionEntryPoint", at = @At("HEAD"), cancellable = true)
protected void be_findDimensionEntryPoint(ServerLevel destination, CallbackInfoReturnable<PortalInfo> info) {
if (be_canTeleport()) {
info.setReturnValue(new PortalInfo(new Vec3(exitPos.getX() + 0.5, exitPos.getY(), exitPos.getZ() + 0.5), getDeltaMovement(), yRot, xRot));
info.setReturnValue(new PortalInfo(
new Vec3(exitPos.getX() + 0.5, exitPos.getY(), exitPos.getZ() + 0.5),
getDeltaMovement(),
yRot,
xRot
));
}
}

View file

@ -121,7 +121,11 @@ public abstract class LivingEntityMixin extends Entity {
if (isFlying && !onGround && !isPassenger() && !hasEffect(MobEffects.LEVITATION)) {
if (ElytraItem.isFlyEnabled(itemStack)) {
if ((fallFlyTicks + 1) % 20 == 0) {
itemStack.hurtAndBreak(1, LivingEntity.class.cast(this), livingEntity -> livingEntity.broadcastBreakEvent(EquipmentSlot.CHEST));
itemStack.hurtAndBreak(
1,
LivingEntity.class.cast(this),
livingEntity -> livingEntity.broadcastBreakEvent(EquipmentSlot.CHEST)
);
}
isFlying = true;
}
@ -167,7 +171,11 @@ public abstract class LivingEntityMixin extends Entity {
}
if (k > 0.0D) {
moveDelta = moveDelta.add((lookAngle.x / k * l - moveDelta.x) * 0.1D, 0.0D, (lookAngle.z / k * l - moveDelta.z) * 0.1D);
moveDelta = moveDelta.add(
(lookAngle.x / k * l - moveDelta.x) * 0.1D,
0.0D,
(lookAngle.z / k * l - moveDelta.z) * 0.1D
);
}
moveDelta = moveDelta.multiply(0.9900000095367432D, 0.9800000190734863D, 0.9900000095367432D);
double movementFactor = ((FallFlyingItem) itemStack.getItem()).getMovementFactor();
@ -196,7 +204,8 @@ public abstract class LivingEntityMixin extends Entity {
private double be_getKnockback(Item tool) {
if (tool == null) return 0.0D;
Collection<AttributeModifier> modifiers = tool.getDefaultAttributeModifiers(EquipmentSlot.MAINHAND).get(Attributes.ATTACK_KNOCKBACK);
Collection<AttributeModifier> modifiers = tool.getDefaultAttributeModifiers(EquipmentSlot.MAINHAND)
.get(Attributes.ATTACK_KNOCKBACK);
if (modifiers.size() > 0) {
return modifiers.iterator().next().getAmount();
}

View file

@ -18,6 +18,10 @@ public abstract class PlayerAdvancementsMixin {
@Inject(method = "award", at = @At(value = "INVOKE", target = "Lnet/minecraft/advancements/AdvancementRewards;grant(Lnet/minecraft/server/level/ServerPlayer;)V", shift = Shift.AFTER))
public void be_award(Advancement advancement, String criterionName, CallbackInfoReturnable<Boolean> info) {
PlayerAdvancementsCallback.PLAYER_ADVANCEMENT_COMPLETE.invoker().onAdvancementComplete(player, advancement, criterionName);
PlayerAdvancementsCallback.PLAYER_ADVANCEMENT_COMPLETE.invoker()
.onAdvancementComplete(player,
advancement,
criterionName
);
}
}

View file

@ -93,7 +93,10 @@ public class PlayerListMixin {
CompoundTag compoundTag = this.load(serverPlayer);
ResourceKey<Level> var23;
if (compoundTag != null) {
DataResult<ResourceKey<Level>> var10000 = DimensionType.parseLegacy(new Dynamic<Tag>(NbtOps.INSTANCE, compoundTag.get("Dimension")));
DataResult<ResourceKey<Level>> var10000 = DimensionType.parseLegacy(new Dynamic<Tag>(
NbtOps.INSTANCE,
compoundTag.get("Dimension")
));
Logger var10001 = LOGGER;
Objects.requireNonNull(var10001);
var23 = (ResourceKey<Level>) var10000.resultOrPartial(var10001::error).orElse(Level.END);
@ -120,21 +123,57 @@ public class PlayerListMixin {
string2 = connection.getRemoteAddress().toString();
}
LOGGER.info("{}[{}] logged in with entity id {} at ({}, {}, {})", serverPlayer.getName().getString(), string2, serverPlayer.getId(), serverPlayer.getX(), serverPlayer.getY(), serverPlayer.getZ());
LOGGER.info(
"{}[{}] logged in with entity id {} at ({}, {}, {})",
serverPlayer.getName().getString(),
string2,
serverPlayer.getId(),
serverPlayer.getX(),
serverPlayer.getY(),
serverPlayer.getZ()
);
LevelData worldProperties = serverLevel3.getLevelData();
serverPlayer.loadGameTypes(compoundTag);
//this.updatePlayerGameMode(serverPlayer, (ServerPlayer) null, serverLevel3);
ServerGamePacketListenerImpl serverPlayNetworkHandler = new ServerGamePacketListenerImpl(this.server, connection, serverPlayer);
ServerGamePacketListenerImpl serverPlayNetworkHandler = new ServerGamePacketListenerImpl(
this.server,
connection,
serverPlayer
);
GameRules gameRules = serverLevel3.getGameRules();
boolean bl = gameRules.getBoolean(GameRules.RULE_DO_IMMEDIATE_RESPAWN);
boolean bl2 = gameRules.getBoolean(GameRules.RULE_REDUCEDDEBUGINFO);
serverPlayNetworkHandler.send(new ClientboundLoginPacket(serverPlayer.getId(), serverPlayer.gameMode.getGameModeForPlayer(), serverPlayer.gameMode.getPreviousGameModeForPlayer(), BiomeManager.obfuscateSeed(serverLevel3.getSeed()), worldProperties.isHardcore(), this.server.levelKeys(), this.registryHolder, serverLevel3.dimensionType(), serverLevel3.dimension(), this.getMaxPlayers(), this.viewDistance, bl2, !bl, serverLevel3.isDebug(), serverLevel3.isFlat()));
serverPlayNetworkHandler.send(new ClientboundCustomPayloadPacket(ClientboundCustomPayloadPacket.BRAND, (new FriendlyByteBuf(Unpooled.buffer())).writeUtf(this.getServer().getServerModName())));
serverPlayNetworkHandler.send(new ClientboundChangeDifficultyPacket(worldProperties.getDifficulty(), worldProperties.isDifficultyLocked()));
serverPlayNetworkHandler.send(new ClientboundLoginPacket(
serverPlayer.getId(),
serverPlayer.gameMode.getGameModeForPlayer(),
serverPlayer.gameMode.getPreviousGameModeForPlayer(),
BiomeManager.obfuscateSeed(serverLevel3.getSeed()),
worldProperties.isHardcore(),
this.server.levelKeys(),
this.registryHolder,
serverLevel3.dimensionType(),
serverLevel3.dimension(),
this.getMaxPlayers(),
this.viewDistance,
bl2,
!bl,
serverLevel3.isDebug(),
serverLevel3.isFlat()
));
serverPlayNetworkHandler.send(new ClientboundCustomPayloadPacket(
ClientboundCustomPayloadPacket.BRAND,
(new FriendlyByteBuf(Unpooled.buffer())).writeUtf(this.getServer().getServerModName())
));
serverPlayNetworkHandler.send(new ClientboundChangeDifficultyPacket(
worldProperties.getDifficulty(),
worldProperties.isDifficultyLocked()
));
serverPlayNetworkHandler.send(new ClientboundPlayerAbilitiesPacket(serverPlayer.getAbilities()));
serverPlayNetworkHandler.send(new ClientboundSetCarriedItemPacket(serverPlayer.getInventory().selected));
serverPlayNetworkHandler.send(new ClientboundUpdateRecipesPacket(this.server.getRecipeManager().getRecipes()));
serverPlayNetworkHandler.send(new ClientboundUpdateTagsPacket(this.server.getTags().serializeToNetwork(this.registryHolder)));
serverPlayNetworkHandler.send(new ClientboundUpdateRecipesPacket(this.server.getRecipeManager()
.getRecipes()));
serverPlayNetworkHandler.send(new ClientboundUpdateTagsPacket(this.server.getTags()
.serializeToNetwork(this.registryHolder)));
this.sendPlayerPermissionLevel(serverPlayer);
serverPlayer.getStats().markAllDirty();
serverPlayer.getRecipeBook().sendInitialRecipeBook(serverPlayer);
@ -142,38 +181,68 @@ public class PlayerListMixin {
this.server.invalidateStatus();
TranslatableComponent mutableText2;
if (serverPlayer.getGameProfile().getName().equalsIgnoreCase(string)) {
mutableText2 = new TranslatableComponent("multiplayer.player.joined", new Object[]{serverPlayer.getDisplayName()});
mutableText2 = new TranslatableComponent(
"multiplayer.player.joined",
new Object[] {serverPlayer.getDisplayName()}
);
}
else {
mutableText2 = new TranslatableComponent("multiplayer.player.joined.renamed", new Object[]{serverPlayer.getDisplayName(), string});
mutableText2 = new TranslatableComponent(
"multiplayer.player.joined.renamed",
new Object[] {serverPlayer.getDisplayName(), string}
);
}
this.broadcastMessage(mutableText2.withStyle(ChatFormatting.YELLOW), ChatType.SYSTEM, Util.NIL_UUID);
serverPlayNetworkHandler.teleport(serverPlayer.getX(), serverPlayer.getY(), serverPlayer.getZ(), serverPlayer.getYRot(), serverPlayer.getXRot());
serverPlayNetworkHandler.teleport(
serverPlayer.getX(),
serverPlayer.getY(),
serverPlayer.getZ(),
serverPlayer.getYRot(),
serverPlayer.getXRot()
);
this.players.add(serverPlayer);
this.playersByUUID.put(serverPlayer.getUUID(), serverPlayer);
this.broadcastAll(new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.ADD_PLAYER, new ServerPlayer[]{serverPlayer}));
this.broadcastAll(new ClientboundPlayerInfoPacket(
ClientboundPlayerInfoPacket.Action.ADD_PLAYER,
new ServerPlayer[] {serverPlayer}
));
for (ServerPlayer player : this.players) {
serverPlayer.connection.send(new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.ADD_PLAYER, new ServerPlayer[]{(ServerPlayer) player}));
serverPlayer.connection.send(new ClientboundPlayerInfoPacket(
ClientboundPlayerInfoPacket.Action.ADD_PLAYER,
new ServerPlayer[] {(ServerPlayer) player}
));
}
serverLevel3.addNewPlayer(serverPlayer);
this.server.getCustomBossEvents().onPlayerConnect(serverPlayer);
this.sendLevelInfo(serverPlayer, serverLevel3);
if (!this.server.getResourcePack().isEmpty()) {
serverPlayer.sendTexturePack(this.server.getResourcePack(), this.server.getResourcePackHash(), this.server.isResourcePackRequired(), this.server.getResourcePackPrompt());
serverPlayer.sendTexturePack(
this.server.getResourcePack(),
this.server.getResourcePackHash(),
this.server.isResourcePackRequired(),
this.server.getResourcePackPrompt()
);
}
for (MobEffectInstance statusEffectInstance : serverPlayer.getActiveEffects()) {
serverPlayNetworkHandler.send(new ClientboundUpdateMobEffectPacket(serverPlayer.getId(), statusEffectInstance));
serverPlayNetworkHandler.send(new ClientboundUpdateMobEffectPacket(
serverPlayer.getId(),
statusEffectInstance
));
}
if (compoundTag != null && compoundTag.contains("RootVehicle", 10)) {
CompoundTag compoundTag2 = compoundTag.getCompound("RootVehicle");
Entity entity = EntityType.loadEntityRecursive(compoundTag2.getCompound("Entity"), serverLevel3, (vehicle) -> {
return !serverLevel3.addWithUUID(vehicle) ? null : vehicle;
});
Entity entity = EntityType.loadEntityRecursive(
compoundTag2.getCompound("Entity"),
serverLevel3,
(vehicle) -> {
return !serverLevel3.addWithUUID(vehicle) ? null : vehicle;
}
);
if (entity != null) {
UUID uUID2;
if (compoundTag2.hasUUID("Attach")) {

View file

@ -67,7 +67,12 @@ public abstract class ServerPlayerMixin extends Player implements TeleportingEnt
@Inject(method = "findDimensionEntryPoint", at = @At("HEAD"), cancellable = true)
protected void be_getTeleportTarget(ServerLevel destination, CallbackInfoReturnable<PortalInfo> info) {
if (be_canTeleport()) {
info.setReturnValue(new PortalInfo(new Vec3(exitPos.getX() + 0.5, exitPos.getY(), exitPos.getZ() + 0.5), getDeltaMovement(), getYRot(), getXRot()));
info.setReturnValue(new PortalInfo(
new Vec3(exitPos.getX() + 0.5, exitPos.getY(), exitPos.getZ() + 0.5),
getDeltaMovement(),
getYRot(),
getXRot()
));
}
}
@ -78,8 +83,20 @@ public abstract class ServerPlayerMixin extends Player implements TeleportingEnt
ServerLevel serverWorld = getLevel();
LevelData worldProperties = destination.getLevelData();
ServerPlayer player = ServerPlayer.class.cast(this);
connection.send(new ClientboundRespawnPacket(destination.dimensionType(), destination.dimension(), BiomeManager.obfuscateSeed(destination.getSeed()), gameMode.getGameModeForPlayer(), gameMode.getPreviousGameModeForPlayer(), destination.isDebug(), destination.isFlat(), true));
connection.send(new ClientboundChangeDifficultyPacket(worldProperties.getDifficulty(), worldProperties.isDifficultyLocked()));
connection.send(new ClientboundRespawnPacket(
destination.dimensionType(),
destination.dimension(),
BiomeManager.obfuscateSeed(destination.getSeed()),
gameMode.getGameModeForPlayer(),
gameMode.getPreviousGameModeForPlayer(),
destination.isDebug(),
destination.isFlat(),
true
));
connection.send(new ClientboundChangeDifficultyPacket(
worldProperties.getDifficulty(),
worldProperties.isDifficultyLocked()
));
PlayerList playerManager = server.getPlayerList();
playerManager.sendPlayerPermissionLevel(player);
serverWorld.removePlayerImmediately(player, RemovalReason.CHANGED_DIMENSION);

View file

@ -52,7 +52,8 @@ public class SpikeFeatureMixin {
String pillarID = String.format("%d_%d", x, z);
CompoundTag pillar = WorldDataAPI.getCompoundTag(BetterEnd.MOD_ID, "pillars");
boolean haveValue = pillar.contains(pillarID);
minY = haveValue ? pillar.getInt(pillarID) : world.getChunk(x >> 4, z >> 4).getHeight(Types.WORLD_SURFACE, x & 15, z);
minY = haveValue ? pillar.getInt(pillarID) : world.getChunk(x >> 4, z >> 4)
.getHeight(Types.WORLD_SURFACE, x & 15, z);
if (!haveValue) {
pillar.putInt(pillarID, minY);
WorldDataAPI.saveFile(BetterEnd.MOD_ID);
@ -68,7 +69,8 @@ public class SpikeFeatureMixin {
if (GeneratorOptions.replacePillars() && be_radiusInRange(radius)) {
radius--;
StructureTemplate base = StructureHelper.readStructure(BetterEnd.makeID("pillars/pillar_base_" + radius));
StructureTemplate top = StructureHelper.readStructure(BetterEnd.makeID("pillars/pillar_top_" + radius + (spike.isGuarded() ? "_cage" : "")));
StructureTemplate top = StructureHelper.readStructure(BetterEnd.makeID("pillars/pillar_top_" + radius + (spike
.isGuarded() ? "_cage" : "")));
Vec3i side = base.getSize();
BlockPos pos1 = new BlockPos(x - (side.getX() >> 1), minY - 3, z - (side.getZ() >> 1));
minY = pos1.getY() + side.getY();
@ -92,7 +94,8 @@ public class SpikeFeatureMixin {
for (int py = minY; py < maxY; py++) {
mut.setY(py);
if (world.getBlockState(mut).getMaterial().isReplaceable()) {
if ((px == radius || px == -radius || pz == radius || pz == -radius) && random.nextInt(24) == 0) {
if ((px == radius || px == -radius || pz == radius || pz == -radius) && random.nextInt(
24) == 0) {
BlocksHelper.setWithoutUpdate(world, mut, Blocks.CRYING_OBSIDIAN);
}
else {
@ -145,8 +148,20 @@ public class SpikeFeatureMixin {
if (bl || bl2 || bl3) {
boolean bl4 = px == -2 || px == 2 || bl3;
boolean bl5 = pz == -2 || pz == 2 || bl3;
BlockState blockState = (BlockState) ((BlockState) ((BlockState) ((BlockState) Blocks.IRON_BARS.defaultBlockState().setValue(IronBarsBlock.NORTH, bl4 && pz != -2)).setValue(IronBarsBlock.SOUTH, bl4 && pz != 2)).setValue(IronBarsBlock.WEST, bl5 && px != -2)).setValue(IronBarsBlock.EAST, bl5 && px != 2);
BlocksHelper.setWithoutUpdate(world, mut.set(spike.getCenterX() + px, maxY + py, spike.getCenterZ() + pz), blockState);
BlockState blockState = (BlockState) ((BlockState) ((BlockState) ((BlockState) Blocks.IRON_BARS
.defaultBlockState()
.setValue(IronBarsBlock.NORTH, bl4 && pz != -2)).setValue(
IronBarsBlock.SOUTH,
bl4 && pz != 2
)).setValue(IronBarsBlock.WEST, bl5 && px != -2)).setValue(
IronBarsBlock.EAST,
bl5 && px != 2
);
BlocksHelper.setWithoutUpdate(
world,
mut.set(spike.getCenterX() + px, maxY + py, spike.getCenterZ() + pz),
blockState
);
}
}
}

View file

@ -31,6 +31,8 @@ public class WeightedBiomePickerMixin implements IBiomeList {
}
private boolean be_isCorrectPicker(WeightedBiomePicker picker) {
return picker == InternalBiomeData.getEndBiomesMap().get(Biomes.SMALL_END_ISLANDS) || picker == InternalBiomeData.getEndBarrensMap().get(Biomes.END_BARRENS);
return picker == InternalBiomeData.getEndBiomesMap()
.get(Biomes.SMALL_END_ISLANDS) || picker == InternalBiomeData.getEndBarrensMap()
.get(Biomes.END_BARRENS);
}
}