diff --git a/src/main/kotlin/net/shadowfacts/phycon/block/extractor/ExtractorBlock.kt b/src/main/kotlin/net/shadowfacts/phycon/block/extractor/ExtractorBlock.kt index 1522fec..b9e3868 100644 --- a/src/main/kotlin/net/shadowfacts/phycon/block/extractor/ExtractorBlock.kt +++ b/src/main/kotlin/net/shadowfacts/phycon/block/extractor/ExtractorBlock.kt @@ -3,13 +3,9 @@ package net.shadowfacts.phycon.block.extractor import net.minecraft.block.Block import net.minecraft.block.BlockState import net.minecraft.block.Material -import net.minecraft.block.ShapeContext import net.minecraft.entity.LivingEntity -import net.minecraft.item.ItemPlacementContext import net.minecraft.item.ItemStack import net.minecraft.sound.BlockSoundGroup -import net.minecraft.state.StateManager -import net.minecraft.state.property.Properties import net.minecraft.util.Identifier import net.minecraft.util.math.BlockPos import net.minecraft.util.math.Direction @@ -17,16 +13,13 @@ import net.minecraft.util.shape.VoxelShape import net.minecraft.util.shape.VoxelShapes import net.minecraft.world.BlockView import net.minecraft.world.World -import net.minecraft.world.WorldAccess import net.shadowfacts.phycon.PhysicalConnectivity -import net.shadowfacts.phycon.api.Interface -import net.shadowfacts.phycon.block.DeviceBlock -import java.util.* +import net.shadowfacts.phycon.block.FaceDeviceBlock /** * @author shadowfacts */ -class ExtractorBlock: DeviceBlock( +class ExtractorBlock: FaceDeviceBlock( Settings.of(Material.METAL) .strength(1.5f) .sounds(BlockSoundGroup.METAL) @@ -34,7 +27,6 @@ class ExtractorBlock: DeviceBlock( companion object { val ID = Identifier(PhysicalConnectivity.MODID, "extractor") - val FACING = Properties.FACING private val EXTRACTOR_SHAPES = mutableMapOf() init { @@ -42,7 +34,6 @@ class ExtractorBlock: DeviceBlock( doubleArrayOf(0.0, 0.0, 0.0, 16.0, 2.0, 16.0), doubleArrayOf(2.0, 2.0, 2.0, 14.0, 4.0, 14.0), doubleArrayOf(4.0, 4.0, 4.0, 12.0, 6.0, 12.0), - doubleArrayOf(6.0, 6.0, 6.0, 10.0, 16.0, 10.0) ) val directions = arrayOf( Triple(Direction.DOWN, null, false), @@ -73,34 +64,11 @@ class ExtractorBlock: DeviceBlock( } } - override fun getNetworkConnectedSides(state: BlockState, world: WorldAccess, pos: BlockPos): Collection { - return EnumSet.of(state[FACING].opposite) - } - - override fun getNetworkInterfaceForSide(side: Direction, state: BlockState, world: WorldAccess, pos: BlockPos): Interface? { - return if (side == state[FACING].opposite) { - getBlockEntity(world, pos) - } else { - null - } - } - - override fun appendProperties(builder: StateManager.Builder) { - super.appendProperties(builder) - builder.add(FACING) - } + override val faceThickness = 6.0 + override val faceShapes: Map = EXTRACTOR_SHAPES override fun createBlockEntity(world: BlockView) = ExtractorBlockEntity() - override fun getPlacementState(context: ItemPlacementContext): BlockState { - val facing = if (context.player?.isSneaking == true) context.side.opposite else context.playerLookDirection.opposite - return defaultState.with(FACING, facing) - } - - override fun getOutlineShape(state: BlockState, world: BlockView, pos: BlockPos, context: ShapeContext): VoxelShape { - return EXTRACTOR_SHAPES[state[FACING]]!! - } - override fun onPlaced(world: World, pos: BlockPos, state: BlockState, entity: LivingEntity?, stack: ItemStack) { if (!world.isClient) { getBlockEntity(world, pos)!!.updateInventory() diff --git a/src/main/kotlin/net/shadowfacts/phycon/block/extractor/ExtractorBlockEntity.kt b/src/main/kotlin/net/shadowfacts/phycon/block/extractor/ExtractorBlockEntity.kt index d471a3c..0305717 100644 --- a/src/main/kotlin/net/shadowfacts/phycon/block/extractor/ExtractorBlockEntity.kt +++ b/src/main/kotlin/net/shadowfacts/phycon/block/extractor/ExtractorBlockEntity.kt @@ -5,13 +5,13 @@ import alexiil.mc.lib.attributes.Simulation import alexiil.mc.lib.attributes.item.FixedItemInv import alexiil.mc.lib.attributes.item.ItemAttributes import alexiil.mc.lib.attributes.item.filter.ExactItemStackFilter -import net.minecraft.block.BlockState import net.minecraft.item.ItemStack import net.minecraft.nbt.CompoundTag import net.minecraft.util.math.Direction import net.shadowfacts.phycon.api.packet.Packet import net.shadowfacts.phycon.init.PhyBlockEntities import net.shadowfacts.phycon.block.DeviceBlockEntity +import net.shadowfacts.phycon.block.FaceDeviceBlock import net.shadowfacts.phycon.component.ActivationController import net.shadowfacts.phycon.component.NetworkStackDispatcher import net.shadowfacts.phycon.component.finishTimedOutPendingInsertions @@ -36,7 +36,7 @@ class ExtractorBlockEntity: DeviceBlockEntity(PhyBlockEntities.EXTRACTOR), } private val facing: Direction - get() = cachedState[ExtractorBlock.FACING] + get() = cachedState[FaceDeviceBlock.FACING] private var inventory: FixedItemInv? = null override val pendingInsertions = mutableListOf() diff --git a/src/main/kotlin/net/shadowfacts/phycon/block/inserter/InserterBlock.kt b/src/main/kotlin/net/shadowfacts/phycon/block/inserter/InserterBlock.kt index 3370b37..c3e9ac3 100644 --- a/src/main/kotlin/net/shadowfacts/phycon/block/inserter/InserterBlock.kt +++ b/src/main/kotlin/net/shadowfacts/phycon/block/inserter/InserterBlock.kt @@ -4,19 +4,14 @@ import net.fabricmc.fabric.api.screenhandler.v1.ExtendedScreenHandlerFactory import net.minecraft.block.Block import net.minecraft.block.BlockState import net.minecraft.block.Material -import net.minecraft.block.ShapeContext import net.minecraft.entity.LivingEntity import net.minecraft.entity.player.PlayerEntity import net.minecraft.entity.player.PlayerInventory -import net.minecraft.item.ItemPlacementContext import net.minecraft.item.ItemStack import net.minecraft.network.PacketByteBuf import net.minecraft.screen.ScreenHandler import net.minecraft.server.network.ServerPlayerEntity import net.minecraft.sound.BlockSoundGroup -import net.minecraft.state.StateManager -import net.minecraft.state.property.Properties -import net.minecraft.text.Text import net.minecraft.util.ActionResult import net.minecraft.util.Hand import net.minecraft.util.Identifier @@ -27,24 +22,20 @@ import net.minecraft.util.shape.VoxelShape import net.minecraft.util.shape.VoxelShapes import net.minecraft.world.BlockView import net.minecraft.world.World -import net.minecraft.world.WorldAccess import net.shadowfacts.phycon.PhysicalConnectivity -import net.shadowfacts.phycon.api.Interface -import net.shadowfacts.phycon.block.DeviceBlock -import net.shadowfacts.phycon.block.extractor.ExtractorBlock +import net.shadowfacts.phycon.block.FaceDeviceBlock import java.util.* /** * @author shadowfacts */ -class InserterBlock: DeviceBlock( +class InserterBlock: FaceDeviceBlock( Settings.of(Material.METAL) .strength(1.5f) .sounds(BlockSoundGroup.METAL) ) { companion object { val ID = Identifier(PhysicalConnectivity.MODID, "inserter") - val FACING = Properties.FACING private val INSERTER_SHAPES = mutableMapOf() init { @@ -52,7 +43,6 @@ class InserterBlock: DeviceBlock( doubleArrayOf(4.0, 0.0, 4.0, 12.0, 2.0, 12.0), doubleArrayOf(2.0, 2.0, 2.0, 14.0, 4.0, 14.0), doubleArrayOf(0.0, 4.0, 0.0, 16.0, 6.0, 16.0), - doubleArrayOf(6.0, 6.0, 6.0, 10.0, 16.0, 10.0) ) val directions = arrayOf( Triple(Direction.DOWN, null, false), @@ -83,34 +73,11 @@ class InserterBlock: DeviceBlock( } } - override fun getNetworkConnectedSides(state: BlockState, world: WorldAccess, pos: BlockPos): Collection { - return EnumSet.of(state[FACING].opposite) - } - - override fun getNetworkInterfaceForSide(side: Direction, state: BlockState, world: WorldAccess, pos: BlockPos): Interface? { - return if (side == state[FACING].opposite) { - getBlockEntity(world, pos) - } else { - null - } - } - - override fun appendProperties(builder: StateManager.Builder) { - super.appendProperties(builder) - builder.add(FACING) - } + override val faceThickness = 6.0 + override val faceShapes: Map = INSERTER_SHAPES override fun createBlockEntity(world: BlockView) = InserterBlockEntity() - override fun getPlacementState(context: ItemPlacementContext): BlockState { - val facing = if (context.player?.isSneaking == true) context.side.opposite else context.playerLookDirection.opposite - return defaultState.with(FACING, facing) - } - - override fun getOutlineShape(state: BlockState, world: BlockView, pos: BlockPos, context: ShapeContext): VoxelShape { - return INSERTER_SHAPES[state[FACING]]!! - } - override fun onPlaced(world: World, pos: BlockPos, state: BlockState, entity: LivingEntity?, stack: ItemStack) { if (!world.isClient) { getBlockEntity(world, pos)!!.updateInventory() diff --git a/src/main/kotlin/net/shadowfacts/phycon/block/inserter/InserterBlockEntity.kt b/src/main/kotlin/net/shadowfacts/phycon/block/inserter/InserterBlockEntity.kt index 13e46f5..378742b 100644 --- a/src/main/kotlin/net/shadowfacts/phycon/block/inserter/InserterBlockEntity.kt +++ b/src/main/kotlin/net/shadowfacts/phycon/block/inserter/InserterBlockEntity.kt @@ -10,6 +10,7 @@ import net.minecraft.nbt.CompoundTag import net.minecraft.util.math.Direction import net.shadowfacts.phycon.api.packet.Packet import net.shadowfacts.phycon.block.DeviceBlockEntity +import net.shadowfacts.phycon.block.FaceDeviceBlock import net.shadowfacts.phycon.component.ActivationController import net.shadowfacts.phycon.component.ItemStackPacketHandler import net.shadowfacts.phycon.component.NetworkStackProvider @@ -34,7 +35,7 @@ class InserterBlockEntity: DeviceBlockEntity(PhyBlockEntities.INSERTER), } private val facing: Direction - get() = cachedState[InserterBlock.FACING] + get() = cachedState[FaceDeviceBlock.FACING] private var inventory: ItemInsertable? = null private var currentRequest: PendingExtractRequest? = null diff --git a/src/main/kotlin/net/shadowfacts/phycon/block/miner/MinerBlock.kt b/src/main/kotlin/net/shadowfacts/phycon/block/miner/MinerBlock.kt index 3239286..1df6765 100644 --- a/src/main/kotlin/net/shadowfacts/phycon/block/miner/MinerBlock.kt +++ b/src/main/kotlin/net/shadowfacts/phycon/block/miner/MinerBlock.kt @@ -18,7 +18,6 @@ import net.minecraft.world.WorldAccess import net.shadowfacts.phycon.PhysicalConnectivity import net.shadowfacts.phycon.api.Interface import net.shadowfacts.phycon.block.DeviceBlock -import net.shadowfacts.phycon.block.extractor.ExtractorBlock import java.util.* /** @@ -56,7 +55,7 @@ class MinerBlock: DeviceBlock( override fun getPlacementState(context: ItemPlacementContext): BlockState? { val facing = if (context.player?.isSneaking == true) context.side.opposite else context.playerFacing.opposite - return defaultState.with(ExtractorBlock.FACING, facing) + return defaultState.with(FACING, facing) } override fun onPlaced(world: World, pos: BlockPos, state: BlockState, entity: LivingEntity?, itemStack: ItemStack) { diff --git a/src/main/kotlin/net/shadowfacts/phycon/client/PhyModelProvider.kt b/src/main/kotlin/net/shadowfacts/phycon/client/PhyModelProvider.kt index 2af7267..eb18cb3 100644 --- a/src/main/kotlin/net/shadowfacts/phycon/client/PhyModelProvider.kt +++ b/src/main/kotlin/net/shadowfacts/phycon/client/PhyModelProvider.kt @@ -19,6 +19,10 @@ class PhyModelProvider(resourceManager: ResourceManager) : ModelResourceProvider val REDSTONE_CONTROLLER = Identifier(PhysicalConnectivity.MODID, "block/redstone_controller") val REDSTONE_EMITTER = Identifier(PhysicalConnectivity.MODID, "block/redstone_emitter") val REDSTONE_EMITTER_SIDE = Identifier(PhysicalConnectivity.MODID, "block/redstone_emitter_side") + val EXTRACTOR = Identifier(PhysicalConnectivity.MODID, "block/extractor") + val EXTRACTOR_SIDE = Identifier(PhysicalConnectivity.MODID, "block/extractor_side") + val INSERTER = Identifier(PhysicalConnectivity.MODID, "block/inserter") + val INSERTER_SIDE = Identifier(PhysicalConnectivity.MODID, "block/inserter_side") } override fun loadModelResource(resourceId: Identifier, context: ModelProviderContext): UnbakedModel? { @@ -26,6 +30,8 @@ class PhyModelProvider(resourceManager: ResourceManager) : ModelResourceProvider INTERFACE -> SimpleFaceDeviceModel(INTERFACE_SIDE) REDSTONE_CONTROLLER -> RedstoneControllerModel REDSTONE_EMITTER -> SimpleFaceDeviceModel(REDSTONE_EMITTER_SIDE) + EXTRACTOR -> SimpleFaceDeviceModel(EXTRACTOR_SIDE) + INSERTER -> SimpleFaceDeviceModel(INSERTER_SIDE) else -> null } } diff --git a/src/main/resources/assets/phycon/blockstates/extractor.json b/src/main/resources/assets/phycon/blockstates/extractor.json index 67438c4..2aa4ddd 100644 --- a/src/main/resources/assets/phycon/blockstates/extractor.json +++ b/src/main/resources/assets/phycon/blockstates/extractor.json @@ -1,29 +1,7 @@ { - "variants": { - "facing=down": { - "model": "phycon:block/extractor" - }, - "facing=up": { - "model": "phycon:block/extractor", - "x": 180 - }, - "facing=north": { - "model": "phycon:block/extractor", - "x": 270 - }, - "facing=south": { - "model": "phycon:block/extractor", - "x": 90 - }, - "facing=west": { - "model": "phycon:block/extractor", - "x": 90, - "y": 90 - }, - "facing=east": { - "model": "phycon:block/extractor", - "x": 90, - "y": 270 + "multipart": [ + { + "apply": {"model": "phycon:block/extractor"} } - } -} \ No newline at end of file + ] +} diff --git a/src/main/resources/assets/phycon/blockstates/inserter.json b/src/main/resources/assets/phycon/blockstates/inserter.json index ef844a4..0239044 100644 --- a/src/main/resources/assets/phycon/blockstates/inserter.json +++ b/src/main/resources/assets/phycon/blockstates/inserter.json @@ -1,29 +1,7 @@ { - "variants": { - "facing=down": { - "model": "phycon:block/inserter" - }, - "facing=up": { - "model": "phycon:block/inserter", - "x": 180 - }, - "facing=north": { - "model": "phycon:block/inserter", - "x": 270 - }, - "facing=south": { - "model": "phycon:block/inserter", - "x": 90 - }, - "facing=west": { - "model": "phycon:block/inserter", - "x": 90, - "y": 90 - }, - "facing=east": { - "model": "phycon:block/inserter", - "x": 90, - "y": 270 + "multipart": [ + { + "apply": {"model": "phycon:block/inserter"} } - } + ] } diff --git a/src/main/resources/assets/phycon/models/block/extractor.json b/src/main/resources/assets/phycon/models/block/extractor_side.json similarity index 75% rename from src/main/resources/assets/phycon/models/block/extractor.json rename to src/main/resources/assets/phycon/models/block/extractor_side.json index c0ad572..1b7176a 100644 --- a/src/main/resources/assets/phycon/models/block/extractor.json +++ b/src/main/resources/assets/phycon/models/block/extractor_side.json @@ -1,8 +1,6 @@ { "parent": "block/block", "textures": { - "cable_side": "phycon:block/cable_straight", - "cable_end": "phycon:block/cable_cap_end" }, "elements": [ { @@ -38,17 +36,6 @@ "west": {"texture": "phycon:block/extractor_side"}, "east": {"texture": "phycon:block/extractor_side"} } - }, - { - "from": [6, 6, 6], - "to": [10, 16, 10], - "faces": { - "up": {"texture": "#cable_end", "cullface": "up"}, - "north": {"texture": "#cable_side"}, - "south": {"texture": "#cable_side"}, - "west": {"texture": "#cable_side"}, - "east": {"texture": "#cable_side"} - } } ] } diff --git a/src/main/resources/assets/phycon/models/block/inserter.json b/src/main/resources/assets/phycon/models/block/inserter_side.json similarity index 75% rename from src/main/resources/assets/phycon/models/block/inserter.json rename to src/main/resources/assets/phycon/models/block/inserter_side.json index e11da66..6fb7d4e 100644 --- a/src/main/resources/assets/phycon/models/block/inserter.json +++ b/src/main/resources/assets/phycon/models/block/inserter_side.json @@ -1,8 +1,6 @@ { "parent": "block/block", "textures": { - "cable_side": "phycon:block/cable_straight", - "cable_end": "phycon:block/cable_cap_end" }, "elements": [ { @@ -38,17 +36,6 @@ "west": {"texture": "phycon:block/extractor_side"}, "east": {"texture": "phycon:block/extractor_side"} } - }, - { - "from": [6, 6, 6], - "to": [10, 16, 10], - "faces": { - "up": {"texture": "#cable_end", "cullface": "up"}, - "north": {"texture": "#cable_side"}, - "south": {"texture": "#cable_side"}, - "west": {"texture": "#cable_side"}, - "east": {"texture": "#cable_side"} - } } ] }