From 5e2b19f8b7ac720c9831726a2c5a1cece0538041 Mon Sep 17 00:00:00 2001 From: mschae23 Date: Tue, 2 Mar 2021 14:15:58 +0100 Subject: [PATCH] Changed ender invasion generation --- build.gradle | 2 +- gradle.properties | 2 +- motherlode-ender-invasion/build.gradle | 3 +- .../enderinvasion/EnderInvasion.java | 158 +++++++++++------- .../enderinvasion/EnderInvasionEvents.java | 10 +- .../MotherlodeEnderInvasionClient.java | 1 + .../enderinvasion/MotherlodeModule.java | 27 ++- .../EnderInvasionChunkComponent.java | 2 +- .../impl/EnderInvasionGenerator.java | 16 ++ .../enderinvasion/impl/EnderInvasionImpl.java | 150 +++++++++++++++++ .../impl/OldEnderInvasionImpl.java | 128 ++++++++++++++ .../enderinvasion/mixin/ServerWorldMixin.java | 4 +- .../recipe/MotherlodeSpreadRecipes.java | 3 +- .../util/EnderInvasionHelper.java | 119 +------------ .../motherlode-ender-invasion/lang/en_us.json | 3 + .../src/main/resources/fabric.mod.json | 5 +- .../motherlode-ender-invasion.mixins.json | 3 +- settings.gradle | 2 +- 18 files changed, 449 insertions(+), 189 deletions(-) create mode 100644 motherlode-ender-invasion/src/main/java/motherlode/enderinvasion/impl/EnderInvasionGenerator.java create mode 100644 motherlode-ender-invasion/src/main/java/motherlode/enderinvasion/impl/EnderInvasionImpl.java create mode 100644 motherlode-ender-invasion/src/main/java/motherlode/enderinvasion/impl/OldEnderInvasionImpl.java create mode 100644 motherlode-ender-invasion/src/main/resources/assets/motherlode-ender-invasion/lang/en_us.json diff --git a/build.gradle b/build.gradle index 8643cdd..dce967b 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'fabric-loom' version '0.5-SNAPSHOT' apply false + id 'fabric-loom' version '0.6-SNAPSHOT' apply false } apply from: 'dependencies.gradle' diff --git a/gradle.properties b/gradle.properties index e3cd84b..227a5a9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,6 +7,6 @@ loader_version=0.11.2 # Mod Properties - mod_version=0.1.1 + mod_version=0.1.2 maven_group=motherlode.core archives_base_name=motherlode diff --git a/motherlode-ender-invasion/build.gradle b/motherlode-ender-invasion/build.gradle index d52683d..e846012 100644 --- a/motherlode-ender-invasion/build.gradle +++ b/motherlode-ender-invasion/build.gradle @@ -1,6 +1,7 @@ -version = "1.0.0+$project.minecraft_version" +version = "1.1.0+$project.minecraft_version" dependencies { implementation project(path: ":motherlode-base", configuration: "dev") implementation project(path: ":motherlode-materials", configuration: "dev") + implementation project(path: ":motherlode-biomes", configuration: "dev") } \ No newline at end of file diff --git a/motherlode-ender-invasion/src/main/java/motherlode/enderinvasion/EnderInvasion.java b/motherlode-ender-invasion/src/main/java/motherlode/enderinvasion/EnderInvasion.java index bde58cc..01d5a9f 100644 --- a/motherlode-ender-invasion/src/main/java/motherlode/enderinvasion/EnderInvasion.java +++ b/motherlode-ender-invasion/src/main/java/motherlode/enderinvasion/EnderInvasion.java @@ -6,6 +6,8 @@ import net.minecraft.item.Items; import net.minecraft.loot.condition.LootConditionType; import net.minecraft.server.world.ServerWorld; +import net.minecraft.text.TranslatableText; +import net.minecraft.util.Formatting; import net.minecraft.util.Identifier; import net.minecraft.util.math.BlockPos; import net.minecraft.util.profiler.Profiler; @@ -16,19 +18,18 @@ import net.minecraft.world.World; import net.minecraft.world.chunk.WorldChunk; import net.fabricmc.fabric.api.event.lifecycle.v1.ServerChunkEvents; +import net.fabricmc.fabric.api.event.player.PlayerBlockBreakEvents; import net.fabricmc.fabric.api.loot.v1.event.LootTableLoadingCallback; import motherlode.enderinvasion.component.EnderInvasionChunkComponent; import motherlode.enderinvasion.component.EnderInvasionComponent; +import motherlode.enderinvasion.impl.EnderInvasionGenerator; import motherlode.enderinvasion.recipe.BlockRecipeManager; import motherlode.enderinvasion.util.EnderInvasionHelper; -import dev.onyxstudios.cca.api.v3.chunk.ChunkComponentFactoryRegistry; -import dev.onyxstudios.cca.api.v3.chunk.ChunkComponentInitializer; +import motherlode.materials.MotherlodeMaterialsBlocks; import dev.onyxstudios.cca.api.v3.component.ComponentKey; import dev.onyxstudios.cca.api.v3.component.ComponentRegistry; -import dev.onyxstudios.cca.api.v3.level.LevelComponentFactoryRegistry; -import dev.onyxstudios.cca.api.v3.level.LevelComponentInitializer; -public final class EnderInvasion implements LevelComponentInitializer, ChunkComponentInitializer { +public final class EnderInvasion { public static final ComponentKey STATE = ComponentRegistry.getOrCreate(MotherlodeModule.id("ender_invasion_state"), EnderInvasionComponent.class); @@ -39,48 +40,51 @@ public final class EnderInvasion implements LevelComponentInitializer, ChunkComp public static final Identifier PLAY_PORTAL_PARTICLE_PACKET_ID = MotherlodeModule.id("ender_invasion_portal_particle"); - public static final double NOISE_THRESHOLD = 0.75; - public static final double NOISE_SCALE = 0.002; - public static final double END_CAP_NOISE_THRESHOLD = 0.75; - public static final double END_FOAM_NOISE_THRESHOLD = 0.9; - public static final double DECORATION_NOISE_SCALE = 0.05; - public static Difficulty SPREAD_DIFFICULTY = Difficulty.HARD; public static int INVASION_END_TIME = 216000; public static double ENDERMAN_SPAWN_RATE_DAY = 0.1; public static double ENDERMAN_SPAWN_RATE_NIGHT = 0.25; - @Override - public void registerLevelComponentFactories(LevelComponentFactoryRegistry registry) { - registry.register(STATE, worldProperties -> new EnderInvasionComponent.Impl(EnderInvasionComponent.State.PRE_ECHERITE)); - } + private final EnderInvasionGenerator generator; - @Override - public void registerChunkComponentFactories(ChunkComponentFactoryRegistry registry) { - registry.register(CHUNK_STATE, chunk -> new EnderInvasionChunkComponent.Impl(EnderInvasionChunkComponent.State.PRE_ECHERITE)); + public EnderInvasion(EnderInvasionGenerator generator) { + this.generator = generator; } - public static void initializeEnderInvasion() { + public void initializeEnderInvasion() { // Prevents clerics from selling ender pearls before the ender invasion has started TradeOffers.PROFESSION_TO_LEVELED_TRADE.get(VillagerProfession.CLERIC).get(4)[2] = new PostEnderInvasionSellItemFactory(Items.ENDER_PEARL, 5, 1, 15); - // Call EnderInvasionHelper.convertChunk when a chunk gets loaded - ServerChunkEvents.CHUNK_LOAD.register(EnderInvasionHelper::convertChunk); + // Call convertChunk when a chunk gets loaded + ServerChunkEvents.CHUNK_LOAD.register(this::convertChunk); + + // Start the ender invasion when Echerite Ore is broken + PlayerBlockBreakEvents.AFTER.register((world, player, pos, state, blockEntity) -> { + if (state.isOf(MotherlodeMaterialsBlocks.ECHERITE_ORE)) { + EnderInvasionComponent component = EnderInvasion.STATE.get(world.getLevelProperties()); - // Convert blocks using BlockRecipeManager.SPREAD and generate decoration - EnderInvasionEvents.CONVERT_BLOCK.register((world, chunk, pos, noise) -> { - EnderInvasionHelper.convert(chunk, BlockRecipeManager.SPREAD, pos); - generateDecoration(world, chunk, pos, EnderInvasionHelper.getNoise(world, pos, DECORATION_NOISE_SCALE)); + if (component.value() == EnderInvasionComponent.State.PRE_ECHERITE) { + component.setValue(EnderInvasionComponent.State.ENDER_INVASION); + + // Send chat message + world.getPlayers().forEach(p -> player.sendMessage(new TranslatableText("message.motherlode-ender-invasion.start").formatted(Formatting.DARK_GREEN), false)); + } + } }); + // Convert blocks using BlockRecipeManager.SPREAD + EnderInvasionEvents.CONVERT_BLOCK.register((world, chunk, pos) -> + EnderInvasionHelper.convert(chunk, BlockRecipeManager.SPREAD, pos)); + // Purify blocks using BlockRecipeManager.PURIFICATION - EnderInvasionEvents.PURIFY_BLOCK.register((world, chunk, pos, noise) -> + EnderInvasionEvents.PURIFY_BLOCK.register((world, chunk, pos) -> EnderInvasionHelper.convert(chunk, BlockRecipeManager.PURIFICATION, pos)); Identifier piglinBarteringLootTable = new Identifier("minecraft", "gameplay/piglin_bartering"); - // Prevents piglins from trading ender pearls before the ender invasion has started + // Override piglin bartering loot table to prevent ender pearls before the ender invasion + // TODO Try to just modify the ender pearl entry instead of overriding the whole thing LootTableLoadingCallback.EVENT.register((resourceManager, lootManager, id, supplier, setter) -> { if (piglinBarteringLootTable.equals(id)) { setter.set(lootManager.getTable(MotherlodeModule.id("gameplay/piglin_bartering"))); @@ -88,43 +92,78 @@ public static void initializeEnderInvasion() { }); } - public static void generateDecoration(ServerWorld world, WorldChunk chunk, BlockPos pos, double noise) { - if (!chunk.getBlockState(pos).isAir() && !chunk.getBlockState(pos).isOf(MotherlodeEnderInvasionBlocks.CORRUPTED_GRASS)) - return; + public void convertChunk(ServerWorld world, WorldChunk chunk) { + final Profiler profiler = world.getProfiler(); + profiler.push("enderinvasion"); + + if (!world.equals(world.getServer().getWorld(World.OVERWORLD))) return; - if (noise >= END_FOAM_NOISE_THRESHOLD && checkEndFoam(chunk, pos)) - chunk.setBlockState(pos, MotherlodeEnderInvasionBlocks.END_FOAM.getDefaultState(), false); + switch (EnderInvasion.STATE.get(world.getLevelProperties()).value()) { + case PRE_ECHERITE: + checkUnaffected(world, chunk); + break; + case ENDER_INVASION: + corruptChunk(world, chunk); + this.generator.generateDecoration(world, chunk); + break; - if (world.getLightLevel(pos) < 15 && noise >= END_CAP_NOISE_THRESHOLD && chunk.getBlockState(pos.down()).isOf(MotherlodeEnderInvasionBlocks.CORRUPTED_DIRT)) { - chunk.setBlockState(pos, MotherlodeEnderInvasionBlocks.END_CAP.getDefaultState(), false); + case POST_ENDER_DRAGON: + if (EnderInvasion.CHUNK_STATE.get(chunk).value() == EnderInvasionChunkComponent.State.PRE_ECHERITE) + corruptChunk(world, chunk); + purifyChunk(world, chunk); + break; } + profiler.pop(); } - public static boolean checkEndFoam(WorldChunk chunk, BlockPos pos) { - boolean ground = false; - for (int i = 3; i > 0; i--) { + public void checkUnaffected(ServerWorld world, WorldChunk chunk) { + EnderInvasionChunkComponent chunkState = EnderInvasion.CHUNK_STATE.get(chunk); - BlockPos blockPos = pos.down(i); - if (chunk.getBlockState(blockPos).isOf(MotherlodeEnderInvasionBlocks.CORRUPTED_DIRT)) { - ground = true; - continue; - } - if (chunk.getBlockState(blockPos).isOf(MotherlodeEnderInvasionBlocks.END_FOAM)) continue; + if (chunkState.value() == EnderInvasionChunkComponent.State.UNAFFECTED) return; - if (ground) { - if (chunk.getBlockState(blockPos).isAir() || MotherlodeEnderInvasionTags.END_FOAM_REPLACEABLE.contains(MotherlodeEnderInvasionBlocks.END_FOAM)) - chunk.setBlockState(blockPos, MotherlodeEnderInvasionBlocks.END_FOAM.getDefaultState(), false); - else return false; - } - } - return ground; + if (this.generator.isChunkUnaffected(world, chunk)) chunkState.setValue( + EnderInvasionChunkComponent.State.UNAFFECTED); + } + + public void corruptChunk(ServerWorld world, WorldChunk chunk) { + final Profiler profiler = world.getProfiler(); + profiler.push("corruptChunk"); + + EnderInvasionChunkComponent chunkState = EnderInvasion.CHUNK_STATE.get(chunk); + + if (chunkState.value() == EnderInvasionChunkComponent.State.ENDER_INVASION + || chunkState.value() == EnderInvasionChunkComponent.State.UNAFFECTED) return; + + boolean unaffected = this.generator.convertChunk(world, chunk); + + chunkState.setValue(unaffected ? EnderInvasionChunkComponent.State.UNAFFECTED : + EnderInvasionChunkComponent.State.ENDER_INVASION); + + profiler.pop(); } - public static void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random) { + public void purifyChunk(ServerWorld world, WorldChunk chunk) { + final Profiler profiler = world.getProfiler(); + profiler.push("purifyChunk"); + + EnderInvasionChunkComponent chunkState = EnderInvasion.CHUNK_STATE.get(chunk); + if (chunkState.value() == EnderInvasionChunkComponent.State.UNAFFECTED + || chunkState.value() == EnderInvasionChunkComponent.State.PURIFIED) return; + + boolean unaffected = this.generator.purifyChunk(world, chunk, + STATE.get(world.getLevelProperties()).getInvasionEndTick() / (double) INVASION_END_TIME); + + chunkState.setValue(unaffected ? EnderInvasionChunkComponent.State.UNAFFECTED : + EnderInvasionChunkComponent.State.PURIFIED); + + profiler.pop(); + } + + public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random) { if (!world.equals(world.getServer().getWorld(World.OVERWORLD))) return; final Profiler profiler = world.getProfiler(); - profiler.push("enderInvasionRandomTick"); + profiler.push("enderInvasionTick"); if (!EnderInvasionHelper.canSurvive(world, pos)) { EnderInvasionHelper.convert(world.getWorldChunk(pos), BlockRecipeManager.PURIFICATION, pos); @@ -133,12 +172,14 @@ public static void randomTick(BlockState state, ServerWorld world, BlockPos pos, return; } - switch (EnderInvasion.STATE.get(world.getLevelProperties()).value()) { + EnderInvasionComponent component = EnderInvasion.STATE.get(world.getLevelProperties()); + + switch (component.value()) { case ENDER_INVASION: - EnderInvasionHelper.spawnParticles(world, pos, random, 4); + EnderInvasionHelper.spawnParticles(world, pos, random, 4, blockPos -> this.generator.isInEnderInvasion(world, pos, 0)); - if (EnderInvasionHelper.getNoise(world, pos, NOISE_SCALE) >= NOISE_THRESHOLD + if (generator.isInEnderInvasion(world, pos, 0) && world.random.nextDouble() < (world.isNight() ? ENDERMAN_SPAWN_RATE_NIGHT : ENDERMAN_SPAWN_RATE_DAY)) { EnderInvasionHelper.spawnMobGroup(world, world.getChunk(pos), EntityType.ENDERMAN, pos, world.getChunkManager().getSpawnInfo()); @@ -151,16 +192,15 @@ public static void randomTick(BlockState state, ServerWorld world, BlockPos pos, if (CHUNK_STATE.get(world.getChunk(pos)).value() == EnderInvasionChunkComponent.State.UNAFFECTED) break; - double noise = EnderInvasionHelper.getNoise(world, pos, NOISE_SCALE); - if (noise < EnderInvasionHelper.getPostEnderDragonNoiseThreshold(world, INVASION_END_TIME, NOISE_THRESHOLD)) - EnderInvasionEvents.PURIFY_BLOCK.invoker().convertBlock(world, world.getWorldChunk(pos), pos, noise); + if (!this.generator.isInEnderInvasion(world, pos, component.getInvasionEndTick() / (double) INVASION_END_TIME)) + EnderInvasionEvents.PURIFY_BLOCK.invoker().convertBlock(world, world.getWorldChunk(pos), pos); break; } profiler.pop(); } - public static void spread(BlockState state, ServerWorld world, BlockPos pos, Random random) { + public void spread(BlockState state, ServerWorld world, BlockPos pos, Random random) { if (!state.isIn(MotherlodeEnderInvasionTags.SPREADABLE)) return; if (world.getDifficulty().getId() < SPREAD_DIFFICULTY.getId()) return; diff --git a/motherlode-ender-invasion/src/main/java/motherlode/enderinvasion/EnderInvasionEvents.java b/motherlode-ender-invasion/src/main/java/motherlode/enderinvasion/EnderInvasionEvents.java index 25e97e4..74847a3 100644 --- a/motherlode-ender-invasion/src/main/java/motherlode/enderinvasion/EnderInvasionEvents.java +++ b/motherlode-ender-invasion/src/main/java/motherlode/enderinvasion/EnderInvasionEvents.java @@ -10,18 +10,18 @@ public class EnderInvasionEvents { /** * Called when a block can be converted. */ - public static final Event CONVERT_BLOCK = EventFactory.createArrayBacked(ConvertBlock.class, callbacks -> (world, chunk, pos, noise) -> { + public static final Event CONVERT_BLOCK = EventFactory.createArrayBacked(ConvertBlock.class, callbacks -> (world, chunk, pos) -> { for (ConvertBlock callback : callbacks) { - callback.convertBlock(world, chunk, pos, noise); + callback.convertBlock(world, chunk, pos); } }); /** * Called when a block can be converted back to its normal form. */ - public static final Event PURIFY_BLOCK = EventFactory.createArrayBacked(ConvertBlock.class, callbacks -> (world, chunk, pos, noise) -> { + public static final Event PURIFY_BLOCK = EventFactory.createArrayBacked(ConvertBlock.class, callbacks -> (world, chunk, pos) -> { for (ConvertBlock callback : callbacks) { - callback.convertBlock(world, chunk, pos, noise); + callback.convertBlock(world, chunk, pos); } }); @@ -37,7 +37,7 @@ public class EnderInvasionEvents { @FunctionalInterface public interface ConvertBlock { - void convertBlock(ServerWorld world, WorldChunk chunk, BlockPos pos, double noise); + void convertBlock(ServerWorld world, WorldChunk chunk, BlockPos pos); } @FunctionalInterface diff --git a/motherlode-ender-invasion/src/main/java/motherlode/enderinvasion/MotherlodeEnderInvasionClient.java b/motherlode-ender-invasion/src/main/java/motherlode/enderinvasion/MotherlodeEnderInvasionClient.java index 54c04e1..9673d77 100644 --- a/motherlode-ender-invasion/src/main/java/motherlode/enderinvasion/MotherlodeEnderInvasionClient.java +++ b/motherlode-ender-invasion/src/main/java/motherlode/enderinvasion/MotherlodeEnderInvasionClient.java @@ -8,6 +8,7 @@ public class MotherlodeEnderInvasionClient implements ClientModInitializer { @Override public void onInitializeClient() { BlockRenderLayerMap.INSTANCE.putBlock(MotherlodeEnderInvasionBlocks.END_FOAM, RenderLayer.getTranslucent()); + BlockRenderLayerMap.INSTANCE.putBlock(MotherlodeEnderInvasionBlocks.CORRUPTED_GRASS, RenderLayer.getCutout()); BlockRenderLayerMap.INSTANCE.putBlock(MotherlodeEnderInvasionBlocks.WITHERED_OAK_LEAVES, RenderLayer.getCutoutMipped()); BlockRenderLayerMap.INSTANCE.putBlock(MotherlodeEnderInvasionBlocks.WITHERED_DARK_OAK_LEAVES, RenderLayer.getCutoutMipped()); diff --git a/motherlode-ender-invasion/src/main/java/motherlode/enderinvasion/MotherlodeModule.java b/motherlode-ender-invasion/src/main/java/motherlode/enderinvasion/MotherlodeModule.java index 6b6b4bd..80e570d 100644 --- a/motherlode-ender-invasion/src/main/java/motherlode/enderinvasion/MotherlodeModule.java +++ b/motherlode-ender-invasion/src/main/java/motherlode/enderinvasion/MotherlodeModule.java @@ -3,20 +3,43 @@ import net.minecraft.util.Identifier; import net.fabricmc.api.ModInitializer; import motherlode.base.Motherlode; +import motherlode.enderinvasion.component.EnderInvasionChunkComponent; +import motherlode.enderinvasion.component.EnderInvasionComponent; +import motherlode.enderinvasion.impl.EnderInvasionImpl; import motherlode.enderinvasion.recipe.MotherlodeSpreadRecipes; +import dev.onyxstudios.cca.api.v3.chunk.ChunkComponentFactoryRegistry; +import dev.onyxstudios.cca.api.v3.chunk.ChunkComponentInitializer; +import dev.onyxstudios.cca.api.v3.level.LevelComponentFactoryRegistry; +import dev.onyxstudios.cca.api.v3.level.LevelComponentInitializer; import org.apache.logging.log4j.Level; -public class MotherlodeModule implements ModInitializer { +public class MotherlodeModule implements ModInitializer, LevelComponentInitializer, ChunkComponentInitializer { public static final String MODID = "motherlode-ender-invasion"; + private static final EnderInvasion ENDER_INVASION = new EnderInvasion(new EnderInvasionImpl()); + @Override public void onInitialize() { - EnderInvasion.initializeEnderInvasion(); + getEnderInvasion().initializeEnderInvasion(); MotherlodeEnderInvasionBlocks.init(); MotherlodeEnderInvasionTags.init(); MotherlodeSpreadRecipes.register(); } + public static EnderInvasion getEnderInvasion() { + return ENDER_INVASION; + } + + @Override + public void registerLevelComponentFactories(LevelComponentFactoryRegistry registry) { + registry.register(EnderInvasion.STATE, worldProperties -> new EnderInvasionComponent.Impl(EnderInvasionComponent.State.PRE_ECHERITE)); + } + + @Override + public void registerChunkComponentFactories(ChunkComponentFactoryRegistry registry) { + registry.register(EnderInvasion.CHUNK_STATE, chunk -> new EnderInvasionChunkComponent.Impl(EnderInvasionChunkComponent.State.PRE_ECHERITE)); + } + public static void log(Level level, CharSequence message) { Motherlode.log(level, "Motherlode Ender Invasion", message); } diff --git a/motherlode-ender-invasion/src/main/java/motherlode/enderinvasion/component/EnderInvasionChunkComponent.java b/motherlode-ender-invasion/src/main/java/motherlode/enderinvasion/component/EnderInvasionChunkComponent.java index 987701b..494596f 100644 --- a/motherlode-ender-invasion/src/main/java/motherlode/enderinvasion/component/EnderInvasionChunkComponent.java +++ b/motherlode-ender-invasion/src/main/java/motherlode/enderinvasion/component/EnderInvasionChunkComponent.java @@ -8,7 +8,7 @@ public interface EnderInvasionChunkComponent extends ComponentV3, CopyableComponent { enum State { - UNAFFECTED, PRE_ECHERITE, ENDER_INVASION + UNAFFECTED, PRE_ECHERITE, ENDER_INVASION, PURIFIED } State value(); diff --git a/motherlode-ender-invasion/src/main/java/motherlode/enderinvasion/impl/EnderInvasionGenerator.java b/motherlode-ender-invasion/src/main/java/motherlode/enderinvasion/impl/EnderInvasionGenerator.java new file mode 100644 index 0000000..1112d99 --- /dev/null +++ b/motherlode-ender-invasion/src/main/java/motherlode/enderinvasion/impl/EnderInvasionGenerator.java @@ -0,0 +1,16 @@ +package motherlode.enderinvasion.impl; + +import net.minecraft.server.world.ServerWorld; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.chunk.WorldChunk; + +public interface EnderInvasionGenerator { + boolean isInEnderInvasion(ServerWorld world, BlockPos pos, double purificationProgress); + + boolean isChunkUnaffected(ServerWorld world, WorldChunk chunk); + + boolean convertChunk(ServerWorld world, WorldChunk chunk); + boolean purifyChunk(ServerWorld world, WorldChunk chunk, double purificationProgress); + + void generateDecoration(ServerWorld world, WorldChunk chunk); +} diff --git a/motherlode-ender-invasion/src/main/java/motherlode/enderinvasion/impl/EnderInvasionImpl.java b/motherlode-ender-invasion/src/main/java/motherlode/enderinvasion/impl/EnderInvasionImpl.java new file mode 100644 index 0000000..f638f7f --- /dev/null +++ b/motherlode-ender-invasion/src/main/java/motherlode/enderinvasion/impl/EnderInvasionImpl.java @@ -0,0 +1,150 @@ +package motherlode.enderinvasion.impl; + +import net.minecraft.server.world.ServerWorld; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.noise.SimplexNoiseSampler; +import net.minecraft.world.biome.source.SeedMixer; +import net.minecraft.world.chunk.WorldChunk; +import net.minecraft.world.gen.SimpleRandom; +import motherlode.enderinvasion.EnderInvasionEvents; +import motherlode.enderinvasion.util.EnderInvasionHelper; + +public class EnderInvasionImpl implements EnderInvasionGenerator { + private static final double PLACEMENT_NOISE_SCALE = 0.0001; + private static final double PLACEMENT_NOISE_THRESHOLD = 0.5; + + private static final double HEIGHT_OFFSET_NOISE_SCALE = 0.0015; + private static final double HEIGHT_OFFSET_NOISE_FACTOR = 32; + + private static final double SPREAD_NOISE_SCALE = 0.00075; + private static final double SPREAD_NOISE_FACTOR = 48; + + private SimplexNoiseSampler placementNoise; + private SimplexNoiseSampler heightOffsetNoise; + private SimplexNoiseSampler spreadNoise; + + private long lastSeed; + + public EnderInvasionImpl() { + this.lastSeed = -1; + this.updateNoiseSamplers(0); // lastSeed = 0 + } + + @Override + public boolean isInEnderInvasion(ServerWorld world, BlockPos pos, double purificationProgress) { + updateNoiseSamplers(world.getSeed()); + + if (!this.isInEnderInvasion(pos.getX(), pos.getZ(), 1 - purificationProgress)) return false; + + int baseline = this.getBaseline(world.getSeaLevel(), pos.getX(), pos.getZ()); + int spread = this.getSpread(pos.getX(), pos.getZ(), 1 - purificationProgress); + + return (pos.getY() > baseline - spread) && (pos.getY() < baseline + spread); + } + + @Override + public boolean isChunkUnaffected(ServerWorld world, WorldChunk chunk) { + for (int i = 0; i < 16; i++) { + for (int j = 0; j < 16; j++) { + if (this.isInEnderInvasion(chunk.getPos().getStartX() + i, chunk.getPos().getStartZ() + j, 1)) + return false; + } + } + + return true; + } + + @Override + public boolean convertChunk(ServerWorld world, WorldChunk chunk) { + EnderInvasionHelper.WrappedBoolean unaffected = new EnderInvasionHelper.WrappedBoolean(true); + + for (int i = 0; i < 16; i++) { + for (int j = 0; j < 16; j++) { + int x = chunk.getPos().getStartX() + i; + int z = chunk.getPos().getStartZ() + j; + + if (!this.isInEnderInvasion(x, z, 1)) continue; + unaffected.set(false); + + int baseline = this.getBaseline(world.getSeaLevel(), x, z); + int spread = this.getSpread(x, z, 1); + + for (int y = baseline - spread + 1; y < baseline + spread; y++) { + if (y < world.getBottomY() || y > world.getBottomY() + world.getLogicalHeight()) continue; + + EnderInvasionEvents.CONVERT_BLOCK.invoker().convertBlock(world, chunk, new BlockPos(x, y, z)); + } + } + } + + EnderInvasionEvents.AFTER_CHUNK_CONVERSION.invoker().afterConversion(world, chunk); + + return unaffected.get(); + } + + @Override + public boolean purifyChunk(ServerWorld world, WorldChunk chunk, double purificationProgress) { + EnderInvasionHelper.WrappedBoolean unaffected = new EnderInvasionHelper.WrappedBoolean(true); + + for (int i = 0; i < 16; i++) { + for (int j = 0; j < 16; j++) { + int x = chunk.getPos().getStartX() + i; + int z = chunk.getPos().getStartZ() + j; + + if (!this.isInEnderInvasion(x, z, 1)) continue; + unaffected.set(false); + + int baseline = this.getBaseline(world.getSeaLevel(), x, z); + int spread = this.getSpread(x, z, 1); + int purifiedSpread = this.getSpread(x, z, 1 - purificationProgress); + + for (int y = baseline - spread + 1; y < baseline - purifiedSpread; y++) { + if (y < world.getBottomY() || y > world.getBottomY() + world.getLogicalHeight()) continue; + + EnderInvasionEvents.PURIFY_BLOCK.invoker().convertBlock(world, chunk, new BlockPos(x, y, z)); + } + + for (int y = baseline + purifiedSpread + 1; y < baseline + spread; y++) { + if (y < world.getBottomY() || y > world.getBottomY() + world.getLogicalHeight()) continue; + + EnderInvasionEvents.PURIFY_BLOCK.invoker().convertBlock(world, chunk, new BlockPos(x, y, z)); + } + } + } + + return unaffected.get(); + } + + @Override + public void generateDecoration(ServerWorld world, WorldChunk chunk) { + // TODO + } + + private int getSpread(int x, int z, double purificationProgress) { + return Math.abs((int) (this.spreadNoise.sample(x * SPREAD_NOISE_SCALE, z * SPREAD_NOISE_SCALE) * purificationProgress * SPREAD_NOISE_FACTOR)); + } + + private int getBaseline(int seaLevel, int x, int z) { + double noise = this.heightOffsetNoise.sample(x * HEIGHT_OFFSET_NOISE_SCALE, z * HEIGHT_OFFSET_NOISE_SCALE); + int offset = (int) (noise * HEIGHT_OFFSET_NOISE_FACTOR); + + return seaLevel + offset; + } + + private boolean isInEnderInvasion(double x, double y, double purificationProgress) { + return getPlacementNoise(x, y, purificationProgress) >= PLACEMENT_NOISE_THRESHOLD; + } + + private double getPlacementNoise(double x, double y, double purificationProgress) { + return this.placementNoise.sample(x * PLACEMENT_NOISE_SCALE, y * PLACEMENT_NOISE_SCALE) * purificationProgress; + } + + private void updateNoiseSamplers(long seed) { + if (this.lastSeed == seed) return; + this.lastSeed = seed; + + this.placementNoise = new SimplexNoiseSampler(new SimpleRandom(SeedMixer.mixSeed(seed, 10L))); + this.heightOffsetNoise = new SimplexNoiseSampler(new SimpleRandom(SeedMixer.mixSeed(seed, 20L))); + this.spreadNoise = new SimplexNoiseSampler(new SimpleRandom(SeedMixer.mixSeed(seed, 30L))); + } +} diff --git a/motherlode-ender-invasion/src/main/java/motherlode/enderinvasion/impl/OldEnderInvasionImpl.java b/motherlode-ender-invasion/src/main/java/motherlode/enderinvasion/impl/OldEnderInvasionImpl.java new file mode 100644 index 0000000..975af05 --- /dev/null +++ b/motherlode-ender-invasion/src/main/java/motherlode/enderinvasion/impl/OldEnderInvasionImpl.java @@ -0,0 +1,128 @@ +package motherlode.enderinvasion.impl; + +import net.minecraft.server.world.ServerWorld; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Vec3i; +import net.minecraft.util.math.noise.SimplexNoiseSampler; +import net.minecraft.world.chunk.WorldChunk; +import net.minecraft.world.gen.SimpleRandom; +import motherlode.enderinvasion.EnderInvasionEvents; +import motherlode.enderinvasion.MotherlodeEnderInvasionBlocks; +import motherlode.enderinvasion.MotherlodeEnderInvasionTags; +import motherlode.enderinvasion.util.EnderInvasionHelper; + +public class OldEnderInvasionImpl implements EnderInvasionGenerator { + public static final double NOISE_THRESHOLD = 0.75; + public static final double NOISE_SCALE = 0.002; + public static final double END_CAP_NOISE_THRESHOLD = 0.75; + public static final double END_FOAM_NOISE_THRESHOLD = 0.9; + public static final double DECORATION_NOISE_SCALE = 0.05; + + private static SimplexNoiseSampler NOISE_GENERATOR; + private static long NOISE_GENERATOR_SEED; + + @Override + public boolean isInEnderInvasion(ServerWorld world, BlockPos pos, double purificationProgress) { + return getNoise(world.getSeed(), pos, NOISE_SCALE) >= getPostEnderDragonNoiseThreshold(NOISE_THRESHOLD, purificationProgress); + } + + @Override + public boolean isChunkUnaffected(ServerWorld world, WorldChunk chunk) { + EnderInvasionHelper.WrappedBoolean unaffected = new EnderInvasionHelper.WrappedBoolean(true); + + EnderInvasionHelper.forEachBlock(chunk, (c, pos) -> { + if (isInEnderInvasion(world, pos, 0)) + unaffected.set(false); + }); + + return unaffected.get(); + } + + @Override + public boolean convertChunk(ServerWorld world, WorldChunk chunk) { + EnderInvasionHelper.WrappedBoolean unaffected = new EnderInvasionHelper.WrappedBoolean(true); + + EnderInvasionHelper.forEachBlock(chunk, (c, pos) -> { + if (isInEnderInvasion(world, pos, 0)) { + unaffected.set(false); + + EnderInvasionEvents.CONVERT_BLOCK.invoker().convertBlock(world, c, pos); + + this.generateDecoration(world, chunk, pos, getNoise(world.getSeed(), pos, DECORATION_NOISE_SCALE)); + } + }); + + EnderInvasionEvents.AFTER_CHUNK_CONVERSION.invoker().afterConversion(world, chunk); + + return unaffected.get(); + } + + @Override + public boolean purifyChunk(ServerWorld world, WorldChunk chunk, double purificationProgress) { + EnderInvasionHelper.WrappedBoolean unaffected = new EnderInvasionHelper.WrappedBoolean(true); + + EnderInvasionHelper.forEachBlock(chunk, (c, pos) -> { + if (!isInEnderInvasion(world, pos, purificationProgress)) { + unaffected.set(false); + + EnderInvasionEvents.PURIFY_BLOCK.invoker().convertBlock(world, c, pos); + } + }); + + return unaffected.get(); + } + + @Override + public void generateDecoration(ServerWorld world, WorldChunk chunk) { + // Empty + } + + public void generateDecoration(ServerWorld world, WorldChunk chunk, BlockPos pos, double noise) { + if (!chunk.getBlockState(pos).isAir() && !chunk.getBlockState(pos).isOf(MotherlodeEnderInvasionBlocks.CORRUPTED_GRASS)) + return; + + if (noise >= END_FOAM_NOISE_THRESHOLD && checkEndFoam(chunk, pos)) + chunk.setBlockState(pos, MotherlodeEnderInvasionBlocks.END_FOAM.getDefaultState(), false); + + if (world.getLightLevel(pos) < 15 && noise >= END_CAP_NOISE_THRESHOLD && chunk.getBlockState(pos.down()).isOf(MotherlodeEnderInvasionBlocks.CORRUPTED_DIRT)) { + chunk.setBlockState(pos, MotherlodeEnderInvasionBlocks.END_CAP.getDefaultState(), false); + } + } + + public boolean checkEndFoam(WorldChunk chunk, BlockPos pos) { + boolean ground = false; + for (int i = 3; i > 0; i--) { + + BlockPos blockPos = pos.down(i); + if (chunk.getBlockState(blockPos).isOf(MotherlodeEnderInvasionBlocks.CORRUPTED_DIRT)) { + ground = true; + continue; + } + if (chunk.getBlockState(blockPos).isOf(MotherlodeEnderInvasionBlocks.END_FOAM)) continue; + + if (ground) { + if (chunk.getBlockState(blockPos).isAir() || MotherlodeEnderInvasionTags.END_FOAM_REPLACEABLE.contains(MotherlodeEnderInvasionBlocks.END_FOAM)) + chunk.setBlockState(blockPos, MotherlodeEnderInvasionBlocks.END_FOAM.getDefaultState(), false); + else return false; + } + } + return ground; + } + + private static SimplexNoiseSampler getNoiseSampler(long seed) { + if (NOISE_GENERATOR == null || NOISE_GENERATOR_SEED != seed) { + + NOISE_GENERATOR = new SimplexNoiseSampler(new SimpleRandom(seed)); + NOISE_GENERATOR_SEED = seed; + } + return NOISE_GENERATOR; + } + + public static double getNoise(long seed, Vec3i pos, double scale) { + return getNoiseSampler(seed).sample(pos.getX() * scale, pos.getY() * scale, pos.getZ() * scale); + } + + public static double getPostEnderDragonNoiseThreshold(double normalThreshold, double progress) { + return (progress - progress * normalThreshold) + normalThreshold; + } +} diff --git a/motherlode-ender-invasion/src/main/java/motherlode/enderinvasion/mixin/ServerWorldMixin.java b/motherlode-ender-invasion/src/main/java/motherlode/enderinvasion/mixin/ServerWorldMixin.java index e9d262e..176a32d 100644 --- a/motherlode-ender-invasion/src/main/java/motherlode/enderinvasion/mixin/ServerWorldMixin.java +++ b/motherlode-ender-invasion/src/main/java/motherlode/enderinvasion/mixin/ServerWorldMixin.java @@ -10,7 +10,7 @@ import net.minecraft.world.MutableWorldProperties; import net.minecraft.world.World; import net.minecraft.world.dimension.DimensionType; -import motherlode.enderinvasion.EnderInvasion; +import motherlode.enderinvasion.MotherlodeModule; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; @@ -28,7 +28,7 @@ public boolean redirectHasRandomTicks(BlockState state) { @Redirect(method = "tickChunk", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BlockState;randomTick(Lnet/minecraft/server/world/ServerWorld;Lnet/minecraft/util/math/BlockPos;Ljava/util/Random;)V")) public void redirectRandomTick(BlockState state, ServerWorld world, BlockPos pos, Random random) { - EnderInvasion.randomTick(state, world, pos, random); + MotherlodeModule.getEnderInvasion().randomTick(state, world, pos, random); if (state.hasRandomTicks()) state.randomTick(world, pos, random); } diff --git a/motherlode-ender-invasion/src/main/java/motherlode/enderinvasion/recipe/MotherlodeSpreadRecipes.java b/motherlode-ender-invasion/src/main/java/motherlode/enderinvasion/recipe/MotherlodeSpreadRecipes.java index 6ce1794..95652e5 100644 --- a/motherlode-ender-invasion/src/main/java/motherlode/enderinvasion/recipe/MotherlodeSpreadRecipes.java +++ b/motherlode-ender-invasion/src/main/java/motherlode/enderinvasion/recipe/MotherlodeSpreadRecipes.java @@ -5,6 +5,7 @@ import net.minecraft.block.LeavesBlock; import net.minecraft.block.PillarBlock; import net.minecraft.tag.BlockTags; +import motherlode.biomes.MotherlodeBiomesBlocks; import motherlode.enderinvasion.MotherlodeEnderInvasionBlocks; import static motherlode.enderinvasion.MotherlodeModule.id; import static motherlode.enderinvasion.recipe.BlockRecipeManager.PURIFICATION; @@ -19,7 +20,7 @@ public static void register() { addSimpleRecipe(SPREAD, id("stone_to_end_stone"), Blocks.STONE, Blocks.END_STONE); addSimpleRecipe(SPREAD, id("grass_to_corrupted_grass"), Blocks.GRASS, MotherlodeEnderInvasionBlocks.CORRUPTED_GRASS); addSimpleRecipe(SPREAD, id("ferns_to_corrupted_grass"), Blocks.FERN, MotherlodeEnderInvasionBlocks.CORRUPTED_GRASS); - // addSimpleRecipe(SPREAD, id("sprouts_to_corrupted_grass"), MotherlodeEnderInvasionBlocks.SPROUTS, MotherlodeEnderInvasionBlocks.CORRUPTED_GRASS); // TODO + addSimpleRecipe(SPREAD, id("sprouts_to_corrupted_grass"), MotherlodeBiomesBlocks.SPROUTS, MotherlodeEnderInvasionBlocks.CORRUPTED_GRASS); addSimpleRecipe(SPREAD, id("brown_mushroom_to_end_cap"), Blocks.BROWN_MUSHROOM, MotherlodeEnderInvasionBlocks.END_CAP); addSimpleRecipe(SPREAD, id("red_mushroom_to_end_cap"), Blocks.RED_MUSHROOM, MotherlodeEnderInvasionBlocks.END_CAP); addRecipe(SPREAD, id("logs_to_withered_log"), BlockTags.LOGS::contains, state -> MotherlodeEnderInvasionBlocks.WITHERED_LOG.getDefaultState() diff --git a/motherlode-ender-invasion/src/main/java/motherlode/enderinvasion/util/EnderInvasionHelper.java b/motherlode-ender-invasion/src/main/java/motherlode/enderinvasion/util/EnderInvasionHelper.java index 3290414..4dc94d2 100644 --- a/motherlode-ender-invasion/src/main/java/motherlode/enderinvasion/util/EnderInvasionHelper.java +++ b/motherlode-ender-invasion/src/main/java/motherlode/enderinvasion/util/EnderInvasionHelper.java @@ -3,6 +3,7 @@ import java.util.Optional; import java.util.Random; import java.util.function.BiConsumer; +import java.util.function.Predicate; import java.util.stream.Stream; import net.minecraft.block.BlockState; import net.minecraft.entity.EntityData; @@ -18,97 +19,17 @@ import net.minecraft.util.math.Direction; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3i; -import net.minecraft.util.math.noise.SimplexNoiseSampler; -import net.minecraft.util.profiler.Profiler; import net.minecraft.world.GameRules; import net.minecraft.world.SpawnHelper; -import net.minecraft.world.World; import net.minecraft.world.WorldView; import net.minecraft.world.chunk.Chunk; import net.minecraft.world.chunk.WorldChunk; -import net.fabricmc.fabric.api.network.ServerSidePacketRegistry; import net.fabricmc.fabric.api.server.PlayerStream; -import motherlode.enderinvasion.EnderInvasion; -import motherlode.enderinvasion.EnderInvasionEvents; -import motherlode.enderinvasion.component.EnderInvasionChunkComponent; import motherlode.enderinvasion.mixin.SpawnHelperAccessor; import motherlode.enderinvasion.recipe.BlockRecipeManager; import io.netty.buffer.Unpooled; public class EnderInvasionHelper { - private static SimplexNoiseSampler NOISE_GENERATOR; - private static long NOISE_GENERATOR_SEED; - - public static void convertChunk(ServerWorld world, WorldChunk chunk) { - final Profiler profiler = world.getProfiler(); - profiler.push("enderinvasion"); - - if (!world.equals(world.getServer().getWorld(World.OVERWORLD))) return; - - switch (EnderInvasion.STATE.get(world.getLevelProperties()).value()) { - case ENDER_INVASION: - corruptChunk(world, chunk); - break; - - case POST_ENDER_DRAGON: - if (EnderInvasion.CHUNK_STATE.get(chunk).value() == EnderInvasionChunkComponent.State.PRE_ECHERITE) - corruptChunk(world, chunk); - purifyChunk(world, chunk); - break; - } - profiler.pop(); - } - - public static void corruptChunk(ServerWorld world, WorldChunk chunk) { - final Profiler profiler = world.getProfiler(); - profiler.push("corruptChunk"); - - EnderInvasionChunkComponent chunkState = EnderInvasion.CHUNK_STATE.get(chunk); - - if (chunkState.value() == EnderInvasionChunkComponent.State.ENDER_INVASION - || chunkState.value() == EnderInvasionChunkComponent.State.UNAFFECTED) return; - - WrappedBoolean unaffected = new WrappedBoolean(true); - - forEachBlock(chunk, (c, pos) -> { - double noise = getNoise(world, pos, EnderInvasion.NOISE_SCALE); - if (noise >= EnderInvasion.NOISE_THRESHOLD) { - unaffected.set(false); - - EnderInvasionEvents.CONVERT_BLOCK.invoker().convertBlock(world, c, pos, noise); - } - }); - EnderInvasionEvents.AFTER_CHUNK_CONVERSION.invoker().afterConversion(world, chunk); - - chunkState.setValue(unaffected.get() ? EnderInvasionChunkComponent.State.UNAFFECTED : - EnderInvasionChunkComponent.State.ENDER_INVASION); - - profiler.pop(); - } - - public static void purifyChunk(ServerWorld world, WorldChunk chunk) { - final Profiler profiler = world.getProfiler(); - profiler.push("purifyChunk"); - - EnderInvasionChunkComponent chunkState = EnderInvasion.CHUNK_STATE.get(chunk); - if (chunkState.value() == EnderInvasionChunkComponent.State.UNAFFECTED) return; - - double noiseThreshold = getPostEnderDragonNoiseThreshold(world, EnderInvasion.INVASION_END_TIME, EnderInvasion.NOISE_THRESHOLD); - WrappedBoolean unaffected = new WrappedBoolean(true); - - forEachBlock(chunk, (c, pos) -> { - double noise = getNoise(world, pos, EnderInvasion.NOISE_SCALE); - if (noise < noiseThreshold) { - unaffected.set(false); - - EnderInvasionEvents.PURIFY_BLOCK.invoker().convertBlock(world, c, pos, noise); - } - }); - if (unaffected.get()) chunkState.setValue(EnderInvasionChunkComponent.State.UNAFFECTED); - - profiler.pop(); - } - public static void forEachBlock(T chunk, BiConsumer consumer) { int maxY = chunk.getHighestNonEmptySectionYOffset() * 16; @@ -121,31 +42,6 @@ public static void forEachBlock(T chunk, BiConsumer 1) - throw new IllegalArgumentException("Normal threshold can't be greater than 1: " + normalThreshold); - int endTick = EnderInvasion.STATE.get(world.getLevelProperties()).getInvasionEndTick(); - int ticksPassed = world.getServer().getTicks() - endTick; - if (ticksPassed >= time) return -1; - - double mark = ticksPassed / (double) time; - return (mark - mark * normalThreshold) + normalThreshold; - } - - private static SimplexNoiseSampler getNoiseSampler(ServerWorld world) { - if (NOISE_GENERATOR == null || NOISE_GENERATOR_SEED != world.getSeed()) { - - NOISE_GENERATOR = new SimplexNoiseSampler(new Random(world.getSeed())); - NOISE_GENERATOR_SEED = world.getSeed(); - } - return NOISE_GENERATOR; - } - - public static double getNoise(ServerWorld world, Vec3i pos, double scale) { - return getNoiseSampler(world).method_22416(pos.getX() * scale, pos.getY() * scale, pos.getZ() * scale); - } - // Spawns a group of mobs public static void spawnMobGroup(ServerWorld world, Chunk chunk, EntityType entityType, BlockPos pos, SpawnHelper.Info info) { if (((SpawnHelperAccessor.Info) info).callIsBelowCap(entityType.getSpawnGroup())) { @@ -251,16 +147,15 @@ public static void convert(WorldChunk chunk, BlockRecipeManager manager, BlockPo // Returns a Vec3i where x and z can be from -1 to 1, and y can be from -2 to 2 public static Vec3i randomNearbyBlockPos(Random random) { - return new Vec3i(random.nextInt(3) - 1, random.nextInt(5) - 2, random.nextInt(3) - 1); } - public static void spawnParticles(ServerWorld world, BlockPos pos, Random random, int tries) { + public static void spawnParticles(ServerWorld world, BlockPos pos, Random random, int tries, Predicate inEnderInvasion) { for (int i = 0; i < tries; i++) { BlockPos blockPos = pos.add(random.nextInt(5) - 2, random.nextInt(5) - 2, random.nextInt(5) - 2); BlockState blockState = world.getBlockState(blockPos); - if (!blockState.isAir() && !world.getBlockState(blockPos.up()).getMaterial().isSolid() && EnderInvasionHelper.getNoise(world, blockPos, EnderInvasion.NOISE_SCALE) >= EnderInvasion.NOISE_THRESHOLD) { + if (!blockState.isAir() && !world.getBlockState(blockPos.up()).getMaterial().isSolid() && inEnderInvasion.test(blockPos)) { Stream watchingPlayers = PlayerStream.watching(world, blockPos); PacketByteBuf passedData = new PacketByteBuf(Unpooled.buffer()); passedData.writeBlockPos(blockPos); @@ -270,16 +165,16 @@ public static void spawnParticles(ServerWorld world, BlockPos pos, Random random passedData.writeDouble((random.nextDouble() + 0.3) * 4); passedData.writeDouble(random.nextDouble() * 2 - 1); - watchingPlayers.forEach(player -> - ServerSidePacketRegistry.INSTANCE.sendToPlayer(player, EnderInvasion.PLAY_PORTAL_PARTICLE_PACKET_ID, passedData)); + /* watchingPlayers.forEach(player -> + ServerSidePacketRegistry.INSTANCE.sendToPlayer(player, EnderInvasion.PLAY_PORTAL_PARTICLE_PACKET_ID, passedData)); */ // TODO } } } - private static class WrappedBoolean { + public static class WrappedBoolean { private boolean value; - WrappedBoolean(boolean value) { + public WrappedBoolean(boolean value) { this.value = value; } diff --git a/motherlode-ender-invasion/src/main/resources/assets/motherlode-ender-invasion/lang/en_us.json b/motherlode-ender-invasion/src/main/resources/assets/motherlode-ender-invasion/lang/en_us.json new file mode 100644 index 0000000..e40b454 --- /dev/null +++ b/motherlode-ender-invasion/src/main/resources/assets/motherlode-ender-invasion/lang/en_us.json @@ -0,0 +1,3 @@ +{ + "message.motherlode-ender-invasion.start": "The ender invasion has begun..." +} \ No newline at end of file diff --git a/motherlode-ender-invasion/src/main/resources/fabric.mod.json b/motherlode-ender-invasion/src/main/resources/fabric.mod.json index c7e2d3d..3faa7f7 100644 --- a/motherlode-ender-invasion/src/main/resources/fabric.mod.json +++ b/motherlode-ender-invasion/src/main/resources/fabric.mod.json @@ -20,7 +20,7 @@ "motherlode.enderinvasion.MotherlodeModule" ], "cardinal-components": [ - "motherlode.enderinvasion.EnderInvasion" + "motherlode.enderinvasion.MotherlodeModule" ], "client": [ "motherlode.enderinvasion.MotherlodeEnderInvasionClient" @@ -34,7 +34,8 @@ "fabric": ">=0.25.0", "minecraft": "1.17.x", "motherlode-base": "*", - "motherlode-materials": "^1.0.0" + "motherlode-materials": "^1.0.0", + "motherlode-biomes": "*" }, "suggests": { }, diff --git a/motherlode-ender-invasion/src/main/resources/motherlode-ender-invasion.mixins.json b/motherlode-ender-invasion/src/main/resources/motherlode-ender-invasion.mixins.json index d3be8e2..81446b2 100644 --- a/motherlode-ender-invasion/src/main/resources/motherlode-ender-invasion.mixins.json +++ b/motherlode-ender-invasion/src/main/resources/motherlode-ender-invasion.mixins.json @@ -8,7 +8,8 @@ "mixins": [ "MobEntityMixin", "ServerWorldMixin", - "SpawnHelperAccessor" + "SpawnHelperAccessor", + "SpawnHelperAccessor$Info" ], "client": [ ] diff --git a/settings.gradle b/settings.gradle index 20e2669..00665eb 100644 --- a/settings.gradle +++ b/settings.gradle @@ -12,7 +12,7 @@ rootProject.name = "motherlode" include 'motherlode-base' include 'motherlode-materials' -// include 'motherlode-ender-invasion' +include 'motherlode-ender-invasion' include 'motherlode-copper-dungeon' include 'motherlode-building-blocks' include 'motherlode-biomes'