Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ktpatient committed Sep 21, 2024
2 parents ce84a4b + 95bea2a commit f2ab3c7
Show file tree
Hide file tree
Showing 32 changed files with 192 additions and 80 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
// 1.21.1 2024-09-20T22:52:49.700157485 Item Models: modjam
2e5c757869c8a635de54e96f2c267632575d7f88 assets/modjam/models/item/aquarine_steel_axe.json
// 1.21.1 2024-09-21T17:45:52.452849613 Item Models: modjam
a94d042befdb0b07687e8780d93b12b87c46b2a1 assets/modjam/models/item/aquarine_steel_axe.json
78fc833245a9706000288da1ba5f1161d9096b8b assets/modjam/models/item/aquarine_steel_axe_enabled.json
51765874ad3111adf69684269ad9a422bfbaac4a assets/modjam/models/item/aquarine_steel_block.json
9cd4fd3035913198bebfee10401997a85c0cdc6d assets/modjam/models/item/aquarine_steel_hoe.json
dfddb2f37a6da335fb3ed051177f75dc1a40e4fd assets/modjam/models/item/aquarine_steel_hoe.json
715d32fa875bf841a76a867a2be587e317510698 assets/modjam/models/item/aquarine_steel_hoe_enabled.json
e674d6859446f65b4ee805ed6e9f47d6cde82515 assets/modjam/models/item/aquarine_steel_ingot.json
37f176b86c6012b6b9bc65bd972c720e294f9844 assets/modjam/models/item/aquarine_steel_pickaxe.json
7621bf9cc6417af323762219c19a2639ae17bb72 assets/modjam/models/item/aquarine_steel_shovel.json
c034bf7af48030b58d7e60cf529b2f045f5d402d assets/modjam/models/item/aquarine_steel_sword.json
925b69eb2b8f05a1e1ec8803976e844d074945f8 assets/modjam/models/item/aquarine_steel_pickaxe.json
b8f49b5662934b30e9ae6f3eb204464d74ecc680 assets/modjam/models/item/aquarine_steel_pickaxe_enabled.json
66ebd3bc63994ee240d94a1e5942b12a4ffb6438 assets/modjam/models/item/aquarine_steel_shovel.json
dda536a9cfc81f45e5c817e205639027c8dd5ff8 assets/modjam/models/item/aquarine_steel_shovel_enabled.json
e9548e9b4cc741a2e3f6624d768914eeb34b14c8 assets/modjam/models/item/aquarine_steel_sword.json
6e8c1f3a22c524f671457fb9315f8b118fc892af assets/modjam/models/item/aquarine_steel_sword_enabled.json
098a336dd0b210f2b650174de2346a665b921edd assets/modjam/models/item/aquarine_steel_wrench.json
dd0c37deb1f33fb0844da4a540706681887fc3d4 assets/modjam/models/item/aquatic_catalyst.json
66eb6899181dacf931e95e546a991d5e25dcc5da assets/modjam/models/item/atlantic_gold_ingot.json
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
{
"parent": "minecraft:item/handheld",
"overrides": [
{
"model": "modjam:item/aquarine_steel_axe",
"predicate": {
"modjam:enabled": 0.0
}
},
{
"model": "modjam:item/aquarine_steel_axe_enabled",
"predicate": {
"modjam:enabled": 1.0
}
}
],
"textures": {
"layer0": "modjam:item/aquarine_steel_axe"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/handheld",
"textures": {
"layer0": "modjam:item/aquarine_steel_axe_enabled"
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
{
"parent": "minecraft:item/handheld",
"overrides": [
{
"model": "modjam:item/aquarine_steel_hoe",
"predicate": {
"modjam:enabled": 0.0
}
},
{
"model": "modjam:item/aquarine_steel_hoe_enabled",
"predicate": {
"modjam:enabled": 1.0
}
}
],
"textures": {
"layer0": "modjam:item/aquarine_steel_hoe"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/handheld",
"textures": {
"layer0": "modjam:item/aquarine_steel_hoe_enabled"
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
{
"parent": "minecraft:item/handheld",
"overrides": [
{
"model": "modjam:item/aquarine_steel_pickaxe",
"predicate": {
"modjam:enabled": 0.0
}
},
{
"model": "modjam:item/aquarine_steel_pickaxe_enabled",
"predicate": {
"modjam:enabled": 1.0
}
}
],
"textures": {
"layer0": "modjam:item/aquarine_steel_pickaxe"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/handheld",
"textures": {
"layer0": "modjam:item/aquarine_steel_pickaxe_enabled"
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
{
"parent": "minecraft:item/handheld",
"overrides": [
{
"model": "modjam:item/aquarine_steel_shovel",
"predicate": {
"modjam:enabled": 0.0
}
},
{
"model": "modjam:item/aquarine_steel_shovel_enabled",
"predicate": {
"modjam:enabled": 1.0
}
}
],
"textures": {
"layer0": "modjam:item/aquarine_steel_shovel"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/handheld",
"textures": {
"layer0": "modjam:item/aquarine_steel_shovel_enabled"
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
{
"parent": "minecraft:item/handheld",
"overrides": [
{
"model": "modjam:item/aquarine_steel_sword",
"predicate": {
"modjam:enabled": 0.0
}
},
{
"model": "modjam:item/aquarine_steel_sword_enabled",
"predicate": {
"modjam:enabled": 1.0
}
}
],
"textures": {
"layer0": "modjam:item/aquarine_steel_sword"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/handheld",
"textures": {
"layer0": "modjam:item/aquarine_steel_sword_enabled"
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package com.portingdeadmods.modjam.content.blocks.multiblock.part;

import com.mojang.serialization.MapCodec;
import com.portingdeadmods.modjam.ModJam;
import com.portingdeadmods.modjam.api.blockentities.ContainerBlockEntity;
import com.portingdeadmods.modjam.api.blocks.DisplayBlock;
import com.portingdeadmods.modjam.api.blocks.blockentities.LaserBlock;
import com.portingdeadmods.modjam.api.multiblocks.Multiblock;
import com.portingdeadmods.modjam.content.blockentities.multiblock.part.DrainPartBlockEntity;
import com.portingdeadmods.modjam.content.items.AquarineWrenchItem;
import com.portingdeadmods.modjam.content.items.tools.AquarineWrenchItem;
import com.portingdeadmods.modjam.content.multiblocks.DrainMultiblock;
import com.portingdeadmods.modjam.registries.MJBlockEntityTypes;
import com.portingdeadmods.modjam.registries.MJMultiblocks;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ private boolean isLog(Level level, BlockPos pos, BlockState state) {
return state.is(BlockTags.LOGS) && level.getBlockEntity(pos) == null;
}


// Recursive function to break the tree
private int breakTree(Level level, BlockPos pos, ItemStack stack, LivingEntity player, IPowerStorage powerStorage, int blocksToBreak) {
BlockState state = level.getBlockState(pos);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
package com.portingdeadmods.modjam.content.items;
package com.portingdeadmods.modjam.content.items.tools;

import com.portingdeadmods.modjam.MJRegistries;
import com.portingdeadmods.modjam.ModJam;
import com.portingdeadmods.modjam.api.multiblocks.Multiblock;
import com.portingdeadmods.modjam.content.blocks.LaserJunctionBlock;
import com.portingdeadmods.modjam.registries.MJItems;
import com.portingdeadmods.modjam.utils.BlockUtils;
import com.portingdeadmods.modjam.utils.MultiblockHelper;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.ItemInteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
Expand All @@ -22,7 +20,6 @@
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.DirectionProperty;
import net.minecraft.world.level.block.state.properties.Property;
import net.minecraft.world.level.material.Fluids;
import org.jetbrains.annotations.NotNull;

public class AquarineWrenchItem extends Item {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,7 @@ public static Boolean isAbilityEnabled(ItemStack stack) {
return stack.getOrDefault(MJDataComponents.ABILITY_ENABLED, false);
}

public static float isAbilityEnabledNBT(ItemStack stack) {
return stack.getOrDefault(MJDataComponents.ABILITY_ENABLED, false) ? 1 : 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ protected void registerModels() {
basicItem(MJItems.EAS_BUCKET.get());
basicItem(MJItems.ETCHING_ACID_BUCKET.get());

handHeldItem(MJItems.AQUARINE_AXE.get());
handHeldItem(MJItems.AQUARINE_HOE.get());
handHeldItem(MJItems.AQUARINE_PICKAXE.get());
handHeldItem(MJItems.AQUARINE_SHOVEL.get());
handHeldItem(MJItems.AQUARINE_SWORD.get());
aquarineSteelTool(MJItems.AQUARINE_AXE.get());
aquarineSteelTool(MJItems.AQUARINE_HOE.get());
aquarineSteelTool(MJItems.AQUARINE_PICKAXE.get());
aquarineSteelTool(MJItems.AQUARINE_SHOVEL.get());
aquarineSteelTool(MJItems.AQUARINE_SWORD.get());

parentItemBlock(MJBlocks.LASER_JUNCTION.asItem(), "_base");

Expand All @@ -78,10 +78,30 @@ public ItemModelBuilder parentItemBlock(Item item, String suffix) {
.parent(new ModelFile.UncheckedModelFile(ResourceLocation.fromNamespaceAndPath(name.getNamespace(), "block/" + name.getPath() + suffix)));
}

public ItemModelBuilder handHeldItem(Item item) {
public void aquarineSteelTool(Item item) {
ResourceLocation location = BuiltInRegistries.ITEM.getKey(item);
return getBuilder(location.toString())
ResourceLocation enabled = ResourceLocation.fromNamespaceAndPath(ModJam.MODID, "enabled");
getBuilder(location.toString())
.parent(new ModelFile.UncheckedModelFile("item/handheld"))
.override()
.model(handHeldItem(item))
.predicate(enabled, 0)
.end()
.override()
.model(handHeldItem(item, "_enabled"))
.predicate(enabled, 1)
.end()
.texture("layer0", ResourceLocation.fromNamespaceAndPath(location.getNamespace(), "item/" + location.getPath()));
}

public ItemModelBuilder handHeldItem(Item item) {
return handHeldItem(item, "");
}

public ItemModelBuilder handHeldItem(Item item, String suffix) {
ResourceLocation location = BuiltInRegistries.ITEM.getKey(item);
return getBuilder(location +suffix)
.parent(new ModelFile.UncheckedModelFile("item/handheld"))
.texture("layer0", ResourceLocation.fromNamespaceAndPath(location.getNamespace(), "item/" + location.getPath()+suffix));
}
}
26 changes: 22 additions & 4 deletions src/main/java/com/portingdeadmods/modjam/events/AugmentEvents.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import com.portingdeadmods.modjam.content.augments.AugmentSlots;
import com.portingdeadmods.modjam.network.SyncAugmentPayload;
import com.portingdeadmods.modjam.utils.AugmentHelper;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.player.Player;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.common.EventBusSubscriber;
Expand All @@ -15,6 +17,7 @@
import net.neoforged.neoforge.network.PacketDistributor;

import java.util.List;
import java.util.Map;

@SuppressWarnings("unused")
@EventBusSubscriber(modid = ModJam.MODID)
Expand All @@ -28,7 +31,7 @@ public static void s(PlayerEvent.PlayerRespawnEvent event) {
}

@SubscribeEvent
public static void breakEvent(BlockEvent.BreakEvent event){
public static void breakEvent(BlockEvent.BreakEvent event) {
Iterable<Augment> augments = AugmentHelper.getAugments(event.getPlayer()).values();
for (Augment augment : augments) {
if (augment != null) {
Expand All @@ -40,14 +43,29 @@ public static void breakEvent(BlockEvent.BreakEvent event){


@SubscribeEvent
public static void playerTick(PlayerTickEvent.Post event){
Iterable<Augment> augments = AugmentHelper.getAugments(event.getEntity()).values();
public static void playerTick(PlayerTickEvent.Post event) {
Player player = event.getEntity();
Iterable<Augment> augments = AugmentHelper.getAugments(player).values();
for (Augment augment : augments) {
if (augment != null) {
AugmentSlot slot = augment.getAugmentSlot();
Player player = event.getEntity();
augment.commonTick(event);
}
}
}

@SubscribeEvent
public static void onPlayerRespawn(PlayerEvent.PlayerRespawnEvent event) {
Player player = event.getEntity();
Iterable<Augment> augments = AugmentHelper.getAugments(player).values();
Map<AugmentSlot, CompoundTag> data = AugmentHelper.getAugmentsData(player);
for (Augment augment : augments) {
if (augment != null) {
AugmentSlot slot = augment.getAugmentSlot();
augment.setPlayer(player);
CompoundTag nbt = data.get(slot);
PacketDistributor.sendToPlayer((ServerPlayer) player, new SyncAugmentPayload(augment, nbt != null ? nbt : new CompoundTag()));
}
}
}
}
Loading

0 comments on commit f2ab3c7

Please sign in to comment.