Various smaller updates
This commit is contained in:
parent
fdd61262c5
commit
10a9a81725
64 changed files with 372 additions and 276 deletions
|
@ -1,31 +1,33 @@
|
|||
package ru.betterend.mixin.common;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
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.CallbackInfoReturnable;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.WorldGenLevel;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.ChorusFlowerBlock;
|
||||
import net.minecraft.world.level.block.PipeBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.level.levelgen.feature.ChorusPlantFeature;
|
||||
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
|
||||
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
|
||||
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.CallbackInfoReturnable;
|
||||
import ru.bclib.util.BlocksHelper;
|
||||
import ru.bclib.util.MHelper;
|
||||
import ru.betterend.blocks.VanillaBlockProperties;
|
||||
import ru.betterend.registry.EndBlocks;
|
||||
import ru.betterend.world.generator.GeneratorOptions;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
@Mixin(ChorusPlantFeature.class)
|
||||
public class ChorusPlantFeatureMixin {
|
||||
@Inject(method = "place", at = @At("HEAD"), cancellable = true)
|
||||
private void be_place(WorldGenLevel structureWorldAccess, ChunkGenerator chunkGenerator, Random random, BlockPos blockPos, NoneFeatureConfiguration defaultFeatureConfig, CallbackInfoReturnable<Boolean> info) {
|
||||
private void be_place(FeaturePlaceContext<NoneFeatureConfiguration> featureConfig, CallbackInfoReturnable<Boolean> info) {
|
||||
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)) {
|
||||
ChorusFlowerBlock.generatePlant(structureWorldAccess, blockPos, random, MHelper.randRange(8, 16, random));
|
||||
BlockState bottom = structureWorldAccess.getBlockState(blockPos);
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -22,8 +22,7 @@ public abstract class EntityMixin implements TeleportingEntity {
|
|||
public float yRot;
|
||||
@Shadow
|
||||
public float xRot;
|
||||
@Shadow
|
||||
public boolean removed;
|
||||
|
||||
@Shadow
|
||||
public Level level;
|
||||
|
||||
|
@ -40,11 +39,16 @@ public abstract class EntityMixin implements TeleportingEntity {
|
|||
@Shadow
|
||||
protected abstract PortalInfo findDimensionEntryPoint(ServerLevel destination);
|
||||
|
||||
@Shadow
|
||||
protected abstract void removeAfterChangingDimensions();
|
||||
|
||||
@Shadow public abstract boolean isRemoved();
|
||||
|
||||
private BlockPos exitPos;
|
||||
|
||||
@Inject(method = "changeDimension", at = @At("HEAD"), cancellable = true)
|
||||
public void be_changeDimension(ServerLevel destination, CallbackInfoReturnable<Entity> info) {
|
||||
if (!removed && be_canTeleport() && level instanceof ServerLevel) {
|
||||
if (!isRemoved() && be_canTeleport() && level instanceof ServerLevel) {
|
||||
unRide();
|
||||
level.getProfiler().push("changeDimension");
|
||||
level.getProfiler().push("reposition");
|
||||
|
@ -54,11 +58,14 @@ 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.xRot);
|
||||
entity.moveTo(teleportTarget.pos.x, teleportTarget.pos.y, teleportTarget.pos.z, teleportTarget.yRot, entity.getXRot());
|
||||
entity.setDeltaMovement(teleportTarget.speed);
|
||||
destination.addFromAnotherDimension(entity);
|
||||
//TODO: check if this works as intended in 1.17
|
||||
|
||||
destination.addDuringTeleport(entity);
|
||||
}
|
||||
removed = true;
|
||||
|
||||
this.removeAfterChangingDimensions();
|
||||
level.getProfiler().pop();
|
||||
((ServerLevel) level).resetEmptyTime();
|
||||
destination.resetEmptyTime();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue