Skip to content

Commit

Permalink
aquatic catalyst and curios rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
Thepigcat76 committed Sep 5, 2024
1 parent fa1b2d4 commit 7e95a8d
Show file tree
Hide file tree
Showing 12 changed files with 124 additions and 29 deletions.
12 changes: 8 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,17 @@ group = mod_group_id

repositories {
mavenLocal()
maven {
url "https://cursemaven.com"
}
maven {
// location of the maven that hosts JEI files since January 2023
name = "Jared's maven"
url = "https://maven.blamejared.com/"
}
maven {
url "https://cursemaven.com"
name = "OctoStudios"
url = uri("https://maven.octo-studios.com/releases")
}
}

Expand All @@ -46,15 +50,15 @@ runs {

server {
systemProperty 'forge.enabledGameTestNamespaces', project.mod_id
programArgument '--nogui'
argument '--nogui'
}

gameTestServer {
systemProperty 'forge.enabledGameTestNamespaces', project.mod_id
}

data {
programArguments.addAll '--mod', project.mod_id, '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath()
arguments.addAll '--mod', project.mod_id, '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath()
}
}

Expand All @@ -67,7 +71,7 @@ configurations {
dependencies {
implementation "net.neoforged:neoforge:${neo_version}"

implementation "curse.maven:curios-continuation-1037991:5690713"
implementation "top.theillusivec4.curios:curios-neoforge:${curios_version}+1.21"

compileOnly "mezz.jei:jei-${minecraft_version}-common-api:${jei_version}"
compileOnly "mezz.jei:jei-${minecraft_version}-neoforge-api:${jei_version}"
Expand Down
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ mod_description=Mod for the curseforge 2024 modjam

## Dependency Properties

jei_version = 19.16.4.170
jei_version = 19.16.4.170
curios_version = 9.0.9
3 changes: 1 addition & 2 deletions src/main/java/com/portingdeadmods/modjam/ModJamClient.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package com.portingdeadmods.modjam;

import com.mojang.datafixers.optics.Prism;
import com.portingdeadmods.modjam.registries.MJItems;
import com.portingdeadmods.modjam.render.curios.PrismMonocleCuriosRenderer;
import com.portingdeadmods.modjam.client.renderer.curios.PrismMonocleCuriosRenderer;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.fml.ModContainer;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package com.portingdeadmods.modjam.client.renderer.curios;

import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import com.mojang.math.Axis;
import com.portingdeadmods.modjam.tiers.MJArmorMaterials;
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.*;
import net.minecraft.client.model.geom.EntityModelSet;
import net.minecraft.client.model.geom.ModelLayerLocation;
import net.minecraft.client.model.geom.ModelLayers;
import net.minecraft.client.model.geom.ModelPart;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.entity.RenderLayerParent;
import net.minecraft.client.renderer.entity.layers.HumanoidArmorLayer;
import net.minecraft.client.renderer.entity.player.PlayerRenderer;
import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.core.component.DataComponents;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ArmorItem;
import net.minecraft.world.item.ArmorMaterial;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.armortrim.ArmorTrim;
import net.neoforged.neoforge.client.ClientHooks;
import net.neoforged.neoforge.client.extensions.common.IClientItemExtensions;
import top.theillusivec4.curios.api.SlotContext;
import top.theillusivec4.curios.api.client.ICurioRenderer;
import top.theillusivec4.curios.api.type.capability.ICurio;

import java.util.List;

public class PrismMonocleCuriosRenderer implements ICurioRenderer {

@Override
public <T extends LivingEntity, M extends EntityModel<T>> void render(ItemStack itemStack,
SlotContext slotContext,
PoseStack poseStack,
RenderLayerParent<T, M> renderLayerParent,
MultiBufferSource multiBufferSource,
int light, float v, float v1, float v2, float v3, float v4, float v5) {
LivingEntity entity = slotContext.entity();
Minecraft mc = Minecraft.getInstance();
EntityModelSet entityModels = mc.getEntityModels();
ModelPart part = entityModels.bakeLayer(ModelLayers.PLAYER_OUTER_ARMOR);
HumanoidModel<LivingEntity> playerHumanoidModel = new HumanoidModel<>(part);
Model armorModel = ClientHooks.getArmorModel(entity, itemStack, EquipmentSlot.HEAD, playerHumanoidModel);
List<ArmorMaterial.Layer> layers = MJArmorMaterials.PRISMARINE.value().layers();
for (int i = 0; i < layers.size(); i++) {
ArmorMaterial.Layer layer = layers.get(i);
ResourceLocation armorTexture = ClientHooks.getArmorTexture(entity, itemStack, layer, false, EquipmentSlot.HEAD);
IClientItemExtensions iClientItemExtensions = IClientItemExtensions.of(itemStack);
int color = iClientItemExtensions.getArmorLayerTintColor(itemStack, entity, layer, i, iClientItemExtensions.getDefaultDyeColor(itemStack));
VertexConsumer vertexconsumer = multiBufferSource.getBuffer(RenderType.armorCutoutNoCull(armorTexture));
ICurioRenderer.followBodyRotations(entity, playerHumanoidModel);
armorModel.renderToBuffer(poseStack, vertexconsumer, light, OverlayTexture.NO_OVERLAY, color);

}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.portingdeadmods.modjam.content.blocks;

import com.portingdeadmods.modjam.utils.MJBlockStateProperties;
import net.minecraft.core.BlockPos;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.ItemInteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.phys.BlockHitResult;

public class AquaticCatalaystBlock extends Block {
public AquaticCatalaystBlock(Properties properties) {
super(properties);
}

@Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
super.createBlockStateDefinition(builder.add(MJBlockStateProperties.HOS_ACTIVE));
}

@Override
protected ItemInteractionResult useItemOn(ItemStack stack, BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hitResult) {
// TODO: Use a tag for this
if (stack.is(Items.HEART_OF_THE_SEA)) {
level.setBlockAndUpdate(pos, state.setValue(MJBlockStateProperties.HOS_ACTIVE, player.getDirection().getOpposite()));
}
return super.useItemOn(stack, state, level, pos, player, hand, hitResult);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public BlockModelProvider(PackOutput output, ExistingFileHelper existingFileHelp
@Override
protected void registerStatesAndModels() {
axisBlock(MJBlocks.DARK_PRISMARINE_PILLAR.get());
blockTexture(MJBlocks.CHISELED_DARK_PRISMARINE.get());
simpleBlock(MJBlocks.CHISELED_DARK_PRISMARINE.get());
simpleBlock(MJBlocks.AQUATIC_CATALYST.get());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
public final class MJBlocks {
public static final DeferredRegister.Blocks BLOCKS = DeferredRegister.createBlocks(ModJam.MODID);

public static final DeferredBlock<RotatedPillarBlock> DARK_PRISMARINE_PILLAR = registerBlockAndItem("chiseled_dark_prismarine", RotatedPillarBlock::new, BlockBehaviour.Properties.ofFullCopy(Blocks.DARK_PRISMARINE));
public static final DeferredBlock<Block> CHISELED_DARK_PRISMARINE = registerBlockAndItem("chiseled_prismarine_pillar", Block::new, BlockBehaviour.Properties.ofFullCopy(Blocks.DARK_PRISMARINE));
public static final DeferredBlock<RotatedPillarBlock> DARK_PRISMARINE_PILLAR = registerBlockAndItem("dark_prismarine_pillar", RotatedPillarBlock::new, BlockBehaviour.Properties.ofFullCopy(Blocks.DARK_PRISMARINE));
public static final DeferredBlock<Block> CHISELED_DARK_PRISMARINE = registerBlockAndItem("chiseled_dark_prismarine", Block::new, BlockBehaviour.Properties.ofFullCopy(Blocks.DARK_PRISMARINE));
public static final DeferredBlock<Block> AQUATIC_CATALYST = registerBlockAndItem("aquatic_catalyst", Block::new, BlockBehaviour.Properties.ofFullCopy(Blocks.DARK_PRISMARINE));

private static <T extends Block> DeferredBlock<T> registerBlockAndItem(String name, Function<BlockBehaviour.Properties, T> blockConstructor, BlockBehaviour.Properties properties) {
return registerBlockAndItem(name, blockConstructor, properties, true);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.portingdeadmods.modjam.utils;

import net.minecraft.world.level.block.state.properties.DirectionProperty;

public final class MJBlockStateProperties {
public static final DirectionProperty HOS_ACTIVE = DirectionProperty.create("hos_active");
}
1 change: 1 addition & 0 deletions src/main/resources/META-INF/accesstransformes.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
public net.minecraft.client.model.PlayerModel slim
3 changes: 3 additions & 0 deletions src/main/resources/META-INF/neoforge.mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@ type = "required"
versionRange = "${minecraft_version_range}"
ordering = "NONE"
side = "BOTH"

[[accessTransformers]]
file = "META-INF/accesstransformer.cfg"
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 7e95a8d

Please sign in to comment.