Skip to content

Commit

Permalink
joint renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
PssbleTrngle committed Sep 21, 2023
1 parent 73ed5a5 commit 1487f5f
Show file tree
Hide file tree
Showing 32 changed files with 281 additions and 134 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "blissful:item/joint"
}
"parent": "minecraft:builtin/entity"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "blissful:item/joint"
}
}
29 changes: 0 additions & 29 deletions common/src/main/java/galena/blissful/client/JointRenderer.java

This file was deleted.

13 changes: 4 additions & 9 deletions common/src/main/java/galena/blissful/index/BlissfuItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,14 @@
import com.tterrag.registrate.util.entry.ItemEntry;
import com.tterrag.registrate.util.nullness.NonNullSupplier;
import galena.blissful.BlissfulClient;
import galena.blissful.BlissfulConstants;
import galena.blissful.platform.Services;
import galena.blissful.world.item.BongItem;
import galena.blissful.world.item.JointItem;
import galena.blissful.world.item.LazyFoodItem;
import galena.blissful.world.item.PotionBongItem;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.registries.Registries;
import net.minecraft.data.recipes.RecipeCategory;
import net.minecraft.data.recipes.ShapelessRecipeBuilder;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagKey;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.food.FoodProperties;
import net.minecraft.world.item.CreativeModeTabs;
Expand Down Expand Up @@ -99,14 +95,13 @@ private static <T extends Item> Consumer<CreativeModeTabModifier> addPotionStack
.properties(it -> it.craftRemainder(Items.GLASS_BOTTLE))
.model((c, p) -> p.generated(c, p.modLoc("item/bong_potion"), p.modLoc("item/bong_potion_overlay")))
.register();

public static final TagKey<Item> NAUSEATING = TagKey.create(Registries.ITEM, new ResourceLocation(BlissfulConstants.MOD_ID, "nauseating"));

public static final ItemEntry<JointItem> JOINT = REGISTRATE
.item("joint", JointItem::new)
.item("joint", Services.PLATFORM::createJointItem)
.properties(it -> it.durability(Services.CONFIG.common().getJointHits()))
.tag(NAUSEATING)
.tag(BlissfulTags.NAUSEATING)
.tag(BlissfulTags.ATTACHED_TO_HEAD)
.tab(CreativeModeTabs.FOOD_AND_DRINKS)
.model(Services.DATAGEN::joint)
.recipe((c, p) -> ShapelessRecipeBuilder
.shapeless(RecipeCategory.FOOD, c.get())
.requires(Items.PAPER)
Expand Down
6 changes: 6 additions & 0 deletions common/src/main/java/galena/blissful/index/BlissfulTags.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
package galena.blissful.index;

import galena.blissful.BlissfulConstants;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagKey;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;

public class BlissfulTags {

public static final TagKey<Block> SUMMER_CROPS = TagKey.create(Registries.BLOCK, new ResourceLocation("sereneseasons", "summer_crops"));

public static final TagKey<Item> NAUSEATING = TagKey.create(Registries.ITEM, new ResourceLocation(BlissfulConstants.MOD_ID, "nauseating"));

public static final TagKey<Item> ATTACHED_TO_HEAD = TagKey.create(Registries.ITEM, new ResourceLocation(BlissfulConstants.MOD_ID, "attached_to_head"));

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package galena.blissful.mixins;

import galena.blissful.index.BlissfuItems;
import net.minecraft.client.renderer.entity.layers.PlayerItemInHandLayer;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;

@Mixin(PlayerItemInHandLayer.class)
public class PlayerItemInHandLayerMixin {

@Redirect(
method = "renderArmWithItem",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/world/item/ItemStack;is(Lnet/minecraft/world/item/Item;)Z"
)
)
public boolean isUsingJoint(ItemStack instance, Item item) {
return BlissfuItems.JOINT.isIn(instance) || instance.is(item);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import com.tterrag.registrate.providers.DataGenContext;
import com.tterrag.registrate.providers.RegistrateBlockstateProvider;
import com.tterrag.registrate.providers.RegistrateItemModelProvider;
import com.tterrag.registrate.providers.loot.RegistrateBlockLootTables;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.CropBlock;

Expand All @@ -14,4 +16,6 @@ public interface IDataGenHelper {

void crate(DataGenContext<Block, ? extends Block> context, RegistrateBlockstateProvider provider);

void joint(DataGenContext<Item, ? extends Item> context, RegistrateItemModelProvider provider);

}
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package galena.blissful.platform.services;

import com.tterrag.registrate.AbstractRegistrate;
import galena.blissful.world.item.JointItem;
import net.minecraft.world.item.Item;

import java.util.function.Consumer;

public interface IPlatformHelper {

AbstractRegistrate<?> getRegistrate();

void registerItemRenderer(Item item, Consumer<Object> consumer);
default JointItem createJointItem(Item.Properties properties) {
return new JointItem(properties);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package galena.blissful.world.effects;

import galena.blissful.index.BlissfuItems;
import galena.blissful.index.BlissfulTags;
import galena.blissful.platform.Services;
import net.minecraft.world.effect.MobEffect;
import net.minecraft.world.effect.MobEffectCategory;
Expand All @@ -20,7 +20,7 @@ public PeaceEffect() {
@Override
public void onIncreasedTo(MobEffectInstance instance, ItemStack source, LivingEntity target, Level level) {
var hitsTaken = instance.getAmplifier() + 1;
if (source.is(BlissfuItems.NAUSEATING) && hitsTaken >= Services.CONFIG.common().nauseaAfterHits()) {
if (source.is(BlissfulTags.NAUSEATING) && hitsTaken >= Services.CONFIG.common().nauseaAfterHits()) {
target.addEffect(new MobEffectInstance(MobEffects.CONFUSION, 20 * 20, 0));
}
}
Expand Down
24 changes: 14 additions & 10 deletions common/src/main/java/galena/blissful/world/item/JointItem.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,31 @@
package galena.blissful.world.item;

import galena.blissful.BlissfulConstants;
import galena.blissful.index.BlissfulEffects;
import galena.blissful.platform.Services;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.item.ItemDisplayContext;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import org.jetbrains.annotations.Nullable;

import java.util.function.Consumer;
import java.util.stream.Stream;

public class JointItem extends SmokingItem {

public static final ModelResourceLocation HAND_MODEL = new ModelResourceLocation(BlissfulConstants.MOD_ID, "joint_in_hand", "inventory");
public static final ModelResourceLocation FLAT_MODEL = new ModelResourceLocation(BlissfulConstants.MOD_ID, "joint_flat", "inventory");


public static ModelResourceLocation getModel(ItemDisplayContext mode) {
return switch (mode) {
case GUI, GROUND, FIXED -> FLAT_MODEL;
default -> HAND_MODEL;
};
}

public JointItem(Properties properties) {
super(properties);
}
Expand All @@ -22,13 +35,4 @@ Stream<MobEffectInstance> getEffects(ItemStack stack, @Nullable Level level, @Nu
return Stream.of(new MobEffectInstance(BlissfulEffects.PEACE.get(), 20 * Services.CONFIG.common().jointPeaceSeconds(), 0));
}

/**
* Overrides method in forge environment
* @param consumer IClientItemExtension
*/
@SuppressWarnings("unused")
public void initializeClient(Consumer<Object> consumer) {
Services.PLATFORM.registerItemRenderer(this, consumer);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public int getUseDuration(ItemStack stack) {

@Override
public UseAnim getUseAnimation(ItemStack stack) {
return UseAnim.BOW;
return UseAnim.SPYGLASS;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,87 +5,30 @@
},
"elements": [
{
"from": [
0.8,
-1,
8
],
"to": [
15.2,
15,
8
],
"rotation": {
"origin": [
8,
8,
8
],
"axis": "y",
"angle": 45,
"rescale": true
},
"from": [0.8, -1, 8],
"to": [15.2, 15, 8],
"shade": false,
"faces": {
"north": {
"uv": [
0,
0,
16,
16
],
"uv": [0, 0, 16, 16],
"texture": "#cross"
},
"south": {
"uv": [
0,
0,
16,
16
],
"uv": [0, 0, 16, 16],
"texture": "#cross"
}
}
},
{
"from": [
8,
-1,
0.8
],
"to": [
8,
15,
15.2
],
"rotation": {
"origin": [
8,
8,
8
],
"axis": "y",
"angle": 45,
"rescale": true
},
}, {
"from": [8, -1, 0.8],
"to": [8, 15, 15.2],
"shade": false,
"faces": {
"west": {
"uv": [
0,
0,
16,
16
],
"uv": [0, 0, 16, 16],
"texture": "#cross"
},
"east": {
"uv": [
0,
0,
16,
16
],
"uv": [0, 0, 16, 16],
"texture": "#cross"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"from": [8, -1, 0],
"to": [8, 31, 16],
"shade": false,
"rotation": {"angle": 0, "axis": "y", "origin": [8, -1, 8]},
"faces": {
"east": {"uv": [0, 0, 8, 16], "texture": "#texture"},
"west": {"uv": [0, 0, 8, 16], "texture": "#texture"}
Expand All @@ -21,7 +20,6 @@
"from": [0, -1, 8],
"to": [16, 31, 8],
"shade": false,
"rotation": {"angle": 0, "axis": "y", "origin": [8, -1, 8]},
"faces": {
"north": {"uv": [0, 0, 8, 16], "texture": "#texture"},
"south": {"uv": [0, 0, 8, 16], "texture": "#texture"}
Expand Down Expand Up @@ -115,5 +113,10 @@
"color": 0,
"children": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
}
]
],
"display": {
"fixed": {
"rotation": [0, 45, 0]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"meta":{"format_version":"4.5","model_format":"java_block","box_uv":true},"name":"joint_in_hand","parent":"","ambientocclusion":true,"front_gui_light":false,"visible_box":[1,1,0],"variable_placeholders":"","variable_placeholder_buttons":[],"unhandled_root_fields":{},"resolution":{"width":64,"height":64},"elements":[{"name":"cube","box_uv":false,"rescale":false,"locked":false,"render_order":"default","allow_mirror_modeling":true,"from":[7,6,4],"to":[9,8,12],"autouv":0,"color":5,"origin":[8,7,8],"faces":{"north":{"uv":[4,0,6,2],"rotation":180,"texture":0},"east":{"uv":[0,2,2,10],"rotation":270,"texture":0},"south":{"uv":[2,0,4,2],"rotation":180,"texture":0},"west":{"uv":[4,2,6,10],"rotation":90,"texture":0},"up":{"uv":[4,2,2,10],"rotation":180,"texture":0},"down":{"uv":[4,2,2,10],"texture":0}},"type":"cube","uuid":"3b627823-ebf5-1080-a94f-799a9d8426b7"}],"outliner":["3b627823-ebf5-1080-a94f-799a9d8426b7"],"textures":[{"path":"D:\\repos\\Minecraft\\Blissful\\common\\src\\main\\resources\\assets\\blissful\\textures\\item\\joint_in_hand.png","name":"joint_in_hand.png","folder":"item","namespace":"blissful","id":"texture","particle":true,"render_mode":"default","render_sides":"auto","frame_time":1,"frame_order_type":"loop","frame_order":"","frame_interpolate":false,"visible":true,"mode":"bitmap","saved":true,"uuid":"e78fa5f9-a8fd-2f43-6a37-70833c41d6b2","relative_path":"../../../textures/item/joint_in_hand.png","source":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAAAXNSR0IArs4c6QAAAaVJREFUeF7tlr0vQ2EchX93MfhoImnaCiI0hiYSlUgawu4PECOTpZPFyOAfYGExsRFmYpEgoSFR0x2kDIhWmkjqY7BcuW+R2M583tOleduznOc8b28D+3ltLExHyUSr7V9cuk92jsLg9zvm97+SMYChvpStHxxboqvFNrdu/ACwuzwbZTrb3chRsteC+oNVX9/dud74tOLaHjWIIAaQHsy5wiPZHruuPFrtNvQHwMlqMcoXxv5d83Lp3J1jE2ZWtrkNWFocjyYnmgZkB9JWuavZ6VnTgOrLB/1vQTA/NxxNFUZd4Y5us7cns8PSlTs3nr/onwaB9wZ4DyC+AplUm1M+35+z8n3o7r43V4D5Xx7SjfoRJwAAARkAQKKOyADqeYFyMgCARB2RAdTzAuVkAACJOiIDqOcFyskAABJ1RAZQzwuUkwEAJOqIDKCeFygnAwBI1BEZQD0vUE4GAJCoIzKAel6gnAwAIFFHZAD1vEA5GQBAoo7IAOp5gXIyAIBEHZEB1PMC5WQAAIk6IgOo5wXKyQAAEnVEBlDPC5STAQAk6oj3BnwDPk5yQYirNyUAAAAASUVORK5CYII="}]}
Loading

0 comments on commit 1487f5f

Please sign in to comment.