Skip to content

Commit

Permalink
Basic functionality is done
Browse files Browse the repository at this point in the history
Gotta fix particles and add tooltip
  • Loading branch information
kckarnige committed Sep 25, 2024
1 parent 7a38616 commit b57bc0e
Show file tree
Hide file tree
Showing 6 changed files with 413 additions and 132 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ public abstract class ItemRendererMixin {
@ModifyVariable(method = "renderItem", at = @At(value = "HEAD"), argsOnly = true)
public BakedModel useMaceModel(BakedModel value, ItemStack stack, ModelTransformationMode renderMode, boolean leftHanded, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay) {
if (stack.isOf(Items.MACE) && renderMode != ModelTransformationMode.GUI && renderMode != ModelTransformationMode.GROUND && renderMode != ModelTransformationMode.FIXED) {
return ((ItemRendererAccessor) this).macebut3d$getModels().getModelManager().getModel(ModelIdentifier.ofInventoryVariant(Identifier.of(MOD_ID, "mace_hand")));
if (stack.getMaxDamage() - 120 == stack.getMaxDamage() - stack.getDamage()) {
return ((ItemRendererAccessor) this).macebut3d$getModels().getModelManager().getModel(ModelIdentifier.ofInventoryVariant(Identifier.of(MOD_ID, "mace_hand")));
} else {
return ((ItemRendererAccessor) this).macebut3d$getModels().getModelManager().getModel(ModelIdentifier.ofInventoryVariant(Identifier.of(MOD_ID, "mace_hand_wind")));
}
}
return value;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public abstract class ModelLoaderMixin {
)}
)
private void addMace(CallbackInfo info) {
this.loadItemModel(ModelIdentifier.ofInventoryVariant(Identifier.of(MOD_ID, "mace_hand_wind")));
this.loadItemModel(ModelIdentifier.ofInventoryVariant(Identifier.of(MOD_ID, "mace_hand")));
}
}
53 changes: 53 additions & 0 deletions src/main/java/com/kckarnige/wham/mixin/MaceMixin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package com.kckarnige.wham.mixin;

import com.kckarnige.wham.wham;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.MaceItem;
import net.minecraft.particle.ParticleTypes;
import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvent;
import net.minecraft.util.Hand;
import net.minecraft.util.Identifier;
import net.minecraft.util.TypedActionResult;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.hit.HitResult;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;

import java.util.Objects;

@Mixin(MaceItem.class)
public abstract class MaceMixin extends Item {

public MaceMixin(Settings settings) {
super(settings);
}

@Override
public TypedActionResult<ItemStack> use(World world, PlayerEntity player, Hand hand) {
if (!world.isClient()) {
if (Objects.equals(String.valueOf(player.getFacing()), "down")) {
HitResult hit = player.raycast(2, 0, false); // 20 is distance used by the DebugHud for "looking at block", false means ignore fluids
if (hit.getType() == HitResult.Type.BLOCK) {
BlockHitResult blockHit = (BlockHitResult) hit;
if (Objects.equals(String.valueOf(blockHit.getSide()), "up")) {
if (!(player.getStackInHand(hand).getMaxDamage() - 120 == player.getStackInHand(hand).getMaxDamage() - player.getStackInHand(hand).getDamage())) {
wham.LOGGER.info(String.valueOf(player.getStackInHand(hand).getMaxDamage() - player.getStackInHand(hand).getDamage()+" of "+player.getStackInHand(hand).getMaxDamage()));
world.playSound(null, player.getBlockPos(), SoundEvent.of(Identifier.of("minecraft:entity.wind_charge.wind_burst")), SoundCategory.PLAYERS);
world.addParticle(ParticleTypes.HEART, player.getX(), player.getY() + 2.0, player.getZ(), 0.0, 0.0, 0.0);
player.addStatusEffect(new StatusEffectInstance(StatusEffects.LEVITATION, 4, 20, false, false, false));
player.getStackInHand(hand).damage(40, player, LivingEntity.getSlotForHand(hand));
return TypedActionResult.success(player.getStackInHand(hand));
}
}
}
}
}
return TypedActionResult.fail(player.getStackInHand(hand));
}
}
132 changes: 1 addition & 131 deletions src/main/resources/assets/wham/models/item/mace_hand.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"credit": "Made with Blockbench",
"texture_size": [8, 8],
"textures": {
"1": "wham:item/mace_windu",
"9": "wham:item/mace_texture",
"particle": "item/mace"
},
Expand Down Expand Up @@ -56,105 +55,6 @@
"west": {"uv": [10.5, 9.5, 11.5, 16], "texture": "#9"}
}
},
{
"from": [6.75, 4.75, 6.75],
"to": [6.75, 8.25, 9.25],
"rotation": {"angle": 0, "axis": "y", "origin": [8, 6.5, 8]},
"faces": {
"north": {"uv": [4, 5, 8, 11], "texture": "#1"},
"east": {"uv": [0, 5, 4, 11], "texture": "#1"},
"south": {"uv": [12, 5, 16, 11], "texture": "#1"},
"west": {"uv": [8, 5, 12, 11], "texture": "#1"}
}
},
{
"from": [6.75, 4.75, 9.25],
"to": [9.25, 8.25, 9.25],
"rotation": {"angle": 0, "axis": "y", "origin": [8, 6.5, 8]},
"faces": {
"north": {"uv": [4, 5, 8, 11], "texture": "#1"},
"east": {"uv": [0, 5, 4, 11], "texture": "#1"},
"south": {"uv": [12, 5, 16, 11], "texture": "#1"},
"west": {"uv": [8, 5, 12, 11], "texture": "#1"}
}
},
{
"from": [6.75, 4.75, 6.75],
"to": [9.25, 8.25, 6.75],
"rotation": {"angle": 0, "axis": "y", "origin": [8, 6.5, 8]},
"faces": {
"north": {"uv": [4, 5, 8, 11], "texture": "#1"},
"east": {"uv": [0, 5, 4, 11], "texture": "#1"},
"south": {"uv": [12, 5, 16, 11], "texture": "#1"},
"west": {"uv": [8, 5, 12, 11], "texture": "#1"}
}
},
{
"from": [9.25, 4.75, 6.75],
"to": [9.25, 8.25, 9.25],
"rotation": {"angle": 0, "axis": "y", "origin": [8, 6.5, 8]},
"faces": {
"north": {"uv": [4, 5, 8, 11], "texture": "#1"},
"east": {"uv": [0, 5, 4, 11], "texture": "#1"},
"south": {"uv": [12, 5, 16, 11], "texture": "#1"},
"west": {"uv": [8, 5, 12, 11], "texture": "#1"}
}
},
{
"from": [6.75, 4.75, 6.75],
"to": [9.25, 8.25, 9.25],
"rotation": {"angle": 0, "axis": "y", "origin": [8, 6.5, 8]},
"faces": {
"north": {"uv": [4, 5, 8, 11], "texture": "#1"},
"east": {"uv": [0, 5, 4, 11], "texture": "#1"},
"south": {"uv": [12, 5, 16, 11], "texture": "#1"},
"west": {"uv": [8, 5, 12, 11], "texture": "#1"}
}
},
{
"from": [10.25, 5.75, 5.75],
"to": [10.25, 7.25, 10.25],
"rotation": {"angle": -45, "axis": "y", "origin": [8, 6.5, 8]},
"faces": {
"north": {"uv": [0, 0, 8, 2], "texture": "#1"},
"east": {"uv": [8, 2, 16, 4], "texture": "#1"},
"south": {"uv": [0, 2, 8, 4], "texture": "#1"},
"west": {"uv": [8, 0, 16, 2], "texture": "#1"}
}
},
{
"from": [5.75, 5.75, 5.75],
"to": [10.25, 7.25, 5.75],
"rotation": {"angle": -45, "axis": "y", "origin": [8, 6.5, 8]},
"faces": {
"north": {"uv": [0, 0, 8, 2], "texture": "#1"},
"east": {"uv": [8, 2, 16, 4], "texture": "#1"},
"south": {"uv": [0, 2, 8, 4], "texture": "#1"},
"west": {"uv": [8, 0, 16, 2], "texture": "#1"}
}
},
{
"from": [5.75, 5.75, 5.75],
"to": [5.75, 7.25, 10.25],
"rotation": {"angle": -45, "axis": "y", "origin": [8, 6.5, 8]},
"faces": {
"north": {"uv": [0, 0, 8, 2], "texture": "#1"},
"east": {"uv": [8, 2, 16, 4], "texture": "#1"},
"south": {"uv": [0, 2, 8, 4], "texture": "#1"},
"west": {"uv": [8, 0, 16, 2], "texture": "#1"}
}
},
{
"from": [5.75, 5.75, 10.25],
"to": [10.25, 7.25, 10.25],
"rotation": {"angle": -45, "axis": "y", "origin": [8, 6.5, 8]},
"faces": {
"north": {"uv": [0, 0, 8, 2], "texture": "#1"},
"east": {"uv": [8, 2, 16, 4], "texture": "#1"},
"south": {"uv": [0, 2, 8, 4], "texture": "#1"},
"west": {"uv": [8, 0, 16, 2], "texture": "#1"}
}
},
{
"name": "plane",
"from": [8, 8, 7.625],
Expand Down Expand Up @@ -312,37 +212,7 @@
"name": "Edit by KayoticCarnige",
"origin": [7.5, 6.375, 7.5],
"color": 0,
"children": [
{
"name": "Wind",
"origin": [8.40005, 5.75, 9.75],
"color": 0,
"children": [
{
"name": "Inner",
"origin": [4.75, 4.25, 4],
"color": 0,
"children": [4, 5, 6, 7, 8]
},
{
"name": "Outer",
"origin": [3.75, 5.25, 3],
"color": 0,
"children": [9, 10, 11, 12]
}
]
},
13,
14,
15,
16,
17,
18,
19,
20,
21,
22
]
"children": [4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
}
]
}
Expand Down
Loading

0 comments on commit b57bc0e

Please sign in to comment.