Skip to content

Commit

Permalink
add megumin's hat (see also: fbombs)
Browse files Browse the repository at this point in the history
  • Loading branch information
afamiliarquiet committed Nov 11, 2024
1 parent 018528f commit fb10f68
Show file tree
Hide file tree
Showing 14 changed files with 172 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@

@Mod(value = "familiar_magic", dist = Dist.CLIENT)
public class FamiliarMagicClient {
public static final ModelResourceLocation BIG_HAT_ON_HEAD_MODEL = ModelResourceLocation.inventory(ResourceLocation.fromNamespaceAndPath(MOD_ID, "big_hat_on_head"));
public static final ResourceLocation FOCUS_OVERLAY = ResourceLocation.fromNamespaceAndPath(MOD_ID, "textures/misc/focus.png");
public static final ResourceLocation FOCUS_LAYER = ResourceLocation.fromNamespaceAndPath(MOD_ID, "focus");
public static final ResourceLocation SUMMONING_REQUEST_LAYER = ResourceLocation.fromNamespaceAndPath(MOD_ID, "summoning_request");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,14 @@ public class FamiliarItems {
new Item.Properties().durability(1031)
)
);
public static final DeferredItem<Item> MEGUMINS_HAT = ITEMS.register( // todo - maybe only have this exist when fbombs loaded?
"megumins_hat",
() -> new ClothingItem(
SOMEWHAT_FAMILIAR_MATERIAL,
ArmorItem.Type.HELMET,
new Item.Properties().durability(1204)
)
);

public static void register(IEventBus eventBus) {
ITEMS.register(eventBus);
Expand Down Expand Up @@ -107,6 +115,11 @@ private static void mrwBuildCreativeModeTabContents(BuildCreativeModeTabContents
BIG_HAT.toStack(),
CreativeModeTab.TabVisibility.PARENT_AND_SEARCH_TABS
);
event.insertBefore(
Items.LEATHER_HELMET.getDefaultInstance(),
MEGUMINS_HAT.toStack(),
CreativeModeTab.TabVisibility.PARENT_AND_SEARCH_TABS
);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import java.util.List;
import java.util.Map;

import static io.github.afamiliarquiet.familiar_magic.FamiliarMagic.MOD_ID;

@Mixin(ModelBakery.class)
public abstract class HatBakeryMixin {
@Shadow
Expand All @@ -25,11 +27,18 @@ public abstract class HatBakeryMixin {
// it kinda sounds like this could be replaced with ModelEvent.RegisterAdditional but. ehhhh...
// this works and that might not. hey u reading this, if that'd work then tell me n i'll try it
@Inject(at = @At("TAIL"), method = "<init>")
private void mmFreshHotHat(BlockColors blockColors,
ProfilerFiller profilerFiller,
Map<ResourceLocation, BlockModel> modelResources,
Map<ResourceLocation, List<BlockStateModelLoader.LoadedJson>> blockStateResources,
CallbackInfo ci) {
this.loadSpecialItemModelAndDependencies(FamiliarMagicClient.BIG_HAT_ON_HEAD_MODEL);
private void mmFreshHotHat(
BlockColors blockColors,
ProfilerFiller profilerFiller,
Map<ResourceLocation, BlockModel> modelResources,
Map<ResourceLocation, List<BlockStateModelLoader.LoadedJson>> blockStateResources,
CallbackInfo ci)
{
this.loadSpecialItemModelAndDependencies(
ModelResourceLocation.inventory(ResourceLocation.fromNamespaceAndPath(MOD_ID, "big_hat_worn"))
);
this.loadSpecialItemModelAndDependencies(
ModelResourceLocation.inventory(ResourceLocation.fromNamespaceAndPath(MOD_ID, "megumins_hat_worn"))
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,21 @@

import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import io.github.afamiliarquiet.familiar_magic.FamiliarMagic;
import io.github.afamiliarquiet.familiar_magic.FamiliarMagicClient;
import io.github.afamiliarquiet.familiar_magic.item.ClothingItem;
import io.github.afamiliarquiet.familiar_magic.item.FamiliarItems;
import net.minecraft.client.renderer.ItemModelShaper;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.entity.ItemRenderer;
import net.minecraft.client.resources.model.BakedModel;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemDisplayContext;
import net.minecraft.world.item.ItemStack;
import org.spongepowered.asm.mixin.Mixin;
Expand Down Expand Up @@ -36,10 +44,16 @@ public void renderModelLists(BakedModel model, ItemStack stack, int combinedLigh
// could maybe replace this with a @modifyvariable n grab itemstack n display context via @local? might try later
@Inject(at = @At("HEAD"), method = "render", cancellable = true)
private void render(ItemStack itemStack, ItemDisplayContext displayContext, boolean leftHand, PoseStack poseStack, MultiBufferSource bufferSource, int combinedLight, int combinedOverlay, BakedModel p_model, CallbackInfo ci) {
if (itemStack.is(FamiliarItems.BIG_HAT) && displayContext == ItemDisplayContext.HEAD) {
if (itemStack.getItem() instanceof ClothingItem && displayContext == ItemDisplayContext.HEAD) {
if (!itemStack.isEmpty()) {
poseStack.pushPose();
p_model = this.itemModelShaper.getModelManager().getModel(FamiliarMagicClient.BIG_HAT_ON_HEAD_MODEL);

ResourceLocation originalLocation = BuiltInRegistries.ITEM.getKey(itemStack.getItem());
p_model = this.itemModelShaper.getModelManager().getModel(ModelResourceLocation.inventory(
ResourceLocation.fromNamespaceAndPath(
originalLocation.getNamespace(), originalLocation.getPath() + "_worn"
)
));

p_model = net.neoforged.neoforge.client.ClientHooks.handleCameraTransforms(poseStack, p_model, displayContext, leftHand);
poseStack.translate(-0.5F, -0.5F, -0.5F);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import io.github.afamiliarquiet.familiar_magic.data.FamiliarAttachments;
import io.github.afamiliarquiet.familiar_magic.data.HatWearer;
import io.github.afamiliarquiet.familiar_magic.item.ClothingItem;
import io.github.afamiliarquiet.familiar_magic.item.FamiliarItems;
import io.github.afamiliarquiet.familiar_magic.network.HattedPayload;
import net.minecraft.world.InteractionHand;
Expand Down Expand Up @@ -32,7 +33,7 @@ private void mobInteract(Player player, InteractionHand hand, CallbackInfoReturn
if (this instanceof HatWearer) {
boolean isClient = this.level().isClientSide;
if (player.isSecondaryUseActive()) {
if (player.getItemInHand(hand).is(FamiliarItems.BIG_HAT)) {
if (player.getItemInHand(hand).getItem() instanceof ClothingItem) {
if (!isClient) {
this.getData(FamiliarAttachments.HAT).setStackInSlot(0, player.getItemInHand(hand));
PacketDistributor.sendToPlayersTrackingEntity(this, new HattedPayload(player.getItemInHand(hand), this.getId()));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.github.afamiliarquiet.familiar_magic.mixin.hattery;

import io.github.afamiliarquiet.familiar_magic.data.HatWearer;
import io.github.afamiliarquiet.familiar_magic.item.ClothingItem;
import io.github.afamiliarquiet.familiar_magic.item.FamiliarItems;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
Expand All @@ -25,7 +26,7 @@ protected WolfHatEquipAndWearMixin(EntityType<? extends TamableAnimal> entityTyp
@Inject(at = @At("HEAD"), method = "mobInteract", cancellable = true)
private void mobInteract(Player player, InteractionHand hand, CallbackInfoReturnable<InteractionResult> cir) {
// there's some nonsense going on in wolf's mobinteract. let's just skip that if we've got hat business
if (player.isSecondaryUseActive() && (player.getItemInHand(hand).is(FamiliarItems.BIG_HAT) || hasHat(this))) {
if (player.isSecondaryUseActive() && (player.getItemInHand(hand).getItem() instanceof ClothingItem || hasHat(this))) {
cir.setReturnValue(super.mobInteract(player, hand));
}
}
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/familiar_magic/lang/en_us.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"item.familiar_magic.true_name": "True Name",
"item.familiar_magic.big_hat": "Big Hat",
"item.familiar_magic.megumins_hat": "Megumin's Hat",
"block.familiar_magic.enchanted_candle": "Enchanted Candle",
"block.familiar_magic.summoning_table": "Summoning Table",
"block.familiar_magic.smoke_wisp": "Wisp of Smoke",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"credit": "Made with Blockbench",
"texture_size": [64, 64],
"parent": "familiar_magic:item/template_hat_worn",
"textures": {
"1": "familiar_magic:item/big_hat_on_head"
"1": "familiar_magic:item/big_hat_worn"
},
"elements": [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "familiar_magic:item/megumins_hat"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
{
"credit": "Made with Blockbench",
"texture_size": [64, 64],
"textures": {
"1": "familiar_magic:item/megumins_hat_worn"
},
"elements": [
{
"from": [-4, 7, -4],
"to": [20, 8, 20],
"rotation": {"angle": 0, "axis": "x", "origin": [8, 7, 8]},
"faces": {
"north": {"uv": [0, 6.75, 6, 7], "texture": "#1"},
"east": {"uv": [0, 6.5, 6, 6.75], "texture": "#1"},
"south": {"uv": [0, 6.25, 6, 6.5], "texture": "#1"},
"west": {"uv": [0, 6, 6, 6.25], "texture": "#1"},
"up": {"uv": [0, 0, 6, 6], "texture": "#1"},
"down": {"uv": [0, 7, 6, 13], "texture": "#1"}
}
},
{
"from": [3, 8, 3],
"to": [13, 13, 13],
"rotation": {"angle": 0, "axis": "x", "origin": [8, 8, 8]},
"faces": {
"north": {"uv": [6, 6.25, 8.5, 7.5], "texture": "#1"},
"east": {"uv": [6, 5, 8.5, 6.25], "texture": "#1"},
"south": {"uv": [6, 3.75, 8.5, 5], "texture": "#1"},
"west": {"uv": [6, 2.5, 8.5, 3.75], "texture": "#1"},
"up": {"uv": [6, 0, 8.5, 2.5], "texture": "#1"},
"down": {"uv": [13.5, 13.5, 16, 16], "texture": "#1"}
}
},
{
"from": [5, 8, 9],
"to": [11, 14, 16],
"rotation": {"angle": -45, "axis": "x", "origin": [8, 8, 8]},
"faces": {
"north": {"uv": [13.5, 13.5, 15, 15], "rotation": 180, "texture": "#1"},
"east": {"uv": [8.5, 5, 10, 6.75], "rotation": 270, "texture": "#1"},
"south": {"uv": [8.5, 0, 10, 1.5], "texture": "#1"},
"west": {"uv": [8.5, 1.5, 10, 3.25], "rotation": 90, "texture": "#1"},
"up": {"uv": [8.5, 6.75, 10, 8.5], "rotation": 180, "texture": "#1"},
"down": {"uv": [8.5, 3.25, 10, 5], "texture": "#1"}
}
},
{
"from": [6, 12, 13],
"to": [10, 16, 18],
"rotation": {"angle": -22.5, "axis": "x", "origin": [8, 8, 8]},
"faces": {
"north": {"uv": [13.5, 13.5, 14.5, 14.5], "rotation": 180, "texture": "#1"},
"east": {"uv": [10, 3.5, 11, 4.75], "rotation": 270, "texture": "#1"},
"south": {"uv": [10, 0, 11, 1], "texture": "#1"},
"west": {"uv": [10, 1, 11, 2.25], "rotation": 90, "texture": "#1"},
"up": {"uv": [10, 4.75, 11, 6], "rotation": 180, "texture": "#1"},
"down": {"uv": [10, 2.25, 11, 3.5], "texture": "#1"}
}
}
],
"display": {
"thirdperson_righthand": {
"scale": [0.5, 0.5, 0.5]
},
"thirdperson_lefthand": {
"scale": [0.5, 0.5, 0.5]
},
"firstperson_righthand": {
"scale": [0.5, 0.5, 0.5]
},
"firstperson_lefthand": {
"scale": [0.5, 0.5, 0.5]
},
"ground": {
"scale": [0.5, 0.5, 0.5]
},
"gui": {
"scale": [0.5, 0.5, 0.5]
},
"head": {
"rotation": [11.25, 0, 0],
"translation": [0, 3, 0],
"scale": [1.6, 1.6, 1.6]
},
"fixed": {
"scale": [0.5, 0.5, 0.5]
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"neoforge:conditions": [
{
"type": "neoforge:mod_loaded",
"modid": "fbombs"
}
],
"type": "minecraft:crafting_shaped",
"category": "equipment",
"key": {
"#": {
"item": "minecraft:brown_wool"
},
"E": {
"item": "fbombs:high_power_tnt"
}
},
"pattern": [
" # ",
"#E#"
],
"result": {
"count": 1,
"id": "familiar_magic:explosion_hat"
}
}

0 comments on commit fb10f68

Please sign in to comment.