Merge branch 'future' of https://github.com/gnembon/fabric-carpet into future

This commit is contained in:
gnembon committed 2021-11-11 23:21:02 +01:00
commit 3ea1be1170
10 files changed
+59 -26

No files matched your search

+4 -4
View File
@@ -4,10 +4,10 @@ org.gradle.jvmargs=-Xmx1G
# Fabric Properties
# check these on https://fabricmc.net/use
# or better: https://modmuss50.me/fabric.html
minecraft_version=21w44a
yarn_mappings=21w44a+build.1
loader_version=0.12.4
fabric_version=0.41.4+1.18
minecraft_version=1.18-pre1
yarn_mappings=1.18-pre1+build.2
loader_version=0.12.5
fabric_version=0.42.1+1.18
# Mod Properties
mod_version = 1.4.52
@@ -0,0 +1,9 @@
package carpet.fakes;
import net.minecraft.world.gen.feature.ConfiguredFeature;
import net.minecraft.world.gen.feature.Feature;
import net.minecraft.world.gen.feature.FeatureConfig;
public interface PlacedFeatureInterface {
ConfiguredFeature<?, ?> getRawFeature();
}
@@ -13,5 +13,5 @@ import net.minecraft.world.gen.feature.FeatureConfig;
public interface StructureFeatureInterface<C extends FeatureConfig>
{
boolean plopAnywhere(ServerWorld world, BlockPos pos, ChunkGenerator generator, boolean wireOnly,Biome biome, C config);
boolean shouldStartPublicAt(ChunkGenerator chunkGenerator, BiomeSource biomeSource, long l, ChunkRandom chunkRandom, ChunkPos chpos, ChunkPos chunkPos, C featureConfig, HeightLimitView heightLimitView);
boolean shouldStartPublicAt(ChunkGenerator chunkGenerator, BiomeSource biomeSource, long l, ChunkPos chunkPos, C featureConfig, HeightLimitView heightLimitView);
}
@@ -1,10 +1,13 @@
package carpet.helpers;
import carpet.CarpetSettings;
import carpet.fakes.PlacedFeatureInterface;
import carpet.fakes.StructureFeatureInterface;
import com.mojang.datafixers.util.Pair;
import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
import net.minecraft.class_6796;
import net.minecraft.class_6797;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.structure.StructureManager;
import net.minecraft.structure.StructureStart;
@@ -185,11 +188,11 @@ public class FeatureGenerator
private static ConfiguredFeature<?, ?> getDefaultFeature(Feature<?> feature, ServerWorld world, BlockPos pos, boolean tryHard)
{
List<List<Supplier<ConfiguredFeature<?, ?>>>> configuredStepFeatures = world.getBiome(pos).getGenerationSettings().getFeatures();
for (List<Supplier<ConfiguredFeature<?, ?>>> step: configuredStepFeatures)
for (Supplier<ConfiguredFeature<?, ?>> provider: step)
List<List<Supplier<class_6796>>> configuredStepFeatures = world.getBiome(pos).getGenerationSettings().getFeatures();
for (List<Supplier<class_6796>> step: configuredStepFeatures)
for (Supplier<class_6796> provider: step)
{
ConfiguredFeature<?, ?> configuredFeature = provider.get();
ConfiguredFeature<?, ?> configuredFeature = ((PlacedFeatureInterface)provider.get()).getRawFeature();
if (configuredFeature.feature == feature)
return configuredFeature;
}
@@ -258,9 +261,9 @@ public class FeatureGenerator
put("coral_claw", simplePlop(Feature.CORAL_CLAW.configure(FeatureConfig.DEFAULT)));
put("coral_mushroom", simplePlop(Feature.CORAL_MUSHROOM.configure(FeatureConfig.DEFAULT)));
put("coral", simplePlop(Feature.SIMPLE_RANDOM_SELECTOR.configure(new SimpleRandomFeatureConfig(List.of(
() -> Feature.CORAL_TREE.configure(FeatureConfig.DEFAULT),
() -> Feature.CORAL_CLAW.configure(FeatureConfig.DEFAULT),
() -> Feature.CORAL_MUSHROOM.configure(FeatureConfig.DEFAULT)
() -> Feature.CORAL_TREE.configure(FeatureConfig.DEFAULT).method_39594(new class_6797[0]),
() -> Feature.CORAL_CLAW.configure(FeatureConfig.DEFAULT).method_39594(new class_6797[0]),
() -> Feature.CORAL_MUSHROOM.configure(FeatureConfig.DEFAULT).method_39594(new class_6797[0])
)))));
put("bastion_remnant_units", spawnCustomStructure(
StructureFeature.BASTION_REMNANT,
@@ -0,0 +1,21 @@
package carpet.mixins;
import carpet.fakes.PlacedFeatureInterface;
import net.minecraft.class_6796;
import net.minecraft.world.gen.feature.ConfiguredFeature;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import java.util.function.Supplier;
@Mixin(class_6796.class)
public class PlacedFeature_scarpetMixin implements PlacedFeatureInterface {
@Shadow @Final private Supplier<ConfiguredFeature<?, ?>> field_35732;
@Override
public ConfiguredFeature<?, ?> getRawFeature() {
return field_35732.get();
}
}
@@ -136,13 +136,10 @@ public abstract class ServerWorld_tickMixin extends World
if (TickSpeed.process_entities) worldBorder.tick();
}
@Redirect(method = "tick", at = @At(
value = "INVOKE",
target = "Lnet/minecraft/world/dimension/DimensionType;hasSkyLight()Z"
))
private boolean tickWorldBorder(DimensionType dimension)
@Inject(method = "method_39501", cancellable = true, at = @At("HEAD"))
private void tickWorldBorder(CallbackInfo ci)
{
return TickSpeed.process_entities && dimension.hasSkyLight();
if (!TickSpeed.process_entities) ci.cancel();
}
@Redirect(method = "tick", at = @At(
@@ -44,10 +44,12 @@ public abstract class StructureFeatureMixin<C extends FeatureConfig> implements
//@Shadow protected abstract boolean shouldStartAt(ChunkGenerator chunkGenerator, BiomeSource biomeSource, long worldSeed, ChunkRandom random, ChunkPos chunkPos, Biome biome, ChunkPos chunkPos2, C featureConfig, HeightLimitView heightLimitView);
@Shadow protected abstract boolean shouldStartAt(ChunkGenerator chunkGenerator, BiomeSource biomeSource, long worldSeed, ChunkRandom random, ChunkPos pos, ChunkPos chunkPos, C featureConfig, HeightLimitView heightLimitView);
//@Shadow protected abstract boolean shouldStartAt(ChunkGenerator chunkGenerator, BiomeSource biomeSource, long worldSeed, ChunkRandom random, ChunkPos pos, ChunkPos chunkPos, C featureConfig, HeightLimitView heightLimitView);
@Shadow protected abstract boolean shouldStartAt(ChunkGenerator chunkGenerator, BiomeSource biomeSource, long worldSeed, ChunkPos chunkPos, C featureConfig, HeightLimitView heightLimitView);
@Shadow @Final private class_6622<C> field_34929;
@Override
public boolean plopAnywhere(ServerWorld world, BlockPos pos, ChunkGenerator generator, boolean wireOnly, Biome biome, C config)
{
@@ -157,8 +159,8 @@ public abstract class StructureFeatureMixin<C extends FeatureConfig> implements
}
@Override
public boolean shouldStartPublicAt(ChunkGenerator chunkGenerator, BiomeSource biomeSource, long l, ChunkRandom chunkRandom, ChunkPos chpos, ChunkPos chunkPos, C featureConfig, HeightLimitView heightLimitView)
public boolean shouldStartPublicAt(ChunkGenerator chunkGenerator, BiomeSource biomeSource, long l, ChunkPos chunkPos, C featureConfig, HeightLimitView heightLimitView)
{
return shouldStartAt(chunkGenerator, biomeSource, l, chunkRandom, chpos, chunkPos, featureConfig, heightLimitView);
return shouldStartAt(chunkGenerator, biomeSource, l, chunkPos, featureConfig, heightLimitView);
}
}
@@ -16,11 +16,11 @@ import net.minecraft.world.Heightmap;
//import net.minecraft.world.TickScheduler;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.chunk.BlendingData;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.ChunkSection;
import net.minecraft.world.chunk.UpgradeData;
import net.minecraft.world.chunk.WorldChunk;
import net.minecraft.world.gen.chunk.Blender;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
@@ -35,9 +35,8 @@ public abstract class WorldChunk_movableTEMixin extends Chunk implements WorldCh
@Final
World world;
public WorldChunk_movableTEMixin(ChunkPos chunkPos, UpgradeData upgradeData, HeightLimitView heightLimitView, Registry<Biome> registry, long l, @Nullable ChunkSection[] chunkSections, @Nullable BlendingData blendingData)
{
super(chunkPos, upgradeData, heightLimitView, registry, l, chunkSections, blendingData);
public WorldChunk_movableTEMixin(ChunkPos pos, UpgradeData upgradeData, HeightLimitView heightLimitView, Registry<Biome> biome, long inhabitedTime, @Nullable ChunkSection[] sectionArrayInitializer, @Nullable Blender blendingData) {
super(pos, upgradeData, heightLimitView, biome, inhabitedTime, sectionArrayInitializer, blendingData);
}
@Shadow
@@ -1,6 +1,7 @@
package carpet.script.utils;
import carpet.fakes.BiomeEffectsInterface;
import carpet.fakes.PlacedFeatureInterface;
import carpet.script.value.BlockValue;
import carpet.script.value.ListValue;
import carpet.script.value.NumericValue;
@@ -41,7 +42,7 @@ public class BiomeInfo
return ListValue.wrap(
b.getGenerationSettings().getFeatures().stream().map(step ->
ListValue.wrap(step.stream().map(cfp ->
ValueConversions.of(registry.getId(cfp.get()))
ValueConversions.of(registry.getId(((PlacedFeatureInterface)cfp.get()).getRawFeature()))
))
)
);
+1
View File
@@ -102,6 +102,7 @@
"World_scarpetPlopMixin",
"ChunkRegion_scarpetPlopMixin",
"StructurePiece_scarpetPlopMixin",
"PlacedFeature_scarpetMixin",
"ServerPlayNetworkHandler_scarpetEventsMixin",
"ServerPlayerInteractionManager_scarpetEventsMixin",