Skip to content

Commit

Permalink
Merge pull request #84 from QWERTY770/trunk
Browse files Browse the repository at this point in the history
2.0.0-beta4
  • Loading branch information
QWERTY770 committed Jan 29, 2024
2 parents bda60fa + 651b3bc commit 92e7e55
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 64 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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());
}
}
}
13 changes: 4 additions & 9 deletions src/main/java/top/xdi8/mod/firefly8/FireflyClientSetup.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand All @@ -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) {
Expand All @@ -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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}
}
Expand Down
47 changes: 24 additions & 23 deletions src/main/java/top/xdi8/mod/firefly8/world/Xdi8DimensionUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<Level> 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<ResourceLocation> 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();
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/assets/firefly8/texts/mod_credits.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
"雪火虫",
"道德死了",
"城市找狮",
"MatLing"
"MatLing",
"Nickid2018"
]
}
]
Expand Down
9 changes: 9 additions & 0 deletions src/main/resources/data/firefly8/tags/items/cedar_logs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"replace": false,
"values": [
"firefly8:cedar_log",
"firefly8:cedar_wood",
"firefly8:stripped_cedar_log",
"firefly8:stripped_cedar_wood"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
},
{
Expand Down

0 comments on commit 92e7e55

Please sign in to comment.