Skip to content

Commit

Permalink
done on malum 1.21 fabric
Browse files Browse the repository at this point in the history
  • Loading branch information
mrsterner committed Dec 5, 2024
1 parent 57ba736 commit 85fe787
Show file tree
Hide file tree
Showing 13 changed files with 313 additions and 113 deletions.
1 change: 0 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ port_lib_modules = \
config,\
core,\
data,\
entity,\
extensions,\
items,\
lazy_registration,\
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/com/sammy/malum/MalumModClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
import com.sammy.malum.client.renderer.curio.TokenOfGratitudeRenderer;
import com.sammy.malum.client.renderer.curio.TopHatCurioRenderer;
import com.sammy.malum.client.renderer.item.SpiritJarItemRenderer;
import com.sammy.malum.core.events.ClientRuntimeEvents;
import com.sammy.malum.registry.client.*;
import com.sammy.malum.registry.common.ContainerRegistry;
import com.sammy.malum.registry.common.SpiritTypeRegistry;
import com.sammy.malum.registry.common.block.BlockEntityRegistry;
import com.sammy.malum.registry.common.block.BlockRegistry;
import com.sammy.malum.registry.common.entity.EntityRegistry;
Expand Down Expand Up @@ -42,7 +44,7 @@ public class MalumModClient implements ClientModInitializer {
public void onInitializeClient() {
ClientTickEvents.START_CLIENT_TICK.register(this::startTick);

//SpiritTypeRegistry.init();
SpiritTypeRegistry.init();
ParticleRegistry.registerParticleFactory();
BlockEntityRegistry.ClientOnly.registerRenderer();
BlockRegistry.ClientOnly.setBlockColors();
Expand All @@ -52,6 +54,8 @@ public void onInitializeClient() {
ContainerRegistry.bindContainerRenderers();

ShaderRegistry.shaderRegistry();
ClientRuntimeEvents.clientTickEvent();
ClientRuntimeEvents.itemTooltipEvent();

EntityJoinLevelEvent.EVENT.register(ParticleEmitterRegistry::addParticleEmitters);

Expand Down
49 changes: 24 additions & 25 deletions src/main/java/com/sammy/malum/client/MalumModelLoaderPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.fabricmc.fabric.api.renderer.v1.render.RenderContext;
import net.minecraft.client.resources.model.BakedModel;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.RandomSource;
import net.minecraft.world.item.ItemDisplayContext;
import net.minecraft.world.item.ItemStack;
Expand All @@ -18,45 +19,47 @@

public class MalumModelLoaderPlugin implements ModelLoadingPlugin {
private static final ModelResourceLocation CREATIVE_BASE_MODEL = createModel("creative_scythe");
private static final ModelResourceLocation CREATIVE_GUI_MODEL = createGuiModel("creative_scythe");
private static final ResourceLocation CREATIVE_GUI_MODEL = MalumMod.malumPath("item/creative_scythe");

private static final ModelResourceLocation CRUDE_BASE_MODEL = createModel("crude_scythe");
private static final ModelResourceLocation CRUDE_GUI_MODEL = createGuiModel("crude_scythe");
private static final ResourceLocation CRUDE_GUI_MODEL = MalumMod.malumPath("item/crude_scythe");

private static final ModelResourceLocation SOUL_BASE_MODEL = createModel("soul_stained_steel_scythe");
private static final ModelResourceLocation SOUL_GUI_MODEL = createGuiModel("soul_stained_steel_scythe");
private static final ResourceLocation SOUL_GUI_MODEL = MalumMod.malumPath("item/soul_stained_steel_scythe");

private static final ModelResourceLocation WORLD_BASE_MODEL = createModel("weight_of_worlds");
private static final ModelResourceLocation WORLD_GUI_MODEL = createGuiModel("weight_of_worlds");

private static final Map<ModelResourceLocation, ModelResourceLocation> modelPairs = Map.of(
CREATIVE_BASE_MODEL, CREATIVE_GUI_MODEL,
CRUDE_BASE_MODEL, CRUDE_GUI_MODEL,
SOUL_BASE_MODEL, SOUL_GUI_MODEL,
WORLD_BASE_MODEL, WORLD_GUI_MODEL
);
private static final ResourceLocation WORLD_GUI_MODEL = MalumMod.malumPath("item/weight_of_worlds");

public MalumModelLoaderPlugin() {
}

@Override
public void onInitializeModelLoader(Context pluginContext) {

pluginContext.addModels(CREATIVE_BASE_MODEL.id(), CREATIVE_GUI_MODEL.id());
pluginContext.addModels(CRUDE_BASE_MODEL.id(), CRUDE_GUI_MODEL.id());
pluginContext.addModels(SOUL_BASE_MODEL.id(), SOUL_GUI_MODEL.id());
pluginContext.addModels(WORLD_BASE_MODEL.id(), WORLD_GUI_MODEL.id());
/*TODO
pluginContext.addModels(CREATIVE_GUI_MODEL);
pluginContext.addModels(CRUDE_GUI_MODEL);
pluginContext.addModels(SOUL_GUI_MODEL);
pluginContext.addModels(WORLD_GUI_MODEL);

pluginContext.modifyModelAfterBake().register((original, context) -> {
ModelResourceLocation guiModelLocation = modelPairs.get(context.topLevelId());
if (guiModelLocation != null) {
BakedModel guiModel = context.baker().bake(guiModelLocation.id(), context.settings());
if (CREATIVE_BASE_MODEL.equals(context.topLevelId())) {
BakedModel guiModel = context.baker().bake(CREATIVE_GUI_MODEL, context.settings());
return new MalumBakedModel(original, guiModel);
}
if (CRUDE_BASE_MODEL.equals(context.topLevelId())) {
BakedModel guiModel = context.baker().bake(CRUDE_GUI_MODEL, context.settings());
return new MalumBakedModel(original, guiModel);
}
if (SOUL_BASE_MODEL.equals(context.topLevelId())) {
BakedModel guiModel = context.baker().bake(SOUL_GUI_MODEL, context.settings());
return new MalumBakedModel(original, guiModel);
}
if (WORLD_BASE_MODEL.equals(context.topLevelId())) {
BakedModel guiModel = context.baker().bake(WORLD_GUI_MODEL, context.settings());
return new MalumBakedModel(original, guiModel);
}
return original;
});
*/
}

private static class MalumBakedModel extends ForwardingBakedModel {
Expand Down Expand Up @@ -87,8 +90,4 @@ public boolean isVanillaAdapter() {
private static ModelResourceLocation createModel(String baseName) {
return new ModelResourceLocation(MalumMod.malumPath(baseName), "inventory");
}

private static ModelResourceLocation createGuiModel(String baseName) {
return new ModelResourceLocation(MalumMod.malumPath(baseName + "_gui"), "inventory");
}
}
18 changes: 0 additions & 18 deletions src/main/java/com/sammy/malum/core/events/ClientSetupEvents.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import net.minecraft.world.entity.LivingEntity;

public class MalumAttributeEventHandler {

public static void processAttributes(LivingDamageEvent event) {
if (event.getAmount() <= 0) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,30 +80,8 @@ public static void buildRecipes(RecipeOutput recipeOutput) {
}

protected static void addTags(MalumItemTags provider, MalumDatagenWoodSet woodSet) {
/*TODO
provider.tag(woodSet.logTag).add(
woodSet.log, woodSet.strippedLog, woodSet.wood, woodSet.strippedWood, woodSet.sapFilledLog, woodSet.strippedSapFilledLog);
provider.tag(woodSet.boardIngredientTag).add(woodSet.log, woodSet.wood);
provider.tag(woodSet.planksTag).add(
woodSet.boards, woodSet.verticalBoards,
woodSet.planks, woodSet.verticalPlanks,
woodSet.rusticPlanks, woodSet.verticalRusticPlanks,
woodSet.tiles, woodSet.rusticTiles
);
provider.tag(woodSet.stairsTag).add(
woodSet.boardsStairs, woodSet.verticalBoardsStairs,
woodSet.planksStairs, woodSet.verticalPlanksStairs,
woodSet.rusticPlanksStairs, woodSet.verticalRusticPlanksStairs,
woodSet.tilesStairs, woodSet.rusticTilesStairs
);
provider.tag(woodSet.slabTag).add(
woodSet.boardsSlab, woodSet.verticalBoardsSlab,
woodSet.planksSlab, woodSet.verticalPlanksSlab,
woodSet.rusticPlanksSlab, woodSet.verticalRusticPlanksSlab,
woodSet.tilesSlab, woodSet.rusticTilesSlab
);
*/


}

protected static void buildRecipes(RecipeOutput recipeOutput, MalumDatagenWoodSet woodSet) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ static ResourceKey<Enchantment> keyOf(String id) {
//TODO: move this to lodestone
public static int getEnchantmentLevel(Level level, ResourceKey<Enchantment> key, ItemStack stack) {
HolderGetter<Enchantment> enchantmentLookup = level.registryAccess().asGetterLookup().lookupOrThrow(Registries.ENCHANTMENT);
return stack.get(DataComponents.ENCHANTMENTS).getLevel(enchantmentLookup.getOrThrow(key));
var opt = enchantmentLookup.get(key);
return opt.map(enchantmentReference -> stack.get(DataComponents.ENCHANTMENTS).getLevel(enchantmentReference)).orElse(0);
}

}
77 changes: 69 additions & 8 deletions src/main/resources/assets/malum/models/item/creative_scythe.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,76 @@
{
"parent": "item/handheld",
"loader": "neoforge:separate_transforms",
"base": {
"parent": "malum:item/creative_scythe_handheld"
"textures": {
"layer0": "malum:item/creative_scythe_huge"
},
"perspectives": {
"gui": {
"parent": "malum:item/creative_scythe_gui"
"display": {
"thirdperson_righthand": {
"rotation": [
0,
-90,
55
],
"translation": [
0,
5,
0.5
],
"scale": [
1.45,
1.45,
1.45
]
},
"fixed": {
"parent": "malum:item/creative_scythe_gui"
"thirdperson_lefthand": {
"rotation": [
0,
90,
-55
],
"translation": [
0,
5,
0.5
],
"scale": [
1.45,
1.45,
1.45
]
},
"firstperson_righthand": {
"rotation": [
0,
-90,
25
],
"translation": [
1.13,
4.2,
1.13
],
"scale": [
1.1,
1.1,
1.1
]
},
"firstperson_lefthand": {
"rotation": [
0,
90,
-25
],
"translation": [
1.13,
4.2,
1.13
],
"scale": [
1.1,
1.1,
1.1
]
}
}
}
77 changes: 69 additions & 8 deletions src/main/resources/assets/malum/models/item/crude_scythe.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,76 @@
{
"parent": "item/handheld",
"loader": "neoforge:separate_transforms",
"base": {
"parent": "malum:item/crude_scythe_handheld"
"textures": {
"layer0": "malum:item/crude_scythe_huge"
},
"perspectives": {
"gui": {
"parent": "malum:item/crude_scythe_gui"
"display": {
"thirdperson_righthand": {
"rotation": [
0,
-90,
55
],
"translation": [
0,
5,
0.5
],
"scale": [
1.45,
1.45,
0.85
]
},
"fixed": {
"parent": "malum:item/crude_scythe_gui"
"thirdperson_lefthand": {
"rotation": [
0,
90,
-55
],
"translation": [
0,
5,
0.5
],
"scale": [
1.45,
1.45,
0.85
]
},
"firstperson_righthand": {
"rotation": [
0,
-90,
25
],
"translation": [
1.13,
4.2,
1.13
],
"scale": [
1.1,
1.1,
0.68
]
},
"firstperson_lefthand": {
"rotation": [
0,
90,
-25
],
"translation": [
1.13,
4.2,
1.13
],
"scale": [
1.1,
1.1,
0.68
]
}
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
{
"parent": "item/handheld",
"loader": "neoforge:separate_transforms",
"base": {
"parent": "malum:item/edge_of_deliverance_handheld"
},
"perspectives": {
"gui": {
"parent": "malum:item/edge_of_deliverance_gui"
},
"fixed": {
"parent": "malum:item/edge_of_deliverance_gui"
}
"textures": {
"layer0": "malum:item/edge_of_deliverance_handheld"
}
}
Loading

0 comments on commit 85fe787

Please sign in to comment.