Add Inverted Golden Hopper
This commit is contained in:
parent
e9e28f5625
commit
5e42cbddce
|
@ -46,7 +46,6 @@ abstract class BaseHopperBlock<T: BaseHopperBlockEntity>(settings: Settings): Bl
|
|||
builder.add(FACING)
|
||||
}
|
||||
|
||||
|
||||
override fun getOutlineShape(state: BlockState, world: BlockView, pos: BlockPos, entityContext: EntityContext): VoxelShape {
|
||||
return when (state.get(FACING)) {
|
||||
Direction.DOWN -> DOWN_SHAPE
|
||||
|
|
|
@ -12,6 +12,7 @@ import net.minecraft.inventory.Inventory
|
|||
import net.minecraft.inventory.SidedInventory
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraft.nbt.CompoundTag
|
||||
import net.minecraft.state.property.DirectionProperty
|
||||
import net.minecraft.util.BooleanBiFunction
|
||||
import net.minecraft.util.DefaultedList
|
||||
import net.minecraft.util.Tickable
|
||||
|
@ -26,6 +27,8 @@ abstract class BaseHopperBlockEntity(type: BlockEntityType<*>): BlockEntity(type
|
|||
|
||||
abstract val inventorySize: Int
|
||||
abstract val maxTransferCooldown: Int
|
||||
abstract val facingProp: DirectionProperty
|
||||
abstract val inputSide: Direction
|
||||
val inventory: DefaultedList<ItemStack> by lazy { DefaultedList.ofSize(inventorySize, ItemStack.EMPTY) }
|
||||
protected var transferCooldown = -1
|
||||
|
||||
|
@ -71,7 +74,7 @@ abstract class BaseHopperBlockEntity(type: BlockEntityType<*>): BlockEntity(type
|
|||
if (!isInvEmpty && insert()) {
|
||||
didWork = true
|
||||
}
|
||||
if (!isFull() && (extractor != null && extractor()) || HopperBlockEntity.extract(this)) {
|
||||
if (!isFull() && (extractor != null && extractor()) || extract()) {
|
||||
didWork = true
|
||||
}
|
||||
|
||||
|
@ -84,7 +87,7 @@ abstract class BaseHopperBlockEntity(type: BlockEntityType<*>): BlockEntity(type
|
|||
fun insert(): Boolean {
|
||||
val outputInv = getOutputInventory() ?: return false
|
||||
|
||||
val insertionSide = cachedState.get(BaseHopperBlock.FACING).opposite
|
||||
val insertionSide = cachedState.get(facingProp).opposite
|
||||
if (isInventoryFull(outputInv, insertionSide)) return false
|
||||
|
||||
for (slot in 0 until invSize) {
|
||||
|
@ -104,15 +107,53 @@ abstract class BaseHopperBlockEntity(type: BlockEntityType<*>): BlockEntity(type
|
|||
return false
|
||||
}
|
||||
|
||||
fun extract(): Boolean {
|
||||
val inputInv = getInputInventory()
|
||||
return if (inputInv != null) {
|
||||
val extractionSide = inputSide.opposite
|
||||
if (!isInventoryEmpty(inputInv, extractionSide)) {
|
||||
inventorySlots(inputInv, extractionSide).any { slot ->
|
||||
extractFromInv(inputInv, slot, extractionSide)
|
||||
}
|
||||
} else {
|
||||
false
|
||||
}
|
||||
} else {
|
||||
HopperBlockEntity.getInputItemEntities(this).any {
|
||||
HopperBlockEntity.extract(this, it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun extractFromInv(inventory: Inventory, slot: Int, extractonSide: Direction): Boolean {
|
||||
val stack = inventory.getInvStack(slot)
|
||||
if (!stack.isEmpty && canExtract(inventory, stack, slot, extractonSide)) {
|
||||
val stackCopy = stack.copy()
|
||||
val remaining = HopperBlockEntity.transfer(inventory, this, inventory.takeInvStack(slot, 1), null)
|
||||
if (remaining.isEmpty) {
|
||||
inventory.markDirty()
|
||||
return true
|
||||
}
|
||||
|
||||
inventory.setInvStack(slot, stackCopy)
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
fun isFull(): Boolean {
|
||||
return inventory.none(ItemStack::isEmpty)
|
||||
}
|
||||
|
||||
fun getOutputInventory(): Inventory? {
|
||||
val facing = cachedState.get(BaseHopperBlock.FACING)
|
||||
val facing = cachedState.get(facingProp)
|
||||
return HopperBlockEntity.getInventoryAt(world!!, pos.offset(facing))
|
||||
}
|
||||
|
||||
fun getInputInventory(): Inventory? {
|
||||
return HopperBlockEntity.getInventoryAt(world!!, pos.offset(inputSide))
|
||||
}
|
||||
|
||||
fun inventorySlots(inv: Inventory, side: Direction): Sequence<Int> {
|
||||
return if (inv is SidedInventory) {
|
||||
inv.getInvAvailableSlots(side).asSequence()
|
||||
|
@ -126,6 +167,19 @@ abstract class BaseHopperBlockEntity(type: BlockEntityType<*>): BlockEntity(type
|
|||
return slots.map(inv::getInvStack).none(ItemStack::isEmpty)
|
||||
}
|
||||
|
||||
fun isInventoryEmpty(inv: Inventory, side: Direction): Boolean {
|
||||
val slots = inventorySlots(inv, side)
|
||||
return slots.map(inv::getInvStack).all(ItemStack::isEmpty)
|
||||
}
|
||||
|
||||
fun canExtract(inv: Inventory, stack: ItemStack, slot: Int, extractionSide: Direction): Boolean {
|
||||
return if (inv is SidedInventory) {
|
||||
inv.canExtractInvStack(slot, stack, extractionSide)
|
||||
} else {
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
// Inventory
|
||||
|
||||
|
||||
|
|
|
@ -4,16 +4,15 @@ 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(
|
||||
abstract class BaseHopperContainer<T: BaseHopperBlockEntity>(
|
||||
syncId: Int,
|
||||
playerInv: PlayerInventory,
|
||||
val hopperInv: Inventory
|
||||
val hopper: T
|
||||
): Container(null, syncId) {
|
||||
|
||||
init {
|
||||
|
@ -40,7 +39,7 @@ abstract class BaseHopperContainer(
|
|||
override fun close(player: PlayerEntity) {
|
||||
super.close(player)
|
||||
|
||||
hopperInv.onInvClose(player)
|
||||
hopper.onInvClose(player)
|
||||
}
|
||||
|
||||
override fun transferSlot(player: PlayerEntity, slotIndex: Int): ItemStack {
|
||||
|
@ -49,11 +48,11 @@ abstract class BaseHopperContainer(
|
|||
if (slot != null && slot.hasStack()) {
|
||||
val slotStack = slot.stack
|
||||
remaining = slotStack.copy()
|
||||
if (slotIndex < hopperInv.invSize) {
|
||||
if (!insertItem(slotStack, hopperInv.invSize, slots.size, true)) {
|
||||
if (slotIndex < hopper.invSize) {
|
||||
if (!insertItem(slotStack, hopper.invSize, slots.size, true)) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
} else if (!insertItem(slotStack, 0, hopperInv.invSize, false)) {
|
||||
} else if (!insertItem(slotStack, 0, hopper.invSize, false)) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ import net.minecraft.util.Identifier
|
|||
/**
|
||||
* @author shadowfacts
|
||||
*/
|
||||
abstract class BaseHopperScreen<T: BaseHopperContainer>(
|
||||
abstract class BaseHopperScreen<T: BaseHopperContainer<*>>(
|
||||
container: T,
|
||||
playerInv: PlayerInventory,
|
||||
title: Text
|
||||
|
@ -21,6 +21,12 @@ abstract class BaseHopperScreen<T: BaseHopperContainer>(
|
|||
containerHeight = 133
|
||||
}
|
||||
|
||||
override fun render(i: Int, j: Int, f: Float) {
|
||||
this.renderBackground()
|
||||
super.render(i, j, f)
|
||||
drawMouseoverTooltip(i, j)
|
||||
}
|
||||
|
||||
override fun drawForeground(mouseX: Int, mouseY: Int) {
|
||||
font.draw(title.asFormattedString(), 8f, 6f, 0x404040)
|
||||
font.draw(playerInventory.displayName.asFormattedString(), 8f, containerHeight - 94f, 0x404040)
|
||||
|
|
|
@ -19,7 +19,7 @@ import net.shadowfacts.extrahoppers.block.base.BaseHopperBlock
|
|||
/**
|
||||
* @author shadowfacts
|
||||
*/
|
||||
class GoldHopperBlock: BaseHopperBlock<GoldHopperBlockEntity>(
|
||||
open class GoldHopperBlock: BaseHopperBlock<GoldHopperBlockEntity>(
|
||||
FabricBlockSettings.of(Material.METAL)
|
||||
.strength(3f, 6f)
|
||||
.sounds(BlockSoundGroup.METAL)
|
||||
|
@ -31,7 +31,7 @@ class GoldHopperBlock: BaseHopperBlock<GoldHopperBlockEntity>(
|
|||
val ID = Identifier("extrahoppers", "gold_hopper")
|
||||
}
|
||||
|
||||
override fun createBlockEntity(world: BlockView) = GoldHopperBlockEntity()
|
||||
override fun createBlockEntity(world: BlockView) = GoldHopperBlockEntity(false)
|
||||
|
||||
override fun onUse(state: BlockState, world: World, pos: BlockPos, player: PlayerEntity, hand: Hand, hitResult: BlockHitResult): ActionResult {
|
||||
if (!world.isClient) {
|
||||
|
|
|
@ -1,14 +1,52 @@
|
|||
package net.shadowfacts.extrahoppers.block.gold
|
||||
|
||||
import net.minecraft.block.Block
|
||||
import net.minecraft.block.entity.Hopper
|
||||
import net.minecraft.nbt.CompoundTag
|
||||
import net.minecraft.util.math.Direction
|
||||
import net.minecraft.util.shape.VoxelShape
|
||||
import net.minecraft.util.shape.VoxelShapes
|
||||
import net.shadowfacts.extrahoppers.block.base.BaseHopperBlock
|
||||
import net.shadowfacts.extrahoppers.block.base.BaseHopperBlockEntity
|
||||
import net.shadowfacts.extrahoppers.init.EHBlockEntities
|
||||
|
||||
/**
|
||||
* @author shadowfacts
|
||||
*/
|
||||
class GoldHopperBlockEntity: BaseHopperBlockEntity(EHBlockEntities.GOLD_HOPPER) {
|
||||
open class GoldHopperBlockEntity(var inverted: Boolean): BaseHopperBlockEntity(
|
||||
if (inverted) EHBlockEntities.INVERTED_GOLD_HOPPER else EHBlockEntities.GOLD_HOPPER
|
||||
) {
|
||||
|
||||
companion object {
|
||||
val INVERTED_INSIDE_SHAPE = Block.createCuboidShape(2.0, 5.0, 2.0, 14.0, 0.0, 14.0)
|
||||
val INVERTED_BELOW_SHAPE = Block.createCuboidShape(0.0, 0.0, 0.0, 16.0, -16.0, 16.0)
|
||||
val INVERTED_INPUT_AREA_SHAPE = VoxelShapes.union(INVERTED_INSIDE_SHAPE, INVERTED_BELOW_SHAPE)
|
||||
}
|
||||
|
||||
override val inventorySize = 5
|
||||
override val maxTransferCooldown = 4
|
||||
override val facingProp = if (inverted) InvertedGoldHopperBlock.INVERTED_FACING else BaseHopperBlock.FACING
|
||||
override val inputSide = if (inverted) Direction.DOWN else Direction.UP
|
||||
|
||||
@Deprecated("only used for deserializing")
|
||||
constructor(): this(false)
|
||||
|
||||
override fun toTag(tag: CompoundTag): CompoundTag {
|
||||
tag.putBoolean("inverted", inverted)
|
||||
return super.toTag(tag)
|
||||
}
|
||||
|
||||
override fun fromTag(tag: CompoundTag) {
|
||||
super.fromTag(tag)
|
||||
inverted = tag.getBoolean("inverted")
|
||||
}
|
||||
|
||||
override fun getInputAreaShape(): VoxelShape {
|
||||
return if (inverted) {
|
||||
INVERTED_INPUT_AREA_SHAPE
|
||||
} else {
|
||||
Hopper.INPUT_AREA_SHAPE
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@ 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
|
||||
|
@ -15,8 +14,8 @@ import net.shadowfacts.extrahoppers.init.EHBlocks
|
|||
class GoldHopperContainer(
|
||||
syncId: Int,
|
||||
playerInv: PlayerInventory,
|
||||
hopperInv: Inventory
|
||||
): BaseHopperContainer(syncId, playerInv, hopperInv) {
|
||||
hopper: GoldHopperBlockEntity
|
||||
): BaseHopperContainer<GoldHopperBlockEntity>(syncId, playerInv, hopper) {
|
||||
|
||||
companion object {
|
||||
val ID = Identifier("extrahoppers", "gold_hopper")
|
||||
|
@ -30,7 +29,7 @@ class GoldHopperContainer(
|
|||
|
||||
override fun addHopperSlots() {
|
||||
for (i in 0 until 5) {
|
||||
addSlot(Slot(hopperInv, i, 44 + i * 18, 20))
|
||||
addSlot(Slot(hopper, i, 44 + i * 18, 20))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ import net.shadowfacts.extrahoppers.block.base.BaseHopperScreen
|
|||
class GoldHopperScreen(
|
||||
container: GoldHopperContainer,
|
||||
playerInv: PlayerInventory
|
||||
): BaseHopperScreen<GoldHopperContainer>(container, playerInv, TranslatableText("block.extrahoppers.gold_hopper")) {
|
||||
): BaseHopperScreen<GoldHopperContainer>(container, playerInv, TranslatableText("block.extrahoppers.${if (container.hopper.inverted) "inverted_" else ""}gold_hopper")) {
|
||||
|
||||
companion object {
|
||||
fun create(container: GoldHopperContainer): GoldHopperScreen {
|
||||
|
|
|
@ -0,0 +1,78 @@
|
|||
package net.shadowfacts.extrahoppers.block.gold
|
||||
|
||||
import net.minecraft.block.Block
|
||||
import net.minecraft.block.BlockState
|
||||
import net.minecraft.entity.EntityContext
|
||||
import net.minecraft.item.ItemPlacementContext
|
||||
import net.minecraft.state.StateManager
|
||||
import net.minecraft.state.property.DirectionProperty
|
||||
import net.minecraft.util.BooleanBiFunction
|
||||
import net.minecraft.util.Identifier
|
||||
import net.minecraft.util.math.BlockPos
|
||||
import net.minecraft.util.math.Direction
|
||||
import net.minecraft.util.shape.VoxelShape
|
||||
import net.minecraft.util.shape.VoxelShapes
|
||||
import net.minecraft.world.BlockView
|
||||
|
||||
/**
|
||||
* @author shadowfacts
|
||||
*/
|
||||
class InvertedGoldHopperBlock: GoldHopperBlock() {
|
||||
|
||||
companion object {
|
||||
val ID = Identifier("extrahoppers", "inverted_gold_hopper")
|
||||
|
||||
val INVERTED_FACING = DirectionProperty.of("inverted_facing") { direction: Direction -> direction != Direction.DOWN }
|
||||
|
||||
val INVERTED_TOP_SHAPE = createCuboidShape(0.0, 6.0, 0.0, 16.0, 0.0, 16.0)
|
||||
val INVERTED_MIDDLE_SHAPE = createCuboidShape(4.0, 12.0, 4.0, 12.0, 6.0, 12.0)
|
||||
val INVERTED_INSIDE_SHAPE = createCuboidShape(2.0, 5.0, 2.0, 14.0, 0.0, 14.0)
|
||||
val INVERTED_OUTSIDE_SHAPE = VoxelShapes.union(INVERTED_MIDDLE_SHAPE, INVERTED_TOP_SHAPE)
|
||||
val INVERTED_DEFAULT_SHAPE = VoxelShapes.combineAndSimplify(INVERTED_OUTSIDE_SHAPE, INVERTED_INSIDE_SHAPE, BooleanBiFunction.ONLY_FIRST)
|
||||
val INVERTED_DOWN_SHAPE = VoxelShapes.union(INVERTED_DEFAULT_SHAPE, createCuboidShape(6.0, 16.0, 6.0, 10.0, 12.0, 10.0))
|
||||
val INVERTED_EAST_SHAPE = VoxelShapes.union(INVERTED_DEFAULT_SHAPE, createCuboidShape(12.0, 12.0, 6.0, 16.0, 8.0, 10.0))
|
||||
val INVERTED_NORTH_SHAPE = VoxelShapes.union(INVERTED_DEFAULT_SHAPE, createCuboidShape(6.0, 12.0, 0.0, 10.0, 8.0, 4.0))
|
||||
val INVERTED_SOUTH_SHAPE = VoxelShapes.union(INVERTED_DEFAULT_SHAPE, createCuboidShape(6.0, 12.0, 12.0, 10.0, 8.0, 16.0))
|
||||
val INVERTED_WEST_SHAPE = VoxelShapes.union(INVERTED_DEFAULT_SHAPE, createCuboidShape(0.0, 12.0, 6.0, 4.0, 8.0, 10.0))
|
||||
val INVERTED_DOWN_RAY_TRACE_SHAPE = INVERTED_INSIDE_SHAPE
|
||||
val INVERTED_EAST_RAY_TRACE_SHAPE = VoxelShapes.union(INVERTED_INSIDE_SHAPE, createCuboidShape(12.0, 8.0, 6.0, 16.0, 6.0, 10.0))
|
||||
val INVERTED_NORTH_RAY_TRACE_SHAPE = VoxelShapes.union(INVERTED_INSIDE_SHAPE, createCuboidShape(6.0, 8.0, 0.0, 10.0, 6.0, 4.0))
|
||||
val INVERTED_SOUTH_RAY_TRACE_SHAPE = VoxelShapes.union(INVERTED_INSIDE_SHAPE, createCuboidShape(6.0, 8.0, 12.0, 10.0, 6.0, 16.0))
|
||||
val INVERTED_WEST_RAY_TRACE_SHAPE = VoxelShapes.union(INVERTED_INSIDE_SHAPE, createCuboidShape(0.0, 8.0, 6.0, 4.0, 6.0, 10.0))
|
||||
}
|
||||
|
||||
override fun appendProperties(builder: StateManager.Builder<Block, BlockState>) {
|
||||
builder.add(INVERTED_FACING)
|
||||
}
|
||||
|
||||
override fun getOutlineShape(state: BlockState, world: BlockView, pos: BlockPos, entityContext: EntityContext): VoxelShape {
|
||||
return when (state.get(INVERTED_FACING)) {
|
||||
Direction.DOWN -> INVERTED_DOWN_SHAPE
|
||||
Direction.NORTH -> INVERTED_NORTH_SHAPE
|
||||
Direction.SOUTH -> INVERTED_SOUTH_SHAPE
|
||||
Direction.WEST -> INVERTED_WEST_SHAPE
|
||||
Direction.EAST -> INVERTED_EAST_SHAPE
|
||||
else -> INVERTED_DEFAULT_SHAPE
|
||||
}
|
||||
}
|
||||
|
||||
override fun getRayTraceShape(state: BlockState, world: BlockView, pos: BlockPos): VoxelShape {
|
||||
return when (state.get(INVERTED_FACING)) {
|
||||
Direction.DOWN -> INVERTED_DOWN_RAY_TRACE_SHAPE
|
||||
Direction.NORTH -> INVERTED_NORTH_RAY_TRACE_SHAPE
|
||||
Direction.SOUTH -> INVERTED_SOUTH_RAY_TRACE_SHAPE
|
||||
Direction.WEST -> INVERTED_WEST_RAY_TRACE_SHAPE
|
||||
Direction.EAST -> INVERTED_EAST_RAY_TRACE_SHAPE
|
||||
else -> INVERTED_INSIDE_SHAPE
|
||||
}
|
||||
}
|
||||
|
||||
override fun getPlacementState(context: ItemPlacementContext): BlockState {
|
||||
val hitFacing = context.side.opposite
|
||||
val facing = if (hitFacing.axis == Direction.Axis.Y) Direction.UP else hitFacing
|
||||
return defaultState.with(INVERTED_FACING, facing)
|
||||
}
|
||||
|
||||
override fun createBlockEntity(world: BlockView) = GoldHopperBlockEntity(true)
|
||||
|
||||
}
|
|
@ -1,6 +1,8 @@
|
|||
package net.shadowfacts.extrahoppers.block.wood
|
||||
|
||||
import net.minecraft.util.Tickable
|
||||
import net.minecraft.util.math.Direction
|
||||
import net.shadowfacts.extrahoppers.block.base.BaseHopperBlock
|
||||
import net.shadowfacts.extrahoppers.block.base.BaseHopperBlockEntity
|
||||
import net.shadowfacts.extrahoppers.init.EHBlockEntities
|
||||
|
||||
|
@ -11,5 +13,7 @@ class WoodHopperBlockEntity: BaseHopperBlockEntity(EHBlockEntities.WOOD_HOPPER),
|
|||
|
||||
override val inventorySize = 1
|
||||
override val maxTransferCooldown = 40
|
||||
override val facingProp = BaseHopperBlock.FACING
|
||||
override val inputSide = Direction.UP
|
||||
|
||||
}
|
||||
|
|
|
@ -12,8 +12,8 @@ import net.shadowfacts.extrahoppers.init.EHBlocks
|
|||
class WoodHopperContainer(
|
||||
syncId: Int,
|
||||
playerInv: PlayerInventory,
|
||||
hopperInv: Inventory
|
||||
): BaseHopperContainer(syncId, playerInv, hopperInv) {
|
||||
hopper: WoodHopperBlockEntity
|
||||
): BaseHopperContainer<WoodHopperBlockEntity>(syncId, playerInv, hopper) {
|
||||
|
||||
companion object {
|
||||
val ID = Identifier("extrahoppers", "wood_hopper")
|
||||
|
@ -26,7 +26,7 @@ class WoodHopperContainer(
|
|||
}
|
||||
|
||||
override fun addHopperSlots() {
|
||||
addSlot(Slot(hopperInv, 0, 80, 20))
|
||||
addSlot(Slot(hopper, 0, 80, 20))
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,17 +7,21 @@ 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.gold.InvertedGoldHopperBlock
|
||||
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)
|
||||
val GOLD_HOPPER = create({ GoldHopperBlockEntity(false) }, EHBlocks.GOLD_HOPPER)
|
||||
val INVERTED_GOLD_HOPPER = create({ GoldHopperBlockEntity(true) }, EHBlocks.INVERTED_GOLD_HOPPER)
|
||||
// val INVERTED_GOLD_HOPPER = create(::InvertedGoldHopperBlockEntity, EHBlocks.INVERTED_GOLD_HOPPER)
|
||||
|
||||
fun init() {
|
||||
register(WoodHopperBlock.ID, WOOD_HOPPER)
|
||||
register(GoldHopperBlock.ID, GOLD_HOPPER)
|
||||
register(InvertedGoldHopperBlock.ID, INVERTED_GOLD_HOPPER)
|
||||
}
|
||||
|
||||
private fun <T: BlockEntity> create(builder: () -> T, block: Block): BlockEntityType<T> {
|
||||
|
|
|
@ -4,16 +4,19 @@ 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.gold.InvertedGoldHopperBlock
|
||||
import net.shadowfacts.extrahoppers.block.wood.WoodHopperBlock
|
||||
|
||||
object EHBlocks {
|
||||
|
||||
val WOOD_HOPPER = WoodHopperBlock()
|
||||
val GOLD_HOPPER = GoldHopperBlock()
|
||||
val INVERTED_GOLD_HOPPER = InvertedGoldHopperBlock()
|
||||
|
||||
fun init() {
|
||||
register(WoodHopperBlock.ID, WOOD_HOPPER)
|
||||
register(GoldHopperBlock.ID, GOLD_HOPPER)
|
||||
register(InvertedGoldHopperBlock.ID, INVERTED_GOLD_HOPPER)
|
||||
}
|
||||
|
||||
private fun register(id: Identifier, block: Block) {
|
||||
|
|
|
@ -5,16 +5,19 @@ 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.gold.InvertedGoldHopperBlock
|
||||
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())
|
||||
val INVERTED_GOLD_HOPPER = BlockItem(EHBlocks.INVERTED_GOLD_HOPPER, Item.Settings())
|
||||
|
||||
fun init() {
|
||||
register(WoodHopperBlock.ID, WOOD_HOPPER)
|
||||
register(GoldHopperBlock.ID, GOLD_HOPPER)
|
||||
register(InvertedGoldHopperBlock.ID, INVERTED_GOLD_HOPPER)
|
||||
}
|
||||
|
||||
private fun register(id: Identifier, item: Item) {
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"variants": {
|
||||
"inverted_facing=up": { "model": "extrahoppers:block/inverted_gold_hopper" },
|
||||
"inverted_facing=north": { "model": "extrahoppers:block/gold_hopper_side", "x": 180, "y": 180 },
|
||||
"inverted_facing=south": { "model": "extrahoppers:block/gold_hopper_side", "x": 180 },
|
||||
"inverted_facing=west": { "model": "extrahoppers:block/gold_hopper_side", "x": 180, "y": 90 },
|
||||
"inverted_facing=east": { "model": "extrahoppers:block/gold_hopper_side", "x": 180, "y": 270 }
|
||||
}
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
"block.extrahoppers.wood_hopper": "Wooden Hopper",
|
||||
"block.extrahoppers.gold_hopper": "Golden Hopper"
|
||||
"block.extrahoppers.gold_hopper": "Golden Hopper",
|
||||
"block.extrahoppers.inverted_gold_hopper": "Inverted Golden Hopper"
|
||||
}
|
||||
|
|
|
@ -0,0 +1,127 @@
|
|||
{
|
||||
"ambientocclusion": false,
|
||||
"textures": {
|
||||
"particle": "block/gold_block",
|
||||
"top": "block/gold_block",
|
||||
"side": "block/gold_block",
|
||||
"inside": "block/gold_block"
|
||||
},
|
||||
"elements": [
|
||||
{
|
||||
"from": [ 0, 5, 0 ],
|
||||
"to": [ 16, 6, 16 ],
|
||||
"faces": {
|
||||
"down": { "texture": "#inside" },
|
||||
"up": { "texture": "#side" },
|
||||
"north": { "texture": "#side" },
|
||||
"south": { "texture": "#side" },
|
||||
"west": { "texture": "#side" },
|
||||
"east": { "texture": "#side" }
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [ 0, 0, 0 ],
|
||||
"to": [ 2, 5, 16 ],
|
||||
"faces": {
|
||||
"down": { "texture": "#top" },
|
||||
"up": { "texture": "#side" },
|
||||
"north": { "texture": "#side" },
|
||||
"south": { "texture": "#side" },
|
||||
"west": { "texture": "#side" },
|
||||
"east": { "texture": "#side" }
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [ 14, 0, 0 ],
|
||||
"to": [ 16, 5, 16 ],
|
||||
"faces": {
|
||||
"down": { "texture": "#top" },
|
||||
"up": { "texture": "#side" },
|
||||
"north": { "texture": "#side" },
|
||||
"south": { "texture": "#side" },
|
||||
"west": { "texture": "#side" },
|
||||
"east": { "texture": "#side" }
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [ 2, 0, 0 ],
|
||||
"to": [ 14, 5, 2 ],
|
||||
"faces": {
|
||||
"down": { "texture": "#top" },
|
||||
"up": { "texture": "#side" },
|
||||
"north": { "texture": "#side" },
|
||||
"south": { "texture": "#side" },
|
||||
"west": { "texture": "#side" },
|
||||
"east": { "texture": "#side" }
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [ 2, 0, 14 ],
|
||||
"to": [ 14, 5, 16 ],
|
||||
"faces": {
|
||||
"down": { "texture": "#top" },
|
||||
"up": { "texture": "#side" },
|
||||
"north": { "texture": "#side" },
|
||||
"south": { "texture": "#side" },
|
||||
"west": { "texture": "#side" },
|
||||
"east": { "texture": "#side" }
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [ 4, 6, 4 ],
|
||||
"to": [ 12, 12, 12 ],
|
||||
"faces": {
|
||||
"down": { "texture": "#side" },
|
||||
"up": { "texture": "#side" },
|
||||
"north": { "texture": "#side" },
|
||||
"south": { "texture": "#side" },
|
||||
"west": { "texture": "#side" },
|
||||
"east": { "texture": "#side" }
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [ 6, 12, 6 ],
|
||||
"to": [ 10, 16, 10 ],
|
||||
"faces": {
|
||||
"down": { "texture": "#side" },
|
||||
"up": { "texture": "#side" },
|
||||
"north": { "texture": "#side" },
|
||||
"south": { "texture": "#side" },
|
||||
"west": { "texture": "#side" },
|
||||
"east": { "texture": "#side" }
|
||||
}
|
||||
}
|
||||
],
|
||||
"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 ]
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"parent": "extrahoppers:block/inverted_gold_hopper"
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"type": "minecraft:crafting_shapeless",
|
||||
"ingredients": [
|
||||
{
|
||||
"item": "extrahoppers:gold_hopper"
|
||||
}
|
||||
],
|
||||
"result": {
|
||||
"item": "extrahoppers:inverted_gold_hopper"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"type": "minecraft:crafting_shapeless",
|
||||
"ingredients": [
|
||||
{
|
||||
"item": "extrahoppers:inverted_gold_hopper"
|
||||
}
|
||||
],
|
||||
"result": {
|
||||
"item": "extrahoppers:gold_hopper"
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue