Skip to content

Commit

Permalink
malm
Browse files Browse the repository at this point in the history
  • Loading branch information
mrsterner committed Dec 19, 2024
1 parent d433193 commit 599ce66
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
{
"model": "malum:item/catalyst_lobber_open",
"predicate": {
"malum:state": 1.0
"malum:state": 0.2
}
},
{
"model": "malum:item/catalyst_lobber_loaded",
"predicate": {
"malum:state": 2.0
"malum:state": 0.1
}
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,31 @@
{
"model": "malum:item/ritual_shard_dim",
"predicate": {
"malum:tier": 2.0
"malum:tier": 0.2
}
},
{
"model": "malum:item/ritual_shard_vague",
"predicate": {
"malum:tier": 3.0
"malum:tier": 0.3
}
},
{
"model": "malum:item/ritual_shard_bright",
"predicate": {
"malum:tier": 4.0
"malum:tier": 0.4
}
},
{
"model": "malum:item/ritual_shard_vivid",
"predicate": {
"malum:tier": 5.0
"malum:tier": 0.5
}
},
{
"model": "malum:item/ritual_shard_radiant",
"predicate": {
"malum:tier": 6.0
"malum:tier": 0.6
}
}
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,62 +1,62 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "malum:item/soulwoven_banner_default"
},
"overrides": [
{
"model": "malum:item/soulwoven_banner_sequence",
"predicate": {
"malum:pattern": 1
},
"model": "malum:item/soulwoven_banner_sequence"
"malum:pattern": 0.1
}
},
{
"model": "malum:item/soulwoven_banner_sanity",
"predicate": {
"malum:pattern": 2
},
"model": "malum:item/soulwoven_banner_sanity"
"malum:pattern": 0.2
}
},
{
"model": "malum:item/soulwoven_banner_breeze",
"predicate": {
"malum:pattern": 3
"malum:pattern": 0.3
}
},
{
"model": "malum:item/soulwoven_banner_breath",
"predicate": {
"malum:pattern": 4
"malum:pattern": 0.4
}
},
{
"model": "malum:item/soulwoven_banner_break",
"predicate": {
"malum:pattern": 5
"malum:pattern": 0.5
}
},
{
"model": "malum:item/soulwoven_banner_hunger",
"predicate": {
"malum:pattern": 6
"malum:pattern": 0.6
}
},
{
"model": "malum:item/soulwoven_banner_horns",
"predicate": {
"malum:pattern": 7
"malum:pattern": 0.7
}
},
{
"model": "malum:item/soulwoven_banner_heft",
"predicate": {
"malum:pattern": 8
"malum:pattern": 0.8
}
},
{
"model": "malum:item/soulwoven_banner_hallucination",
"predicate": {
"malum:pattern": 9
"malum:pattern": 0.9
}
}
]
],
"textures": {
"layer0": "malum:item/soulwoven_banner_default"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public void appendHoverText(ItemStack stack, Item.TooltipContext context, List<C
}

public static float getBannerPattern(ItemStack stack) {
var pattern = stack.get(DataComponentRegistry.SOULWOVEN_BANNER_PATTERN.get());
return SoulwovenBannerPatternData.REGISTERED_PATTERNS.indexOf(pattern) ;
var pattern = stack.getOrDefault(DataComponentRegistry.SOULWOVEN_BANNER_PATTERN.get(), SoulwovenBannerPatternData.DEFAULT);
return SoulwovenBannerPatternData.REGISTERED_PATTERNS.contains(pattern) ? SoulwovenBannerPatternData.REGISTERED_PATTERNS.indexOf(pattern) / 10f : 0;
}

public static void addBannerVariantsToCreativeTab() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.sammy.malum.common.entity.nitrate.*;
import com.sammy.malum.registry.common.*;
import com.sammy.malum.registry.common.item.*;
import net.minecraft.network.chat.Component;
import net.minecraft.sounds.*;
import net.minecraft.stats.*;
import net.minecraft.world.*;
Expand All @@ -12,6 +13,7 @@
import net.minecraft.world.item.*;
import net.minecraft.world.level.*;

import java.util.List;
import java.util.function.*;

public class CatalystLobberItem extends Item {
Expand All @@ -22,12 +24,19 @@ public CatalystLobberItem(Properties pProperties, Function<Player, AbstractNitra
this.entitySupplier = entitySupplier;
}

public static int getStateDisplay(ItemStack stack) {
@Override
public void appendHoverText(ItemStack stack, TooltipContext context, List<Component> tooltipComponents, TooltipFlag tooltipFlag) {
var data = stack.get(DataComponentRegistry.CATALYST_LOBBER_STATE.get());
tooltipComponents.add(Component.literal(String.valueOf(data.state())));
super.appendHoverText(stack, context, tooltipComponents, tooltipFlag);
}

public static float getStateDisplay(ItemStack stack) {
var data = stack.get(DataComponentRegistry.CATALYST_LOBBER_STATE.get());
if (data == null) {
return -1;
}
return data.state();
return data.state() / 10f;
}
@Override
public boolean isValidRepairItem(ItemStack stack, ItemStack repairCandidate) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ public RitualShardItem(Properties properties) {
super(properties);
}

public static int getStateDisplay(ItemStack stack) {
public static float getStateDisplay(ItemStack stack) {
var data = stack.get(DataComponentRegistry.RITUAL_DATA.get());
if (data == null) {
return -1;
}
return data.ritualTier().potency;
return data.ritualTier().potency / 10f;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class MalumItemModelSmithTypes {
String path = ritualTier.identifier.getPath();
ResourceLocation itemTexturePath = provider.getItemTexture(base + "_" + path);
provider.getBuilder(BuiltInRegistries.ITEM.getKey(item).getPath()).override()
.predicate(MalumMod.malumPath("tier"), ritualTier.potency)
.predicate(MalumMod.malumPath("tier"), ritualTier.potency / 10f)
.model(provider.withExistingParent(provider.getItemName(item) + "_" + path, GENERATED).texture("layer0", itemTexturePath))
.end();
}
Expand All @@ -59,7 +59,7 @@ public class MalumItemModelSmithTypes {
String base = provider.getItemName(item);
provider.createGenericModel(item, GENERATED, provider.getItemTexture(base + "_default"));
for (SoulwovenBannerPatternData pattern : SoulwovenBannerPatternData.REGISTERED_PATTERNS) {
final int i = SoulwovenBannerPatternData.REGISTERED_PATTERNS.indexOf(pattern);
final float i = SoulwovenBannerPatternData.REGISTERED_PATTERNS.indexOf(pattern) / 10f;
if (pattern.equals(SoulwovenBannerPatternData.DEFAULT)) {
continue;
}
Expand All @@ -75,11 +75,15 @@ public class MalumItemModelSmithTypes {
public static ItemModelSmith CATALYST_LOBBER = new ItemModelSmith((item, provider) -> {
String base = provider.getItemName(item);
provider.createGenericModel(item, HANDHELD, provider.getItemTexture(base));
for (int i = 1; i <= 2; i++) {
String affix = i == 1 ? "open" : "loaded";

float[] states = {0.2f, 0.1f};
String[] affixes = {"open", "loaded"};

for (int i = 0; i < states.length; i++) {
String affix = affixes[i];
ResourceLocation itemTexturePath = provider.getItemTexture(base + "_" + affix);
provider.getBuilder(BuiltInRegistries.ITEM.getKey(item).getPath()).override()
.predicate(MalumMod.malumPath("state"), i)
.predicate(MalumMod.malumPath("state"), states[i])
.model(provider.withExistingParent(base + "_" + affix, HANDHELD).texture("layer0", itemTexturePath))
.end();
}
Expand Down

0 comments on commit 599ce66

Please sign in to comment.