Various smaller updates

This commit is contained in:
Frank Bauer 2021-06-24 17:11:48 +02:00
parent fdd61262c5
commit 10a9a81725
64 changed files with 372 additions and 276 deletions

View file

@ -1,7 +1,16 @@
package ru.betterend.mixin.common;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Vec3i;
import net.minecraft.nbt.NbtUtils;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.chunk.ChunkStatus;
import net.minecraft.world.level.levelgen.Heightmap.Types;
import net.minecraft.world.level.levelgen.feature.EndPodiumFeature;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructurePlaceSettings;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@ -9,22 +18,13 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyVariable;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.NbtUtils;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.chunk.ChunkStatus;
import net.minecraft.world.level.levelgen.Heightmap.Types;
import net.minecraft.world.level.levelgen.feature.EndPodiumFeature;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructurePlaceSettings;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate;
import ru.bclib.api.WorldDataAPI;
import ru.bclib.util.StructureHelper;
import ru.betterend.BetterEnd;
import ru.betterend.world.generator.GeneratorOptions;
import java.util.Random;
@Mixin(EndPodiumFeature.class)
public class EndPodiumFeatureMixin {
@Final
@ -32,17 +32,19 @@ public class EndPodiumFeatureMixin {
private boolean active;
@Inject(method = "place", at = @At("HEAD"), cancellable = true)
private void be_place(WorldGenLevel world, ChunkGenerator generator, Random random, BlockPos blockPos, NoneFeatureConfiguration config, CallbackInfoReturnable<Boolean> info) {
private void be_place(FeaturePlaceContext<NoneFeatureConfiguration> featurePlaceContext, CallbackInfoReturnable<Boolean> info) {
if (!GeneratorOptions.hasPortal()) {
info.setReturnValue(false);
info.cancel();
}
else if (GeneratorOptions.replacePortal()) {
blockPos = be_updatePos(blockPos, world);
Random random = featurePlaceContext.random();
WorldGenLevel world = featurePlaceContext.level();
BlockPos blockPos = be_updatePos(featurePlaceContext.origin(), world);
StructureTemplate structure = StructureHelper.readStructure(BetterEnd.makeID(active ? "portal/end_portal_active" : "portal/end_portal_inactive"));
BlockPos size = structure.getSize();
Vec3i size = structure.getSize();
blockPos = blockPos.offset(-(size.getX() >> 1), -1, -(size.getZ() >> 1));
structure.placeInWorldChunk(world, blockPos, new StructurePlaceSettings(), random);
structure.placeInWorld(world, blockPos, blockPos, new StructurePlaceSettings(), random, 2);
info.setReturnValue(true);
info.cancel();
}