From f06f07a534a1495f40016e51c7e976526432741e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Ryb=C3=A1rsky?= Date: Tue, 25 Jun 2024 18:35:21 +0200 Subject: [PATCH] Fix 1 --- .../blocks/HardDriveContainerBlock.java | 36 ++++++------------- .../server_storage/blocks/StorageBlock.java | 14 ++++---- .../server_storage/items/SimpleBlockItem.java | 13 ++++--- .../brn/server_storage/items/SimpleItem.java | 6 ++-- 4 files changed, 29 insertions(+), 40 deletions(-) diff --git a/src/main/java/systems/brn/server_storage/blocks/HardDriveContainerBlock.java b/src/main/java/systems/brn/server_storage/blocks/HardDriveContainerBlock.java index c7d74a8..3a28fba 100644 --- a/src/main/java/systems/brn/server_storage/blocks/HardDriveContainerBlock.java +++ b/src/main/java/systems/brn/server_storage/blocks/HardDriveContainerBlock.java @@ -5,61 +5,45 @@ import eu.pb4.polymer.blocks.api.PolymerBlockModel; import eu.pb4.polymer.blocks.api.PolymerBlockResourceUtils; import eu.pb4.polymer.blocks.api.PolymerTexturedBlock; import eu.pb4.polymer.core.api.block.PolymerBlockUtils; +import eu.pb4.polymer.core.api.block.SimplePolymerBlock; import net.fabricmc.fabric.api.event.player.UseBlockCallback; -import net.minecraft.block.Block; -import net.minecraft.block.BlockEntityProvider; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; +import net.minecraft.block.*; import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.entity.BlockEntityType; -import net.minecraft.component.DataComponentTypes; -import net.minecraft.component.type.WrittenBookContentComponent; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; import net.minecraft.registry.Registries; import net.minecraft.registry.Registry; import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.text.RawFilteredPair; -import net.minecraft.text.Text; import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; +import net.minecraft.util.Identifier; import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import org.jetbrains.annotations.Nullable; -import systems.brn.server_storage.ServerStorage; import systems.brn.server_storage.blockentities.HardDriveContainerBlockEntity; -import systems.brn.server_storage.blockentities.StorageBlockEntity; import systems.brn.server_storage.screens.DriveScreen; -import systems.brn.server_storage.screens.StorageScreen; - -import java.util.List; import static systems.brn.server_storage.ServerStorage.*; -import static systems.brn.server_storage.lib.Util.generateBookContent; -public class HardDriveContainerBlock extends Block implements PolymerTexturedBlock, BlockEntityProvider { +public class HardDriveContainerBlock extends SimplePolymerBlock implements PolymerTexturedBlock, BlockEntityProvider { - String modelID; + final Identifier identifier; - BlockModelType blockModelType; - - public HardDriveContainerBlock(Settings settings, BlockModelType type, String modelId) { - super(settings); - this.modelID = modelId; - this.blockModelType = type; + public HardDriveContainerBlock(AbstractBlock.Settings settings, Identifier identifier) { + super(settings, Blocks.NOTE_BLOCK); + this.identifier = identifier; } @Override public BlockState getPolymerBlockState(BlockState state) { - return PolymerBlockResourceUtils.requestBlock(BlockModelType.FULL_BLOCK, PolymerBlockModel.of(id(this.modelID))); + return PolymerBlockResourceUtils.requestBlock(BlockModelType.FULL_BLOCK, PolymerBlockModel.of(identifier)); } public static void register() { var modId = id(HARD_DRIVE_CONTAINER_BLOCK_MODEL_ID); HARD_DRIVE_CONTAINER_BLOCK = Registry.register(Registries.BLOCK, modId, - new HardDriveContainerBlock(Settings.copy(Blocks.WHITE_WOOL), BlockModelType.FULL_BLOCK, ServerStorage.HARD_DRIVE_CONTAINER_BLOCK_MODEL_ID)); + new HardDriveContainerBlock(Settings.copy(Blocks.WHITE_WOOL), modId)); UseBlockCallback.EVENT.register(HardDriveContainerBlock::onUse); HARD_DRIVE_CONTAINER_BLOCK_ENTITY = Registry.register( diff --git a/src/main/java/systems/brn/server_storage/blocks/StorageBlock.java b/src/main/java/systems/brn/server_storage/blocks/StorageBlock.java index 9866d40..7729e5e 100644 --- a/src/main/java/systems/brn/server_storage/blocks/StorageBlock.java +++ b/src/main/java/systems/brn/server_storage/blocks/StorageBlock.java @@ -4,6 +4,7 @@ import eu.pb4.polymer.blocks.api.BlockModelType; import eu.pb4.polymer.blocks.api.PolymerBlockModel; import eu.pb4.polymer.blocks.api.PolymerBlockResourceUtils; import eu.pb4.polymer.blocks.api.PolymerTexturedBlock; +import eu.pb4.polymer.core.api.block.SimplePolymerBlock; import net.fabricmc.fabric.api.event.player.UseBlockCallback; import net.minecraft.block.*; import net.minecraft.block.entity.BlockEntity; @@ -24,7 +25,6 @@ import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import org.jetbrains.annotations.Nullable; -import systems.brn.server_storage.ServerStorage; import systems.brn.server_storage.blockentities.StorageBlockEntity; import systems.brn.server_storage.screens.StorageScreen; @@ -33,21 +33,23 @@ import java.util.List; import static systems.brn.server_storage.ServerStorage.*; import static systems.brn.server_storage.lib.Util.generateBookContent; -public class StorageBlock extends Block implements PolymerTexturedBlock, BlockEntityProvider { +public class StorageBlock extends SimplePolymerBlock implements PolymerTexturedBlock, BlockEntityProvider { + final Identifier identifier; - public StorageBlock(Settings settings, BlockModelType type, String modelId) { - super(settings); + public StorageBlock(Settings settings, Identifier identifier) { + super(settings, Blocks.NOTE_BLOCK); + this.identifier = identifier; } @Override public BlockState getPolymerBlockState(BlockState state) { - return PolymerBlockResourceUtils.requestBlock(BlockModelType.FULL_BLOCK, PolymerBlockModel.of(Identifier.of(MOD_ID, STORAGE_MODEL_ID))); + return PolymerBlockResourceUtils.requestBlock(BlockModelType.FULL_BLOCK, PolymerBlockModel.of(identifier)); } public static void register() { var modId = id(STORAGE_MODEL_ID); STORAGE_BLOCK = Registry.register(Registries.BLOCK, modId, - new StorageBlock(AbstractBlock.Settings.copy(Blocks.WHITE_WOOL), BlockModelType.FULL_BLOCK, ServerStorage.STORAGE_MODEL_ID)); + new StorageBlock(AbstractBlock.Settings.copy(Blocks.WHITE_WOOL), modId)); UseBlockCallback.EVENT.register(StorageBlock::onUse); } diff --git a/src/main/java/systems/brn/server_storage/items/SimpleBlockItem.java b/src/main/java/systems/brn/server_storage/items/SimpleBlockItem.java index c38dc4e..a7ec692 100644 --- a/src/main/java/systems/brn/server_storage/items/SimpleBlockItem.java +++ b/src/main/java/systems/brn/server_storage/items/SimpleBlockItem.java @@ -1,25 +1,28 @@ package systems.brn.server_storage.items; +import eu.pb4.polymer.core.api.item.PolymerBlockItem; import eu.pb4.polymer.core.api.item.PolymerItem; import eu.pb4.polymer.resourcepack.api.PolymerModelData; import eu.pb4.polymer.resourcepack.api.PolymerResourcePackUtils; import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents; import net.minecraft.block.Block; -import net.minecraft.item.*; +import net.minecraft.item.Item; +import net.minecraft.item.ItemGroups; +import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; import net.minecraft.registry.Registries; import net.minecraft.registry.Registry; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.util.Identifier; import org.jetbrains.annotations.Nullable; -import systems.brn.server_storage.ServerStorage; -import static systems.brn.server_storage.ServerStorage.*; +import static systems.brn.server_storage.ServerStorage.id; -public class SimpleBlockItem extends BlockItem implements PolymerItem { +public class SimpleBlockItem extends PolymerBlockItem implements PolymerItem { private final PolymerModelData polymerModel; public SimpleBlockItem(Item.Settings settings, Block block, Identifier identifier) { - super(block, settings); + super(block, settings, Items.BARRIER); this.polymerModel = PolymerResourcePackUtils.requestModel(Items.BARRIER, identifier); } diff --git a/src/main/java/systems/brn/server_storage/items/SimpleItem.java b/src/main/java/systems/brn/server_storage/items/SimpleItem.java index 2b2f110..8e5114d 100644 --- a/src/main/java/systems/brn/server_storage/items/SimpleItem.java +++ b/src/main/java/systems/brn/server_storage/items/SimpleItem.java @@ -1,6 +1,7 @@ package systems.brn.server_storage.items; import eu.pb4.polymer.core.api.item.PolymerItem; +import eu.pb4.polymer.core.api.item.SimplePolymerItem; import eu.pb4.polymer.resourcepack.api.PolymerModelData; import eu.pb4.polymer.resourcepack.api.PolymerResourcePackUtils; import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents; @@ -15,13 +16,12 @@ import net.minecraft.util.Identifier; import org.jetbrains.annotations.Nullable; import static systems.brn.server_storage.ServerStorage.id; -import static systems.brn.server_storage.ServerStorage.tiers; -public class SimpleItem extends Item implements PolymerItem { +public class SimpleItem extends SimplePolymerItem implements PolymerItem { private final PolymerModelData polymerModel; public SimpleItem(Settings settings, Identifier identifier) { - super(settings); + super(settings, Items.BARRIER); this.polymerModel = PolymerResourcePackUtils.requestModel(Items.BARRIER, identifier); }