Skip to content

Commit

Permalink
1.21
Browse files Browse the repository at this point in the history
  • Loading branch information
PTOM76 committed Jun 28, 2024
1 parent 8bcef2e commit c66e53d
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 24 deletions.
14 changes: 7 additions & 7 deletions src/main/java/net/pitan76/storagebox/AutoCollectRecipe.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package net.pitan76.storagebox;

import net.minecraft.inventory.RecipeInputInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.recipe.RecipeSerializer;
import net.minecraft.recipe.SpecialCraftingRecipe;
import net.minecraft.recipe.book.CraftingRecipeCategory;
import net.minecraft.recipe.input.CraftingRecipeInput;
import net.minecraft.registry.RegistryWrapper;
import net.minecraft.world.World;

Expand All @@ -14,11 +14,11 @@ public AutoCollectRecipe(CraftingRecipeCategory category) {
}

@Override
public boolean matches(RecipeInputInventory inventory, World world) {
public boolean matches(CraftingRecipeInput input, World world) {
int count = 0;

for (int i = 0; i < inventory.size(); ++i) {
ItemStack stack = inventory.getStack(i);
for (int i = 0; i < input.getStacks().size(); ++i) {
ItemStack stack = input.getStacks().get(i);
if (stack.isEmpty()) continue;
++count;
if (!(stack.getItem() instanceof StorageBoxItem)) return false;
Expand All @@ -27,9 +27,9 @@ public boolean matches(RecipeInputInventory inventory, World world) {
}

@Override
public ItemStack craft(RecipeInputInventory inventory, RegistryWrapper.WrapperLookup lookup) {
for (int i = 0; i < inventory.size(); ++i) {
ItemStack stack = inventory.getStack(i);
public ItemStack craft(CraftingRecipeInput input, RegistryWrapper.WrapperLookup lookup) {
for (int i = 0; i < input.getStacks().size(); ++i) {
ItemStack stack = input.getStacks().get(i);
if (stack.isEmpty()) continue;
if (!(stack.getItem() instanceof StorageBoxItem)) continue;

Expand Down
14 changes: 7 additions & 7 deletions src/main/java/net/pitan76/storagebox/DataComponentTypes.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
package net.pitan76.storagebox;

import net.minecraft.component.DataComponentType;
import net.minecraft.component.ComponentType;
import net.minecraft.item.ItemStack;
import net.minecraft.network.codec.PacketCodecs;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.util.dynamic.Codecs;

public class DataComponentTypes {
public static DataComponentType<Integer> ITEM_COUNT;
public static DataComponentType<Integer> AUTO_COLLECT;
public static DataComponentType<ItemStack> ITEM_DATA;
public static ComponentType<Integer> ITEM_COUNT;
public static ComponentType<Integer> AUTO_COLLECT;
public static ComponentType<ItemStack> ITEM_DATA;

public static void init() {
ITEM_COUNT = Registry.register(Registries.DATA_COMPONENT_TYPE, StorageBoxMod.id("size"), DataComponentType.<Integer>builder().codec(Codecs.NONNEGATIVE_INT).packetCodec(PacketCodecs.VAR_INT).build());
AUTO_COLLECT = Registry.register(Registries.DATA_COMPONENT_TYPE, StorageBoxMod.id("auto"), DataComponentType.<Integer>builder().codec(Codecs.NONNEGATIVE_INT).packetCodec(PacketCodecs.VAR_INT).build());
ITEM_DATA = Registry.register(Registries.DATA_COMPONENT_TYPE, StorageBoxMod.id("item_data"), DataComponentType.<ItemStack>builder().codec(ItemStack.CODEC).packetCodec(ItemStack.PACKET_CODEC).build());
ITEM_COUNT = Registry.register(Registries.DATA_COMPONENT_TYPE, StorageBoxMod.id("size"), ComponentType.<Integer>builder().codec(Codecs.NONNEGATIVE_INT).packetCodec(PacketCodecs.VAR_INT).build());
AUTO_COLLECT = Registry.register(Registries.DATA_COMPONENT_TYPE, StorageBoxMod.id("auto"), ComponentType.<Integer>builder().codec(Codecs.NONNEGATIVE_INT).packetCodec(PacketCodecs.VAR_INT).build());
ITEM_DATA = Registry.register(Registries.DATA_COMPONENT_TYPE, StorageBoxMod.id("item_data"), ComponentType.<ItemStack>builder().codec(ItemStack.CODEC).packetCodec(ItemStack.PACKET_CODEC).build());
}
}
18 changes: 9 additions & 9 deletions src/main/java/net/pitan76/storagebox/StorageBoxItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents;
import net.minecraft.block.BlockState;
import net.minecraft.client.item.TooltipType;
import net.minecraft.component.DataComponentType;
import net.minecraft.component.ComponentType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroups;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUsageContext;
import net.minecraft.item.tooltip.TooltipType;
import net.minecraft.screen.NamedScreenHandlerFactory;
import net.minecraft.screen.PlayerScreenHandler;
import net.minecraft.screen.SimpleNamedScreenHandlerFactory;
Expand Down Expand Up @@ -98,7 +98,7 @@ public static ItemStack getStackInStorageBox(ItemStack storageBoxStack) {
}

// stackのコンポーネントから数値のデータを取り出す
public static int getComponentAsInt(ItemStack storageBoxStack, DataComponentType<Integer> type) {
public static int getComponentAsInt(ItemStack storageBoxStack, ComponentType<Integer> type) {
int data = 0;
//NbtCompound nbt = storageBoxStack.getNbt();

Expand Down Expand Up @@ -135,18 +135,18 @@ public static void changeAutoCollect(ItemStack storageBoxStack) {
setComponentAsInt(storageBoxStack, DataComponentTypes.AUTO_COLLECT, value);
}

public static void setComponentAsInt(ItemStack storageBoxStack, DataComponentType<Integer> type, int data) {
public static void setComponentAsInt(ItemStack storageBoxStack, ComponentType<Integer> type, int data) {
storageBoxStack.set(type, data);
}

public static void setComponentStack(ItemStack storageBoxStack, DataComponentType<ItemStack> type, ItemStack stack) {
public static void setComponentStack(ItemStack storageBoxStack, ComponentType<ItemStack> type, ItemStack stack) {
if (!stack.isEmpty())
storageBoxStack.set(type, stack);
else
storageBoxStack.remove(type);
}

public static void removeComponent(ItemStack storageBoxStack, DataComponentType<?> type) {
public static void removeComponent(ItemStack storageBoxStack, ComponentType<?> type) {
storageBoxStack.remove(type);
}

Expand Down Expand Up @@ -329,15 +329,15 @@ public UseAction getUseAction(ItemStack storageBoxStack) {
}

@Override
public int getMaxUseTime(ItemStack storageBoxStack) {
public int getMaxUseTime(ItemStack storageBoxStack, LivingEntity entity) {
Item item = getItem(storageBoxStack);

if (item != null) {
ItemStack stack = getStackInStorageBox(storageBoxStack);
return item.getMaxUseTime(stack);
return item.getMaxUseTime(stack, entity);
}

return super.getMaxUseTime(storageBoxStack);
return super.getMaxUseTime(storageBoxStack, entity);
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/pitan76/storagebox/StorageBoxMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ public static void log(Level level, String message){
}

public static Identifier id(String id) {
return new Identifier(MOD_ID, id);
return Identifier.of(MOD_ID, id);
}
}

0 comments on commit c66e53d

Please sign in to comment.