更新内容
1. 补充完善了相关共工具方法 2. 添加部分javadoc
This commit is contained in:
parent
97a232944b
commit
6efdb5fb13
|
|
@ -3,7 +3,13 @@ package top.r3944realms.lib39.base.datagen.provider;
|
|||
import top.r3944realms.lib39.content.register.Lib39Blocks;
|
||||
import top.r3944realms.lib39.datagen.provider.subprovider.BlockLootTables;
|
||||
|
||||
/**
|
||||
* The type Lib 39 block loot table.
|
||||
*/
|
||||
public class Lib39BlockLootTable extends BlockLootTables {
|
||||
/**
|
||||
* Instantiates a new Lib 39 block loot table.
|
||||
*/
|
||||
public Lib39BlockLootTable() {
|
||||
super(Lib39Blocks.BLOCKS);
|
||||
dropSelf(Lib39Blocks.DOLL);
|
||||
|
|
|
|||
|
|
@ -12,7 +12,15 @@ import top.r3944realms.lib39.content.register.Lib39Items;
|
|||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* The type Lib 39 recipe provider.
|
||||
*/
|
||||
public class Lib39RecipeProvider extends RecipeProvider {
|
||||
/**
|
||||
* Instantiates a new Lib 39 recipe provider.
|
||||
*
|
||||
* @param output the output
|
||||
*/
|
||||
public Lib39RecipeProvider(PackOutput output) {
|
||||
super(output);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,11 +7,27 @@ import net.minecraftforge.common.data.SoundDefinitionsProvider;
|
|||
import top.r3944realms.lib39.Lib39;
|
||||
import top.r3944realms.lib39.content.register.Lib39SoundEvents;
|
||||
|
||||
/**
|
||||
* The type Lib 39 sound definitions provider.
|
||||
*/
|
||||
public class Lib39SoundDefinitionsProvider extends SoundDefinitionsProvider {
|
||||
/**
|
||||
* Instantiates a new Lib 39 sound definitions provider.
|
||||
*
|
||||
* @param output the output
|
||||
* @param helper the helper
|
||||
*/
|
||||
public Lib39SoundDefinitionsProvider(PackOutput output, ExistingFileHelper helper) {
|
||||
super(output, Lib39.MOD_ID, helper);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets sound definition.
|
||||
*
|
||||
* @param subTitle the sub title
|
||||
* @param sounds the sounds
|
||||
* @return the sound definition
|
||||
*/
|
||||
public SoundDefinition getSoundDefinition(String subTitle, SoundDefinition.Sound... sounds) {
|
||||
return SoundDefinition.definition().subtitle(subTitle).with(sounds);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,8 +11,17 @@ import net.minecraft.client.renderer.RenderType;
|
|||
import org.jetbrains.annotations.NotNull;
|
||||
import top.r3944realms.lib39.Lib39;
|
||||
|
||||
/**
|
||||
* The type Doll model.
|
||||
*/
|
||||
public class DollModel extends Model {
|
||||
/**
|
||||
* The constant LAYER_LOCATION.
|
||||
*/
|
||||
public static final ModelLayerLocation LAYER_LOCATION = new ModelLayerLocation(Lib39.rl("doll_model"), "main");
|
||||
/**
|
||||
* The Slim.
|
||||
*/
|
||||
public boolean slim = false;
|
||||
private final ModelPart head;
|
||||
private final ModelPart body;
|
||||
|
|
@ -23,6 +32,11 @@ public class DollModel extends Model {
|
|||
private final ModelPart leftArmSlim;
|
||||
private final ModelPart leftLeg;
|
||||
|
||||
/**
|
||||
* Instantiates a new Doll model.
|
||||
*
|
||||
* @param root the root
|
||||
*/
|
||||
public DollModel(ModelPart root) {
|
||||
super(RenderType::entityTranslucent);
|
||||
this.head = root.getChild("head");
|
||||
|
|
@ -35,6 +49,11 @@ public class DollModel extends Model {
|
|||
this.leftLeg = root.getChild("left_leg");
|
||||
}
|
||||
|
||||
/**
|
||||
* Create body layer layer definition.
|
||||
*
|
||||
* @return the layer definition
|
||||
*/
|
||||
public static LayerDefinition createBodyLayer() {
|
||||
MeshDefinition meshdefinition = new MeshDefinition();
|
||||
PartDefinition partdefinition = meshdefinition.getRoot();
|
||||
|
|
|
|||
|
|
@ -19,9 +19,17 @@ import top.r3944realms.lib39.content.block.DollBlock;
|
|||
import top.r3944realms.lib39.content.block.blockentity.DollBlockEntity;
|
||||
import top.r3944realms.lib39.util.lang.Pair;
|
||||
|
||||
/**
|
||||
* The type Doll block entity renderer.
|
||||
*/
|
||||
public class DollBlockEntityRenderer implements BlockEntityRenderer<DollBlockEntity> {
|
||||
private final DollModel dollModel;
|
||||
|
||||
/**
|
||||
* Instantiates a new Doll block entity renderer.
|
||||
*
|
||||
* @param context the context
|
||||
*/
|
||||
public DollBlockEntityRenderer(BlockEntityRendererProvider.@NotNull Context context) {
|
||||
this.dollModel = new DollModel(context.bakeLayer(DollModel.LAYER_LOCATION));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,9 @@ import top.r3944realms.lib39.content.item.DollItem;
|
|||
import top.r3944realms.lib39.util.GameProfileHelper;
|
||||
import top.r3944realms.lib39.util.lang.Pair;
|
||||
|
||||
/**
|
||||
* The type Doll item renderer.
|
||||
*/
|
||||
public class DollItemRenderer extends BlockEntityWithoutLevelRenderer {
|
||||
private static DollItemRenderer instance;
|
||||
private final DollModel dollModel;
|
||||
|
|
@ -31,6 +34,12 @@ public class DollItemRenderer extends BlockEntityWithoutLevelRenderer {
|
|||
Minecraft.getInstance().getEntityModels().bakeLayer(DollModel.LAYER_LOCATION)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets instance.
|
||||
*
|
||||
* @return the instance
|
||||
*/
|
||||
public static DollItemRenderer getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new DollItemRenderer();
|
||||
|
|
@ -67,6 +76,12 @@ public class DollItemRenderer extends BlockEntityWithoutLevelRenderer {
|
|||
poseStack.popPose();
|
||||
}
|
||||
|
||||
/**
|
||||
* Load skin pair.
|
||||
*
|
||||
* @param profile the profile
|
||||
* @return the pair
|
||||
*/
|
||||
public static @NotNull Pair<ResourceLocation,Boolean> loadSkin(GameProfile profile) {
|
||||
SkinManager skinManager = Minecraft.getInstance().getSkinManager();
|
||||
ResourceLocation playerSkin;
|
||||
|
|
|
|||
|
|
@ -78,6 +78,12 @@ public class DollBlockEntity extends BlockEntity {
|
|||
|
||||
this.updateOwnerProfile();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets owner.
|
||||
*
|
||||
* @param ownerName the owner name
|
||||
*/
|
||||
public void setOwner(@Nullable String ownerName) {
|
||||
setOwner(new GameProfile(Util.NIL_UUID, ownerName));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,17 +8,40 @@ import net.minecraftforge.registries.ForgeRegistries;
|
|||
import net.minecraftforge.registries.RegistryObject;
|
||||
import top.r3944realms.lib39.Lib39;
|
||||
|
||||
/**
|
||||
* The type Lib 39 sound events.
|
||||
*/
|
||||
public class Lib39SoundEvents {
|
||||
/**
|
||||
* The constant SOUND_EVENTS.
|
||||
*/
|
||||
public static final DeferredRegister<SoundEvent> SOUND_EVENTS = DeferredRegister.create(ForgeRegistries.SOUND_EVENTS, Lib39.MOD_ID);
|
||||
/**
|
||||
* The constant RL_DUCK_TOY.
|
||||
*/
|
||||
public static final ResourceLocation RL_DUCK_TOY = Lib39.rl("duck_toy");
|
||||
/**
|
||||
* The constant DUCK_TOY.
|
||||
*/
|
||||
public static final RegistryObject<SoundEvent> DUCK_TOY = SOUND_EVENTS.register("duck_toy",
|
||||
() -> SoundEvent.createFixedRangeEvent(RL_DUCK_TOY, 32.0f));
|
||||
|
||||
/**
|
||||
* Register.
|
||||
*
|
||||
* @param bus the bus
|
||||
*/
|
||||
public static void register(IEventBus bus) {
|
||||
SOUND_EVENTS.register(bus);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets sub title translate key.
|
||||
*
|
||||
* @param name the name
|
||||
* @return the sub title translate key
|
||||
*/
|
||||
public static String getSubTitleTranslateKey(String name) {
|
||||
return "sound." + Lib39.MOD_ID + ".subtitle." + name;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -82,11 +82,11 @@ public class CompatManager {
|
|||
public void addListenerForCompat(ResourceLocation compatId, @Nullable Dist dists, Mod.EventBusSubscriber.Bus bus) {
|
||||
listenerConfigs.add(new ListenerConfig(compatId, dists, bus));
|
||||
}
|
||||
|
||||
/**
|
||||
* 为特定兼容模块配置事件监听器
|
||||
*
|
||||
* @param compatId the compat id
|
||||
|
||||
*/
|
||||
public void addListenerForCompat(ResourceLocation compatId) {
|
||||
addListenerForCompat(compatId, null, Mod.EventBusSubscriber.Bus.FORGE);
|
||||
|
|
|
|||
|
|
@ -46,6 +46,11 @@ public class ClientEventHandler {
|
|||
event.registerBlockEntityRenderer(Lib39BlockEntities.DOLL_BLOCK_ENTITY.get(),DollBlockEntityRenderer::new);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register layer definitions.
|
||||
*
|
||||
* @param event the event
|
||||
*/
|
||||
@SubscribeEvent
|
||||
public static void registerLayerDefinitions(EntityRenderersEvent.RegisterLayerDefinitions event) {
|
||||
event.registerLayerDefinition(DollModel.LAYER_LOCATION, DollModel::createBodyLayer);
|
||||
|
|
|
|||
|
|
@ -135,6 +135,12 @@ public class CommonEventHandler {
|
|||
syncData2Manager.forEach(((resourceLocation, iSyncManager) -> iSyncManager.foreach(ISyncData::checkIfDirtyThenUpdate)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* On anvil rename.
|
||||
*
|
||||
* @param event the event
|
||||
*/
|
||||
@SubscribeEvent
|
||||
public static void onAnvilRename(AnvilUpdateEvent event) {
|
||||
if (event.getLeft().getItem() instanceof DollItem) {
|
||||
|
|
@ -245,6 +251,7 @@ public class CommonEventHandler {
|
|||
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Add item to tabs.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -37,8 +37,11 @@ public class BlockLootTables extends BlockLootSubProvider {
|
|||
|
||||
private final List<BlockEntry> blockEntries = new ArrayList<>();
|
||||
private final DeferredRegister<Block> knowBlocks;
|
||||
|
||||
/**
|
||||
* Instantiates a new Block loot tables.
|
||||
*
|
||||
* @param deferredRegister the deferred register
|
||||
*/
|
||||
public BlockLootTables(DeferredRegister<Block> deferredRegister) {
|
||||
super(Set.of(), FeatureFlags.REGISTRY.allFlags());
|
||||
|
|
@ -332,6 +335,7 @@ public class BlockLootTables extends BlockLootSubProvider {
|
|||
/**
|
||||
* 创建新的战利品表生成器
|
||||
*
|
||||
* @param deferredRegister the deferred register
|
||||
* @return the block loot tables
|
||||
*/
|
||||
@Contract("_ -> new")
|
||||
|
|
|
|||
|
|
@ -427,6 +427,7 @@ public class LangKeyValue implements ILangKeyValue {
|
|||
.isDefault(isDefault)
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy of lang key value.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@ package top.r3944realms.lib39.datagen.value;
|
|||
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
|
|
@ -57,6 +59,10 @@ public enum ModPartEnum {
|
|||
* 图形界面
|
||||
*/
|
||||
GUI,
|
||||
/**
|
||||
* 容器
|
||||
*/
|
||||
CONTAINER,
|
||||
/**
|
||||
* 画作描述
|
||||
*/
|
||||
|
|
@ -127,11 +133,12 @@ public enum ModPartEnum {
|
|||
* @param name the name
|
||||
* @return the full key
|
||||
*/
|
||||
public String getFullKey(String modId, String name) {
|
||||
@Contract(pure = true)
|
||||
public @NotNull String getFullKey(String modId, String name) {
|
||||
return switch (this) {
|
||||
case ITEM -> "item." + modId + "." + name;
|
||||
case BLOCK -> "block." + modId + "." + name;
|
||||
case ENCHANTMENT -> "enchantment.";
|
||||
case ENCHANTMENT -> "enchantment." + modId + "." + name;
|
||||
case ADVANCEMENT_TITLE -> "advancement." + modId + "." + name + ".title";
|
||||
case ADVANCEMENT_DESCRIPTION -> "advancement." + modId + "." + name + ".description";
|
||||
case CREATIVE_TAB -> "creativetab." + modId + "." + name;
|
||||
|
|
@ -139,17 +146,18 @@ public enum ModPartEnum {
|
|||
case CONFIG -> "config." + modId + "." + name;
|
||||
case ENTITY -> "entity." + modId + "." + name;
|
||||
case GUI -> "gui." + modId + "." + name;
|
||||
case CONTAINER -> "container." + modId + "." + name;
|
||||
case PAINTING_AUTHOR -> "painting." + modId + "." + name + ".author";
|
||||
case PAINTING_TITLE -> "painting." + modId + "." + name + ".title";
|
||||
case TITLE -> "title." + modId + "." + name;
|
||||
case NAME -> "name." + modId + "." + name;
|
||||
case GAME_RULE -> "gamerule.";
|
||||
case DESCRIPTION -> "description.";
|
||||
case GAME_RULE -> "gamerule."+ modId + "." + name;
|
||||
case DESCRIPTION -> "description." + modId + "." + name;
|
||||
case INFO -> "info." + modId + "." + name;
|
||||
case MESSAGE -> "message." + modId + "." + name;
|
||||
case COMMAND -> "command." + modId + "." + name;
|
||||
case SOUND -> "sound." + modId + "." + name;
|
||||
default -> modId + name;
|
||||
default -> modId + "." + name;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,9 @@ import top.r3944realms.lib39.util.GameProfileHelper;
|
|||
import tschipp.carryon.client.render.CarriedObjectRender;
|
||||
import tschipp.carryon.common.carry.CarryOnDataManager;
|
||||
|
||||
/**
|
||||
* The type Mixin carried object render.
|
||||
*/
|
||||
@Pseudo
|
||||
@Mixin(value = CarriedObjectRender.class, remap = false)
|
||||
public class MixinCarriedObjectRender {
|
||||
|
|
|
|||
|
|
@ -30,7 +30,13 @@ import java.util.concurrent.atomic.AtomicReference;
|
|||
* The type GameProfile helper.
|
||||
*/
|
||||
public class GameProfileHelper {
|
||||
/**
|
||||
* The constant TAG_BE.
|
||||
*/
|
||||
public static final String TAG_BE = "BlockEntityTag";
|
||||
/**
|
||||
* The constant TAG_OWN_PROFILE.
|
||||
*/
|
||||
public static final String TAG_OWN_PROFILE = "OwnerProfile";
|
||||
|
||||
|
||||
|
|
@ -61,7 +67,13 @@ public class GameProfileHelper {
|
|||
.getInsecureSkinLocation(gameProfile);
|
||||
}
|
||||
|
||||
// 判断玩家是否使用纤细手臂
|
||||
/**
|
||||
* Has slim arms boolean.
|
||||
*
|
||||
* @param player the player
|
||||
* @return the boolean
|
||||
*/
|
||||
// 判断玩家是否使用纤细手臂
|
||||
public static boolean hasSlimArms(@NotNull Player player) {
|
||||
if (player.level().isClientSide) {
|
||||
return hasSlimArmsClient(player);
|
||||
|
|
@ -105,7 +117,13 @@ public class GameProfileHelper {
|
|||
return false;
|
||||
}
|
||||
|
||||
// 获取皮肤模型名称
|
||||
/**
|
||||
* Gets skin model name.
|
||||
*
|
||||
* @param player the player
|
||||
* @return the skin model name
|
||||
*/
|
||||
// 获取皮肤模型名称
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static @NotNull String getSkinModelName(@NotNull Player player) {
|
||||
if (player.level().isClientSide && player instanceof AbstractClientPlayer) {
|
||||
|
|
@ -115,10 +133,12 @@ public class GameProfileHelper {
|
|||
}
|
||||
return "default";
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断玩家是否为纤细手臂(Alex模型)
|
||||
*
|
||||
* @param profile 玩家的GameProfile
|
||||
* @return true=纤细手臂,false=正常手臂
|
||||
* @return true =纤细手臂,false=正常手臂
|
||||
*/
|
||||
public static boolean isSlimArms(GameProfile profile) {
|
||||
if (profile == null) {
|
||||
|
|
@ -189,6 +209,7 @@ public class GameProfileHelper {
|
|||
|
||||
/**
|
||||
* 获取皮肤模型名称
|
||||
*
|
||||
* @param profile GameProfile
|
||||
* @return "slim" 或 "default"
|
||||
*/
|
||||
|
|
@ -224,8 +245,12 @@ public class GameProfileHelper {
|
|||
|
||||
return "default";
|
||||
}
|
||||
|
||||
/**
|
||||
* 从ItemStack的NBT中读取GameProfile
|
||||
*
|
||||
* @param stack the stack
|
||||
* @return the profile from item stack
|
||||
*/
|
||||
@Nullable
|
||||
public static GameProfile getProfileFromItemStack(ItemStack stack) {
|
||||
|
|
@ -251,8 +276,12 @@ public class GameProfileHelper {
|
|||
});
|
||||
return profileRef.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* 将GameProfile保存到ItemStack的NBT
|
||||
*
|
||||
* @param stack the stack
|
||||
* @param profile the profile
|
||||
*/
|
||||
public static void saveProfileToItemStack(@NotNull ItemStack stack, @Nullable GameProfile profile) {
|
||||
if (stack.isEmpty()) {
|
||||
|
|
@ -280,6 +309,9 @@ public class GameProfileHelper {
|
|||
|
||||
/**
|
||||
* 检查ItemStack是否有保存的皮肤数据
|
||||
*
|
||||
* @param stack the stack
|
||||
* @return the boolean
|
||||
*/
|
||||
public static boolean hasProfileData(@NotNull ItemStack stack) {
|
||||
if (stack.isEmpty()) {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,11 @@
|
|||
package top.r3944realms.lib39.util.block;
|
||||
|
||||
import net.minecraft.client.renderer.item.ItemProperties;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.world.item.CreativeModeTabs;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
|
|
@ -19,6 +22,9 @@ import java.util.function.Supplier;
|
|||
public class BlockRegistryBuilder {
|
||||
private String registryName;
|
||||
private RegistryObject<Block> blockObject;
|
||||
private DeferredRegister<Item> items;
|
||||
private boolean needBuildItem;
|
||||
private Item.Properties properties;
|
||||
|
||||
/**
|
||||
* 创建新的构建器实例
|
||||
|
|
@ -56,11 +62,38 @@ public class BlockRegistryBuilder {
|
|||
/**
|
||||
* 注册对应的方块物品
|
||||
*
|
||||
* @param blockObject the block object
|
||||
* @param blockDeferredRegister the block deferred register
|
||||
* @param itemRegister the item deferred register
|
||||
* @return the block registry builder
|
||||
*/
|
||||
public void registerBlockItem(RegistryObject<Block> blockObject, @NotNull DeferredRegister<Block> blockDeferredRegister) {
|
||||
blockDeferredRegister.register(this.registryName, blockObject);
|
||||
public BlockRegistryBuilder registerItem(DeferredRegister<Item> itemRegister) {
|
||||
this.items = itemRegister;
|
||||
needBuildItem = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册对应的方块带有对应属性物品
|
||||
*
|
||||
* @param itemRegister the item deferred register
|
||||
* @param properties the item properties
|
||||
* @return the block registry builder
|
||||
*/
|
||||
public BlockRegistryBuilder registerItemWithProperties(DeferredRegister<Item> itemRegister, Item.Properties properties) {
|
||||
this.items = itemRegister;
|
||||
this.properties = properties;
|
||||
needBuildItem = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 对应的方块物品属性
|
||||
*
|
||||
* @param properties the item properties
|
||||
* @return the block registry builder
|
||||
*/
|
||||
public BlockRegistryBuilder ItemProperties(Item.Properties properties) {
|
||||
this.properties = properties;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -103,6 +136,9 @@ public class BlockRegistryBuilder {
|
|||
* @return the registry object
|
||||
*/
|
||||
public RegistryObject<Block> build() {
|
||||
if (needBuildItem) {
|
||||
items.register(this.registryName, () -> new BlockItem(this.blockObject.get(), properties == null ? new Item.Properties() : properties));
|
||||
}
|
||||
return this.blockObject;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user