carrot stack

This commit is contained in:
Jörg Henke 2020-10-25 20:13:26 +01:00
parent 1a7e5ca02a
commit 281129212d
35 changed files with 317 additions and 29 deletions

View File

@ -8,7 +8,7 @@ org.gradle.jvmargs=-Xmx1G
loader_version=0.9.3+build.207
# Mod Properties
mod_version = 1.16.3.5
mod_version = 1.16.3.6
maven_group = de.jottyfan.minecraft
archives_base_name = quickiefabric

View File

@ -1,5 +1,8 @@
package de.jottyfan.minecraft.quickiefabric.container;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import de.jottyfan.minecraft.quickiefabric.init.RegistryManager;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
@ -15,6 +18,8 @@ import net.minecraft.util.Hand;
public class BackpackScreenHandler extends ScreenHandler {
private static final Logger LOGGER = LogManager.getLogger(BackpackScreenHandler.class);
private final BackpackInventory backpackInventory;
private final PlayerEntity player;
private final ItemStack thisStack;
@ -63,38 +68,24 @@ public class BackpackScreenHandler extends ScreenHandler {
this.backpackInventory.onClose(player);
}
@Override
public ItemStack transferSlot(PlayerEntity player, int slotIndex) {
ItemStack copy = ItemStack.EMPTY;
Slot chosenSlot = this.slots.get(slotIndex);
if (chosenSlot != null && chosenSlot.hasStack()) {
ItemStack chosenStack = chosenSlot.getStack();
copy = chosenStack.copy();
if (slotIndex < backpackInventory.size()) {
if (!this.insertItem(chosenStack, backpackInventory.size(), this.slots.size(), true)) {
return ItemStack.EMPTY;
}
} else if (!this.insertItem(chosenStack, 0, backpackInventory.size(), false)) {
return ItemStack.EMPTY;
}
if (chosenStack.isEmpty()) {
chosenSlot.setStack(ItemStack.EMPTY);
} else {
chosenSlot.markDirty();
}
}
return copy;
}
@Override
public ItemStack onSlotClick(int slotId, int quickCraftData, SlotActionType actionType, PlayerEntity playerEntity) {
if (slotId >= 0) {
ItemStack stack = getSlot(slotId).getStack();
Slot slot = slotId >= 0 && slotId < this.slots.size() ? this.slots.get(slotId) : null;
ItemStack stack = slot == null ? ItemStack.EMPTY : slot.getStack();
if (actionType.equals(SlotActionType.PICKUP) || actionType.equals(SlotActionType.PICKUP_ALL)
|| actionType.equals(SlotActionType.SWAP)) {
if (stack.getName().equals(thisStack.getName())) {
return stack;
return stack; // omit to put the backpack into itself; as a side effect, omits adding same
// colored backpacks into this one
}
return super.onSlotClick(slotId, quickCraftData, actionType, playerEntity);
} else {
if (playerEntity.world.isClient) {
LOGGER.debug("ignoring action type {} on slotId {} for {} x {}", actionType.toString(), slotId, stack.getCount(),
stack.getItem().toString());
}
return stack;
}
return super.onSlotClick(slotId, quickCraftData, actionType, playerEntity);
}
@Environment(EnvType.CLIENT)

View File

@ -94,6 +94,7 @@ public class RegistryManager {
stacks.add(new ItemStack(QuickieItems.LEVELUP));
stacks.add(new ItemStack(QuickieItems.PENCIL));
stacks.add(new ItemStack(QuickieItems.ROTTEN_FLESH_STRIPES));
stacks.add(new ItemStack(QuickieItems.CARROTSTACK));
stacks.add(new ItemStack(QuickieItems.BACKPACK_BROWN));
stacks.add(new ItemStack(QuickieItems.BACKPACK_WHITE));
stacks.add(new ItemStack(QuickieItems.BACKPACK_BLACK));
@ -103,6 +104,13 @@ public class RegistryManager {
stacks.add(new ItemStack(QuickieItems.BACKPACK_PINK));
stacks.add(new ItemStack(QuickieItems.BACKPACK_RED));
stacks.add(new ItemStack(QuickieItems.BACKPACK_YELLOW));
stacks.add(new ItemStack(QuickieItems.BACKPACK_DARKGRAY));
stacks.add(new ItemStack(QuickieItems.BACKPACK_LIGHTGRAY));
stacks.add(new ItemStack(QuickieItems.BACKPACK_LIGHTGREEN));
stacks.add(new ItemStack(QuickieItems.BACKPACK_MAGENTA));
stacks.add(new ItemStack(QuickieItems.BACKPACK_ORANGE));
stacks.add(new ItemStack(QuickieItems.BACKPACK_PURPLE));
stacks.add(new ItemStack(QuickieItems.BACKPACK_LIGHTBLUE));
stacks.add(new ItemStack(QuickieTools.SPEEDPOWDERAXE));
stacks.add(new ItemStack(QuickieTools.SPEEDPOWDERPICKAXE));
stacks.add(new ItemStack(QuickieTools.SPEEDPOWDERSHOVEL));
@ -159,6 +167,7 @@ public class RegistryManager {
registerItem(QuickieItems.SALPETER, "salpeter");
registerItem(QuickieItems.SULPHOR, "sulphor");
registerItem(QuickieItems.ROTTEN_FLESH_STRIPES, "rotten_flesh_stripes");
registerItem(QuickieItems.CARROTSTACK, "carrotstack");
registerItem(QuickieItems.BACKPACK_BROWN, "backpack_brown");
registerItem(QuickieItems.BACKPACK_WHITE, "backpack_white");
registerItem(QuickieItems.BACKPACK_BLACK, "backpack_black");
@ -168,6 +177,13 @@ public class RegistryManager {
registerItem(QuickieItems.BACKPACK_PINK, "backpack_pink");
registerItem(QuickieItems.BACKPACK_RED, "backpack_red");
registerItem(QuickieItems.BACKPACK_YELLOW, "backpack_yellow");
registerItem(QuickieItems.BACKPACK_DARKGRAY, "backpack_darkgray");
registerItem(QuickieItems.BACKPACK_LIGHTGRAY, "backpack_lightgray");
registerItem(QuickieItems.BACKPACK_LIGHTGREEN, "backpack_lightgreen");
registerItem(QuickieItems.BACKPACK_MAGENTA, "backpack_magenta");
registerItem(QuickieItems.BACKPACK_ORANGE, "backpack_orange");
registerItem(QuickieItems.BACKPACK_PURPLE, "backpack_purple");
registerItem(QuickieItems.BACKPACK_LIGHTBLUE, "backpack_lightblue");
}
public static final void registerTools() {

View File

@ -0,0 +1,16 @@
package de.jottyfan.minecraft.quickiefabric.items;
import de.jottyfan.minecraft.quickiefabric.init.RegistryManager;
import net.minecraft.item.FoodComponent;
import net.minecraft.item.Item;
/**
*
* @author jotty
*
*/
public class ItemCarrotstack extends Item {
public ItemCarrotstack() {
super(new Item.Settings().group(RegistryManager.QUICKIEFABRIC_GROUP).maxCount(99).food(new FoodComponent.Builder().hunger(12).saturationModifier(0.6F).build()));
}
}

View File

@ -20,5 +20,13 @@ public class QuickieItems {
public static final ItemBackpack BACKPACK_PINK = new ItemBackpack();
public static final ItemBackpack BACKPACK_RED = new ItemBackpack();
public static final ItemBackpack BACKPACK_YELLOW = new ItemBackpack();
public static final ItemBackpack BACKPACK_DARKGRAY = new ItemBackpack();
public static final ItemBackpack BACKPACK_LIGHTGRAY = new ItemBackpack();
public static final ItemBackpack BACKPACK_LIGHTGREEN = new ItemBackpack();
public static final ItemBackpack BACKPACK_MAGENTA = new ItemBackpack();
public static final ItemBackpack BACKPACK_ORANGE = new ItemBackpack();
public static final ItemBackpack BACKPACK_PURPLE = new ItemBackpack();
public static final ItemBackpack BACKPACK_LIGHTBLUE = new ItemBackpack();
public static final ItemRottenFleshStripes ROTTEN_FLESH_STRIPES = new ItemRottenFleshStripes();
public static final ItemCarrotstack CARROTSTACK = new ItemCarrotstack();
}

View File

@ -16,11 +16,19 @@
"item.quickiefabric.backpack_brown": "brauner Rucksack",
"item.quickiefabric.backpack_cyan": "türkiser Rucksack",
"item.quickiefabric.backpack_green": "grüner Rucksack",
"item.quickiefabric.backpack_pink": "pinker Rucksack",
"item.quickiefabric.backpack_pink": "rosaner Rucksack",
"item.quickiefabric.backpack_red": "roter Rucksack",
"item.quickiefabric.backpack_white": "weißer Rucksack",
"item.quickiefabric.backpack_yellow": "gelber Rucksack",
"item.quickiefabric.backpack_darkgray": "dunkelgrauer Rucksack",
"item.quickiefabric.backpack_lightgray": "hellgrauer Rucksack",
"item.quickiefabric.backpack_lightgreen": "hellgrüner Rucksack",
"item.quickiefabric.backpack_magenta": "pinker Rucksack",
"item.quickiefabric.backpack_orange": "orangener Rucksack",
"item.quickiefabric.backpack_purple": "lilaner Rucksack",
"item.quickiefabric.backpack_lightblue": "hellblauer Rucksack",
"item.quickiefabric.rotten_flesh_stripes": "geschnittenes Gammelfleisch",
"item.quickiefabric.carrotstack": "Karottenbündel",
"block.quickiefabric.orenethersulphor": "Nether-Schwefel",
"block.quickiefabric.oresalpeter": "Salpetererz",
"block.quickiefabric.oresandsalpeter": "Salpetergestein",

View File

@ -20,7 +20,15 @@
"item.quickiefabric.backpack_red": "red backpack",
"item.quickiefabric.backpack_white": "white backpack",
"item.quickiefabric.backpack_yellow": "yellow backpack",
"item.quickiefabric.backpack_darkgray": "dark gray backpack",
"item.quickiefabric.backpack_lightgray": "light gray backpack",
"item.quickiefabric.backpack_lightgreen": "lime backpack",
"item.quickiefabric.backpack_magenta": "magenta backpack",
"item.quickiefabric.backpack_orange": "orange backpack",
"item.quickiefabric.backpack_purple": "purple backpack",
"item.quickiefabric.backpack_lightblue": "light blue backpack",
"item.quickiefabric.rotten_flesh_stripes": "rotten flesh stripes",
"item.quickiefabric.carrotstack": "a bundle of carrots",
"block.quickiefabric.orenethersulphor": "nether sulfur",
"block.quickiefabric.oresalpeter": "salpeter ore",
"block.quickiefabric.oresandsalpeter": "salpeter stone",

View File

@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "quickiefabric:item/backpack_darkgray"
}
}

View File

@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "quickiefabric:item/backpack_lightblue"
}
}

View File

@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "quickiefabric:item/backpack_lightgray"
}
}

View File

@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "quickiefabric:item/backpack_lightgreen"
}
}

View File

@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "quickiefabric:item/backpack_magenta"
}
}

View File

@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "quickiefabric:item/backpack_orange"
}
}

View File

@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "quickiefabric:item/backpack_purple"
}
}

View File

@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "quickiefabric:item/carrotstack"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 650 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 694 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 634 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 613 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 690 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 602 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 687 B

After

Width:  |  Height:  |  Size: 651 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 687 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 604 B

View File

@ -0,0 +1,22 @@
{
"type": "crafting_shaped",
"pattern": [
"wlw",
"lsl",
"wlw"
],
"key": {
"s": {
"item": "minecraft:string"
},
"l": {
"item": "minecraft:leather"
},
"w": {
"item": "minecraft:gray_wool"
}
},
"result": {
"item": "quickiefabric:backpack_darkgray"
}
}

View File

@ -0,0 +1,22 @@
{
"type": "crafting_shaped",
"pattern": [
"wlw",
"lsl",
"wlw"
],
"key": {
"s": {
"item": "minecraft:string"
},
"l": {
"item": "minecraft:leather"
},
"w": {
"item": "minecraft:light_blue_wool"
}
},
"result": {
"item": "quickiefabric:backpack_lightblue"
}
}

View File

@ -0,0 +1,22 @@
{
"type": "crafting_shaped",
"pattern": [
"wlw",
"lsl",
"wlw"
],
"key": {
"s": {
"item": "minecraft:string"
},
"l": {
"item": "minecraft:leather"
},
"w": {
"item": "minecraft:light_gray_wool"
}
},
"result": {
"item": "quickiefabric:backpack_lightgray"
}
}

View File

@ -0,0 +1,22 @@
{
"type": "crafting_shaped",
"pattern": [
"wlw",
"lsl",
"wlw"
],
"key": {
"s": {
"item": "minecraft:string"
},
"l": {
"item": "minecraft:leather"
},
"w": {
"item": "minecraft:lime_wool"
}
},
"result": {
"item": "quickiefabric:backpack_lightgreen"
}
}

View File

@ -0,0 +1,22 @@
{
"type": "crafting_shaped",
"pattern": [
"wlw",
"lsl",
"wlw"
],
"key": {
"s": {
"item": "minecraft:string"
},
"l": {
"item": "minecraft:leather"
},
"w": {
"item": "minecraft:magenta_wool"
}
},
"result": {
"item": "quickiefabric:backpack_magenta"
}
}

View File

@ -0,0 +1,22 @@
{
"type": "crafting_shaped",
"pattern": [
"wlw",
"lsl",
"wlw"
],
"key": {
"s": {
"item": "minecraft:string"
},
"l": {
"item": "minecraft:leather"
},
"w": {
"item": "minecraft:orange_wool"
}
},
"result": {
"item": "quickiefabric:backpack_orange"
}
}

View File

@ -0,0 +1,22 @@
{
"type": "crafting_shaped",
"pattern": [
"wlw",
"lsl",
"wlw"
],
"key": {
"s": {
"item": "minecraft:string"
},
"l": {
"item": "minecraft:leather"
},
"w": {
"item": "minecraft:purple_wool"
}
},
"result": {
"item": "quickiefabric:backpack_purple"
}
}

View File

@ -0,0 +1,12 @@
{
"type": "minecraft:crafting_shapeless",
"ingredients": [
{
"item": "quickiefabric:carrotstack"
}
],
"result": {
"item": "minecraft:carrot",
"count": 4
}
}

View File

@ -0,0 +1,15 @@
{
"type": "crafting_shaped",
"pattern": [
"cc",
"cc"
],
"key": {
"c": {
"item": "minecraft:carrot"
}
},
"result": {
"item": "quickiefabric:carrotstack"
}
}

View File

@ -0,0 +1,12 @@
{
"type": "minecraft:crafting_shapeless",
"ingredients": [
{
"item": "minecraft:white_wool"
}
],
"result": {
"item": "minecraft:string",
"count": 4
}
}