This commit is contained in:
gnembon committed 2022-02-10 03:15:53 +01:00
1 parent 695b569977
commit 212814f46d
27 files changed
+264 -144

No files matched your search

@@ -4,6 +4,7 @@ import carpet.fakes.BlockPredicateInterface;
import carpet.script.value.StringValue;
import carpet.script.value.Value;
import carpet.script.value.ValueConversions;
import net.minecraft.tags.TagKey;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@@ -34,7 +35,7 @@ public class BlockPredicate_scarpetMixin implements BlockPredicateInterface
}
@Override
public Tag<Block> getCMBlockTag()
public TagKey<Block> getCMBlockTagKey()
{
return null;
}
@@ -9,17 +9,17 @@ import org.spongepowered.asm.mixin.Shadow;
@Mixin(ChunkGenerator.class)
public abstract class ChunkGenerator_scarpetMixin implements ChunkGeneratorInterface
{
@Shadow protected abstract void generateStrongholds();
@Shadow private static boolean validStrongholdBiome(Biome biome) { return true;}
//@Shadow protected abstract void generateStrongholds(); // postInit
//@Shadow private static boolean validStrongholdBiome(Biome biome) { return true;}
@Override
public void initStrongholds()
{
generateStrongholds();
}
// @Override
//public void initStrongholds()
//{
// generateStrongholds();
//}
@Override
public boolean canPlaceStrongholdInBiomeCM(Biome biome) {
return validStrongholdBiome(biome);
}
//@Override
//public boolean canPlaceStrongholdInBiomeCM(Biome biome) {
// return validStrongholdBiome(biome);
//}
}
@@ -3,6 +3,8 @@ package carpet.mixins;
import carpet.CarpetSettings;
import carpet.fakes.CoralFeatureInterface;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Holder;
import net.minecraft.core.Registry;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.tags.BlockTags;
import net.minecraft.tags.FluidTags;
@@ -23,6 +25,8 @@ import net.minecraft.world.level.material.MaterialColor;
import org.spongepowered.asm.mixin.Mixin;
import java.util.Random;
import java.util.Set;
import java.util.stream.Collectors;
@Mixin(CoralFanBlock.class)
public abstract class CoralFanBlock_renewableCoralMixin implements BonemealableBlock
@@ -53,7 +57,8 @@ public abstract class CoralFanBlock_renewableCoralMixin implements BonemealableB
MaterialColor color = blockUnder.getMapColor(worldIn, pos);
BlockState proper_block = blockUnder;
for (Block block: BlockTags.CORAL_BLOCKS.getValues())
Set<Block> coralBlockSet = worldIn.registryAccess().registryOrThrow(Registry.BLOCK_REGISTRY).getTag(BlockTags.CORAL_BLOCKS).orElseThrow().stream().map(Holder::value).collect(Collectors.toUnmodifiableSet());
for (Block block: coralBlockSet)
{
proper_block = block.defaultBlockState();
if (proper_block.getMapColor(worldIn,pos) == color)
@@ -72,7 +77,7 @@ public abstract class CoralFanBlock_renewableCoralMixin implements BonemealableB
if (worldIn.random.nextInt(10)==0)
{
BlockPos randomPos = pos.offset(worldIn.random.nextInt(16)-8,worldIn.random.nextInt(8),worldIn.random.nextInt(16)-8 );
if (BlockTags.CORAL_BLOCKS.contains(worldIn.getBlockState(randomPos).getBlock()))
if (coralBlockSet.contains(worldIn.getBlockState(randomPos).getBlock()))
{
worldIn.setBlock(randomPos, Blocks.WET_SPONGE.defaultBlockState(), 3);
}
@@ -2,9 +2,14 @@ package carpet.mixins;
import carpet.CarpetSettings;
import carpet.fakes.CoralFeatureInterface;
import net.minecraft.core.Holder;
import net.minecraft.core.Registry;
import org.spongepowered.asm.mixin.Mixin;
import java.util.Random;
import java.util.Set;
import java.util.stream.Collectors;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.tags.BlockTags;
@@ -54,7 +59,8 @@ public abstract class CoralPlantBlock_renewableCoralMixin implements Bonemealabl
MaterialColor color = blockUnder.getMapColor(worldIn, pos);
BlockState proper_block = blockUnder;
for (Block block: BlockTags.CORAL_BLOCKS.getValues())
Set<Block> coralBlockSet = worldIn.registryAccess().registryOrThrow(Registry.BLOCK_REGISTRY).getTag(BlockTags.CORAL_BLOCKS).orElseThrow().stream().map(Holder::value).collect(Collectors.toUnmodifiableSet());
for (Block block: coralBlockSet)
{
proper_block = block.defaultBlockState();
if (proper_block.getMapColor(worldIn,pos) == color)
@@ -73,7 +79,7 @@ public abstract class CoralPlantBlock_renewableCoralMixin implements Bonemealabl
if (worldIn.random.nextInt(10)==0)
{
BlockPos randomPos = pos.offset(worldIn.random.nextInt(16)-8,worldIn.random.nextInt(8),worldIn.random.nextInt(16)-8 );
if (BlockTags.CORAL_BLOCKS.contains(worldIn.getBlockState(randomPos).getBlock()))
if (coralBlockSet.contains(worldIn.getBlockState(randomPos).getBlock()))
{
worldIn.setBlock(randomPos, Blocks.WET_SPONGE.defaultBlockState(), 3);
}
@@ -2,6 +2,7 @@ package carpet.mixins;
import carpet.CarpetSettings;
import carpet.helpers.CustomSpawnLists;
import net.minecraft.core.Holder;
import org.spongepowered.asm.mixin.Mixin;
import net.minecraft.core.BlockPos;
@@ -30,7 +31,7 @@ public abstract class FlatLevelSource_structuresMixin extends ChunkGenerator
}
@Override
public WeightedRandomList<MobSpawnSettings.SpawnerData> getMobsAt(Biome biome, StructureFeatureManager accessor, MobCategory group, BlockPos pos)
public WeightedRandomList<MobSpawnSettings.SpawnerData> getMobsAt(Holder<Biome> biome, StructureFeatureManager accessor, MobCategory group, BlockPos pos)
{
if (!CarpetSettings.flatWorldStructureSpawning) return super.getMobsAt(biome, accessor, group, pos);
@@ -5,7 +5,6 @@ import carpet.helpers.TickSpeed;
import net.minecraft.Util;
import net.minecraft.resources.ResourceKey;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.ServerResources;
import net.minecraft.server.TickTask;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.thread.ReentrantBlockableEventLoop;
@@ -45,7 +44,7 @@ public abstract class MinecraftServer_scarpetMixin extends ReentrantBlockableEve
@Shadow @Final private Map<ResourceKey<Level>, ServerLevel> levels;
@Shadow private ServerResources resources;
//@Shadow private ServerResources resources;
@Override
public void forceTick(BooleanSupplier isAhead)
@@ -61,10 +60,10 @@ public abstract class MinecraftServer_scarpetMixin extends ReentrantBlockableEve
return storageSource;
}
@Override
public ServerResources getResourceManager() {
return resources;
}
//@Override
//public ServerResources getResourceManager() {
// return resources;
//}
@Override
public Map<ResourceKey<Level>, ServerLevel> getCMWorlds()
@@ -2,6 +2,7 @@ package carpet.mixins;
import carpet.CarpetSettings;
import carpet.helpers.CustomSpawnLists;
import net.minecraft.core.Holder;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
@@ -28,13 +29,13 @@ public abstract class NoiseBasedChunkGenerator_husksSpawnMixin extends ChunkGene
}
@Inject(method = "getMobsAt", at = @At("HEAD"), cancellable = true)
private void isInsidePyramid(Biome biome, StructureFeatureManager accessor, MobCategory group, BlockPos pos, CallbackInfoReturnable<WeightedRandomList<MobSpawnSettings.SpawnerData>> cir)
private void isInsidePyramid(Holder<Biome> holder, StructureFeatureManager structureFeatureManager, MobCategory mobCategory, BlockPos blockPos, CallbackInfoReturnable<WeightedRandomList<MobSpawnSettings.SpawnerData>> cir)
{
if (group == MobCategory.MONSTER)
if (mobCategory == MobCategory.MONSTER)
{
if (CarpetSettings.huskSpawningInTemples)
{
if (accessor.getStructureAt(pos, StructureFeature.DESERT_PYRAMID).isValid())
if (structureFeatureManager.getStructureAt(blockPos, StructureFeature.DESERT_PYRAMID).isValid())
{
cir.setReturnValue(CustomSpawnLists.PYRAMID_SPAWNS);
return;
@@ -42,7 +43,7 @@ public abstract class NoiseBasedChunkGenerator_husksSpawnMixin extends ChunkGene
}
if (CarpetSettings.shulkerSpawningInEndCities)
{
if (accessor.getStructureAt(pos, StructureFeature.END_CITY).isValid())
if (structureFeatureManager.getStructureAt(blockPos, StructureFeature.END_CITY).isValid())
{
cir.setReturnValue(CustomSpawnLists.SHULKER_SPAWNS);
return;
@@ -50,7 +51,7 @@ public abstract class NoiseBasedChunkGenerator_husksSpawnMixin extends ChunkGene
}
if (CarpetSettings.piglinsSpawningInBastions)
{
if (accessor.getStructureAt(pos, StructureFeature.BASTION_REMNANT).isValid())
if (structureFeatureManager.getStructureAt(blockPos, StructureFeature.BASTION_REMNANT).isValid())
{
cir.setReturnValue(CustomSpawnLists.BASTION_SPAWNS);
}
@@ -2,6 +2,7 @@ package carpet.mixins;
import carpet.CarpetSettings;
import net.minecraft.tags.Tag;
import net.minecraft.tags.TagKey;
import net.minecraft.world.item.DiggerItem;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.PickaxeItem;
@@ -15,7 +16,7 @@ import org.spongepowered.asm.mixin.Mixin;
public class PickaxeItem_missingToolsMixin extends DiggerItem
{
protected PickaxeItem_missingToolsMixin(float attackDamage, float attackSpeed, Tier material, Tag<Block> tag, Properties settings) {
protected PickaxeItem_missingToolsMixin(float attackDamage, float attackSpeed, Tier material, TagKey<Block> tag, Properties settings) {
super(attackDamage, attackSpeed, material, tag, settings);
}
@@ -12,10 +12,4 @@ import net.minecraft.world.level.levelgen.placement.PlacedFeature;
@Mixin(PlacedFeature.class)
public class PlacedFeature_scarpetMixin implements PlacedFeatureInterface {
@Shadow @Final private Supplier<ConfiguredFeature<?, ?>> feature;
@Override
public ConfiguredFeature<?, ?> getRawFeature() {
return feature.get();
}
}
@@ -23,7 +23,7 @@ public abstract class SaplingBlock_desertShrubsMixin
cancellable = true)
private void onGenerate(ServerLevel serverWorld_1, BlockPos blockPos_1, BlockState blockState_1, Random random_1, CallbackInfo ci)
{
if(CarpetSettings.desertShrubs && serverWorld_1.getBiome(blockPos_1).getBiomeCategory() == Biome.BiomeCategory.DESERT && !BlockSaplingHelper.hasWater(serverWorld_1, blockPos_1))
if(CarpetSettings.desertShrubs && Biome.getBiomeCategory(serverWorld_1.getBiome(blockPos_1)) == Biome.BiomeCategory.DESERT && !BlockSaplingHelper.hasWater(serverWorld_1, blockPos_1))
{
serverWorld_1.setBlock(blockPos_1, Blocks.DEAD_BUSH.defaultBlockState(), 3);
ci.cancel();
@@ -2,6 +2,7 @@ package carpet.mixins;
import carpet.helpers.TickSpeed;
import carpet.utils.CarpetProfiler;
import net.minecraft.core.Holder;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
@@ -23,7 +24,7 @@ import net.minecraft.world.level.storage.WritableLevelData;
@Mixin(ServerLevel.class)
public abstract class ServerLevel_tickMixin extends Level
{
protected ServerLevel_tickMixin(WritableLevelData properties, ResourceKey<Level> registryKey, DimensionType dimensionType, Supplier<ProfilerFiller> supplier, boolean bl, boolean bl2, long l)
protected ServerLevel_tickMixin(WritableLevelData properties, ResourceKey<Level> registryKey, Holder<DimensionType> dimensionType, Supplier<ProfilerFiller> supplier, boolean bl, boolean bl2, long l)
{
super(properties, registryKey, dimensionType, supplier, bl, bl2, l);
}
@@ -3,6 +3,7 @@ package carpet.mixins;
import carpet.fakes.BlockPredicateInterface;
import carpet.script.value.StringValue;
import carpet.script.value.Value;
import net.minecraft.tags.TagKey;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@@ -17,7 +18,7 @@ import net.minecraft.world.level.block.state.BlockState;
@Mixin(targets = "net.minecraft.commands.arguments.blocks.BlockPredicateArgument$TagPredicate")
public class TagPredicate_scarpetMixin implements BlockPredicateInterface
{
@Shadow @Final private Tag<Block> tag;
@Shadow @Final private TagKey<Block> tag;
@Shadow @Final private Map<String, String> vagueProperties;
@@ -30,7 +31,7 @@ public class TagPredicate_scarpetMixin implements BlockPredicateInterface
}
@Override
public Tag<Block> getCMBlockTag()
public TagKey<Block> getCMBlockTagKey()
{
return tag;
}