diff --git a/src/main/java/com/megatrex4/ukrainian_dlight/UkrainianDelight.java b/src/main/java/com/megatrex4/ukrainian_dlight/UkrainianDelight.java index a5b8c17..3c5afbc 100644 --- a/src/main/java/com/megatrex4/ukrainian_dlight/UkrainianDelight.java +++ b/src/main/java/com/megatrex4/ukrainian_dlight/UkrainianDelight.java @@ -2,7 +2,6 @@ import com.megatrex4.ukrainian_dlight.block.DrinkBottleBlock; import com.megatrex4.ukrainian_dlight.block.FoodJarBlocks; -import com.megatrex4.ukrainian_dlight.item.KrashankyItem; import com.megatrex4.ukrainian_dlight.registry.BlockRegistry; import com.megatrex4.ukrainian_dlight.block.entity.ModBlockEntities; //import com.megatrex4.ukrainian_dlight.compat.patchouli.CustomBrewingRecipeProcessor; @@ -16,7 +15,9 @@ import com.megatrex4.ukrainian_dlight.registry.ScreenHandlersRegistry; import com.megatrex4.ukrainian_dlight.registry.ScreensRegistry; import net.fabricmc.api.ModInitializer; +import net.fabricmc.fabric.api.client.rendering.v1.BuiltinItemRendererRegistry; import net.minecraft.entity.damage.DamageType; +import net.minecraft.item.ItemConvertible; import net.minecraft.registry.RegistryKey; import net.minecraft.registry.RegistryKeys; import net.minecraft.text.MutableText; diff --git a/src/main/java/com/megatrex4/ukrainian_dlight/block/custom/BottleBlock.java b/src/main/java/com/megatrex4/ukrainian_dlight/block/BottleBlock.java similarity index 99% rename from src/main/java/com/megatrex4/ukrainian_dlight/block/custom/BottleBlock.java rename to src/main/java/com/megatrex4/ukrainian_dlight/block/BottleBlock.java index 7a5576f..eaea653 100644 --- a/src/main/java/com/megatrex4/ukrainian_dlight/block/custom/BottleBlock.java +++ b/src/main/java/com/megatrex4/ukrainian_dlight/block/BottleBlock.java @@ -1,4 +1,4 @@ -package com.megatrex4.ukrainian_dlight.block.custom; +package com.megatrex4.ukrainian_dlight.block; import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; diff --git a/src/main/java/com/megatrex4/ukrainian_dlight/block/custom/BrewingKegBlock.java b/src/main/java/com/megatrex4/ukrainian_dlight/block/BrewingKegBlock.java similarity index 96% rename from src/main/java/com/megatrex4/ukrainian_dlight/block/custom/BrewingKegBlock.java rename to src/main/java/com/megatrex4/ukrainian_dlight/block/BrewingKegBlock.java index 7fee69a..c979d77 100644 --- a/src/main/java/com/megatrex4/ukrainian_dlight/block/custom/BrewingKegBlock.java +++ b/src/main/java/com/megatrex4/ukrainian_dlight/block/BrewingKegBlock.java @@ -1,10 +1,9 @@ -package com.megatrex4.ukrainian_dlight.block.custom; +package com.megatrex4.ukrainian_dlight.block; import com.megatrex4.ukrainian_dlight.UkrainianDelight; import com.megatrex4.ukrainian_dlight.block.entity.BrewingKegBlockEntity; import com.megatrex4.ukrainian_dlight.block.entity.ModBlockEntities; import com.megatrex4.ukrainian_dlight.screen.renderer.FluidStackRenderer; -import com.megatrex4.ukrainian_dlight.util.CompoundTagUtils; import com.megatrex4.ukrainian_dlight.util.FluidStack; import net.fabricmc.api.EnvType; @@ -18,39 +17,30 @@ import net.minecraft.entity.ItemEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.fluid.FluidState; -import net.minecraft.fluid.Fluids; -import net.minecraft.inventory.Inventories; import net.minecraft.item.ItemPlacementContext; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.nbt.NbtCompound; import net.minecraft.nbt.NbtElement; import net.minecraft.particle.ParticleTypes; -import net.minecraft.registry.Registries; import net.minecraft.screen.NamedScreenHandlerFactory; -import net.minecraft.screen.ScreenHandler; import net.minecraft.sound.SoundCategory; import net.minecraft.sound.SoundEvents; import net.minecraft.state.StateManager; import net.minecraft.state.property.DirectionProperty; -import net.minecraft.state.property.EnumProperty; import net.minecraft.state.property.Properties; -import net.minecraft.state.property.Property; import net.minecraft.text.MutableText; import net.minecraft.text.Text; import net.minecraft.util.*; -import net.minecraft.util.collection.DefaultedList; import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; import net.minecraft.util.math.random.Random; import net.minecraft.util.shape.VoxelShape; -import net.minecraft.util.shape.VoxelShapes; import net.minecraft.world.BlockView; import net.minecraft.world.World; import org.jetbrains.annotations.Nullable; -import java.util.Iterator; import java.util.List; public class BrewingKegBlock extends BlockWithEntity implements BlockEntityProvider { diff --git a/src/main/java/com/megatrex4/ukrainian_dlight/block/custom/BrewingKegBlockItem.java b/src/main/java/com/megatrex4/ukrainian_dlight/block/BrewingKegBlockItem.java similarity index 97% rename from src/main/java/com/megatrex4/ukrainian_dlight/block/custom/BrewingKegBlockItem.java rename to src/main/java/com/megatrex4/ukrainian_dlight/block/BrewingKegBlockItem.java index 565ba3f..a372088 100644 --- a/src/main/java/com/megatrex4/ukrainian_dlight/block/custom/BrewingKegBlockItem.java +++ b/src/main/java/com/megatrex4/ukrainian_dlight/block/BrewingKegBlockItem.java @@ -1,4 +1,4 @@ -package com.megatrex4.ukrainian_dlight.block.custom; +package com.megatrex4.ukrainian_dlight.block; import net.minecraft.block.Block; import net.minecraft.item.BlockItem; diff --git a/src/main/java/com/megatrex4/ukrainian_dlight/block/DrinkBottleBlock.java b/src/main/java/com/megatrex4/ukrainian_dlight/block/DrinkBottleBlock.java index 3f884da..ee12ab0 100644 --- a/src/main/java/com/megatrex4/ukrainian_dlight/block/DrinkBottleBlock.java +++ b/src/main/java/com/megatrex4/ukrainian_dlight/block/DrinkBottleBlock.java @@ -1,7 +1,6 @@ package com.megatrex4.ukrainian_dlight.block; import com.megatrex4.ukrainian_dlight.UkrainianDelight; -import com.megatrex4.ukrainian_dlight.block.custom.BottleBlock; import com.megatrex4.ukrainian_dlight.item.DrinkBlockItem; import net.minecraft.block.Block; import net.minecraft.entity.effect.StatusEffectInstance; diff --git a/src/main/java/com/megatrex4/ukrainian_dlight/block/FoodJarBlocks.java b/src/main/java/com/megatrex4/ukrainian_dlight/block/FoodJarBlocks.java index daa43f7..0b35de5 100644 --- a/src/main/java/com/megatrex4/ukrainian_dlight/block/FoodJarBlocks.java +++ b/src/main/java/com/megatrex4/ukrainian_dlight/block/FoodJarBlocks.java @@ -1,7 +1,6 @@ package com.megatrex4.ukrainian_dlight.block; import com.megatrex4.ukrainian_dlight.UkrainianDelight; -import com.megatrex4.ukrainian_dlight.block.custom.JarBlock; import com.megatrex4.ukrainian_dlight.item.FoodBlockItem; import net.minecraft.block.Block; import net.minecraft.item.BlockItem; diff --git a/src/main/java/com/megatrex4/ukrainian_dlight/block/custom/JarBlock.java b/src/main/java/com/megatrex4/ukrainian_dlight/block/JarBlock.java similarity index 99% rename from src/main/java/com/megatrex4/ukrainian_dlight/block/custom/JarBlock.java rename to src/main/java/com/megatrex4/ukrainian_dlight/block/JarBlock.java index 64adaa2..1fcbc55 100644 --- a/src/main/java/com/megatrex4/ukrainian_dlight/block/custom/JarBlock.java +++ b/src/main/java/com/megatrex4/ukrainian_dlight/block/JarBlock.java @@ -1,4 +1,4 @@ -package com.megatrex4.ukrainian_dlight.block.custom; +package com.megatrex4.ukrainian_dlight.block; import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; diff --git a/src/main/java/com/megatrex4/ukrainian_dlight/block/custom/SaltBlock.java b/src/main/java/com/megatrex4/ukrainian_dlight/block/SaltBlock.java similarity index 95% rename from src/main/java/com/megatrex4/ukrainian_dlight/block/custom/SaltBlock.java rename to src/main/java/com/megatrex4/ukrainian_dlight/block/SaltBlock.java index 5ecb7f5..9d40a44 100644 --- a/src/main/java/com/megatrex4/ukrainian_dlight/block/custom/SaltBlock.java +++ b/src/main/java/com/megatrex4/ukrainian_dlight/block/SaltBlock.java @@ -1,4 +1,4 @@ -package com.megatrex4.ukrainian_dlight.block.custom; +package com.megatrex4.ukrainian_dlight.block; import net.minecraft.block.Block; import net.minecraft.block.BlockState; diff --git a/src/main/java/com/megatrex4/ukrainian_dlight/block/custom/PysankerTableBlock.java b/src/main/java/com/megatrex4/ukrainian_dlight/block/custom/PysankerTableBlock.java deleted file mode 100644 index fa51f77..0000000 --- a/src/main/java/com/megatrex4/ukrainian_dlight/block/custom/PysankerTableBlock.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.megatrex4.ukrainian_dlight.block.custom; - -import com.megatrex4.ukrainian_dlight.screen.PysankersTableScreenHandler; -import net.fabricmc.fabric.api.screenhandler.v1.ExtendedScreenHandlerFactory; -import net.minecraft.block.AbstractBlock; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.inventory.SimpleInventory; -import net.minecraft.network.PacketByteBuf; -import net.minecraft.screen.NamedScreenHandlerFactory; -import net.minecraft.screen.ScreenHandler; -import net.minecraft.screen.ScreenHandlerContext; -import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.text.Text; -import net.minecraft.util.ActionResult; -import net.minecraft.util.Hand; -import net.minecraft.util.hit.BlockHitResult; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import org.jetbrains.annotations.Nullable; - -public class PysankerTableBlock extends Block { - - public PysankerTableBlock(AbstractBlock.Settings settings) { - super(settings); - } - - @Override - public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { - if (!world.isClient) { - player.openHandledScreen(createScreenHandlerFactory(state, world, pos)); - } - return ActionResult.SUCCESS; - } - - @Nullable - @Override - public NamedScreenHandlerFactory createScreenHandlerFactory(BlockState state, World world, BlockPos pos) { - return new ExtendedScreenHandlerFactory() { - @Override - public void writeScreenOpeningData(ServerPlayerEntity player, PacketByteBuf buf) { - buf.writeBlockPos(pos); - } - - @Override - public Text getDisplayName() { - return Text.translatable("container.pysankers_table"); - } - - @Override - public ScreenHandler createMenu(int syncId, net.minecraft.entity.player.PlayerInventory inv, PlayerEntity player) { - return new PysankersTableScreenHandler(syncId, inv, (PysankerTableBlock) state.getBlock(), new SimpleInventory(PysankersTableScreenHandler.INVENTORY_SIZE), ScreenHandlerContext.create(world, pos)); - } - - }; - } -} diff --git a/src/main/java/com/megatrex4/ukrainian_dlight/block/entity/BrewingKegBlockEntity.java b/src/main/java/com/megatrex4/ukrainian_dlight/block/entity/BrewingKegBlockEntity.java index efcb0e3..e54e58c 100644 --- a/src/main/java/com/megatrex4/ukrainian_dlight/block/entity/BrewingKegBlockEntity.java +++ b/src/main/java/com/megatrex4/ukrainian_dlight/block/entity/BrewingKegBlockEntity.java @@ -50,7 +50,7 @@ import java.util.*; -import static com.megatrex4.ukrainian_dlight.block.custom.BrewingKegBlock.FACING; +import static com.megatrex4.ukrainian_dlight.block.BrewingKegBlock.FACING; public class BrewingKegBlockEntity extends BlockEntity implements ExtendedScreenHandlerFactory, ImplementedInventory { private final DefaultedList inventory = DefaultedList.ofSize(INVENTORY_SIZE, ItemStack.EMPTY); diff --git a/src/main/java/com/megatrex4/ukrainian_dlight/features/Features.java b/src/main/java/com/megatrex4/ukrainian_dlight/gen/features/Features.java similarity index 76% rename from src/main/java/com/megatrex4/ukrainian_dlight/features/Features.java rename to src/main/java/com/megatrex4/ukrainian_dlight/gen/features/Features.java index df782ec..aa4d82b 100644 --- a/src/main/java/com/megatrex4/ukrainian_dlight/features/Features.java +++ b/src/main/java/com/megatrex4/ukrainian_dlight/gen/features/Features.java @@ -1,8 +1,8 @@ -package com.megatrex4.ukrainian_dlight.features; +package com.megatrex4.ukrainian_dlight.gen.features; import com.megatrex4.ukrainian_dlight.UkrainianDelight; -import com.megatrex4.ukrainian_dlight.features.features.SaltCavesFeature; -import com.megatrex4.ukrainian_dlight.features.features.config.SaltCavesFeatureConfig; +import com.megatrex4.ukrainian_dlight.gen.features.features.SaltCavesFeature; +import com.megatrex4.ukrainian_dlight.gen.features.features.config.SaltCavesFeatureConfig; import net.minecraft.registry.Registries; import net.minecraft.registry.Registry; import net.minecraft.world.gen.feature.Feature; diff --git a/src/main/java/com/megatrex4/ukrainian_dlight/features/features/SaltCavesFeature.java b/src/main/java/com/megatrex4/ukrainian_dlight/gen/features/features/SaltCavesFeature.java similarity index 96% rename from src/main/java/com/megatrex4/ukrainian_dlight/features/features/SaltCavesFeature.java rename to src/main/java/com/megatrex4/ukrainian_dlight/gen/features/features/SaltCavesFeature.java index 33567c0..c76f35a 100644 --- a/src/main/java/com/megatrex4/ukrainian_dlight/features/features/SaltCavesFeature.java +++ b/src/main/java/com/megatrex4/ukrainian_dlight/gen/features/features/SaltCavesFeature.java @@ -1,7 +1,7 @@ -package com.megatrex4.ukrainian_dlight.features.features; +package com.megatrex4.ukrainian_dlight.gen.features.features; -import com.megatrex4.ukrainian_dlight.features.features.config.SaltCavesFeatureConfig; +import com.megatrex4.ukrainian_dlight.gen.features.features.config.SaltCavesFeatureConfig; import com.mojang.serialization.Codec; import net.minecraft.block.BlockState; import net.minecraft.util.math.BlockPos; diff --git a/src/main/java/com/megatrex4/ukrainian_dlight/features/features/config/SaltCavesFeatureConfig.java b/src/main/java/com/megatrex4/ukrainian_dlight/gen/features/features/config/SaltCavesFeatureConfig.java similarity index 94% rename from src/main/java/com/megatrex4/ukrainian_dlight/features/features/config/SaltCavesFeatureConfig.java rename to src/main/java/com/megatrex4/ukrainian_dlight/gen/features/features/config/SaltCavesFeatureConfig.java index 2c37132..e16d250 100644 --- a/src/main/java/com/megatrex4/ukrainian_dlight/features/features/config/SaltCavesFeatureConfig.java +++ b/src/main/java/com/megatrex4/ukrainian_dlight/gen/features/features/config/SaltCavesFeatureConfig.java @@ -1,4 +1,4 @@ -package com.megatrex4.ukrainian_dlight.features.features.config; +package com.megatrex4.ukrainian_dlight.gen.features.features.config; import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.RecordCodecBuilder; diff --git a/src/main/java/com/megatrex4/ukrainian_dlight/item/KrashankyItem.java b/src/main/java/com/megatrex4/ukrainian_dlight/item/KrashankyItem.java index 89361ca..8d3f3de 100644 --- a/src/main/java/com/megatrex4/ukrainian_dlight/item/KrashankyItem.java +++ b/src/main/java/com/megatrex4/ukrainian_dlight/item/KrashankyItem.java @@ -1,6 +1,12 @@ package com.megatrex4.ukrainian_dlight.item; +import net.minecraft.client.item.TooltipContext; import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.text.Text; +import net.minecraft.world.World; + +import java.util.List; public class KrashankyItem extends Item { public KrashankyItem(Settings settings) { diff --git a/src/main/java/com/megatrex4/ukrainian_dlight/item/ModItemGroups.java b/src/main/java/com/megatrex4/ukrainian_dlight/item/ModItemGroups.java index dc0830f..cfdf924 100644 --- a/src/main/java/com/megatrex4/ukrainian_dlight/item/ModItemGroups.java +++ b/src/main/java/com/megatrex4/ukrainian_dlight/item/ModItemGroups.java @@ -33,7 +33,6 @@ public class ModItemGroups { .icon(() -> new ItemStack(ItemsRegistry.CUCUMBER)) .entries((displayContext, entries) -> { entries.add(BlockRegistry.BREWING_KEG); - entries.add(BlockRegistry.PYSANKER_TABLE); entries.add(BlockRegistry.SALT_BAG); entries.add(BlockRegistry.SALT_BLOCK); entries.add(ItemsRegistry.SALT); diff --git a/src/main/java/com/megatrex4/ukrainian_dlight/registry/BlockRegistry.java b/src/main/java/com/megatrex4/ukrainian_dlight/registry/BlockRegistry.java index 803915c..a694eab 100644 --- a/src/main/java/com/megatrex4/ukrainian_dlight/registry/BlockRegistry.java +++ b/src/main/java/com/megatrex4/ukrainian_dlight/registry/BlockRegistry.java @@ -1,10 +1,9 @@ package com.megatrex4.ukrainian_dlight.registry; import com.megatrex4.ukrainian_dlight.UkrainianDelight; -import com.megatrex4.ukrainian_dlight.block.custom.BrewingKegBlock; -import com.megatrex4.ukrainian_dlight.block.custom.BrewingKegBlockItem; -import com.megatrex4.ukrainian_dlight.block.custom.PysankerTableBlock; -import com.megatrex4.ukrainian_dlight.block.custom.SaltBlock; +import com.megatrex4.ukrainian_dlight.block.BrewingKegBlock; +import com.megatrex4.ukrainian_dlight.block.BrewingKegBlockItem; +import com.megatrex4.ukrainian_dlight.block.SaltBlock; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.minecraft.block.Block; import net.minecraft.block.Blocks; @@ -29,8 +28,6 @@ public class BlockRegistry { public static final Block BREWING_KEG = registerBlock("brewing_keg", new BrewingKegBlock(FabricBlockSettings.copyOf(Blocks.OAK_PLANKS).sounds(BlockSoundGroup.WOOD).nonOpaque())); - public static final Block PYSANKER_TABLE = registerBlock("pysankers_table", - new PysankerTableBlock(FabricBlockSettings.copyOf(Blocks.OAK_PLANKS).sounds(BlockSoundGroup.WOOD))); private static Block registerBlock(String name, Block block){ registerBlockItem(name, block); diff --git a/src/main/java/com/megatrex4/ukrainian_dlight/registry/ItemsRegistry.java b/src/main/java/com/megatrex4/ukrainian_dlight/registry/ItemsRegistry.java index 5c85935..a471349 100644 --- a/src/main/java/com/megatrex4/ukrainian_dlight/registry/ItemsRegistry.java +++ b/src/main/java/com/megatrex4/ukrainian_dlight/registry/ItemsRegistry.java @@ -1,5 +1,7 @@ package com.megatrex4.ukrainian_dlight.registry; +import com.google.common.collect.FluentIterable; +import com.google.common.collect.ImmutableList; import com.megatrex4.ukrainian_dlight.UkrainianDelight; import com.megatrex4.ukrainian_dlight.item.FoodItemBuilder; import com.megatrex4.ukrainian_dlight.item.ModFoodComponents; @@ -10,6 +12,8 @@ import net.minecraft.registry.Registry; import net.minecraft.util.Identifier; +import java.util.List; + public class ItemsRegistry { // Define items using the ItemBuilder @@ -70,6 +74,7 @@ public class ItemsRegistry { public static final Item SALT = registerItem("salt", new FoodItemBuilder().build()); public static final Item YEAST = registerItem("yeast", new FoodItemBuilder().build()); + //KRASHANKY public static final Item BLACK_KRASHANKA = registerItem("black_krashanka", new KrashankyItem(new FabricItemSettings())); public static final Item BLUE_KRASHANKA = registerItem("blue_krashanka", new KrashankyItem(new FabricItemSettings())); public static final Item BROWN_KRASHANKA = registerItem("brown_krashanka", new KrashankyItem(new FabricItemSettings())); @@ -87,6 +92,29 @@ public class ItemsRegistry { public static final Item WHITE_KRASHANKA = registerItem("white_krashanka", new KrashankyItem(new FabricItemSettings())); public static final Item YELLOW_KRASHANKA = registerItem("yellow_krashanka", new KrashankyItem(new FabricItemSettings())); +// public static final FluentIterable KRASHANKY_ITEMS = ; + + //make to add all KRASHANY to KRASHANY_ITEMS to FluentIterable + public static final ImmutableList KRASHANKY_ITEMS = ImmutableList.of( + BLACK_KRASHANKA, + BLUE_KRASHANKA, + BROWN_KRASHANKA, + CYAN_KRASHANKA, + GREEN_KRASHANKA, + GRAY_KRASHANKA, + LIGHT_BLUE_KRASHANKA, + LIGHT_GRAY_KRASHANKA, + LIME_KRASHANKA, + MAGENTA_KRASHANKA, + ORANGE_KRASHANKA, + PINK_KRASHANKA, + PURPLE_KRASHANKA, + RED_KRASHANKA, + WHITE_KRASHANKA, + YELLOW_KRASHANKA + ); + + // Register items public static Item registerItem(String name, Item item) { diff --git a/src/main/java/com/megatrex4/ukrainian_dlight/registry/PatternRegistry.java b/src/main/java/com/megatrex4/ukrainian_dlight/registry/PatternRegistry.java deleted file mode 100644 index d91c429..0000000 --- a/src/main/java/com/megatrex4/ukrainian_dlight/registry/PatternRegistry.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.megatrex4.ukrainian_dlight.registry; - -import net.minecraft.util.Identifier; - -public class PatternRegistry { - - private final Identifier id; - private final String texturePath; - - public PatternRegistry(String patternName) { - this.id = new Identifier("ukrainian_dlight", patternName); - this.texturePath = "assets/ukrainian_delight/textures/item/krashanky/patterns/" + patternName + ".png"; - } - - public Identifier getId() { - return id; - } - - public String getTexturePath() { - return texturePath; - } -} diff --git a/src/main/java/com/megatrex4/ukrainian_dlight/registry/ScreenHandlersRegistry.java b/src/main/java/com/megatrex4/ukrainian_dlight/registry/ScreenHandlersRegistry.java index 49b4af7..2fe441a 100644 --- a/src/main/java/com/megatrex4/ukrainian_dlight/registry/ScreenHandlersRegistry.java +++ b/src/main/java/com/megatrex4/ukrainian_dlight/registry/ScreenHandlersRegistry.java @@ -2,7 +2,6 @@ import com.megatrex4.ukrainian_dlight.UkrainianDelight; import com.megatrex4.ukrainian_dlight.screen.BrewingKegScreenHandler; -import com.megatrex4.ukrainian_dlight.screen.PysankersTableScreenHandler; import net.fabricmc.fabric.api.screenhandler.v1.ExtendedScreenHandlerType; import net.minecraft.inventory.SimpleInventory; import net.minecraft.registry.Registries; @@ -16,12 +15,6 @@ public class ScreenHandlersRegistry { Registry.register(Registries.SCREEN_HANDLER, new Identifier(UkrainianDelight.MOD_ID, "brewing_keg_screen_handler"), new ExtendedScreenHandlerType<>(BrewingKegScreenHandler::new)); - - //register PYSANKERS_TABLE - public static final ScreenHandlerType PYSANKERS_TABLE_SCREEN_HANDLER = - Registry.register(Registries.SCREEN_HANDLER, new Identifier(UkrainianDelight.MOD_ID, "pysankers_table_screen_handler"), - new ExtendedScreenHandlerType<>((syncId, inv, buf) -> new PysankersTableScreenHandler(syncId, inv, null, new SimpleInventory(PysankersTableScreenHandler.INVENTORY_SIZE), ScreenHandlerContext.EMPTY))); - public static void registerModScreenHandlers() { UkrainianDelight.LOGGER.info("Registering Mod Screen Handlers for " + UkrainianDelight.MOD_ID); // If there are more screen handlers, register them here diff --git a/src/main/java/com/megatrex4/ukrainian_dlight/registry/ScreensRegistry.java b/src/main/java/com/megatrex4/ukrainian_dlight/registry/ScreensRegistry.java index dbba606..5600da2 100644 --- a/src/main/java/com/megatrex4/ukrainian_dlight/registry/ScreensRegistry.java +++ b/src/main/java/com/megatrex4/ukrainian_dlight/registry/ScreensRegistry.java @@ -1,12 +1,10 @@ package com.megatrex4.ukrainian_dlight.registry; import com.megatrex4.ukrainian_dlight.screen.BrewingKegScreen; -import com.megatrex4.ukrainian_dlight.screen.PysankersTableScreen; import net.fabricmc.fabric.api.client.screenhandler.v1.ScreenRegistry; public class ScreensRegistry { public static void registerScreens() { ScreenRegistry.register(ScreenHandlersRegistry.BREWING_KEG_SCREEN_HANDLER, BrewingKegScreen::new); - ScreenRegistry.register(ScreenHandlersRegistry.PYSANKERS_TABLE_SCREEN_HANDLER, PysankersTableScreen::new); } } diff --git a/src/main/java/com/megatrex4/ukrainian_dlight/registry/manager/PatternManager.java b/src/main/java/com/megatrex4/ukrainian_dlight/registry/manager/PatternManager.java deleted file mode 100644 index 76a0bf1..0000000 --- a/src/main/java/com/megatrex4/ukrainian_dlight/registry/manager/PatternManager.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.megatrex4.ukrainian_dlight.registry.manager; - -import com.megatrex4.ukrainian_dlight.registry.PatternRegistry; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NbtCompound; -import net.minecraft.nbt.NbtList; - -import java.util.HashMap; -import java.util.Map; - -public class PatternManager { - private static final Map patterns = new HashMap<>(); - - static { - // Define all patterns here - patterns.put("border", new PatternRegistry("border")); - patterns.put("circle", new PatternRegistry("circle")); - patterns.put("cross", new PatternRegistry("cross")); - patterns.put("diagonal_left", new PatternRegistry("diagonal_left")); - patterns.put("diagonal_right", new PatternRegistry("diagonal_right")); - patterns.put("flower", new PatternRegistry("flower")); - patterns.put("globe", new PatternRegistry("globe")); - patterns.put("gradient", new PatternRegistry("gradient")); - patterns.put("gradient_up", new PatternRegistry("gradient_up")); - patterns.put("half_vertical", new PatternRegistry("half_vertical")); - patterns.put("half_vertical_right", new PatternRegistry("half_vertical_right")); - patterns.put("piglin", new PatternRegistry("piglin")); - patterns.put("rhombus", new PatternRegistry("rhombus")); - patterns.put("small_stripes", new PatternRegistry("small_stripes")); - patterns.put("straight_cross", new PatternRegistry("straight_cross")); - patterns.put("stripe_bottom", new PatternRegistry("stripe_bottom")); - patterns.put("stripe_center", new PatternRegistry("stripe_center")); - patterns.put("stripe_downleft", new PatternRegistry("stripe_downleft")); - patterns.put("stripe_downright", new PatternRegistry("stripe_downright")); - patterns.put("stripe_middle", new PatternRegistry("stripe_middle")); - patterns.put("stripe_top", new PatternRegistry("stripe_top")); - patterns.put("triangles_bottom", new PatternRegistry("triangles_bottom")); - patterns.put("triangles_top", new PatternRegistry("triangles_top")); - patterns.put("triangle_bottom", new PatternRegistry("triangle_bottom")); - patterns.put("triangle_top", new PatternRegistry("triangle_top")); - } - - public static PatternRegistry getPatternForItem(ItemStack itemStack) { - if (itemStack.hasNbt()) { - NbtCompound nbt = itemStack.getNbt(); - if (nbt != null && nbt.contains("Patterns", NbtCompound.LIST_TYPE)) { - NbtList patternList = nbt.getList("Patterns", NbtCompound.COMPOUND_TYPE); - if (!patternList.isEmpty()) { - NbtCompound patternData = patternList.getCompound(0); // Assumes the first pattern is the one to use - String patternName = patternData.getString("Pattern"); - return patterns.getOrDefault(patternName, patterns.get("border")); // Default to "border" if not found - } - } - } - return patterns.get("border"); // Default to "border" if no NBT data or pattern not found - } -} diff --git a/src/main/java/com/megatrex4/ukrainian_dlight/screen/PysankersTableScreen.java b/src/main/java/com/megatrex4/ukrainian_dlight/screen/PysankersTableScreen.java deleted file mode 100644 index 8cf609c..0000000 --- a/src/main/java/com/megatrex4/ukrainian_dlight/screen/PysankersTableScreen.java +++ /dev/null @@ -1,74 +0,0 @@ -package com.megatrex4.ukrainian_dlight.screen; - -import com.megatrex4.ukrainian_dlight.registry.PatternRegistry; -import com.megatrex4.ukrainian_dlight.registry.manager.PatternManager; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; -import net.minecraft.client.gui.DrawContext; -import net.minecraft.client.gui.screen.ingame.HandledScreen; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.screen.slot.Slot; -import net.minecraft.text.Text; -import net.minecraft.util.Identifier; - -@Environment(EnvType.CLIENT) -public class PysankersTableScreen extends HandledScreen { - private static final Identifier TEXTURE = new Identifier("ukrainian_delight", "textures/gui/container/pysankers_table.png"); - - public PysankersTableScreen(PysankersTableScreenHandler handler, PlayerInventory inventory, Text title) { - super(handler, inventory, title); - this.backgroundWidth = 176; - this.backgroundHeight = 166; - } - - @Override - protected void init() { - super.init(); - } - - @Override - protected void drawBackground(DrawContext context, float delta, int mouseX, int mouseY) { - // Draw the main GUI texture - context.drawTexture(TEXTURE, this.x, this.y, 0, 0, this.backgroundWidth, this.backgroundHeight); - - // Get the slots from the handler - Slot krashankaSlot = this.handler.getSlot(0); - Slot dyeSlot = this.handler.getSlot(1); - Slot patternSlot = this.handler.getSlot(2); - Slot outputSlot = this.handler.getSlot(3); - - // Draw slot backgrounds - if (!krashankaSlot.hasStack()) { - context.drawTexture(TEXTURE, this.x + krashankaSlot.x, this.y + krashankaSlot.y, this.backgroundWidth, 0, 16, 16); - } - if (!dyeSlot.hasStack()) { - context.drawTexture(TEXTURE, this.x + dyeSlot.x, this.y + dyeSlot.y, this.backgroundWidth + 16, 0, 16, 16); - } - if (!patternSlot.hasStack()) { - context.drawTexture(TEXTURE, this.x + patternSlot.x, this.y + patternSlot.y, this.backgroundWidth + 32, 0, 16, 16); - } - - // Draw the pattern if available - ItemStack patternStack = patternSlot.getStack(); - if (!patternStack.isEmpty()) { - // Get the pattern ID - PatternRegistry patternRegistry = PatternManager.getPatternForItem(patternStack); - if (patternRegistry != null) { - Identifier patternTexture = new Identifier("ukrainian_dlight", "textures/item/krashanky/patterns/" + patternRegistry.getId().getPath() + ".png"); - - // Render the pattern texture - context.drawTexture(patternTexture, this.x + patternSlot.x + 1, this.y + patternSlot.y + 1, 0, 0, 16, 16); - } - } - } - - @Override - public void render(DrawContext context, int mouseX, int mouseY, float delta) { - this.renderBackground(context); - super.render(context, mouseX, mouseY, delta); - this.drawMouseoverTooltip(context, mouseX, mouseY); - } -} - - diff --git a/src/main/java/com/megatrex4/ukrainian_dlight/screen/PysankersTableScreenHandler.java b/src/main/java/com/megatrex4/ukrainian_dlight/screen/PysankersTableScreenHandler.java deleted file mode 100644 index 6f6725d..0000000 --- a/src/main/java/com/megatrex4/ukrainian_dlight/screen/PysankersTableScreenHandler.java +++ /dev/null @@ -1,151 +0,0 @@ -package com.megatrex4.ukrainian_dlight.screen; - -import com.megatrex4.ukrainian_dlight.block.custom.PysankerTableBlock; -import com.megatrex4.ukrainian_dlight.registry.PatternRegistry; -import com.megatrex4.ukrainian_dlight.registry.ScreenHandlersRegistry; -import com.megatrex4.ukrainian_dlight.registry.manager.PatternManager; -import net.fabricmc.fabric.api.util.NbtType; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.inventory.Inventory; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NbtCompound; -import net.minecraft.nbt.NbtList; -import net.minecraft.registry.entry.RegistryEntry; -import net.minecraft.screen.Property; -import net.minecraft.screen.ScreenHandler; -import net.minecraft.screen.ScreenHandlerContext; -import net.minecraft.screen.slot.Slot; -import net.minecraft.screen.slot.SlotActionType; -import net.minecraft.util.Identifier; - -import java.util.List; - -public class PysankersTableScreenHandler extends ScreenHandler { - private final Inventory inventory; - private final ScreenHandlerContext context; - - // Slot indices - public static final int KRASHANKA_SLOT = 0; - public static final int DYE_SLOT = 1; - public static final int PATTERN_SLOT = 2; - public static final int OUTPUT_SLOT = 3; - - // Inventory size - public static final int INVENTORY_SIZE = 4; // 4 slots for krashanka, dye, pattern, and output - - private final Property selectedPattern; - private List> patterns; - private Runnable inventoryChangeListener; - - public PysankersTableScreenHandler(int syncId, PlayerInventory playerInventory, PysankerTableBlock block, Inventory inventory, ScreenHandlerContext context) { - super(ScreenHandlersRegistry.PYSANKERS_TABLE_SCREEN_HANDLER, syncId); - this.inventory = inventory; - checkSize(inventory, INVENTORY_SIZE); - this.selectedPattern = Property.create(); - this.patterns = List.of(); - this.inventoryChangeListener = () -> {}; - - this.context = context; - - // Add slots for the Pysankers Table - this.addSlot(new Slot(inventory, KRASHANKA_SLOT, 13, 26)); // Input slot for krashanka - this.addSlot(new Slot(inventory, DYE_SLOT, 33, 26)); // Dye slot - this.addSlot(new Slot(inventory, PATTERN_SLOT, 23, 45)); // Pattern slot - this.addSlot(new Slot(inventory, OUTPUT_SLOT, 143, 58)); // Output slot - - addPlayerInventory(playerInventory); - addPlayerHotbar(playerInventory); - } - - @Override - public boolean canUse(PlayerEntity player) { - return this.inventory.canPlayerUse(player); - } - - // Example method for applying a pattern to krashanka - public void applyPattern(ItemStack krashanka, ItemStack patternItem) { - Identifier patternId = PatternManager.getPatternForItem(patternItem).getId(); - NbtCompound nbt = krashanka.getOrCreateNbt(); - NbtList patterns; - if (nbt.contains("Patterns", NbtType.LIST)) { - patterns = nbt.getList("Patterns", NbtType.COMPOUND); - } else { - patterns = new NbtList(); - nbt.put("Patterns", patterns); - } - NbtCompound patternData = new NbtCompound(); - patternData.putString("Pattern", patternId.toString()); - patterns.add(patternData); - krashanka.setNbt(nbt); - this.slots.get(OUTPUT_SLOT).setStack(krashanka.copy()); // Update output slot - } - - - @Override - public ItemStack quickMove(PlayerEntity player, int slotId) { - Slot slot = this.slots.get(slotId); - if (slot == null || !slot.hasStack()) { - return ItemStack.EMPTY; - } - - ItemStack stack = slot.getStack(); - ItemStack stackCopy = stack.copy(); - - if (slotId < INVENTORY_SIZE) { - // Move from container to player inventory - if (!this.insertItem(stack, INVENTORY_SIZE, INVENTORY_SIZE + 36, true)) { - return ItemStack.EMPTY; - } - } else { - // Move from player inventory to container - if (!this.insertItem(stack, 0, INVENTORY_SIZE, false)) { - return ItemStack.EMPTY; - } - } - - if (stack.isEmpty()) { - slot.setStack(ItemStack.EMPTY); - } else { - slot.markDirty(); - } - - return stackCopy; - } - - - @Override - public void onSlotClick(int slotId, int button, SlotActionType actionType, PlayerEntity player) { - if (slotId >= 0 && slotId < this.slots.size()) { - Slot slot = this.slots.get(slotId); - if (slot != null) { - if (slotId == PATTERN_SLOT) { - ItemStack patternItem = slot.getStack(); - ItemStack krashankaItem = this.getSlot(KRASHANKA_SLOT).getStack(); - - // Apply the pattern to the krashanka item - applyPattern(krashankaItem, patternItem); - this.slots.get(OUTPUT_SLOT).setStack(krashankaItem.copy()); // Update output slot - } else { - super.onSlotClick(slotId, button, actionType, player); // Call parent method for default handling - } - } - } - } - - private void addPlayerInventory(PlayerInventory playerInventory) { - // Add slots for the player's inventory - for (int i = 0; i < 3; ++i) { - for (int l = 0; l < 9; ++l) { - this.addSlot(new Slot(playerInventory, l + i * 9 + 9, 8 + l * 18, 84 + i * 18)); - } - } - } - - private void addPlayerHotbar(PlayerInventory playerInventory) { - // Add slots for the player's hotbar - for (int i = 0; i < 9; ++i) { - this.addSlot(new Slot(playerInventory, i, 8 + i * 18, 142)); - } - } -}