From 5faafdc7ef69e5dee3cc2762ca74cb0cc0107b22 Mon Sep 17 00:00:00 2001 From: Justin Zhang <2691475984@qq.com> Date: Wed, 24 Jan 2024 23:41:51 +0800 Subject: [PATCH 1/3] Fix render bugs --- build.gradle | 4 ++-- .../top/xdi8/mod/firefly8/forge/Firefly8Forge.java | 6 ++++++ .../top/xdi8/mod/firefly8/FireflyClientSetup.java | 13 ++++--------- .../data/firefly8/tags/items/cedar_logs.json | 9 +++++++++ 4 files changed, 21 insertions(+), 11 deletions(-) create mode 100644 src/main/resources/data/firefly8/tags/items/cedar_logs.json diff --git a/build.gradle b/build.gradle index 9de8444a..54c7c372 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ plugins { id "idea" id "java" id ("architectury-plugin") version "3.4-SNAPSHOT" - id ("dev.architectury.loom") version "1.1-SNAPSHOT" + id ("dev.architectury.loom") version "1.0-SNAPSHOT" //id 'org.jetbrains.kotlin.jvm' version '1.6.20' id ("com.github.johnrengelman.shadow") version "7.1.2" apply false id "maven-publish" @@ -44,7 +44,7 @@ allprojects { apply plugin: "io.github.juuxel.loom-vineflower" apply plugin: "maven-publish" - version = "1.18.2-2.0.0-beta3+build.${Constant.timestamp}" + version = "1.18.2-2.0.0-beta4+build.${Constant.timestamp}" group = "top.xdi8.mod" archivesBaseName = "Xdi8aho-Mod" diff --git a/forge/src/main/java/top/xdi8/mod/firefly8/forge/Firefly8Forge.java b/forge/src/main/java/top/xdi8/mod/firefly8/forge/Firefly8Forge.java index 19e81fa4..b49663ee 100644 --- a/forge/src/main/java/top/xdi8/mod/firefly8/forge/Firefly8Forge.java +++ b/forge/src/main/java/top/xdi8/mod/firefly8/forge/Firefly8Forge.java @@ -2,6 +2,8 @@ import dev.architectury.platform.forge.EventBuses; import dev.architectury.registry.client.particle.ParticleProviderRegistry; +import dev.architectury.registry.client.rendering.RenderTypeRegistry; +import net.minecraft.client.renderer.RenderType; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.eventbus.api.SubscribeEvent; @@ -11,6 +13,7 @@ import net.minecraftforge.forgespi.Environment; import top.xdi8.mod.firefly8.Firefly8; import top.xdi8.mod.firefly8.FireflyClientSetup; +import top.xdi8.mod.firefly8.block.FireflyBlocks; import top.xdi8.mod.firefly8.client.FireflyParticle; import top.xdi8.mod.firefly8.network.FireflyNetwork; import top.xdi8.mod.firefly8.particle.FireflyParticles; @@ -45,6 +48,9 @@ public static final class ClientSetup { @SubscribeEvent public static void onClientSetup(FMLClientSetupEvent event) { event.enqueueWork(new FireflyClientSetup()); + RenderTypeRegistry.register(RenderType.cutoutMipped(), FireflyBlocks.XDI8AHO_PORTAL_TOP_BLOCK.get(), FireflyBlocks.CEDAR_LEAVES.get()); + RenderTypeRegistry.register(RenderType.cutout(), FireflyBlocks.XDI8AHO_BACK_FIRE_BLOCK.get(), FireflyBlocks.CEDAR_SAPLING.get(), + FireflyBlocks.CEDAR_TRAPDOOR.get(), FireflyBlocks.CEDAR_DOOR.get()); } } } diff --git a/src/main/java/top/xdi8/mod/firefly8/FireflyClientSetup.java b/src/main/java/top/xdi8/mod/firefly8/FireflyClientSetup.java index ec93fc19..94d8c77d 100644 --- a/src/main/java/top/xdi8/mod/firefly8/FireflyClientSetup.java +++ b/src/main/java/top/xdi8/mod/firefly8/FireflyClientSetup.java @@ -1,6 +1,7 @@ package top.xdi8.mod.firefly8; import dev.architectury.registry.client.rendering.ColorHandlerRegistry; +import dev.architectury.registry.client.rendering.RenderTypeRegistry; import dev.architectury.registry.menu.MenuRegistry; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.BiomeColors; @@ -10,8 +11,6 @@ import net.minecraft.world.item.BlockItem; import net.minecraft.world.level.FoliageColor; import net.minecraft.world.level.block.state.BlockState; -import org.featurehouse.mcmod.spm.platform.api.client.BlockRenderTypes; -import org.spongepowered.include.com.google.common.collect.ImmutableList; import top.xdi8.mod.firefly8.block.FireflyBlocks; import top.xdi8.mod.firefly8.client.TakeOnlyContainerScreen; import top.xdi8.mod.firefly8.client.Xdi8TableScreen; @@ -22,7 +21,6 @@ public class FireflyClientSetup implements Runnable { @Override public void run() { - // EntityRendererRegistry.register(FireflyEntityTypes.FIREFLY, NoopRenderer::new); EntityRenderers.register(FireflyEntityTypes.FIREFLY.get(), NoopRenderer::new); ColorHandlerRegistry.registerBlockColors((blockState, blockAndTintGetter, blockPos, i) -> { if (blockAndTintGetter == null || blockPos == null) { @@ -36,11 +34,8 @@ public void run() { }, FireflyBlocks.CEDAR_LEAVES); MenuRegistry.registerScreenFactory(FireflyMenus.TAKE_ONLY_CHEST.get(), TakeOnlyContainerScreen::new); MenuRegistry.registerScreenFactory(FireflyMenus.XDI8_TABLE.get(), Xdi8TableScreen::new); - BlockRenderTypes.register(RenderType.cutoutMipped(), ImmutableList.of( - FireflyBlocks.XDI8AHO_PORTAL_TOP_BLOCK, FireflyBlocks.CEDAR_LEAVES - )); - BlockRenderTypes.register(RenderType.cutout(), ImmutableList.of( - FireflyBlocks.XDI8AHO_BACK_FIRE_BLOCK, FireflyBlocks.CEDAR_SAPLING, FireflyBlocks.CEDAR_TRAPDOOR - )); + RenderTypeRegistry.register(RenderType.cutoutMipped(), FireflyBlocks.XDI8AHO_PORTAL_TOP_BLOCK.get(), FireflyBlocks.CEDAR_LEAVES.get()); + RenderTypeRegistry.register(RenderType.cutout(), FireflyBlocks.XDI8AHO_BACK_FIRE_BLOCK.get(), FireflyBlocks.CEDAR_SAPLING.get(), + FireflyBlocks.CEDAR_TRAPDOOR.get(), FireflyBlocks.CEDAR_DOOR.get()); } } diff --git a/src/main/resources/data/firefly8/tags/items/cedar_logs.json b/src/main/resources/data/firefly8/tags/items/cedar_logs.json new file mode 100644 index 00000000..f7fff7ca --- /dev/null +++ b/src/main/resources/data/firefly8/tags/items/cedar_logs.json @@ -0,0 +1,9 @@ +{ + "replace": false, + "values": [ + "firefly8:cedar_log", + "firefly8:cedar_wood", + "firefly8:stripped_cedar_log", + "firefly8:stripped_cedar_wood" + ] +} \ No newline at end of file From 5ab1ffaa4cea35836b934db4d54e0a2b3d75d3b0 Mon Sep 17 00:00:00 2001 From: Justin Zhang <2691475984@qq.com> Date: Wed, 24 Jan 2024 23:45:28 +0800 Subject: [PATCH 2/3] Fix xdi8aho dimension generation bug (thanks to Nickid2018) --- .../assets/firefly8/texts/mod_credits.json | 3 +- .../noise_settings/xdi8aho_noise.json | 61 ++++++++++--------- 2 files changed, 35 insertions(+), 29 deletions(-) diff --git a/src/main/resources/assets/firefly8/texts/mod_credits.json b/src/main/resources/assets/firefly8/texts/mod_credits.json index e1f2b9c3..47c2fb55 100644 --- a/src/main/resources/assets/firefly8/texts/mod_credits.json +++ b/src/main/resources/assets/firefly8/texts/mod_credits.json @@ -27,7 +27,8 @@ "雪火虫", "道德死了", "城市找狮", - "MatLing" + "MatLing", + "Nickid2018" ] } ] diff --git a/src/main/resources/data/firefly8/worldgen/noise_settings/xdi8aho_noise.json b/src/main/resources/data/firefly8/worldgen/noise_settings/xdi8aho_noise.json index af8d61da..2fcd7fe5 100644 --- a/src/main/resources/data/firefly8/worldgen/noise_settings/xdi8aho_noise.json +++ b/src/main/resources/data/firefly8/worldgen/noise_settings/xdi8aho_noise.json @@ -20,39 +20,44 @@ "type": "minecraft:condition", "if_true": { "type": "minecraft:stone_depth", - "add_surface_depth": true, "offset": 0, - "secondary_depth_range": 0, - "surface_type": "floor" + "surface_type": "floor", + "add_surface_depth": false, + "secondary_depth_range": 0 }, "then_run": { - "type": "minecraft:sequence", - "sequence": [ - { - "type": "minecraft:condition", - "if_true": { - "type": "minecraft:water", - "add_stone_depth": false, - "offset": 0, - "surface_depth_multiplier": 0 - }, - "then_run": { - "type": "minecraft:block", - "result_state": { - "Name": "minecraft:grass_block", - "Properties": { - "snowy": "false" - } - } - } - }, - { - "type": "minecraft:block", - "result_state": { - "Name": "minecraft:dirt" + "type": "minecraft:condition", + "if_true": { + "type": "minecraft:water", + "offset": 0, + "surface_depth_multiplier": 0, + "add_stone_depth": false + }, + "then_run": { + "type": "minecraft:block", + "result_state": { + "Name": "minecraft:grass_block", + "Properties": { + "snowy": "false" } } - ] + } + } + }, + { + "type": "minecraft:condition", + "if_true": { + "type": "minecraft:stone_depth", + "offset": 0, + "surface_type": "floor", + "add_surface_depth": true, + "secondary_depth_range": 0 + }, + "then_run": { + "type": "minecraft:block", + "result_state": { + "Name": "minecraft:dirt" + } } }, { From 651b3bc1fcb0e15521cd35bba682d0162b5f7b2c Mon Sep 17 00:00:00 2001 From: Justin Zhang <2691475984@qq.com> Date: Sat, 27 Jan 2024 15:02:04 +0800 Subject: [PATCH 3/3] O2X portal teleporting non-player entities --- .../firefly8/block/Xdi8ahoPortalBlock.java | 8 +++- .../firefly8/world/Xdi8DimensionUtils.java | 47 ++++++++++--------- 2 files changed, 31 insertions(+), 24 deletions(-) diff --git a/src/main/java/top/xdi8/mod/firefly8/block/Xdi8ahoPortalBlock.java b/src/main/java/top/xdi8/mod/firefly8/block/Xdi8ahoPortalBlock.java index 92cf8d48..c8b54194 100644 --- a/src/main/java/top/xdi8/mod/firefly8/block/Xdi8ahoPortalBlock.java +++ b/src/main/java/top/xdi8/mod/firefly8/block/Xdi8ahoPortalBlock.java @@ -3,6 +3,7 @@ import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.server.level.ServerLevel; +import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.Entity; import net.minecraft.world.level.Level; import net.minecraft.world.level.LevelAccessor; @@ -36,7 +37,12 @@ public void entityInside(@NotNull BlockState pState, @NotNull Level pLevel, if (!pEntity.isPassenger() && !pEntity.isVehicle() && pEntity.canChangeDimensions() && !entityExt.xdi8$isOnCooldown()) { ServerLevel level = (ServerLevel) pLevel; - Xdi8DimensionUtils.teleportToXdi8aho(level, pEntity, pPos); + if (pEntity instanceof ServerPlayer player){ + Xdi8DimensionUtils.teleportPlayerToXdi8aho(level, player, pPos); + } + else { + Xdi8DimensionUtils.teleportToXdi8aho(level, pEntity); + } entityExt.xdi8$resetShortCooldown(); } } diff --git a/src/main/java/top/xdi8/mod/firefly8/world/Xdi8DimensionUtils.java b/src/main/java/top/xdi8/mod/firefly8/world/Xdi8DimensionUtils.java index e5c1b26a..31926bb5 100644 --- a/src/main/java/top/xdi8/mod/firefly8/world/Xdi8DimensionUtils.java +++ b/src/main/java/top/xdi8/mod/firefly8/world/Xdi8DimensionUtils.java @@ -15,44 +15,45 @@ import top.xdi8.mod.firefly8.ext.IServerPlayerWithHiddenInventory; import top.xdi8.mod.firefly8.stats.FireflyStats; -import java.util.Collection; -import java.util.Collections; - public class Xdi8DimensionUtils { private static final Logger LOGGER = LogUtils.getLogger(); - private static final ResourceLocation P_LOCATION = new ResourceLocation("firefly8", "xdi8aho"); + private static final ResourceLocation DIM_LOCATION = new ResourceLocation("firefly8", "xdi8aho"); public static final ResourceKey XDI8AHO_DIM_KEY = - ResourceKey.create(Registry.DIMENSION_REGISTRY, P_LOCATION); + ResourceKey.create(Registry.DIMENSION_REGISTRY, DIM_LOCATION); - public static void teleportToXdi8aho(ServerLevel oldLevel, Entity entity, BlockPos portalPos) { + public static void teleportPlayerToXdi8aho(ServerLevel oldLevel, ServerPlayer entity, BlockPos portalPos) { var dim = oldLevel.getServer().getLevel(Xdi8DimensionUtils.XDI8AHO_DIM_KEY); if (dim != null) { - final Entity e = changeDimension(entity, dim, new Xdi8TeleporterImpl(oldLevel)); - if (e instanceof ServerPlayer serverPlayer) { // && e != null - IServerPlayerWithHiddenInventory ext = IServerPlayerWithHiddenInventory.xdi8$extend(serverPlayer); - //ext.xdi8$setPortal(oldLevel.dimension(), portalPos); - BlockPos thatPos = portalPos; - for (int i = 1; i < 16; i++) { - thatPos = thatPos.above(); - if (oldLevel.getBlockState(thatPos).is(FireflyBlocks.XDI8AHO_PORTAL_TOP_BLOCK.get())) { - ext.xdi8$setPortal(oldLevel.dimension(), thatPos); - break; - } + final ServerPlayer serverPlayer = (ServerPlayer) changeDimension(entity, dim, new Xdi8TeleporterImpl(oldLevel)); + IServerPlayerWithHiddenInventory ext = IServerPlayerWithHiddenInventory.xdi8$extend(serverPlayer); + BlockPos thatPos = portalPos; + for (int i = 1; i < 16; i++) { + thatPos = thatPos.above(); + if (oldLevel.getBlockState(thatPos).is(FireflyBlocks.XDI8AHO_PORTAL_TOP_BLOCK.get())) { + ext.xdi8$setPortal(oldLevel.dimension(), thatPos); + break; } - serverPlayer.awardStat(FireflyStats.O2X_PORTALS_ENTERED.get()); } - } - else + serverPlayer.awardStat(FireflyStats.O2X_PORTALS_ENTERED.get()); + } else { LOGGER.error("Can't find dimension {} in current server", XDI8AHO_DIM_KEY); + } } - static final Collection SPECIAL_RESPAWN = - Collections.singleton(P_LOCATION); + public static void teleportToXdi8aho(ServerLevel oldLevel, Entity entity) { + var dim = oldLevel.getServer().getLevel(Xdi8DimensionUtils.XDI8AHO_DIM_KEY); + if (dim != null && !entity.isPassenger() && !entity.isVehicle() && entity.canChangeDimensions()) { + changeDimension(entity, dim, new Xdi8TeleporterImpl(oldLevel)); + } else { + LOGGER.error("Can't find dimension {} in current server", XDI8AHO_DIM_KEY); + } + } public static boolean canRedirectRespawn(Level level) { - return SPECIAL_RESPAWN.contains(level.dimension().location()); + return DIM_LOCATION.equals(level.dimension().location()); } + @SuppressWarnings("unused") @ExpectPlatform static Entity changeDimension(Entity e, ServerLevel xdi8Level, TeleportWrapper teleporter) { throw new AssertionError();