1.4.87 for 22w44a
This commit is contained in:
1 parent
c51f59c799
commit
4be362e58b
20 files changed
+236
-185
No files matched your search
@@ -4,30 +4,23 @@ import carpet.fakes.ChunkGeneratorInterface;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.level.levelgen.RandomState;
|
||||
import net.minecraft.world.level.levelgen.structure.Structure;
|
||||
import net.minecraft.world.level.levelgen.structure.placement.StructurePlacement;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mixin(ChunkGenerator.class)
|
||||
public abstract class ChunkGenerator_scarpetMixin implements ChunkGeneratorInterface
|
||||
{
|
||||
|
||||
@Shadow public abstract void ensureStructuresGenerated(RandomState randomState);
|
||||
|
||||
@Shadow protected abstract List<StructurePlacement> getPlacementsForStructure(Holder<Structure> holder, RandomState randomState);
|
||||
|
||||
@Override
|
||||
public void initStrongholds(final ServerLevel level)
|
||||
{
|
||||
ensureStructuresGenerated(level.getChunkSource().randomState());
|
||||
level.getChunkSource().getGeneratorState().ensureStructuresGenerated();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StructurePlacement> getPlacementsForFeatureCM(final ServerLevel level, Structure structure) {
|
||||
return getPlacementsForStructure(Holder.direct(structure), level.getChunkSource().randomState());
|
||||
return level.getChunkSource().getGeneratorState().getPlacementsForStructure(Holder.direct(structure));
|
||||
}
|
||||
}
|
||||
@@ -9,14 +9,13 @@ import net.minecraft.world.level.biome.BiomeSource;
|
||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.level.levelgen.FlatLevelSource;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@Mixin(FlatLevelSource.class)
|
||||
@Mixin(FlatLevelSource.class) // YEET
|
||||
public abstract class FlatLevelSource_structuresMixin extends ChunkGenerator
|
||||
{
|
||||
public FlatLevelSource_structuresMixin(Registry<StructureSet> registry, Optional<HolderSet<StructureSet>> optional, BiomeSource biomeSource) {
|
||||
super(registry, optional, biomeSource);
|
||||
public FlatLevelSource_structuresMixin(BiomeSource biomeSource) {
|
||||
super(biomeSource);
|
||||
}
|
||||
|
||||
/*
|
||||
@Override
|
||||
public WeightedRandomList<MobSpawnSettings.SpawnerData> getMobsAt(Holder<Biome> biome, StructureFeatureManager accessor, MobCategory group, BlockPos pos)
|
||||
|
||||
@@ -79,7 +79,7 @@ public abstract class PrimedTntMixin extends Entity implements TntEntityInterfac
|
||||
this.level.explode(this, this.getX(), this.getY() + (double)(this.getBbHeight() / 16.0F),
|
||||
this.getZ(),
|
||||
4.0F,
|
||||
Explosion.BlockInteraction.BREAK);
|
||||
Level.ExplosionInteraction.TNT);
|
||||
}
|
||||
|
||||
@Inject(method = "tick", at = @At(value = "INVOKE",
|
||||
|
||||
@@ -2,6 +2,8 @@ package carpet.mixins;
|
||||
|
||||
import carpet.fakes.ServerWorldInterface;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.util.profiling.ProfilerFiller;
|
||||
import net.minecraft.world.DifficultyInstance;
|
||||
@@ -11,10 +13,14 @@ import net.minecraft.world.entity.LightningBolt;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.Explosion;
|
||||
import net.minecraft.world.level.ExplosionDamageCalculator;
|
||||
import net.minecraft.world.level.GameRules;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.chunk.LevelChunk;
|
||||
import net.minecraft.world.level.dimension.DimensionType;
|
||||
import net.minecraft.world.level.entity.LevelEntityGetter;
|
||||
import net.minecraft.world.level.entity.PersistentEntitySectionManager;
|
||||
import net.minecraft.world.level.storage.ServerLevelData;
|
||||
import net.minecraft.world.level.storage.WritableLevelData;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@@ -24,14 +30,20 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import static carpet.script.CarpetEventServer.Event.EXPLOSION;
|
||||
import static carpet.script.CarpetEventServer.Event.LIGHTNING;
|
||||
import static carpet.script.CarpetEventServer.Event.CHUNK_UNLOADED;
|
||||
|
||||
|
||||
@Mixin(ServerLevel.class)
|
||||
public class ServerLevel_scarpetMixin implements ServerWorldInterface
|
||||
public abstract class ServerLevel_scarpetMixin extends Level implements ServerWorldInterface
|
||||
{
|
||||
protected ServerLevel_scarpetMixin(WritableLevelData writableLevelData, ResourceKey<Level> resourceKey, Holder<DimensionType> holder, Supplier<ProfilerFiller> supplier, boolean bl, boolean bl2, long l, int i) {
|
||||
super(writableLevelData, resourceKey, holder, supplier, bl, bl2, l, i);
|
||||
}
|
||||
|
||||
@Inject(method = "tickChunk", locals = LocalCapture.CAPTURE_FAILHARD, at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/level/ServerLevel;addFreshEntity(Lnet/minecraft/world/entity/Entity;)Z",
|
||||
@@ -45,11 +57,24 @@ public class ServerLevel_scarpetMixin implements ServerWorldInterface
|
||||
if (LIGHTNING.isNeeded()) LIGHTNING.onWorldEventFlag((ServerLevel) (Object)this, blockPos, bl2?1:0);
|
||||
}
|
||||
|
||||
private Explosion.BlockInteraction getCMDestroyType(final GameRules.Key<GameRules.BooleanValue> rule) {
|
||||
return getGameRules().getBoolean(rule) ? Explosion.BlockInteraction.DESTROY_WITH_DECAY : Explosion.BlockInteraction.DESTROY;
|
||||
}
|
||||
|
||||
@Inject(method = "explode", at = @At("HEAD"))
|
||||
private void handleExplosion(/*@Nullable*/ Entity entity, /*@Nullable*/ DamageSource damageSource, /*@Nullable*/ ExplosionDamageCalculator explosionBehavior, double d, double e, double f, float g, boolean bl, Explosion.BlockInteraction destructionType, CallbackInfoReturnable<Explosion> cir)
|
||||
private void handleExplosion(/*@Nullable*/ Entity entity, /*@Nullable*/ DamageSource damageSource, /*@Nullable*/ ExplosionDamageCalculator explosionBehavior, double d, double e, double f, float g, boolean bl, Level.ExplosionInteraction explosionInteraction, CallbackInfoReturnable<Explosion> cir)
|
||||
{
|
||||
if (EXPLOSION.isNeeded())
|
||||
EXPLOSION.onExplosion((ServerLevel) (Object)this, entity, null, d, e, f, g, bl, null, null, destructionType);
|
||||
if (EXPLOSION.isNeeded()) {
|
||||
Explosion.BlockInteraction var10000 = switch (explosionInteraction) {
|
||||
case NONE -> Explosion.BlockInteraction.KEEP;
|
||||
case BLOCK -> this.getCMDestroyType(GameRules.RULE_BLOCK_EXPLOSION_DROP_DECAY);
|
||||
case MOB -> this.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) ? this.getCMDestroyType(GameRules.RULE_MOB_EXPLOSION_DROP_DECAY) : Explosion.BlockInteraction.KEEP;
|
||||
case TNT -> this.getCMDestroyType(GameRules.RULE_TNT_EXPLOSION_DROP_DECAY);
|
||||
default -> throw new IncompatibleClassChangeError();
|
||||
};
|
||||
|
||||
EXPLOSION.onExplosion((ServerLevel) (Object) this, entity, null, d, e, f, g, bl, null, null, var10000);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "unload", at = @At("HEAD"))
|
||||
|
||||
Reference in new issue
Block a user