Improve code struct
This commit is contained in:
parent
bc8614dedd
commit
d70ff3229f
|
|
@ -17,7 +17,6 @@ buildscript {
|
|||
plugins {
|
||||
id 'eclipse'
|
||||
id 'maven-publish'
|
||||
// id 'org.parchmentmc.librarian.forgegradle' version '1.+'
|
||||
}
|
||||
apply plugin: 'net.minecraftforge.gradle'
|
||||
apply plugin: 'org.spongepowered.mixin'
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
38eeb75da0923717638f16acc5c7068aecba156e assets/modernlifepatch/lang/en_us.json
|
||||
bab598e47751847b120edd8d3418781229ec5fd6 assets/modernlifepatch/lang/zh_cn.json
|
||||
6f0bbd40a288accb8182faf81af9d89c51a874f6 assets/modernlifepatch/lang/en_us.json
|
||||
4df80d238afe07938df313f114e33764825ca257 assets/modernlifepatch/lang/zh_cn.json
|
||||
ac9cec2e51193a3ebaa165fe91c9bb3f9f3fcc32 assets/modernlifepatch/models/item/large_mirror.json
|
||||
de63e31ba044ddc8d09dd10945a560d414e185c4 assets/modernlifepatch/models/item/massive_mirror.json
|
||||
80cb85eae418087ea09e8b0d34289b3faf7f0faf assets/modernlifepatch/models/item/mirror.json
|
||||
|
|
|
|||
|
|
@ -1,4 +1,8 @@
|
|||
{
|
||||
"block.modernlifepatch.large_mirror": "Large Mirror",
|
||||
"block.modernlifepatch.massive_mirror": "Massive Mirror",
|
||||
"block.modernlifepatch.mirror": "Mirror",
|
||||
"block.modernlifepatch.tall_mirror": "Tall Mirror",
|
||||
"gui.tag_filter.modernlifepatch.bathroom": "BathRoom",
|
||||
"gui.tag_filter.modernlifepatch.bedchamber": "Bedchamber",
|
||||
"gui.tag_filter.modernlifepatch.door": "Door",
|
||||
|
|
|
|||
|
|
@ -1,4 +1,8 @@
|
|||
{
|
||||
"block.modernlifepatch.large_mirror": "\u5927\u578B\u955C\u5B50",
|
||||
"block.modernlifepatch.massive_mirror": "\u8D85\u5927\u578B\u955C\u5B50",
|
||||
"block.modernlifepatch.mirror": "\u955C\u5B50",
|
||||
"block.modernlifepatch.tall_mirror": "\u9AD8\u955C\u5B50",
|
||||
"gui.tag_filter.modernlifepatch.bathroom": "\u536B\u751F\u95F4",
|
||||
"gui.tag_filter.modernlifepatch.bedchamber": "\u5BDD\u5BA4",
|
||||
"gui.tag_filter.modernlifepatch.door": "\u95E8",
|
||||
|
|
|
|||
|
|
@ -2,29 +2,26 @@ package com.r3944realms.modernlifepatch;
|
|||
|
||||
import com.dairymoose.modernlife.core.CustomBlocks;
|
||||
import com.r3944realms.modernlifepatch.client.event.CreativeScreenEvents;
|
||||
import com.r3944realms.modernlifepatch.client.renderer.blockentity.MirrorBlockEntityRenderer;
|
||||
import com.r3944realms.modernlifepatch.content.blocks.ModBlocks;
|
||||
import com.r3944realms.modernlifepatch.content.blocks.entities.ModBlockEntityType;
|
||||
import net.minecraft.client.renderer.ItemBlockRenderTypes;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.server.packs.repository.Pack;
|
||||
import net.minecraft.server.packs.repository.PackSource;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderers;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.client.event.EntityRenderersEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.AddPackFindersEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.ModList;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
import net.minecraftforge.forgespi.locating.IModFile;
|
||||
import net.minecraftforge.resource.PathResourcePack;
|
||||
|
||||
import java.nio.file.Path;
|
||||
public abstract class ClientEventHandler {
|
||||
// @net.minecraftforge.fml.common.Mod.EventBusSubscriber(value = Dist.CLIENT, bus = net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus.FORGE, modid = ModernLifePatch.MOD_ID)
|
||||
public static class Game extends ClientEventHandler {
|
||||
|
||||
|
||||
public abstract class EventHandler {
|
||||
@net.minecraftforge.fml.common.Mod.EventBusSubscriber(modid = ModernLifePatch.MOD_ID, bus = net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus.MOD ,value = Dist.CLIENT)
|
||||
public static class ModClient extends EventHandler {
|
||||
}
|
||||
@net.minecraftforge.fml.common.Mod.EventBusSubscriber(value = Dist.CLIENT, bus = net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus.MOD, modid = ModernLifePatch.MOD_ID)
|
||||
public static class Mod extends ClientEventHandler {
|
||||
@SubscribeEvent
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static void onClientSetup(FMLClientSetupEvent event) {
|
||||
|
|
@ -43,30 +40,9 @@ public abstract class EventHandler {
|
|||
});
|
||||
MinecraftForge.EVENT_BUS.register(new CreativeScreenEvents());
|
||||
}
|
||||
}
|
||||
@Mod.EventBusSubscriber(modid = ModernLifePatch.MOD_ID, bus = net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus.MOD)
|
||||
public static class ModBoth extends EventHandler {
|
||||
@SubscribeEvent
|
||||
public static void onCommonSetup(FMLCommonSetupEvent event) {
|
||||
event.enqueueWork(() -> {
|
||||
|
||||
});
|
||||
}
|
||||
@SubscribeEvent
|
||||
public static void onRegisterResourcePack(AddPackFindersEvent event) {
|
||||
IModFile modFile = ModList.get().getModFileById(ModernLifePatch.MOD_ID).getFile();
|
||||
Path modFilePath = modFile.findResource("resourcepacks/modernlifepatch");
|
||||
event.addRepositorySource((consumer, packConstructor) -> {
|
||||
Pack pack = Pack.create(
|
||||
"Modern Life Patch",
|
||||
true,
|
||||
() -> new PathResourcePack(ModernLifePatch.MOD_ID, modFilePath),
|
||||
packConstructor,
|
||||
Pack.Position.TOP,
|
||||
PackSource.BUILT_IN
|
||||
);
|
||||
if(pack != null) consumer.accept(pack);
|
||||
});
|
||||
public static void onRegisterRenderer (EntityRenderersEvent.RegisterRenderers event) {
|
||||
event.registerBlockEntityRenderer(ModBlockEntityType.MIRROR.get(), MirrorBlockEntityRenderer::new);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
package com.r3944realms.modernlifepatch;
|
||||
|
||||
import net.minecraft.server.packs.repository.Pack;
|
||||
import net.minecraft.server.packs.repository.PackSource;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.event.AddPackFindersEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.ModList;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
import net.minecraftforge.forgespi.locating.IModFile;
|
||||
import net.minecraftforge.resource.PathResourcePack;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
public abstract class CommonEventHandler {
|
||||
// @net.minecraftforge.fml.common.Mod.EventBusSubscriber(bus = net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus.FORGE, modid = ModernLifePatch.MOD_ID)
|
||||
public static class Game extends CommonEventHandler {
|
||||
|
||||
}
|
||||
@net.minecraftforge.fml.common.Mod.EventBusSubscriber(bus = net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus.MOD, modid = ModernLifePatch.MOD_ID)
|
||||
public static class Mod extends CommonEventHandler {
|
||||
@SubscribeEvent
|
||||
public static void onCommonSetup(FMLCommonSetupEvent event) {
|
||||
event.enqueueWork(() -> {
|
||||
|
||||
});
|
||||
}
|
||||
@SubscribeEvent
|
||||
public static void onRegisterResourcePack(AddPackFindersEvent event) {
|
||||
IModFile modFile = ModList.get().getModFileById(ModernLifePatch.MOD_ID).getFile();
|
||||
Path modFilePath = modFile.findResource("resourcepacks/modernlifepatch");
|
||||
event.addRepositorySource((consumer, packConstructor) -> {
|
||||
Pack pack = Pack.create(
|
||||
"Modern Life Patch",
|
||||
true,
|
||||
() -> new PathResourcePack(ModernLifePatch.MOD_ID, modFilePath),
|
||||
packConstructor,
|
||||
Pack.Position.TOP,
|
||||
PackSource.BUILT_IN
|
||||
);
|
||||
if(pack != null) consumer.accept(pack);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,14 +2,21 @@ package com.r3944realms.modernlifepatch.client.renderer.blockentity;
|
|||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.r3944realms.modernlifepatch.content.blocks.entities.type.mirror.MirrorBlockEntity;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screens.inventory.InventoryScreen;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class MirrorRenderer implements BlockEntityRenderer<MirrorBlockEntity> {
|
||||
public class MirrorBlockEntityRenderer implements BlockEntityRenderer<MirrorBlockEntity> {
|
||||
|
||||
public MirrorBlockEntityRenderer(BlockEntityRendererProvider.Context context) {
|
||||
|
||||
}
|
||||
@Override
|
||||
public void render(@NotNull MirrorBlockEntity pBlockEntity, float pPartialTick, @NotNull PoseStack pPoseStack, @NotNull MultiBufferSource pBufferSource, int pPackedLight, int pPackedOverlay) {
|
||||
|
||||
|
|
@ -16,6 +16,6 @@ public class MLPConfig {
|
|||
static {
|
||||
Pair<MLPConfig, ForgeConfigSpec> configure = new ForgeConfigSpec.Builder().configure(MLPConfig::new);
|
||||
spec = configure.getRight();
|
||||
INSTANCE = configure.getLeft();
|
||||
INSTANCE = configure.getLeft();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ public class ModBlockEntityType {
|
|||
public static final DeferredRegister<BlockEntityType<?>> BLOCK_ENTITY_TYPE
|
||||
= DeferredRegister.create(ForgeRegistries.BLOCK_ENTITIES, ModernLifePatch.MOD_ID);
|
||||
@SuppressWarnings("DataFlowIssue")
|
||||
public static final RegistryObject<BlockEntityType<?>> MIRROR
|
||||
public static final RegistryObject<BlockEntityType<MirrorBlockEntity>> MIRROR
|
||||
= BLOCK_ENTITY_TYPE.register("mirror", () -> new BlockEntityType<>(MirrorBlockEntity::new, Set.of(ModBlocks.MIRROR.get()), null));
|
||||
public static void register(IEventBus bus) {
|
||||
BLOCK_ENTITY_TYPE.register(bus);
|
||||
|
|
|
|||
|
|
@ -1,19 +1,15 @@
|
|||
package com.r3944realms.modernlifepatch.content.blocks.type.mirror;
|
||||
|
||||
import com.r3944realms.modernlifepatch.common.ModTags;
|
||||
import com.r3944realms.modernlifepatch.content.blocks.blockstate.ModBlockStateProperties;
|
||||
import com.r3944realms.modernlifepatch.content.blocks.entities.type.mirror.MirrorBlockEntity;
|
||||
import com.r3944realms.modernlifepatch.content.blocks.type.mirror.shape.IMirrorShape;
|
||||
import com.r3944realms.modernlifepatch.content.items.ModItems;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
|
@ -142,18 +138,14 @@ public class MirrorBlock extends HorizontalDirectionalBlock implements EntityBlo
|
|||
// 破坏自身
|
||||
pLevel.destroyBlock(pCurrentPos, true);
|
||||
// 若另一部分存在,则破坏另一部分
|
||||
// if (!flag) {
|
||||
pLevel.destroyBlock(otherPartPos, false);
|
||||
// }
|
||||
pLevel.destroyBlock(otherPartPos, false);
|
||||
yield Blocks.AIR.defaultBlockState();
|
||||
}
|
||||
if(!flag) {
|
||||
pLevel.destroyBlock(otherPartPos, true);
|
||||
pLevel.destroyBlock(pCurrentPos, false);
|
||||
}
|
||||
// 如果另一部分被破坏,自身也需更新
|
||||
yield flag ? pState : Blocks.AIR.defaultBlockState();
|
||||
// 另一部分不存在时破坏自身
|
||||
}
|
||||
case LARGE_MIRROR -> {
|
||||
boolean isMainPart = part == MirrorPart.FOOT_LEFT;
|
||||
|
|
@ -351,6 +343,7 @@ public class MirrorBlock extends HorizontalDirectionalBlock implements EntityBlo
|
|||
case LARGE_MIRROR -> {
|
||||
}
|
||||
case MASSIVE_MIRROR -> {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,12 +2,25 @@ package com.r3944realms.modernlifepatch.datagen.lang;
|
|||
|
||||
import com.r3944realms.modernlifepatch.ModernLifePatch;
|
||||
import com.r3944realms.modernlifepatch.common.ModTags;
|
||||
import com.r3944realms.modernlifepatch.content.blocks.ModBlocks;
|
||||
import com.r3944realms.modernlifepatch.content.items.ModItems;
|
||||
import com.r3944realms.modernlifepatch.utils.Enum.LanguageEnum;
|
||||
import com.r3944realms.modernlifepatch.utils.String.StringValidator;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public enum ModLangKeyValue {
|
||||
|
||||
MIRROR_ITEM(getItemKey(ModItems.MIRROR_ITEM), "Mirror", "镜子"),
|
||||
TALL_MIRROR_ITEM(getItemKey(ModItems.TALL_MIRROR_ITEM), "Tall Mirror", "高镜子"),
|
||||
LARGE_MIRROR_ITEM(getItemKey(ModItems.LARGE_MIRROR_ITEM), "Large Mirror","大型镜子"),
|
||||
MASSIVE_MIRROR_ITEM(getItemKey(ModItems.MASSIVE_MIRROR_ITEM), "Massive Mirror", "超大型镜子"),
|
||||
MIRROR(getBlockKey(ModBlocks.MIRROR), copyEnglish(MIRROR_ITEM), copySimpleChinese(MIRROR_ITEM)),
|
||||
TALL_MIRROR(getBlockKey(ModBlocks.TALL_MIRROR), copyEnglish(TALL_MIRROR_ITEM), copySimpleChinese(TALL_MIRROR_ITEM)),
|
||||
LARGE_MIRROR(getBlockKey(ModBlocks.LARGE_MIRROR), copyEnglish(LARGE_MIRROR_ITEM), copySimpleChinese(LARGE_MIRROR_ITEM)),
|
||||
MASSIVE_MIRROR(getBlockKey(ModBlocks.MASSIVE_MIRROR), copyEnglish(MASSIVE_MIRROR_ITEM), copySimpleChinese(MASSIVE_MIRROR_ITEM)),
|
||||
CREATIVE_TAB_NAME(getCreativeTabNameKey(ModernLifePatch.MOD_ID), "Modern Life Patch", "摩登生活补丁"),
|
||||
CT_F_TAG_GENERAL(getTagKey(ModTags.Items.GENERAL), "General", "普通"),
|
||||
CT_F_TAG_KITCHEN(getTagKey(ModTags.Items.KITCHEN), "Kitchen", "厨房"),
|
||||
|
|
@ -175,4 +188,22 @@ public enum ModLangKeyValue {
|
|||
return "itemGroup." + tabName;
|
||||
}
|
||||
|
||||
public static String getBlockKey(Supplier<? extends Block> block) {
|
||||
return getBlockKey(block.get());
|
||||
}
|
||||
public static String getBlockKey(Block block) {
|
||||
return block.getDescriptionId();
|
||||
}
|
||||
public static String getItemKey(Supplier<? extends Item> item) {
|
||||
return getItemKey(item.get());
|
||||
}
|
||||
public static String getItemKey(Item item) {
|
||||
return item.getDescriptionId();
|
||||
}
|
||||
public static String copyEnglish(ModLangKeyValue modLangKeyValue) {
|
||||
return modLangKeyValue.US_EN;
|
||||
}
|
||||
public static String copySimpleChinese(ModLangKeyValue modLangKeyValue) {
|
||||
return modLangKeyValue.SIM_CN;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user