Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
Thepigcat76 committed Sep 4, 2024
2 parents 6683edb + 723f83b commit 83a1352
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.portingdeadmods.modjam.capabilities;

import com.portingdeadmods.modjam.ModJam;
import com.portingdeadmods.modjam.capabilities.augmentation.IPlayerAugmentation;
import com.portingdeadmods.modjam.capabilities.power.IPowerStorage;
import net.minecraft.core.Direction;
import net.minecraft.resources.ResourceLocation;
Expand All @@ -15,6 +16,9 @@ public static final class PowerStorage {
public static final ItemCapability<IPowerStorage, @Nullable Void> ITEM = ItemCapability.createVoid(create("power"), IPowerStorage.class);
public static final EntityCapability<IPowerStorage, @Nullable Direction> ENTITY = EntityCapability.createSided(create("power"), IPowerStorage.class);
}
public static final class PlayerAugmentation{
public static final EntityCapability<IPlayerAugmentation, Void> ENTITY = EntityCapability.createVoid(create("augmentation"), IPlayerAugmentation.class);
}

private static ResourceLocation create(String path) {
return ResourceLocation.fromNamespaceAndPath(ModJam.MODID, path);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.portingdeadmods.modjam.capabilities.augmentation;

public enum AugmentationSlot {
HEAD,BODY,ARMS,LEGS,HEART
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.portingdeadmods.modjam.capabilities.augmentation;

import net.minecraft.nbt.CompoundTag;

public interface IPlayerAugmentation {
int getAugment(AugmentationSlot slot);
void setAugment(AugmentationSlot slot, int value);
void saveNBTData(CompoundTag tag);
void loadNBTData(CompoundTag tag);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package com.portingdeadmods.modjam.capabilities.augmentation;

import net.minecraft.nbt.CompoundTag;


public class PlayerAugmentationCapability implements IPlayerAugmentation {

private int headId;
private int bodyId;
private int armsId;
private int legsId;
private int heartId;

public int getAugment(AugmentationSlot slot){
switch (slot){
case LEGS -> {
return legsId;
}
case ARMS -> {
return armsId;
}
case BODY -> {
return bodyId;
}
case HEAD -> {
return headId;
}
case HEART -> {
return heartId;
}
}
return -2;
}
public void setAugment(AugmentationSlot slot, int value){
switch (slot){
case HEART -> heartId = value;
case HEAD -> headId = value;
case BODY -> bodyId = value;
case ARMS -> armsId = value;
case LEGS -> legsId = value;
}
}
public void saveNBTData(CompoundTag tag){
tag.putInt("heart_id", heartId);
tag.putInt("head_id", headId);
tag.putInt("body_id", bodyId);
tag.putInt("arms_id", armsId);
tag.putInt("legs_id", legsId);
}
public void loadNBTData(CompoundTag tag){
heartId = tag.getInt("heart_id");
headId = tag.getInt("head_id");
bodyId = tag.getInt("body_id");
armsId = tag.getInt("arms_id");
legsId = tag.getInt("legs_id");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.portingdeadmods.modjam.capabilities.power.ItemPowerWrapper;
import com.portingdeadmods.modjam.data.MJDataComponents;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.item.Item;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.common.EventBusSubscriber;
Expand All @@ -19,6 +20,11 @@ public final class CapabilityAttachEvent {
@SubscribeEvent
public static void registerCapabilities(RegisterCapabilitiesEvent event) {
registerItemCaps(event);
registerEntityCaps(event);
}

private static void registerEntityCaps(RegisterCapabilitiesEvent event){
// TODO: Register Player Augmentation Capability
}

private static void registerItemCaps(RegisterCapabilitiesEvent event) {
Expand Down

0 comments on commit 83a1352

Please sign in to comment.