generated from NeoForgeMDKs/MDK-1.21-NeoGradle
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1 parent
132ab1f
commit 42d3fdd
Showing
41 changed files
with
761 additions
and
546 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,20 @@ | ||
package com.portingdeadmods.modjam; | ||
|
||
import com.portingdeadmods.modjam.api.augments.Augment; | ||
import com.portingdeadmods.modjam.api.augments.AugmentSlot; | ||
import com.portingdeadmods.modjam.api.augments.AugmentType; | ||
import com.portingdeadmods.modjam.api.multiblocks.Multiblock; | ||
import com.portingdeadmods.modjam.content.augments.StaticAugment; | ||
import net.minecraft.core.Registry; | ||
import net.minecraft.resources.ResourceKey; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.neoforged.neoforge.registries.RegistryBuilder; | ||
|
||
public final class MJRegistries { | ||
private static final ResourceKey<Registry<StaticAugment>> AUGMENT_KEY = ResourceKey.createRegistryKey(ResourceLocation.fromNamespaceAndPath(ModJam.MODID, "augment")); | ||
private static final ResourceKey<Registry<AugmentType<?>>> AUGMENT_TYPE_KEY = ResourceKey.createRegistryKey(ResourceLocation.fromNamespaceAndPath(ModJam.MODID, "augment_type")); | ||
public static final ResourceKey<Registry<AugmentSlot>> AUGMENT_SLOT_KEY = ResourceKey.createRegistryKey(ResourceLocation.fromNamespaceAndPath(ModJam.MODID, "augment_slot")); | ||
private static final ResourceKey<Registry<Multiblock>> MULTIBLOCK_KEY = ResourceKey.createRegistryKey(ResourceLocation.fromNamespaceAndPath(ModJam.MODID, "multiblock")); | ||
public static final Registry<StaticAugment> AUGMENT = new RegistryBuilder<>(AUGMENT_KEY).create(); | ||
|
||
public static final Registry<AugmentType<?>> AUGMENT_TYPE = new RegistryBuilder<>(AUGMENT_TYPE_KEY).create(); | ||
public static final Registry<AugmentSlot> AUGMENT_SLOT = new RegistryBuilder<>(AUGMENT_SLOT_KEY).create(); | ||
public static final Registry<Multiblock> MULTIBLOCK = new RegistryBuilder<>(MULTIBLOCK_KEY).create(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
src/main/java/com/portingdeadmods/modjam/api/augments/Augment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package com.portingdeadmods.modjam.api.augments; | ||
|
||
import net.minecraft.core.HolderLookup; | ||
import net.minecraft.nbt.CompoundTag; | ||
import net.minecraft.world.entity.player.Player; | ||
import net.neoforged.neoforge.common.util.INBTSerializable; | ||
import net.neoforged.neoforge.event.level.BlockEvent; | ||
import net.neoforged.neoforge.event.tick.PlayerTickEvent; | ||
import org.jetbrains.annotations.UnknownNullability; | ||
|
||
public abstract class Augment implements INBTSerializable<CompoundTag> { | ||
protected final AugmentType<?> augmentType; | ||
protected Player player; | ||
protected final AugmentSlot augmentSlot; | ||
|
||
// Serialized | ||
private int cooldown; | ||
|
||
public Augment(AugmentType<?> augmentType, AugmentSlot augmentSlot) { | ||
this.augmentType = augmentType; | ||
this.augmentSlot = augmentSlot; | ||
} | ||
|
||
public void setPlayer(Player player) { | ||
this.player = player; | ||
} | ||
|
||
public AugmentType<?> getAugmentType() { | ||
return augmentType; | ||
} | ||
|
||
public Player getPlayer() { | ||
return player; | ||
} | ||
|
||
public AugmentSlot getAugmentSlot() { | ||
return augmentSlot; | ||
} | ||
|
||
public int getCooldown() { | ||
return cooldown; | ||
} | ||
|
||
public void setCooldown(int cooldown) { | ||
this.cooldown = cooldown; | ||
} | ||
|
||
public void breakBlock(BlockEvent.BreakEvent event) { | ||
|
||
} | ||
|
||
public void commonTick(PlayerTickEvent.Post event) { | ||
if (player.level().isClientSide) clientTick(event); | ||
else serverTick(event); | ||
} | ||
|
||
@Deprecated | ||
public void clientTick(PlayerTickEvent.Post event) { | ||
|
||
} | ||
|
||
@Deprecated | ||
public void serverTick(PlayerTickEvent.Post event) { | ||
|
||
} | ||
|
||
public void handleKeybindPress() { | ||
} | ||
|
||
public boolean isOnCooldown() { | ||
return getCooldown() > 0; | ||
} | ||
|
||
@Override | ||
public @UnknownNullability CompoundTag serializeNBT(HolderLookup.Provider provider) { | ||
return new CompoundTag(); | ||
} | ||
|
||
@Override | ||
public void deserializeNBT(HolderLookup.Provider provider, CompoundTag nbt) { | ||
|
||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
src/main/java/com/portingdeadmods/modjam/api/augments/AugmentSlot.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.portingdeadmods.modjam.api.augments; | ||
|
||
import net.minecraft.resources.ResourceLocation; | ||
|
||
public interface AugmentSlot { | ||
int getSlotId(); | ||
|
||
ResourceLocation getLocation(); | ||
|
||
default String getName() { | ||
return getLocation().getPath(); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
src/main/java/com/portingdeadmods/modjam/api/augments/AugmentType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.portingdeadmods.modjam.api.augments; | ||
|
||
import com.portingdeadmods.modjam.MJRegistries; | ||
import com.portingdeadmods.modjam.registries.MJAugments; | ||
|
||
public class AugmentType<T extends Augment> { | ||
private final AugmentConstructor<T> augmentConstructor; | ||
|
||
public static<T extends Augment> AugmentType<T> of(AugmentConstructor<T> constructor) { | ||
return new AugmentType<>(constructor); | ||
} | ||
|
||
private AugmentType(AugmentConstructor<T> augmentConstructor) { | ||
this.augmentConstructor = augmentConstructor; | ||
} | ||
|
||
public T create(AugmentSlot augmentSlot) { | ||
return augmentConstructor.create(augmentSlot); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return MJRegistries.AUGMENT_TYPE.getKey(this).toString(); | ||
} | ||
|
||
@FunctionalInterface | ||
public interface AugmentConstructor<T extends Augment> { | ||
T create(AugmentSlot augmentSlot); | ||
} | ||
} |
29 changes: 0 additions & 29 deletions
29
src/main/java/com/portingdeadmods/modjam/capabilities/augmentation/Slot.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 0 additions & 40 deletions
40
src/main/java/com/portingdeadmods/modjam/content/augments/Augment.java
This file was deleted.
Oops, something went wrong.
136 changes: 0 additions & 136 deletions
136
src/main/java/com/portingdeadmods/modjam/content/augments/AugmentHelper.java
This file was deleted.
Oops, something went wrong.
42 changes: 42 additions & 0 deletions
42
src/main/java/com/portingdeadmods/modjam/content/augments/AugmentSlots.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.portingdeadmods.modjam.content.augments; | ||
|
||
import com.portingdeadmods.modjam.ModJam; | ||
import com.portingdeadmods.modjam.api.augments.AugmentSlot; | ||
import net.minecraft.resources.ResourceLocation; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public enum AugmentSlots implements AugmentSlot { | ||
HEAD("head", 0), | ||
BODY("body", 1), | ||
ARMS("arms", 2), | ||
LEGS("legs",3), | ||
HEART("heart", 4), | ||
NONE("none", -1); | ||
|
||
private final ResourceLocation name; | ||
private final int slotId; | ||
|
||
AugmentSlots(String name, int id) { | ||
this.name = ResourceLocation.fromNamespaceAndPath(ModJam.MODID, name); | ||
this.slotId = id; | ||
} | ||
|
||
public static AugmentSlots getValue(int id) { | ||
AugmentSlots[] Slots = AugmentSlots.values(); | ||
for (AugmentSlots slot : Slots) { | ||
if (slot.slotId == id) | ||
return slot; | ||
} | ||
return AugmentSlots.NONE; | ||
} | ||
|
||
@Override | ||
public @NotNull ResourceLocation getLocation() { | ||
return name; | ||
} | ||
|
||
@Override | ||
public int getSlotId() { | ||
return slotId; | ||
} | ||
} |
14 changes: 8 additions & 6 deletions
14
src/main/java/com/portingdeadmods/modjam/content/augments/DisallowBreakingAugment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,18 @@ | ||
package com.portingdeadmods.modjam.content.augments; | ||
|
||
import com.portingdeadmods.modjam.capabilities.augmentation.Slot; | ||
import com.portingdeadmods.modjam.api.augments.Augment; | ||
import com.portingdeadmods.modjam.api.augments.AugmentSlot; | ||
import com.portingdeadmods.modjam.registries.MJAugments; | ||
import net.minecraft.world.entity.player.Player; | ||
import net.neoforged.neoforge.event.level.BlockEvent; | ||
|
||
public class DisallowBreakingAugment extends Augment{ | ||
@Override | ||
public int getId() { | ||
return 1; | ||
public class DisallowBreakingAugment extends Augment { | ||
public DisallowBreakingAugment(AugmentSlot augmentSlot) { | ||
super(MJAugments.DISALLOW_BREAKING.get(), augmentSlot); | ||
} | ||
|
||
@Override | ||
public void breakBlock(Slot slot, BlockEvent.BreakEvent event) { | ||
public void breakBlock(BlockEvent.BreakEvent event) { | ||
event.setCanceled(true); | ||
} | ||
} |
8 changes: 0 additions & 8 deletions
8
src/main/java/com/portingdeadmods/modjam/content/augments/EmptyAugment.java
This file was deleted.
Oops, something went wrong.
15 changes: 8 additions & 7 deletions
15
src/main/java/com/portingdeadmods/modjam/content/augments/GiveDiamondAugment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,30 @@ | ||
package com.portingdeadmods.modjam.content.augments; | ||
|
||
import com.mojang.blaze3d.platform.InputConstants; | ||
import com.portingdeadmods.modjam.capabilities.augmentation.Slot; | ||
import com.portingdeadmods.modjam.api.augments.Augment; | ||
import com.portingdeadmods.modjam.api.augments.AugmentSlot; | ||
import com.portingdeadmods.modjam.network.KeyPressedPayload; | ||
import com.portingdeadmods.modjam.registries.MJAugments; | ||
import com.portingdeadmods.modjam.utils.InputUtils; | ||
import net.minecraft.world.entity.player.Player; | ||
import net.minecraft.world.item.Items; | ||
import net.neoforged.neoforge.event.tick.PlayerTickEvent; | ||
import net.neoforged.neoforge.network.PacketDistributor; | ||
|
||
public class GiveDiamondAugment extends Augment { | ||
@Override | ||
public int getId() { | ||
return 2; | ||
public GiveDiamondAugment(AugmentSlot augmentSlot) { | ||
super(MJAugments.GIVE_DIAMOND.get(), augmentSlot); | ||
} | ||
|
||
@Override | ||
public void clientTick(Slot slot, PlayerTickEvent.Post event) { | ||
public void clientTick(PlayerTickEvent.Post event) { | ||
if (InputUtils.isKeyDown(InputConstants.KEY_Y)) { | ||
PacketDistributor.sendToServer(new KeyPressedPayload(getId(), slot.slotId)); | ||
PacketDistributor.sendToServer(new KeyPressedPayload(augmentSlot, augmentSlot.getSlotId())); | ||
} | ||
} | ||
|
||
@Override | ||
public void handleKeybindPress(Slot slot, Player player) { | ||
public void handleKeybindPress() { | ||
player.addItem(Items.DIAMOND.getDefaultInstance()); | ||
} | ||
} |
13 changes: 7 additions & 6 deletions
13
src/main/java/com/portingdeadmods/modjam/content/augments/PreventPlayerLoseAirAugment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 0 additions & 15 deletions
15
src/main/java/com/portingdeadmods/modjam/content/augments/StaticAugment.java
This file was deleted.
Oops, something went wrong.
24 changes: 13 additions & 11 deletions
24
src/main/java/com/portingdeadmods/modjam/content/augments/ThrowBouncingTridentAugment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,34 @@ | ||
package com.portingdeadmods.modjam.content.augments; | ||
|
||
import com.mojang.blaze3d.platform.InputConstants; | ||
import com.portingdeadmods.modjam.capabilities.augmentation.Slot; | ||
import com.portingdeadmods.modjam.api.augments.Augment; | ||
import com.portingdeadmods.modjam.api.augments.AugmentSlot; | ||
import com.portingdeadmods.modjam.content.entites.ThrownBouncingTrident; | ||
import com.portingdeadmods.modjam.network.KeyPressedPayload; | ||
import com.portingdeadmods.modjam.registries.MJAugments; | ||
import com.portingdeadmods.modjam.utils.AugmentHelper; | ||
import com.portingdeadmods.modjam.utils.InputUtils; | ||
import net.minecraft.world.entity.player.Player; | ||
import net.minecraft.world.item.Items; | ||
import net.neoforged.neoforge.event.tick.PlayerTickEvent; | ||
import net.neoforged.neoforge.network.PacketDistributor; | ||
|
||
public class ThrowBouncingTridentAugment extends Augment{ | ||
@Override | ||
public int getId() { | ||
return 7; | ||
public class ThrowBouncingTridentAugment extends Augment { | ||
public ThrowBouncingTridentAugment(AugmentSlot augmentSlot) { | ||
super(MJAugments.THROWN_BOUNCING_TRIDENT_AUGMENT.get(), augmentSlot); | ||
} | ||
|
||
@Override | ||
public void clientTick(Slot slot, PlayerTickEvent.Post event) { | ||
if (InputUtils.isKeyDown(InputConstants.KEY_Y) && !onCooldown(slot, event.getEntity())) { | ||
PacketDistributor.sendToServer(new KeyPressedPayload(getId(), slot.slotId)); | ||
public void clientTick(PlayerTickEvent.Post event) { | ||
if (InputUtils.isKeyDown(InputConstants.KEY_Y) && !isOnCooldown()) { | ||
PacketDistributor.sendToServer(new KeyPressedPayload(augmentSlot, augmentSlot.getSlotId())); | ||
} | ||
} | ||
|
||
@Override | ||
public void handleKeybindPress(Slot slot, Player player) { | ||
public void handleKeybindPress() { | ||
ThrownBouncingTrident trident = new ThrownBouncingTrident(player.level(),player,Items.TRIDENT.getDefaultInstance()); | ||
trident.shootFromRotation(player, player.getXRot(), player.getYRot(), 0.0f, 1.5f, 0.0f); | ||
player.level().addFreshEntity(trident); | ||
AugmentHelper.setCooldownAndUpdate(player, slot, 20); // Set the cooldown, which decrements by 1 every tick | ||
setCooldown(20); // Set the cooldown, which decrements by 1 every tick | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 9 additions & 6 deletions
15
...main/java/com/portingdeadmods/modjam/content/augments/UnderwaterMovementSpeedAugment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
src/main/java/com/portingdeadmods/modjam/content/commands/AugmentSlotArgumentType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package com.portingdeadmods.modjam.content.commands; | ||
|
||
import com.mojang.brigadier.StringReader; | ||
import com.mojang.brigadier.arguments.ArgumentType; | ||
import com.mojang.brigadier.context.CommandContext; | ||
import com.mojang.brigadier.exceptions.CommandSyntaxException; | ||
import com.mojang.brigadier.exceptions.DynamicCommandExceptionType; | ||
import com.mojang.brigadier.suggestion.Suggestions; | ||
import com.mojang.brigadier.suggestion.SuggestionsBuilder; | ||
import com.portingdeadmods.modjam.MJRegistries; | ||
import com.portingdeadmods.modjam.ModJam; | ||
import com.portingdeadmods.modjam.api.augments.AugmentSlot; | ||
import com.portingdeadmods.modjam.api.augments.AugmentType; | ||
import net.minecraft.commands.SharedSuggestionProvider; | ||
import net.minecraft.network.chat.Component; | ||
import net.minecraft.resources.ResourceKey; | ||
import net.minecraft.resources.ResourceLocation; | ||
|
||
import java.util.HashSet; | ||
import java.util.Set; | ||
import java.util.concurrent.CompletableFuture; | ||
|
||
public class AugmentSlotArgumentType implements ArgumentType<AugmentSlot> { | ||
private static final AugmentSlotArgumentType INSTANCE = new AugmentSlotArgumentType(); | ||
|
||
private static final DynamicCommandExceptionType UNKNOWN_TYPE = new DynamicCommandExceptionType( | ||
type -> Component.literal("Unknown augment slot: " + type)); | ||
public static Set<String> suggestions = new HashSet<>(); | ||
|
||
private AugmentSlotArgumentType() { | ||
} | ||
|
||
public static AugmentSlotArgumentType getInstance() { | ||
return INSTANCE; | ||
} | ||
|
||
@Override | ||
public AugmentSlot parse(StringReader reader) throws CommandSyntaxException { | ||
ResourceLocation read = ResourceLocation.read(reader); | ||
ModJam.LOGGER.debug("Res: {}", read); | ||
AugmentSlot augmentSlot = MJRegistries.AUGMENT_SLOT.get(ResourceKey.create(MJRegistries.AUGMENT_SLOT_KEY, read)); | ||
if (augmentSlot != null) { | ||
return augmentSlot; | ||
} | ||
throw UNKNOWN_TYPE.create(read.toString()); | ||
} | ||
|
||
@Override | ||
public <S> CompletableFuture<Suggestions> listSuggestions(CommandContext<S> context, SuggestionsBuilder builder) { | ||
return SharedSuggestionProvider.suggest(suggestions, builder); | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
src/main/java/com/portingdeadmods/modjam/content/commands/AugmentTypeArgumentType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package com.portingdeadmods.modjam.content.commands; | ||
|
||
import com.mojang.brigadier.StringReader; | ||
import com.mojang.brigadier.arguments.ArgumentType; | ||
import com.mojang.brigadier.context.CommandContext; | ||
import com.mojang.brigadier.exceptions.CommandExceptionType; | ||
import com.mojang.brigadier.exceptions.CommandSyntaxException; | ||
import com.mojang.brigadier.exceptions.DynamicCommandExceptionType; | ||
import com.mojang.brigadier.suggestion.Suggestions; | ||
import com.mojang.brigadier.suggestion.SuggestionsBuilder; | ||
import com.portingdeadmods.modjam.MJRegistries; | ||
import com.portingdeadmods.modjam.ModJam; | ||
import com.portingdeadmods.modjam.api.augments.AugmentType; | ||
import net.minecraft.commands.SharedSuggestionProvider; | ||
import net.minecraft.network.chat.Component; | ||
import net.minecraft.resources.ResourceLocation; | ||
|
||
import java.util.HashSet; | ||
import java.util.Set; | ||
import java.util.concurrent.CompletableFuture; | ||
|
||
public class AugmentTypeArgumentType implements ArgumentType<AugmentType<?>> { | ||
private static final AugmentTypeArgumentType INSTANCE = new AugmentTypeArgumentType(); | ||
|
||
private static final DynamicCommandExceptionType UNKNOWN_TYPE = new DynamicCommandExceptionType( | ||
type -> Component.literal("Unknown augment type: " + type)); | ||
public static Set<String> suggestions = new HashSet<>(); | ||
|
||
private AugmentTypeArgumentType() { | ||
} | ||
|
||
public static AugmentTypeArgumentType getInstance() { | ||
return INSTANCE; | ||
} | ||
|
||
@Override | ||
public <S> CompletableFuture<Suggestions> listSuggestions(CommandContext<S> context, SuggestionsBuilder builder) { | ||
return SharedSuggestionProvider.suggest(suggestions, builder); | ||
} | ||
|
||
@Override | ||
public AugmentType<?> parse(StringReader reader) throws CommandSyntaxException { | ||
ResourceLocation read = ResourceLocation.read(reader); | ||
AugmentType<?> augmentType = MJRegistries.AUGMENT_TYPE.get(read); | ||
if (augmentType != null) { | ||
return augmentType; | ||
} | ||
throw UNKNOWN_TYPE.create(read.toString()); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
src/main/java/com/portingdeadmods/modjam/content/commands/GetAugmentCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.portingdeadmods.modjam.content.commands; | ||
|
||
import com.mojang.brigadier.CommandDispatcher; | ||
import com.mojang.brigadier.context.CommandContext; | ||
import com.portingdeadmods.modjam.ModJam; | ||
import com.portingdeadmods.modjam.api.augments.Augment; | ||
import com.portingdeadmods.modjam.api.augments.AugmentSlot; | ||
import com.portingdeadmods.modjam.api.augments.AugmentType; | ||
import com.portingdeadmods.modjam.content.augments.AugmentSlots; | ||
import com.portingdeadmods.modjam.utils.AugmentHelper; | ||
import net.minecraft.commands.CommandSourceStack; | ||
import net.minecraft.commands.Commands; | ||
import net.minecraft.network.chat.Component; | ||
import net.minecraft.server.level.ServerLevel; | ||
import net.minecraft.world.entity.player.Player; | ||
|
||
// /modjam augments get <slot> | ||
public class GetAugmentCommand { | ||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher) { | ||
dispatcher.register(Commands.literal(ModJam.MODID) | ||
.then(Commands.literal("augments") | ||
.then(Commands.literal("get") | ||
.then(Commands.argument("slot", AugmentSlotArgumentType.getInstance()) | ||
.executes(GetAugmentCommand::execute))))); | ||
} | ||
|
||
private static int execute(CommandContext<CommandSourceStack> ctx) { | ||
Player player = ctx.getSource().getPlayer(); | ||
AugmentSlot augmentSlot = ctx.getArgument("slot", AugmentSlot.class); | ||
Augment augmentBySlot = AugmentHelper.getAugmentBySlot(player, augmentSlot); | ||
String augment = "None"; | ||
if (augmentBySlot != null) { | ||
AugmentType<?> augmentType = augmentBySlot.getAugmentType(); | ||
augment = augmentType.toString(); | ||
} | ||
player.sendSystemMessage(Component.literal("Augment in slot '" + augmentSlot.getName() + "': " + augment)); | ||
return 1; | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
src/main/java/com/portingdeadmods/modjam/content/commands/SetAugmentCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.portingdeadmods.modjam.content.commands; | ||
|
||
import com.mojang.brigadier.CommandDispatcher; | ||
import com.mojang.brigadier.arguments.IntegerArgumentType; | ||
import com.mojang.brigadier.context.CommandContext; | ||
import com.portingdeadmods.modjam.ModJam; | ||
import com.portingdeadmods.modjam.api.augments.Augment; | ||
import com.portingdeadmods.modjam.api.augments.AugmentSlot; | ||
import com.portingdeadmods.modjam.api.augments.AugmentType; | ||
import com.portingdeadmods.modjam.content.augments.AugmentSlots; | ||
import com.portingdeadmods.modjam.utils.AugmentHelper; | ||
import net.minecraft.commands.CommandSourceStack; | ||
import net.minecraft.commands.Commands; | ||
import net.minecraft.network.chat.Component; | ||
import net.minecraft.server.level.ServerLevel; | ||
import net.minecraft.world.entity.player.Player; | ||
|
||
// /modjam augments set <slot> <augment> | ||
|
||
// TODO: Only set augments for slots that support them | ||
public class SetAugmentCommand { | ||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher) { | ||
dispatcher.register(Commands.literal(ModJam.MODID) | ||
.then(Commands.literal("augments") | ||
.then(Commands.literal("set") | ||
.then(Commands.argument("slot", AugmentSlotArgumentType.getInstance()) | ||
.then(Commands.argument("augment", AugmentTypeArgumentType.getInstance()) | ||
.executes(SetAugmentCommand::execute)))))); | ||
} | ||
|
||
private static int execute(CommandContext<CommandSourceStack> ctx) { | ||
Player player = ctx.getSource().getPlayer(); | ||
AugmentSlot slot = ctx.getArgument("slot", AugmentSlot.class); | ||
AugmentType<?> type = ctx.getArgument("augment", AugmentType.class); | ||
Augment augment = type.create(slot); | ||
augment.setPlayer(player); | ||
AugmentHelper.setAugment(player, slot, augment); | ||
player.sendSystemMessage(Component.literal("Set augment in slot '" + slot.getName() + "' to: " + type)); | ||
return 1; | ||
} | ||
|
||
} |
30 changes: 0 additions & 30 deletions
30
src/main/java/com/portingdeadmods/modjam/content/commands/SetAugmentIdCommand.java
This file was deleted.
Oops, something went wrong.
26 changes: 0 additions & 26 deletions
26
src/main/java/com/portingdeadmods/modjam/content/commands/ShowAugmentIdCommand.java
This file was deleted.
Oops, something went wrong.
29 changes: 0 additions & 29 deletions
29
src/main/java/com/portingdeadmods/modjam/content/commands/TestCommand.java
This file was deleted.
Oops, something went wrong.
51 changes: 51 additions & 0 deletions
51
...in/java/com/portingdeadmods/modjam/content/multiblocks/AugmentationStationMultiblock.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.portingdeadmods.modjam.content.multiblocks; | ||
|
||
import com.portingdeadmods.modjam.api.blockentities.multiblock.MultiblockEntity; | ||
import com.portingdeadmods.modjam.api.multiblocks.Multiblock; | ||
import com.portingdeadmods.modjam.api.multiblocks.MultiblockData; | ||
import com.portingdeadmods.modjam.api.multiblocks.MultiblockLayer; | ||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap; | ||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.world.entity.player.Player; | ||
import net.minecraft.world.level.Level; | ||
import net.minecraft.world.level.block.Block; | ||
import net.minecraft.world.level.block.entity.BlockEntityType; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public class AugmentationStationMultiblock implements Multiblock { | ||
@Override | ||
public Block getUnformedController() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public Block getFormedController() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public MultiblockLayer[] getLayout() { | ||
return new MultiblockLayer[0]; | ||
} | ||
|
||
@Override | ||
public Int2ObjectMap<Block> getDefinition() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public BlockEntityType<? extends MultiblockEntity> getMultiBlockEntityType() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public @Nullable BlockState formBlock(Level level, BlockPos blockPos, BlockPos controllerPos, int layerIndex, int layoutIndex, MultiblockData multiblockData, @Nullable Player player) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public boolean isFormed(Level level, BlockPos blockPos) { | ||
return false; | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/main/java/com/portingdeadmods/modjam/data/MJDataAttachments.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.portingdeadmods.modjam.data; | ||
|
||
import com.portingdeadmods.modjam.ModJam; | ||
import com.portingdeadmods.modjam.api.augments.Augment; | ||
import com.portingdeadmods.modjam.api.augments.AugmentSlot; | ||
import com.portingdeadmods.modjam.utils.AugmentCodecs; | ||
import com.portingdeadmods.modjam.utils.AugmentHelper; | ||
import net.minecraft.nbt.CompoundTag; | ||
import net.neoforged.neoforge.attachment.AttachmentType; | ||
import net.neoforged.neoforge.registries.DeferredRegister; | ||
import net.neoforged.neoforge.registries.NeoForgeRegistries; | ||
|
||
import java.util.Collections; | ||
import java.util.Map; | ||
import java.util.function.Supplier; | ||
|
||
public final class MJDataAttachments { | ||
public static final DeferredRegister<AttachmentType<?>> ATTACHMENTS = DeferredRegister.create(NeoForgeRegistries.ATTACHMENT_TYPES, ModJam.MODID); | ||
|
||
public static final Supplier<AttachmentType<Map<AugmentSlot, Augment>>> AUGMENTS = ATTACHMENTS.register( | ||
"augments", () -> AttachmentType.<Map<AugmentSlot, Augment>>builder(Collections::emptyMap) | ||
.serialize(AugmentCodecs.AUGMENTS_CODEC).copyOnDeath().build() | ||
); | ||
public static final Supplier<AttachmentType<Map<AugmentSlot, CompoundTag>>> AUGMENTS_EXTRA_DATA = ATTACHMENTS.register( | ||
"augments_extra_data", () -> AttachmentType.<Map<AugmentSlot, CompoundTag>>builder(Collections::emptyMap) | ||
.serialize(AugmentCodecs.AUGMENTS_EXTRA_DATA_CODEC).copyOnDeath().build() | ||
); | ||
} |
34 changes: 19 additions & 15 deletions
34
src/main/java/com/portingdeadmods/modjam/events/AugmentEvents.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/main/java/com/portingdeadmods/modjam/registries/MJArgumentTypes.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.portingdeadmods.modjam.registries; | ||
|
||
import com.portingdeadmods.modjam.ModJam; | ||
import com.portingdeadmods.modjam.content.commands.AugmentSlotArgumentType; | ||
import com.portingdeadmods.modjam.content.commands.AugmentTypeArgumentType; | ||
import net.minecraft.commands.synchronization.ArgumentTypeInfo; | ||
import net.minecraft.commands.synchronization.ArgumentTypeInfos; | ||
import net.minecraft.commands.synchronization.SingletonArgumentInfo; | ||
import net.minecraft.core.registries.Registries; | ||
import net.neoforged.neoforge.registries.DeferredRegister; | ||
import top.theillusivec4.curios.api.CuriosApi; | ||
import top.theillusivec4.curios.server.command.CurioArgumentType; | ||
|
||
import java.util.function.Supplier; | ||
|
||
public final class MJArgumentTypes { | ||
public static final DeferredRegister<ArgumentTypeInfo<?, ?>> ARGUMENT_TYPES = | ||
DeferredRegister.create(Registries.COMMAND_ARGUMENT_TYPE, ModJam.MODID); | ||
|
||
public static final Supplier<ArgumentTypeInfo<?, ?>> AUGMENT_SLOT_ARGUMENT = | ||
ARGUMENT_TYPES.register("augment_slot", | ||
() -> ArgumentTypeInfos.registerByClass(AugmentSlotArgumentType.class, | ||
SingletonArgumentInfo.contextFree(AugmentSlotArgumentType::getInstance))); | ||
public static final Supplier<ArgumentTypeInfo<?, ?>> AUGMENT_TYPE_ARGUMENT = | ||
ARGUMENT_TYPES.register("augment_type", | ||
() -> ArgumentTypeInfos.registerByClass(AugmentTypeArgumentType.class, | ||
SingletonArgumentInfo.contextFree(AugmentTypeArgumentType::getInstance))); | ||
} |
19 changes: 19 additions & 0 deletions
19
src/main/java/com/portingdeadmods/modjam/registries/MJAugmentSlots.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.portingdeadmods.modjam.registries; | ||
|
||
import com.portingdeadmods.modjam.MJRegistries; | ||
import com.portingdeadmods.modjam.ModJam; | ||
import com.portingdeadmods.modjam.api.augments.AugmentSlot; | ||
import com.portingdeadmods.modjam.content.augments.AugmentSlots; | ||
import net.neoforged.neoforge.registries.DeferredRegister; | ||
|
||
import java.util.function.Supplier; | ||
|
||
public final class MJAugmentSlots { | ||
public static final DeferredRegister<AugmentSlot> AUGMENT_SLOTS = DeferredRegister.create(MJRegistries.AUGMENT_SLOT, ModJam.MODID); | ||
|
||
public static final Supplier<AugmentSlot> HEAD = AUGMENT_SLOTS.register("head", () -> AugmentSlots.HEAD); | ||
public static final Supplier<AugmentSlot> BODY = AUGMENT_SLOTS.register("body", () -> AugmentSlots.BODY); | ||
public static final Supplier<AugmentSlot> ARMS = AUGMENT_SLOTS.register("arms", () -> AugmentSlots.ARMS); | ||
public static final Supplier<AugmentSlot> LEGS = AUGMENT_SLOTS.register("legs", () -> AugmentSlots.LEGS); | ||
public static final Supplier<AugmentSlot> HEART = AUGMENT_SLOTS.register("heart", () -> AugmentSlots.HEART); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 0 additions & 67 deletions
67
src/main/java/com/portingdeadmods/modjam/registries/MJDataAttachments.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/main/java/com/portingdeadmods/modjam/utils/AugmentCodecs.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.portingdeadmods.modjam.utils; | ||
|
||
import com.mojang.serialization.Codec; | ||
import com.mojang.serialization.codecs.RecordCodecBuilder; | ||
import com.portingdeadmods.modjam.MJRegistries; | ||
import com.portingdeadmods.modjam.api.augments.Augment; | ||
import com.portingdeadmods.modjam.api.augments.AugmentSlot; | ||
import com.portingdeadmods.modjam.api.augments.AugmentType; | ||
import io.netty.buffer.ByteBuf; | ||
import net.minecraft.nbt.CompoundTag; | ||
import net.minecraft.network.codec.ByteBufCodecs; | ||
import net.minecraft.network.codec.StreamCodec; | ||
import net.minecraft.resources.ResourceLocation; | ||
|
||
import java.util.Map; | ||
|
||
public final class AugmentCodecs { | ||
public static final Codec<AugmentSlot> AUGMENT_SLOT_CODEC = | ||
ResourceLocation.CODEC.xmap(MJRegistries.AUGMENT_SLOT::get, MJRegistries.AUGMENT_SLOT::getKey); | ||
public static final Codec<AugmentType<?>> AUGMENT_TYPE_CODEC = | ||
ResourceLocation.CODEC.xmap(MJRegistries.AUGMENT_TYPE::get, MJRegistries.AUGMENT_TYPE::getKey); | ||
public static final Codec<Augment> AUGMENT_CODEC = RecordCodecBuilder.create(builder -> builder.group( | ||
AUGMENT_TYPE_CODEC.fieldOf("type").forGetter(Augment::getAugmentType), | ||
AUGMENT_SLOT_CODEC.fieldOf("slot").forGetter(Augment::getAugmentSlot) | ||
).apply(builder, AugmentType::create)); | ||
public static final Codec<Map<AugmentSlot, Augment>> AUGMENTS_CODEC = Codec.unboundedMap(AUGMENT_SLOT_CODEC, AUGMENT_CODEC); | ||
public static final Codec<Map<AugmentSlot, CompoundTag>> AUGMENTS_EXTRA_DATA_CODEC = Codec.unboundedMap(AUGMENT_SLOT_CODEC, CompoundTag.CODEC); | ||
|
||
public static final StreamCodec<ByteBuf, AugmentSlot> AUGMENT_SLOT_STREAM_CODEC = | ||
ByteBufCodecs.INT.map(MJRegistries.AUGMENT_SLOT::byId, MJRegistries.AUGMENT_SLOT::getId); | ||
} |
28 changes: 28 additions & 0 deletions
28
src/main/java/com/portingdeadmods/modjam/utils/AugmentHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.portingdeadmods.modjam.utils; | ||
|
||
import com.google.common.collect.ImmutableMap; | ||
import com.portingdeadmods.modjam.api.augments.Augment; | ||
import com.portingdeadmods.modjam.api.augments.AugmentSlot; | ||
import com.portingdeadmods.modjam.api.augments.AugmentType; | ||
import com.portingdeadmods.modjam.data.MJDataAttachments; | ||
import it.unimi.dsi.fastutil.objects.Object2ObjectMap; | ||
import net.minecraft.world.entity.player.Player; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public final class AugmentHelper { | ||
public static Augment getAugmentBySlot(Player player, AugmentSlot augmentSlot) { | ||
return getAugments(player).get(augmentSlot); | ||
} | ||
|
||
public static Map<AugmentSlot, Augment> getAugments(Player player) { | ||
return player.getData(MJDataAttachments.AUGMENTS); | ||
} | ||
|
||
public static void setAugment(Player player, AugmentSlot augmentSlot, Augment augment) { | ||
Map<AugmentSlot, Augment> augments = new HashMap<>(getAugments(player)); | ||
augments.put(augmentSlot, augment); | ||
player.setData(MJDataAttachments.AUGMENTS, augments); | ||
} | ||
} |