From e9e28f562501361d92a7172659e6d15686737eb4 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Sat, 28 Mar 2020 14:26:39 -0400 Subject: [PATCH] Add Golden Hopper --- .../shadowfacts/extrahoppers/ExtraHoppers.kt | 2 + .../extrahoppers/ExtraHoppersClient.kt | 3 + .../block/base/BaseHopperBlockEntity.kt | 6 +- .../block/base/BaseHopperContainer.kt | 70 +++++++++++++++++++ .../block/base/BaseHopperScreen.kt | 37 ++++++++++ .../block/gold/GoldHopperBlock.kt | 46 ++++++++++++ .../block/gold/GoldHopperBlockEntity.kt | 14 ++++ .../block/gold/GoldHopperContainer.kt | 37 ++++++++++ .../block/gold/GoldHopperScreen.kt | 24 +++++++ .../block/wood/WoodHopperContainer.kt | 56 ++------------- .../block/wood/WoodHopperScreen.kt | 29 ++------ .../extrahoppers/init/EHBlockEntities.kt | 6 +- .../shadowfacts/extrahoppers/init/EHBlocks.kt | 5 +- .../shadowfacts/extrahoppers/init/EHItems.kt | 5 +- .../extrahoppers/blockstates/gold_hopper.json | 9 +++ .../assets/extrahoppers/lang/en_us.json | 3 +- .../models/block/gold_hopper.json | 41 +++++++++++ .../models/block/gold_hopper_side.json | 9 +++ .../extrahoppers/models/item/gold_hopper.json | 3 + .../advancements/recipes/gold_hopper.json | 35 ++++++++++ .../loot_tables/blocks/gold_hopper.json | 19 +++++ .../extrahoppers/recipes/gold_hopper.json | 19 +++++ 22 files changed, 400 insertions(+), 78 deletions(-) create mode 100644 src/main/kotlin/net/shadowfacts/extrahoppers/block/base/BaseHopperContainer.kt create mode 100644 src/main/kotlin/net/shadowfacts/extrahoppers/block/base/BaseHopperScreen.kt create mode 100644 src/main/kotlin/net/shadowfacts/extrahoppers/block/gold/GoldHopperBlock.kt create mode 100644 src/main/kotlin/net/shadowfacts/extrahoppers/block/gold/GoldHopperBlockEntity.kt create mode 100644 src/main/kotlin/net/shadowfacts/extrahoppers/block/gold/GoldHopperContainer.kt create mode 100644 src/main/kotlin/net/shadowfacts/extrahoppers/block/gold/GoldHopperScreen.kt create mode 100644 src/main/resources/assets/extrahoppers/blockstates/gold_hopper.json create mode 100644 src/main/resources/assets/extrahoppers/models/block/gold_hopper.json create mode 100644 src/main/resources/assets/extrahoppers/models/block/gold_hopper_side.json create mode 100644 src/main/resources/assets/extrahoppers/models/item/gold_hopper.json create mode 100644 src/main/resources/data/extrahoppers/advancements/recipes/gold_hopper.json create mode 100644 src/main/resources/data/extrahoppers/loot_tables/blocks/gold_hopper.json create mode 100644 src/main/resources/data/extrahoppers/recipes/gold_hopper.json diff --git a/src/main/kotlin/net/shadowfacts/extrahoppers/ExtraHoppers.kt b/src/main/kotlin/net/shadowfacts/extrahoppers/ExtraHoppers.kt index 82ec65a..3378e26 100644 --- a/src/main/kotlin/net/shadowfacts/extrahoppers/ExtraHoppers.kt +++ b/src/main/kotlin/net/shadowfacts/extrahoppers/ExtraHoppers.kt @@ -3,6 +3,7 @@ package net.shadowfacts.extrahoppers import net.fabricmc.api.ModInitializer import net.fabricmc.fabric.api.container.ContainerFactory import net.fabricmc.fabric.api.container.ContainerProviderRegistry +import net.shadowfacts.extrahoppers.block.gold.GoldHopperContainer import net.shadowfacts.extrahoppers.block.wood.WoodHopperContainer import net.shadowfacts.extrahoppers.init.EHBlockEntities import net.shadowfacts.extrahoppers.init.EHBlocks @@ -16,6 +17,7 @@ object ExtraHoppers: ModInitializer { EHItems.init() ContainerProviderRegistry.INSTANCE.registerFactory(WoodHopperContainer.ID, ContainerFactory(WoodHopperContainer.Companion::create)) + ContainerProviderRegistry.INSTANCE.registerFactory(GoldHopperContainer.ID, ContainerFactory(GoldHopperContainer.Companion::create)) } } diff --git a/src/main/kotlin/net/shadowfacts/extrahoppers/ExtraHoppersClient.kt b/src/main/kotlin/net/shadowfacts/extrahoppers/ExtraHoppersClient.kt index 64d2fc6..1002e28 100644 --- a/src/main/kotlin/net/shadowfacts/extrahoppers/ExtraHoppersClient.kt +++ b/src/main/kotlin/net/shadowfacts/extrahoppers/ExtraHoppersClient.kt @@ -3,6 +3,8 @@ package net.shadowfacts.extrahoppers import net.fabricmc.api.ClientModInitializer import net.fabricmc.fabric.api.client.screen.ContainerScreenFactory import net.fabricmc.fabric.api.client.screen.ScreenProviderRegistry +import net.shadowfacts.extrahoppers.block.gold.GoldHopperContainer +import net.shadowfacts.extrahoppers.block.gold.GoldHopperScreen import net.shadowfacts.extrahoppers.block.wood.WoodHopperContainer import net.shadowfacts.extrahoppers.block.wood.WoodHopperScreen @@ -10,6 +12,7 @@ object ExtraHoppersClient: ClientModInitializer { override fun onInitializeClient() { ScreenProviderRegistry.INSTANCE.registerFactory(WoodHopperContainer.ID, ContainerScreenFactory(WoodHopperScreen.Companion::create)) + ScreenProviderRegistry.INSTANCE.registerFactory(GoldHopperContainer.ID, ContainerScreenFactory(GoldHopperScreen.Companion::create)) } } diff --git a/src/main/kotlin/net/shadowfacts/extrahoppers/block/base/BaseHopperBlockEntity.kt b/src/main/kotlin/net/shadowfacts/extrahoppers/block/base/BaseHopperBlockEntity.kt index c3647d8..97b5bb1 100644 --- a/src/main/kotlin/net/shadowfacts/extrahoppers/block/base/BaseHopperBlockEntity.kt +++ b/src/main/kotlin/net/shadowfacts/extrahoppers/block/base/BaseHopperBlockEntity.kt @@ -24,9 +24,9 @@ import net.shadowfacts.extrahoppers.util.toVec3d */ abstract class BaseHopperBlockEntity(type: BlockEntityType<*>): BlockEntity(type), Inventory, Hopper, Tickable { - protected open val inventorySize = 5 - protected open val maxTransferCooldown = 8 - var inventory: DefaultedList = DefaultedList.ofSize(inventorySize, ItemStack.EMPTY) + abstract val inventorySize: Int + abstract val maxTransferCooldown: Int + val inventory: DefaultedList by lazy { DefaultedList.ofSize(inventorySize, ItemStack.EMPTY) } protected var transferCooldown = -1 override fun toTag(tag: CompoundTag): CompoundTag { diff --git a/src/main/kotlin/net/shadowfacts/extrahoppers/block/base/BaseHopperContainer.kt b/src/main/kotlin/net/shadowfacts/extrahoppers/block/base/BaseHopperContainer.kt new file mode 100644 index 0000000..54aa415 --- /dev/null +++ b/src/main/kotlin/net/shadowfacts/extrahoppers/block/base/BaseHopperContainer.kt @@ -0,0 +1,70 @@ +package net.shadowfacts.extrahoppers.block.base + +import net.minecraft.container.Container +import net.minecraft.container.Slot +import net.minecraft.entity.player.PlayerEntity +import net.minecraft.entity.player.PlayerInventory +import net.minecraft.inventory.Inventory +import net.minecraft.item.ItemStack + +/** + * @author shadowfacts + */ +abstract class BaseHopperContainer( + syncId: Int, + playerInv: PlayerInventory, + val hopperInv: Inventory +): Container(null, syncId) { + + init { + addHopperSlots() + + // player inv + for (y in 0 until 3) { + for (x in 0 until 9) { + addSlot(Slot(playerInv, x + y * 9 + 9, 8 + x * 18, 51 + y * 18)) + } + } + // hotbar + for (x in 0 until 9) { + addSlot(Slot(playerInv, x, 8 + x * 18, 109)) + } + } + + abstract fun addHopperSlots() + + override fun canUse(player: PlayerEntity): Boolean { + return true + } + + override fun close(player: PlayerEntity) { + super.close(player) + + hopperInv.onInvClose(player) + } + + override fun transferSlot(player: PlayerEntity, slotIndex: Int): ItemStack { + var remaining = ItemStack.EMPTY + val slot = slots[slotIndex] + if (slot != null && slot.hasStack()) { + val slotStack = slot.stack + remaining = slotStack.copy() + if (slotIndex < hopperInv.invSize) { + if (!insertItem(slotStack, hopperInv.invSize, slots.size, true)) { + return ItemStack.EMPTY; + } + } else if (!insertItem(slotStack, 0, hopperInv.invSize, false)) { + return ItemStack.EMPTY; + } + + if (slotStack.isEmpty) { + slot.stack = ItemStack.EMPTY; + } else { + slot.markDirty() + } + } + + return remaining + } + +} diff --git a/src/main/kotlin/net/shadowfacts/extrahoppers/block/base/BaseHopperScreen.kt b/src/main/kotlin/net/shadowfacts/extrahoppers/block/base/BaseHopperScreen.kt new file mode 100644 index 0000000..7b54d83 --- /dev/null +++ b/src/main/kotlin/net/shadowfacts/extrahoppers/block/base/BaseHopperScreen.kt @@ -0,0 +1,37 @@ +package net.shadowfacts.extrahoppers.block.base + +import com.mojang.blaze3d.platform.GlStateManager +import net.minecraft.client.gui.screen.ingame.ContainerScreen +import net.minecraft.entity.player.PlayerInventory +import net.minecraft.text.Text +import net.minecraft.util.Identifier + +/** + * @author shadowfacts + */ +abstract class BaseHopperScreen( + container: T, + playerInv: PlayerInventory, + title: Text +): ContainerScreen(container, playerInv, title) { + + abstract val background: Identifier + + init { + containerHeight = 133 + } + + override fun drawForeground(mouseX: Int, mouseY: Int) { + font.draw(title.asFormattedString(), 8f, 6f, 0x404040) + font.draw(playerInventory.displayName.asFormattedString(), 8f, containerHeight - 94f, 0x404040) + } + + override fun drawBackground(delta: Float, mouseX: Int, mouseY: Int) { + GlStateManager.color4f(1f, 1f, 1f, 1f) + minecraft!!.textureManager.bindTexture(background) + val x = (width - containerWidth) / 2 + val y = (height - containerHeight) / 2 + blit(x, y, 0, 0, containerWidth, containerHeight) + } + +} diff --git a/src/main/kotlin/net/shadowfacts/extrahoppers/block/gold/GoldHopperBlock.kt b/src/main/kotlin/net/shadowfacts/extrahoppers/block/gold/GoldHopperBlock.kt new file mode 100644 index 0000000..4ef79b6 --- /dev/null +++ b/src/main/kotlin/net/shadowfacts/extrahoppers/block/gold/GoldHopperBlock.kt @@ -0,0 +1,46 @@ +package net.shadowfacts.extrahoppers.block.gold + +import net.fabricmc.fabric.api.block.FabricBlockSettings +import net.fabricmc.fabric.api.container.ContainerProviderRegistry +import net.minecraft.block.BlockState +import net.minecraft.block.Material +import net.minecraft.entity.player.PlayerEntity +import net.minecraft.sound.BlockSoundGroup +import net.minecraft.stat.Stats +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.BlockView +import net.minecraft.world.World +import net.shadowfacts.extrahoppers.block.base.BaseHopperBlock + +/** + * @author shadowfacts + */ +class GoldHopperBlock: BaseHopperBlock( + FabricBlockSettings.of(Material.METAL) + .strength(3f, 6f) + .sounds(BlockSoundGroup.METAL) + .nonOpaque() + .build() +) { + + companion object { + val ID = Identifier("extrahoppers", "gold_hopper") + } + + override fun createBlockEntity(world: BlockView) = GoldHopperBlockEntity() + + override fun onUse(state: BlockState, world: World, pos: BlockPos, player: PlayerEntity, hand: Hand, hitResult: BlockHitResult): ActionResult { + if (!world.isClient) { + player.incrementStat(Stats.INSPECT_HOPPER) + ContainerProviderRegistry.INSTANCE.openContainer(GoldHopperContainer.ID, player) { buf -> + buf.writeBlockPos(pos) + } + } + return ActionResult.SUCCESS + } + +} diff --git a/src/main/kotlin/net/shadowfacts/extrahoppers/block/gold/GoldHopperBlockEntity.kt b/src/main/kotlin/net/shadowfacts/extrahoppers/block/gold/GoldHopperBlockEntity.kt new file mode 100644 index 0000000..5330fed --- /dev/null +++ b/src/main/kotlin/net/shadowfacts/extrahoppers/block/gold/GoldHopperBlockEntity.kt @@ -0,0 +1,14 @@ +package net.shadowfacts.extrahoppers.block.gold + +import net.shadowfacts.extrahoppers.block.base.BaseHopperBlockEntity +import net.shadowfacts.extrahoppers.init.EHBlockEntities + +/** + * @author shadowfacts + */ +class GoldHopperBlockEntity: BaseHopperBlockEntity(EHBlockEntities.GOLD_HOPPER) { + + override val inventorySize = 5 + override val maxTransferCooldown = 4 + +} diff --git a/src/main/kotlin/net/shadowfacts/extrahoppers/block/gold/GoldHopperContainer.kt b/src/main/kotlin/net/shadowfacts/extrahoppers/block/gold/GoldHopperContainer.kt new file mode 100644 index 0000000..3cb415e --- /dev/null +++ b/src/main/kotlin/net/shadowfacts/extrahoppers/block/gold/GoldHopperContainer.kt @@ -0,0 +1,37 @@ +package net.shadowfacts.extrahoppers.block.gold + +import net.minecraft.container.Slot +import net.minecraft.entity.player.PlayerEntity +import net.minecraft.entity.player.PlayerInventory +import net.minecraft.inventory.Inventory +import net.minecraft.util.Identifier +import net.minecraft.util.PacketByteBuf +import net.shadowfacts.extrahoppers.block.base.BaseHopperContainer +import net.shadowfacts.extrahoppers.init.EHBlocks + +/** + * @author shadowfacts + */ +class GoldHopperContainer( + syncId: Int, + playerInv: PlayerInventory, + hopperInv: Inventory +): BaseHopperContainer(syncId, playerInv, hopperInv) { + + companion object { + val ID = Identifier("extrahoppers", "gold_hopper") + + fun create(syncId: Int, identifier: Identifier, player: PlayerEntity, buf: PacketByteBuf): GoldHopperContainer { + val pos = buf.readBlockPos() + val blockEntity = EHBlocks.GOLD_HOPPER.getBlockEntity(player.world, pos)!! + return GoldHopperContainer(syncId, player.inventory, blockEntity) + } + } + + override fun addHopperSlots() { + for (i in 0 until 5) { + addSlot(Slot(hopperInv, i, 44 + i * 18, 20)) + } + } + +} diff --git a/src/main/kotlin/net/shadowfacts/extrahoppers/block/gold/GoldHopperScreen.kt b/src/main/kotlin/net/shadowfacts/extrahoppers/block/gold/GoldHopperScreen.kt new file mode 100644 index 0000000..78c2446 --- /dev/null +++ b/src/main/kotlin/net/shadowfacts/extrahoppers/block/gold/GoldHopperScreen.kt @@ -0,0 +1,24 @@ +package net.shadowfacts.extrahoppers.block.gold + +import net.minecraft.client.MinecraftClient +import net.minecraft.entity.player.PlayerInventory +import net.minecraft.text.TranslatableText +import net.minecraft.util.Identifier +import net.shadowfacts.extrahoppers.block.base.BaseHopperScreen + +/** + * @author shadowfacts + */ +class GoldHopperScreen( + container: GoldHopperContainer, + playerInv: PlayerInventory +): BaseHopperScreen(container, playerInv, TranslatableText("block.extrahoppers.gold_hopper")) { + + companion object { + fun create(container: GoldHopperContainer): GoldHopperScreen { + return GoldHopperScreen(container, MinecraftClient.getInstance().player!!.inventory) + } + } + + override val background = Identifier("minecraft", "textures/gui/container/hopper.png") +} diff --git a/src/main/kotlin/net/shadowfacts/extrahoppers/block/wood/WoodHopperContainer.kt b/src/main/kotlin/net/shadowfacts/extrahoppers/block/wood/WoodHopperContainer.kt index 009284e..333d3d9 100644 --- a/src/main/kotlin/net/shadowfacts/extrahoppers/block/wood/WoodHopperContainer.kt +++ b/src/main/kotlin/net/shadowfacts/extrahoppers/block/wood/WoodHopperContainer.kt @@ -1,16 +1,19 @@ package net.shadowfacts.extrahoppers.block.wood -import net.minecraft.container.Container import net.minecraft.container.Slot 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.util.Identifier import net.minecraft.util.PacketByteBuf +import net.shadowfacts.extrahoppers.block.base.BaseHopperContainer import net.shadowfacts.extrahoppers.init.EHBlocks -class WoodHopperContainer(syncId: Int, playerInv: PlayerInventory, val hopperInv: Inventory): Container(null, syncId) { +class WoodHopperContainer( + syncId: Int, + playerInv: PlayerInventory, + hopperInv: Inventory +): BaseHopperContainer(syncId, playerInv, hopperInv) { companion object { val ID = Identifier("extrahoppers", "wood_hopper") @@ -22,53 +25,8 @@ class WoodHopperContainer(syncId: Int, playerInv: PlayerInventory, val hopperInv } } - init { + override fun addHopperSlots() { addSlot(Slot(hopperInv, 0, 80, 20)) - - // player inv - for (y in 0 until 3) { - for (x in 0 until 9) { - addSlot(Slot(playerInv, x + y * 9 + 9, 8 + x * 18, 51 + y * 18)) - } - } - // hotbar - for (x in 0 until 9) { - addSlot(Slot(playerInv, x, 8 + x * 18, 109)) - } - } - - override fun canUse(player: PlayerEntity): Boolean { - return true - } - - override fun close(player: PlayerEntity) { - super.close(player) - - hopperInv.onInvClose(player) - } - - override fun transferSlot(player: PlayerEntity, slotIndex: Int): ItemStack { - var remaining = ItemStack.EMPTY - val slot = slots[slotIndex] - if (slot != null && slot.hasStack()) { - val slotStack = slot.stack - remaining = slotStack.copy() - if (slotIndex < hopperInv.invSize) { - if (!insertItem(slotStack, hopperInv.invSize, slots.size, true)) { - return ItemStack.EMPTY; - } - } else if (!insertItem(slotStack, 0, hopperInv.invSize, false)) { - return ItemStack.EMPTY; - } - - if (slotStack.isEmpty) { - slot.stack = ItemStack.EMPTY; - } else { - slot.markDirty() - } - } - - return remaining } } diff --git a/src/main/kotlin/net/shadowfacts/extrahoppers/block/wood/WoodHopperScreen.kt b/src/main/kotlin/net/shadowfacts/extrahoppers/block/wood/WoodHopperScreen.kt index f59925d..31f161f 100644 --- a/src/main/kotlin/net/shadowfacts/extrahoppers/block/wood/WoodHopperScreen.kt +++ b/src/main/kotlin/net/shadowfacts/extrahoppers/block/wood/WoodHopperScreen.kt @@ -1,37 +1,22 @@ package net.shadowfacts.extrahoppers.block.wood -import com.mojang.blaze3d.platform.GlStateManager import net.minecraft.client.MinecraftClient -import net.minecraft.client.gui.screen.ingame.ContainerScreen import net.minecraft.entity.player.PlayerInventory -import net.minecraft.text.LiteralText +import net.minecraft.text.TranslatableText import net.minecraft.util.Identifier +import net.shadowfacts.extrahoppers.block.base.BaseHopperScreen -class WoodHopperScreen(container: WoodHopperContainer, playerInv: PlayerInventory): ContainerScreen(container, playerInv, LiteralText("Wooden Hopper")) { +class WoodHopperScreen( + container: WoodHopperContainer, + playerInv: PlayerInventory +): BaseHopperScreen(container, playerInv, TranslatableText("block.extrahoppers.gold_hopper")) { companion object { - val BACKGROUND = Identifier("extrahoppers", "textures/gui/wood_hopper.png") - fun create(container: WoodHopperContainer): WoodHopperScreen { return WoodHopperScreen(container, MinecraftClient.getInstance().player!!.inventory) } } - init { - containerHeight = 133 - } - - override fun drawForeground(mouseX: Int, mouseY: Int) { - font.draw(title.asFormattedString(), 8f, 6f, 0x404040) - font.draw(playerInventory.displayName.asFormattedString(), 8f, containerHeight - 94f, 0x404040) - } - - override fun drawBackground(f: Float, i: Int, j: Int) { - GlStateManager.color4f(1f, 1f, 1f, 1f) - minecraft!!.textureManager.bindTexture(BACKGROUND) - val x = (width - containerWidth) / 2 - val y = (height - containerHeight) / 2 - blit(x, y, 0, 0, containerWidth, containerHeight) - } + override val background = Identifier("extrahoppers", "textures/gui/wood_hopper.png") } diff --git a/src/main/kotlin/net/shadowfacts/extrahoppers/init/EHBlockEntities.kt b/src/main/kotlin/net/shadowfacts/extrahoppers/init/EHBlockEntities.kt index e21cbfa..a0f6a19 100644 --- a/src/main/kotlin/net/shadowfacts/extrahoppers/init/EHBlockEntities.kt +++ b/src/main/kotlin/net/shadowfacts/extrahoppers/init/EHBlockEntities.kt @@ -5,15 +5,19 @@ import net.minecraft.block.entity.BlockEntity import net.minecraft.block.entity.BlockEntityType import net.minecraft.util.Identifier import net.minecraft.util.registry.Registry +import net.shadowfacts.extrahoppers.block.gold.GoldHopperBlock +import net.shadowfacts.extrahoppers.block.gold.GoldHopperBlockEntity import net.shadowfacts.extrahoppers.block.wood.WoodHopperBlock import net.shadowfacts.extrahoppers.block.wood.WoodHopperBlockEntity object EHBlockEntities { val WOOD_HOPPER = create(::WoodHopperBlockEntity, EHBlocks.WOOD_HOPPER) + val GOLD_HOPPER = create(::GoldHopperBlockEntity, EHBlocks.GOLD_HOPPER) fun init() { register(WoodHopperBlock.ID, WOOD_HOPPER) + register(GoldHopperBlock.ID, GOLD_HOPPER) } private fun create(builder: () -> T, block: Block): BlockEntityType { @@ -24,4 +28,4 @@ object EHBlockEntities { Registry.register(Registry.BLOCK_ENTITY_TYPE, id, type) } -} \ No newline at end of file +} diff --git a/src/main/kotlin/net/shadowfacts/extrahoppers/init/EHBlocks.kt b/src/main/kotlin/net/shadowfacts/extrahoppers/init/EHBlocks.kt index 0599315..932df1c 100644 --- a/src/main/kotlin/net/shadowfacts/extrahoppers/init/EHBlocks.kt +++ b/src/main/kotlin/net/shadowfacts/extrahoppers/init/EHBlocks.kt @@ -3,18 +3,21 @@ package net.shadowfacts.extrahoppers.init import net.minecraft.block.Block import net.minecraft.util.Identifier import net.minecraft.util.registry.Registry +import net.shadowfacts.extrahoppers.block.gold.GoldHopperBlock import net.shadowfacts.extrahoppers.block.wood.WoodHopperBlock object EHBlocks { val WOOD_HOPPER = WoodHopperBlock() + val GOLD_HOPPER = GoldHopperBlock() fun init() { register(WoodHopperBlock.ID, WOOD_HOPPER) + register(GoldHopperBlock.ID, GOLD_HOPPER) } private fun register(id: Identifier, block: Block) { Registry.register(Registry.BLOCK, id, block) } -} \ No newline at end of file +} diff --git a/src/main/kotlin/net/shadowfacts/extrahoppers/init/EHItems.kt b/src/main/kotlin/net/shadowfacts/extrahoppers/init/EHItems.kt index 414853a..b3547ff 100644 --- a/src/main/kotlin/net/shadowfacts/extrahoppers/init/EHItems.kt +++ b/src/main/kotlin/net/shadowfacts/extrahoppers/init/EHItems.kt @@ -4,18 +4,21 @@ import net.minecraft.item.BlockItem import net.minecraft.item.Item import net.minecraft.util.Identifier import net.minecraft.util.registry.Registry +import net.shadowfacts.extrahoppers.block.gold.GoldHopperBlock import net.shadowfacts.extrahoppers.block.wood.WoodHopperBlock object EHItems { val WOOD_HOPPER = BlockItem(EHBlocks.WOOD_HOPPER, Item.Settings()) + val GOLD_HOPPER = BlockItem(EHBlocks.GOLD_HOPPER, Item.Settings()) fun init() { register(WoodHopperBlock.ID, WOOD_HOPPER) + register(GoldHopperBlock.ID, GOLD_HOPPER) } private fun register(id: Identifier, item: Item) { Registry.register(Registry.ITEM, id, item) } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/extrahoppers/blockstates/gold_hopper.json b/src/main/resources/assets/extrahoppers/blockstates/gold_hopper.json new file mode 100644 index 0000000..a1aa177 --- /dev/null +++ b/src/main/resources/assets/extrahoppers/blockstates/gold_hopper.json @@ -0,0 +1,9 @@ +{ + "variants": { + "facing=down": { "model": "extrahoppers:block/gold_hopper" }, + "facing=north": { "model": "extrahoppers:block/gold_hopper_side" }, + "facing=south": { "model": "extrahoppers:block/gold_hopper_side", "y": 180 }, + "facing=west": { "model": "extrahoppers:block/gold_hopper_side", "y": 270 }, + "facing=east": { "model": "extrahoppers:block/gold_hopper_side", "y": 90 } + } +} diff --git a/src/main/resources/assets/extrahoppers/lang/en_us.json b/src/main/resources/assets/extrahoppers/lang/en_us.json index 2affa7f..92a2e4f 100644 --- a/src/main/resources/assets/extrahoppers/lang/en_us.json +++ b/src/main/resources/assets/extrahoppers/lang/en_us.json @@ -1,3 +1,4 @@ { - "block.extrahoppers.wood_hopper": "Wooden Hopper" + "block.extrahoppers.wood_hopper": "Wooden Hopper", + "block.extrahoppers.gold_hopper": "Golden Hopper" } diff --git a/src/main/resources/assets/extrahoppers/models/block/gold_hopper.json b/src/main/resources/assets/extrahoppers/models/block/gold_hopper.json new file mode 100644 index 0000000..c4c1109 --- /dev/null +++ b/src/main/resources/assets/extrahoppers/models/block/gold_hopper.json @@ -0,0 +1,41 @@ +{ + "parent": "block/hopper", + "textures": { + "particle": "block/gold_block", + "top": "block/gold_block", + "side": "block/gold_block", + "inside": "block/gold_block" + }, + "display": { + "gui": { + "rotation": [ 30, 225, 0 ], + "translation": [ 0, 0, 0], + "scale":[ 0.625, 0.625, 0.625 ] + }, + "ground": { + "rotation": [ 0, 0, 0 ], + "translation": [ 0, 3, 0], + "scale":[ 0.25, 0.25, 0.25 ] + }, + "fixed": { + "rotation": [ 0, 0, 0 ], + "translation": [ 0, 0, 0], + "scale":[ 0.5, 0.5, 0.5 ] + }, + "thirdperson_righthand": { + "rotation": [ 75, 45, 0 ], + "translation": [ 0, 2.5, 0], + "scale": [ 0.375, 0.375, 0.375 ] + }, + "firstperson_righthand": { + "rotation": [ 0, 45, 0 ], + "translation": [ 0, 0, 0 ], + "scale": [ 0.40, 0.40, 0.40 ] + }, + "firstperson_lefthand": { + "rotation": [ 0, 225, 0 ], + "translation": [ 0, 0, 0 ], + "scale": [ 0.40, 0.40, 0.40 ] + } + } +} diff --git a/src/main/resources/assets/extrahoppers/models/block/gold_hopper_side.json b/src/main/resources/assets/extrahoppers/models/block/gold_hopper_side.json new file mode 100644 index 0000000..fa1f982 --- /dev/null +++ b/src/main/resources/assets/extrahoppers/models/block/gold_hopper_side.json @@ -0,0 +1,9 @@ +{ + "parent": "block/hopper_side", + "textures": { + "particle": "block/gold_block", + "top": "block/gold_block", + "side": "block/gold_block", + "inside": "block/gold_block" + } +} diff --git a/src/main/resources/assets/extrahoppers/models/item/gold_hopper.json b/src/main/resources/assets/extrahoppers/models/item/gold_hopper.json new file mode 100644 index 0000000..58d3a2d --- /dev/null +++ b/src/main/resources/assets/extrahoppers/models/item/gold_hopper.json @@ -0,0 +1,3 @@ +{ + "parent": "extrahoppers:block/gold_hopper" +} diff --git a/src/main/resources/data/extrahoppers/advancements/recipes/gold_hopper.json b/src/main/resources/data/extrahoppers/advancements/recipes/gold_hopper.json new file mode 100644 index 0000000..5dfe7d5 --- /dev/null +++ b/src/main/resources/data/extrahoppers/advancements/recipes/gold_hopper.json @@ -0,0 +1,35 @@ +{ + "parent": "minecraft:recipes/root", + "rewards": { + "recipes": [ + "extrahoppers:gold_hopper" + ] + }, + "criteria": { + "has_hopper_and_gold": { + "trigger": "minecraft:inventory_changed", + "conditions": { + "items": [ + { + "item": "minecraft:hopper" + }, + { + "item": "minecraft:gold_ingot" + } + ] + } + }, + "has_the_recipe": { + "trigger": "minecraft:recipe_unlocked", + "conditions": { + "recipe": "extrahoppers:gold_hopper" + } + } + }, + "requirements": [ + [ + "has_hopper_and_gold", + "has_the_recipe" + ] + ] +} diff --git a/src/main/resources/data/extrahoppers/loot_tables/blocks/gold_hopper.json b/src/main/resources/data/extrahoppers/loot_tables/blocks/gold_hopper.json new file mode 100644 index 0000000..1692911 --- /dev/null +++ b/src/main/resources/data/extrahoppers/loot_tables/blocks/gold_hopper.json @@ -0,0 +1,19 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:item", + "name": "extrahoppers:gold_hopper" + } + ], + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ] + } + ] +} diff --git a/src/main/resources/data/extrahoppers/recipes/gold_hopper.json b/src/main/resources/data/extrahoppers/recipes/gold_hopper.json new file mode 100644 index 0000000..b542787 --- /dev/null +++ b/src/main/resources/data/extrahoppers/recipes/gold_hopper.json @@ -0,0 +1,19 @@ +{ + "type": "minecraft:crafting_shaped", + "pattern": [ + "G G", + "GCG", + " G " + ], + "key": { + "C": { + "item": "minecraft:chest" + }, + "G": { + "item": "minecraft:gold_ingot" + } + }, + "result": { + "item": "extrahoppers:gold_hopper" + } +}