multiple bags, config
@ -38,7 +38,7 @@ mod_name=QuantumBags
|
|||||||
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
|
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
|
||||||
mod_license=All Rights Reserved
|
mod_license=All Rights Reserved
|
||||||
# The mod version. See https://semver.org/
|
# The mod version. See https://semver.org/
|
||||||
mod_version=0.0.2
|
mod_version=0.0.3
|
||||||
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
|
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
|
||||||
# This should match the base package used for the mod sources.
|
# This should match the base package used for the mod sources.
|
||||||
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
|
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||||
@ -46,4 +46,4 @@ mod_group_id=com.smthng
|
|||||||
# The authors of the mod. This is a simple text string that is used for display purposes in the mod list.
|
# The authors of the mod. This is a simple text string that is used for display purposes in the mod list.
|
||||||
mod_authors=xJenny69
|
mod_authors=xJenny69
|
||||||
# The description of the mod. This is a simple multiline text string that is used for display purposes in the mod list.
|
# The description of the mod. This is a simple multiline text string that is used for display purposes in the mod list.
|
||||||
mod_description=2^20 items in one slot
|
mod_description=adds bundles with huge capacities
|
@ -15,22 +15,23 @@ import net.minecraft.world.item.ItemStack;
|
|||||||
import net.minecraft.world.item.Items;
|
import net.minecraft.world.item.Items;
|
||||||
import net.minecraft.world.item.TooltipFlag;
|
import net.minecraft.world.item.TooltipFlag;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
|
import net.minecraftforge.common.ForgeConfigSpec;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class QuantumBag extends Item {
|
public class QuantumBag extends Item {
|
||||||
private final int maxSize;
|
ForgeConfigSpec.ConfigValue<Integer> size;
|
||||||
|
|
||||||
public QuantumBag(Properties pProperties, int maxSize) {
|
public QuantumBag(Properties pProperties, ForgeConfigSpec.ConfigValue<Integer> size) {
|
||||||
super(pProperties);
|
super(pProperties);
|
||||||
this.maxSize = maxSize;
|
this.size = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean overrideOtherStackedOnMe(ItemStack pStack, ItemStack pOther, Slot pSlot, ClickAction pAction, Player pPlayer, SlotAccess pAccess) {
|
public boolean overrideOtherStackedOnMe(ItemStack pStack, ItemStack pOther, Slot pSlot, ClickAction pAction, Player pPlayer, SlotAccess pAccess) {
|
||||||
boolean canBeStored = !(pOther.getItem().equals(Items.AIR) || pOther.getItem().equals(items.QUANTUM_BAG.get()));
|
boolean canBeStored = !(pOther.getItem().equals(Items.AIR) || pOther.getItem().equals(this));
|
||||||
if (pAction.equals(ClickAction.PRIMARY)) { // left click on bag
|
if (pAction.equals(ClickAction.PRIMARY)) { // left click on bag
|
||||||
if (canBeStored && matchesStored(pStack, pOther)) {
|
if (canBeStored && matchesStored(pStack, pOther)) {
|
||||||
addItems(pStack, pOther);
|
addItems(pStack, pOther);
|
||||||
@ -70,9 +71,9 @@ public class QuantumBag extends Item {
|
|||||||
} else if (mode(pStack) == 2) { // suck items into bag
|
} else if (mode(pStack) == 2) { // suck items into bag
|
||||||
ItemStack stored = getStoredStack(pStack);
|
ItemStack stored = getStoredStack(pStack);
|
||||||
for (ItemStack itemStack : pPlayer.getInventory().items) {
|
for (ItemStack itemStack : pPlayer.getInventory().items) {
|
||||||
if (stored.getCount() < maxSize) {
|
if (stored.getCount() < size.get()) {
|
||||||
if (itemStackSame(stored, itemStack)) {
|
if (itemStackSame(stored, itemStack)) {
|
||||||
int removeAmount = Math.min(maxSize - stored.getCount(), itemStack.getCount());
|
int removeAmount = Math.min(size.get() - stored.getCount(), itemStack.getCount());
|
||||||
stored.setCount(stored.getCount() + removeAmount);
|
stored.setCount(stored.getCount() + removeAmount);
|
||||||
|
|
||||||
itemStack.setCount(itemStack.getCount() - removeAmount);
|
itemStack.setCount(itemStack.getCount() - removeAmount);
|
||||||
@ -108,7 +109,7 @@ public class QuantumBag extends Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void addItems(@NotNull ItemStack bag, @NotNull ItemStack itemStack) {
|
private void addItems(@NotNull ItemStack bag, @NotNull ItemStack itemStack) {
|
||||||
int removeAmount = Math.min(maxSize - storedItemCount(bag), itemStack.getCount());
|
int removeAmount = Math.min(size.get() - storedItemCount(bag), itemStack.getCount());
|
||||||
if (removeAmount > 0) {
|
if (removeAmount > 0) {
|
||||||
ItemStack stored = itemStack.copy();
|
ItemStack stored = itemStack.copy();
|
||||||
stored.setCount(removeAmount + storedItemCount(bag));
|
stored.setCount(removeAmount + storedItemCount(bag));
|
||||||
@ -118,7 +119,7 @@ public class QuantumBag extends Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void addOne(@NotNull ItemStack bag, @NotNull ItemStack itemStack) {
|
private void addOne(@NotNull ItemStack bag, @NotNull ItemStack itemStack) {
|
||||||
int removeAmount = Math.min(maxSize - storedItemCount(bag), 1);
|
int removeAmount = Math.min(size.get() - storedItemCount(bag), 1);
|
||||||
if (removeAmount > 0) {
|
if (removeAmount > 0) {
|
||||||
ItemStack stored = itemStack.copy();
|
ItemStack stored = itemStack.copy();
|
||||||
stored.setCount(removeAmount + storedItemCount(bag));
|
stored.setCount(removeAmount + storedItemCount(bag));
|
||||||
|
@ -3,6 +3,7 @@ package com.smthng.quantumbags;
|
|||||||
import com.mojang.logging.LogUtils;
|
import com.mojang.logging.LogUtils;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.core.registries.Registries;
|
import net.minecraft.core.registries.Registries;
|
||||||
|
import net.minecraft.server.commands.LocateCommand;
|
||||||
import net.minecraft.world.food.FoodProperties;
|
import net.minecraft.world.food.FoodProperties;
|
||||||
import net.minecraft.world.item.BlockItem;
|
import net.minecraft.world.item.BlockItem;
|
||||||
import net.minecraft.world.item.CreativeModeTab;
|
import net.minecraft.world.item.CreativeModeTab;
|
||||||
@ -42,10 +43,13 @@ public class Quantumbags {
|
|||||||
|
|
||||||
items.register(modEventBus);
|
items.register(modEventBus);
|
||||||
MinecraftForge.EVENT_BUS.register(this);
|
MinecraftForge.EVENT_BUS.register(this);
|
||||||
|
ModLoadingContext.get().registerConfig(ModConfig.Type.SERVER, ServerConfig.SPEC, "quantumbags-server.toml");
|
||||||
modEventBus.addListener(this::addCreative);
|
modEventBus.addListener(this::addCreative);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addCreative(@NotNull BuildCreativeModeTabContentsEvent event) {
|
private void addCreative(@NotNull BuildCreativeModeTabContentsEvent event) {
|
||||||
if (event.getTabKey() == CreativeModeTabs.TOOLS_AND_UTILITIES) event.accept(items.QUANTUM_BAG);
|
if (event.getTabKey() == CreativeModeTabs.TOOLS_AND_UTILITIES) {
|
||||||
|
items.ITEMS.getEntries().forEach((e) -> event.accept(e.get().getDefaultInstance()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
21
src/main/java/com/smthng/quantumbags/ServerConfig.java
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
package com.smthng.quantumbags;
|
||||||
|
|
||||||
|
import net.minecraftforge.common.ForgeConfigSpec;
|
||||||
|
import net.minecraftforge.fml.common.Mod;
|
||||||
|
|
||||||
|
import static com.smthng.quantumbags.Quantumbags.MODID;
|
||||||
|
|
||||||
|
@Mod.EventBusSubscriber(modid = MODID, bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||||
|
public class ServerConfig {
|
||||||
|
public static final ForgeConfigSpec.ConfigValue<Integer> C_SIZE_SMALL, C_SIZE_MEDIUM, C_SIZE_LARGE, C_SIZE_HUGE;
|
||||||
|
private static final ForgeConfigSpec.Builder BUILDER = new ForgeConfigSpec.Builder();
|
||||||
|
public static final ForgeConfigSpec SPEC;
|
||||||
|
|
||||||
|
static {
|
||||||
|
C_SIZE_SMALL = BUILDER.define("size_small", 512);
|
||||||
|
C_SIZE_MEDIUM = BUILDER.define("size_medium", 4096);
|
||||||
|
C_SIZE_LARGE = BUILDER.define("size_large", 32768);
|
||||||
|
C_SIZE_HUGE = BUILDER.define("size_huge", 262144);
|
||||||
|
SPEC = BUILDER.build();
|
||||||
|
}
|
||||||
|
}
|
@ -10,7 +10,11 @@ import static com.smthng.quantumbags.Quantumbags.MODID;
|
|||||||
|
|
||||||
public class items {
|
public class items {
|
||||||
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID);
|
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID);
|
||||||
public static final RegistryObject<Item> QUANTUM_BAG = ITEMS.register("quantum_bag", () -> new QuantumBag(new Item.Properties().stacksTo(1), 1048576));
|
public static final RegistryObject<Item> QUANTUM_BAG_SMALL = ITEMS.register("quantum_bag_small", () -> new QuantumBag(new Item.Properties().stacksTo(1), ServerConfig.C_SIZE_SMALL));
|
||||||
|
public static final RegistryObject<Item> QUANTUM_BAG_MEDIUM = ITEMS.register("quantum_bag_medium", () -> new QuantumBag(new Item.Properties().stacksTo(1), ServerConfig.C_SIZE_MEDIUM));
|
||||||
|
public static final RegistryObject<Item> QUANTUM_BAG_LARGE = ITEMS.register("quantum_bag_large", () -> new QuantumBag(new Item.Properties().stacksTo(1), ServerConfig.C_SIZE_LARGE));
|
||||||
|
public static final RegistryObject<Item> QUANTUM_BAG_HUGE = ITEMS.register("quantum_bag_huge", () -> new QuantumBag(new Item.Properties().stacksTo(1), ServerConfig.C_SIZE_HUGE));
|
||||||
|
|
||||||
|
|
||||||
public static void register(IEventBus bus) {
|
public static void register(IEventBus bus) {
|
||||||
ITEMS.register(bus);
|
ITEMS.register(bus);
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
{
|
{
|
||||||
"item.quantumbags.quantum_bag": "Quantum Bag"
|
"item.quantumbags.quantum_bag_small": "Small Quantum Bag",
|
||||||
|
"item.quantumbags.quantum_bag_medium": "Medium Quantum Bag",
|
||||||
|
"item.quantumbags.quantum_bag_large": "Large Quantum Bag",
|
||||||
|
"item.quantumbags.quantum_bag_huge": "Huge Quantum Bag"
|
||||||
}
|
}
|
@ -1,6 +0,0 @@
|
|||||||
{
|
|
||||||
"parent": "minecraft:item/handheld",
|
|
||||||
"textures": {
|
|
||||||
"layer0": "quantumbags:item/quantum_bag_filling"
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,20 +1,20 @@
|
|||||||
{
|
{
|
||||||
"parent": "minecraft:item/handheld",
|
"parent": "minecraft:item/handheld",
|
||||||
"textures": {
|
"textures": {
|
||||||
"layer0": "quantumbags:item/quantum_bag"
|
"layer0": "quantumbags:item/quantum_bag_huge"
|
||||||
},
|
},
|
||||||
"overrides": [
|
"overrides": [
|
||||||
{
|
{
|
||||||
"predicate": {
|
"predicate": {
|
||||||
"custom_model_data": 1
|
"custom_model_data": 1
|
||||||
},
|
},
|
||||||
"model": "quantumbags:item/quantum_bag_filling"
|
"model": "quantumbags:item/quantum_bag_huge_filling"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"predicate": {
|
"predicate": {
|
||||||
"custom_model_data": 2
|
"custom_model_data": 2
|
||||||
},
|
},
|
||||||
"model": "quantumbags:item/quantum_bag_sucking"
|
"model": "quantumbags:item/quantum_bag_huge_sucking"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"parent": "minecraft:item/handheld",
|
||||||
|
"textures": {
|
||||||
|
"layer0": "quantumbags:item/quantum_bag_huge",
|
||||||
|
"layer1": "quantumbags:item/filling"
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"parent": "minecraft:item/handheld",
|
||||||
|
"textures": {
|
||||||
|
"layer0": "quantumbags:item/quantum_bag_huge",
|
||||||
|
"layer1": "quantumbags:item/sucking"
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"parent": "minecraft:item/handheld",
|
||||||
|
"textures": {
|
||||||
|
"layer0": "quantumbags:item/quantum_bag_large"
|
||||||
|
},
|
||||||
|
"overrides": [
|
||||||
|
{
|
||||||
|
"predicate": {
|
||||||
|
"custom_model_data": 1
|
||||||
|
},
|
||||||
|
"model": "quantumbags:item/quantum_bag_large_filling"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"predicate": {
|
||||||
|
"custom_model_data": 2
|
||||||
|
},
|
||||||
|
"model": "quantumbags:item/quantum_bag_large_sucking"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"parent": "minecraft:item/handheld",
|
||||||
|
"textures": {
|
||||||
|
"layer0": "quantumbags:item/quantum_bag_large",
|
||||||
|
"layer1": "quantumbags:item/filling"
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"parent": "minecraft:item/handheld",
|
||||||
|
"textures": {
|
||||||
|
"layer0": "quantumbags:item/quantum_bag_large",
|
||||||
|
"layer1": "quantumbags:item/sucking"
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"parent": "minecraft:item/handheld",
|
||||||
|
"textures": {
|
||||||
|
"layer0": "quantumbags:item/quantum_bag_medium"
|
||||||
|
},
|
||||||
|
"overrides": [
|
||||||
|
{
|
||||||
|
"predicate": {
|
||||||
|
"custom_model_data": 1
|
||||||
|
},
|
||||||
|
"model": "quantumbags:item/quantum_bag_medium_filling"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"predicate": {
|
||||||
|
"custom_model_data": 2
|
||||||
|
},
|
||||||
|
"model": "quantumbags:item/quantum_bag_medium_sucking"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"parent": "minecraft:item/handheld",
|
||||||
|
"textures": {
|
||||||
|
"layer0": "quantumbags:item/quantum_bag_medium",
|
||||||
|
"layer1": "quantumbags:item/filling"
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"parent": "minecraft:item/handheld",
|
||||||
|
"textures": {
|
||||||
|
"layer0": "quantumbags:item/quantum_bag_medium",
|
||||||
|
"layer1": "quantumbags:item/sucking"
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"parent": "minecraft:item/handheld",
|
||||||
|
"textures": {
|
||||||
|
"layer0": "quantumbags:item/quantum_bag_small"
|
||||||
|
},
|
||||||
|
"overrides": [
|
||||||
|
{
|
||||||
|
"predicate": {
|
||||||
|
"custom_model_data": 1
|
||||||
|
},
|
||||||
|
"model": "quantumbags:item/quantum_bag_small_filling"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"predicate": {
|
||||||
|
"custom_model_data": 2
|
||||||
|
},
|
||||||
|
"model": "quantumbags:item/quantum_bag_small_sucking"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"parent": "minecraft:item/handheld",
|
||||||
|
"textures": {
|
||||||
|
"layer0": "quantumbags:item/quantum_bag_small",
|
||||||
|
"layer1": "quantumbags:item/filling"
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"parent": "minecraft:item/handheld",
|
||||||
|
"textures": {
|
||||||
|
"layer0": "quantumbags:item/quantum_bag_small",
|
||||||
|
"layer1": "quantumbags:item/sucking"
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +0,0 @@
|
|||||||
{
|
|
||||||
"parent": "minecraft:item/handheld",
|
|
||||||
"textures": {
|
|
||||||
"layer0": "quantumbags:item/quantum_bag_sucking"
|
|
||||||
}
|
|
||||||
}
|
|
BIN
src/main/resources/assets/quantumbags/textures/item/filling.png
Normal file
After Width: | Height: | Size: 114 B |
Before Width: | Height: | Size: 288 B |
After Width: | Height: | Size: 265 B |
After Width: | Height: | Size: 260 B |
After Width: | Height: | Size: 262 B |
Before Width: | Height: | Size: 266 B After Width: | Height: | Size: 266 B |
Before Width: | Height: | Size: 282 B |
BIN
src/main/resources/assets/quantumbags/textures/item/sucking.png
Normal file
After Width: | Height: | Size: 107 B |
@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"type": "minecraft:crafting_shaped",
|
||||||
|
"pattern": [
|
||||||
|
"#S#",
|
||||||
|
"S S",
|
||||||
|
"#S#"
|
||||||
|
],
|
||||||
|
"key": {
|
||||||
|
"#": {
|
||||||
|
"item": "minecraft:leather"
|
||||||
|
},
|
||||||
|
"S": {
|
||||||
|
"item": "quantumbags:quantum_bag_large"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"result": {
|
||||||
|
"item": "quantumbags:quantum_bag_huge",
|
||||||
|
"count": 1
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"type": "minecraft:crafting_shaped",
|
||||||
|
"pattern": [
|
||||||
|
"#S#",
|
||||||
|
"S S",
|
||||||
|
"#S#"
|
||||||
|
],
|
||||||
|
"key": {
|
||||||
|
"#": {
|
||||||
|
"item": "minecraft:leather"
|
||||||
|
},
|
||||||
|
"S": {
|
||||||
|
"item": "quantumbags:quantum_bag_medium"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"result": {
|
||||||
|
"item": "quantumbags:quantum_bag_large",
|
||||||
|
"count": 1
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"type": "minecraft:crafting_shaped",
|
||||||
|
"pattern": [
|
||||||
|
"#S#",
|
||||||
|
"S S",
|
||||||
|
"#S#"
|
||||||
|
],
|
||||||
|
"key": {
|
||||||
|
"#": {
|
||||||
|
"item": "minecraft:leather"
|
||||||
|
},
|
||||||
|
"S": {
|
||||||
|
"item": "quantumbags:quantum_bag_small"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"result": {
|
||||||
|
"item": "quantumbags:quantum_bag_medium",
|
||||||
|
"count": 1
|
||||||
|
}
|
||||||
|
}
|
@ -14,7 +14,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"result": {
|
"result": {
|
||||||
"item": "quantumbags:quantum_bag",
|
"item": "quantumbags:quantum_bag_small",
|
||||||
"count": 1
|
"count": 1
|
||||||
}
|
}
|
||||||
}
|
}
|