Skip to content

Commit

Permalink
Rebalance inventory modifiers
Browse files Browse the repository at this point in the history
Tool belt now only requires an ability slot for the first level, but has multiple later levels that each add +1 slot
Shield strap is now an upgrade instead of an ability
Removed pocket chain
Pockets now grants 18 slots per level
TODO: better support for retriving items left when the tool belt slot count changes
  • Loading branch information
KnightMiner committed Sep 29, 2022
1 parent 4b13e1f commit 30a2c27
Show file tree
Hide file tree
Showing 35 changed files with 385 additions and 180 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"type": "tconstruct:modifier",
"inputs": [
{
"item": "minecraft:leather"
},
{
"tag": "forge:ingots/iron"
},
{
"item": "minecraft:leather"
}
],
"tools": {
"tag": "tconstruct:modifiable/armor/leggings"
},
"slots": {
"abilities": 1
},
"result": {
"name": "tconstruct:tool_belt",
"level": 1
},
"max_level": 1
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"type": "tconstruct:modifier",
"inputs": [
{
"item": "minecraft:leather"
},
{
"tag": "forge:ingots/gold"
},
{
"item": "minecraft:leather"
}
],
"tools": {
"tag": "tconstruct:modifiable/armor/leggings"
},
"requirements": {
"name": "tconstruct:tool_belt",
"level": 1,
"error": "recipe.tconstruct.modifier.tool_belt"
},
"result": {
"name": "tconstruct:tool_belt",
"level": 1
},
"max_level": 2
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"type": "tconstruct:modifier",
"inputs": [
{
"item": "minecraft:leather"
},
{
"tag": "forge:ingots/rose_gold"
},
{
"item": "minecraft:leather"
}
],
"tools": {
"tag": "tconstruct:modifiable/armor/leggings"
},
"requirements": {
"name": "tconstruct:tool_belt",
"level": 2,
"error": "recipe.tconstruct.modifier.tool_belt"
},
"result": {
"name": "tconstruct:tool_belt",
"level": 1
},
"max_level": 3
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"type": "tconstruct:modifier",
"inputs": [
{
"item": "minecraft:leather"
},
{
"tag": "forge:ingots/cobalt"
},
{
"item": "minecraft:leather"
}
],
"tools": {
"tag": "tconstruct:modifiable/armor/leggings"
},
"requirements": {
"name": "tconstruct:tool_belt",
"level": 3,
"error": "recipe.tconstruct.modifier.tool_belt"
},
"result": {
"name": "tconstruct:tool_belt",
"level": 1
},
"max_level": 4
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,21 @@
{
"tag": "forge:ingots/hepatizon"
},
{
"item": "minecraft:leather"
},
{
"item": "minecraft:leather"
},
{
"item": "minecraft:leather"
}
],
"tools": {
"tag": "tconstruct:modifiable/armor/leggings"
},
"slots": {
"abilities": 1
"requirements": {
"name": "tconstruct:tool_belt",
"level": 4,
"error": "recipe.tconstruct.modifier.tool_belt"
},
"result": {
"name": "tconstruct:tool_belt",
"level": 1
},
"max_level": 2
"max_level": 5
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"type": "tconstruct:modifier",
"inputs": [
{
"item": "minecraft:leather"
},
{
"tag": "forge:ingots/manyullyn"
},
{
"item": "minecraft:leather"
}
],
"tools": {
"tag": "tconstruct:modifiable/armor/leggings"
},
"requirements": {
"name": "tconstruct:tool_belt",
"level": 5,
"error": "recipe.tconstruct.modifier.tool_belt"
},
"result": {
"name": "tconstruct:tool_belt",
"level": 1
},
"max_level": 6
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"tag": "tconstruct:modifiable/armor/leggings"
},
"slots": {
"abilities": 1
"upgrades": 1
},
"modifier": "tconstruct:shield_strap",
"min_level": 1
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@
"tag": "tconstruct:modifiable/armor/leggings"
},
"slots": {
"abilities": 1
"upgrades": 1
},
"result": {
"name": "tconstruct:shield_strap",
"level": 1
},
"max_level": 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"redirects": [
{
"id": "tconstruct:shield_strap"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type": "tconstruct:inventory_with_menu",
"size": 18
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"type": "tconstruct:tool_belt",
"level_slots": [
4,
5,
6,
7,
8,
9
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -243,12 +243,12 @@ protected void generate() {
with.accept(ModifierIds.looting);
withL.accept(TinkerModifiers.pathMaker);
withL.accept(TinkerModifiers.plowing);
withL.accept(TinkerModifiers.pockets);
with.accept(ModifierIds.pockets);
withL.accept(TinkerModifiers.shieldStrap);
withL.accept(TinkerModifiers.slurping);
withL.accept(TinkerModifiers.snowdrift);
with.accept(ModifierIds.strength);
withL.accept(TinkerModifiers.toolBelt);
with.accept(ModifierIds.toolBelt);
withL.accept(TinkerModifiers.unarmed);
withL.accept(TinkerModifiers.zoom);
// harvest
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package slimeknights.tconstruct.library.json.serializer;

import com.google.gson.JsonObject;
import lombok.RequiredArgsConstructor;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.util.GsonHelper;
import slimeknights.mantle.data.GenericLoaderRegistry.IGenericLoader;
import slimeknights.mantle.data.GenericLoaderRegistry.IHaveLoader;

import java.util.function.IntFunction;
import java.util.function.ToIntFunction;

/** Generic serializer for classes that just have a single int value */
@RequiredArgsConstructor
public class GenericIntSerializer<T extends IHaveLoader<?>> implements IGenericLoader<T> {
private final String key;
private final IntFunction<T> constructor;
private final ToIntFunction<T> getter;

@Override
public void serialize(T object, JsonObject json) {
json.addProperty(key, getter.applyAsInt(object));
}

@Override
public T deserialize(JsonObject json) {
return constructor.apply(GsonHelper.getAsInt(json, key));
}

@Override
public void toNetwork(T object, FriendlyByteBuf buffer) {
buffer.writeVarInt(getter.applyAsInt(object));
}

@Override
public T fromNetwork(FriendlyByteBuf buffer) {
return constructor.apply(buffer.readVarInt());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
package slimeknights.tconstruct.library.json.serializer;

import net.minecraft.MethodsReturnNonnullByDefault;

import javax.annotation.ParametersAreNonnullByDefault;
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
package slimeknights.tconstruct.tools.modifiers.ability.armor;
package slimeknights.tconstruct.library.modifiers.dynamic;

import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.player.Player;
import slimeknights.tconstruct.TConstruct;
import slimeknights.mantle.data.GenericLoaderRegistry.IGenericLoader;
import slimeknights.tconstruct.library.json.serializer.GenericIntSerializer;
import slimeknights.tconstruct.library.modifiers.Modifier;
import slimeknights.tconstruct.library.modifiers.hooks.IArmorInteractModifier;
import slimeknights.tconstruct.library.modifiers.impl.InventoryModifier;
import slimeknights.tconstruct.library.tools.capability.ToolInventoryCapability;
import slimeknights.tconstruct.library.tools.nbt.IToolStackView;

import javax.annotation.Nullable;

public class PocketsModifier extends InventoryModifier implements IArmorInteractModifier {
private static final ResourceLocation INVENTORY_KEY = TConstruct.getResource("pockets");
public PocketsModifier() {
super(INVENTORY_KEY, 9);
public class InventoryMenuModifier extends InventoryModifier implements IArmorInteractModifier {
/** Loader instance */
public static final GenericIntSerializer<InventoryMenuModifier> LOADER = new GenericIntSerializer<>("size", InventoryMenuModifier::new, t -> t.slotsPerLevel);

public InventoryMenuModifier(int size) {
super(size);
}

@Override
Expand All @@ -34,4 +37,9 @@ public <T> T getModule(Class<T> type) {
}
return super.getModule(type);
}

@Override
public IGenericLoader<? extends Modifier> getLoader() {
return LOADER;
}
}

0 comments on commit 30a2c27

Please sign in to comment.