just in case i fuck everything up
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
//? if fabric {
|
||||
package org.neoflock.neocomputers.platforms.fabric;
|
||||
/*package org.neoflock.neocomputers.platforms.fabric;
|
||||
|
||||
import com.terraformersmc.modmenu.api.ConfigScreenFactory;
|
||||
import com.terraformersmc.modmenu.api.ModMenuApi;
|
||||
@@ -10,4 +10,4 @@ public class ModMenuIntegration implements ModMenuApi {
|
||||
return ConfigScreen::createConfigScreen;
|
||||
}
|
||||
}
|
||||
//?}
|
||||
*///?}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//? if fabric {
|
||||
package org.neoflock.neocomputers.platforms.fabric;
|
||||
/*package org.neoflock.neocomputers.platforms.fabric;
|
||||
|
||||
import org.neoflock.neocomputers.ModPlatform;
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
@@ -24,4 +24,4 @@ public class NeoComputersFabric implements ModInitializer {
|
||||
}
|
||||
}
|
||||
}
|
||||
//?}
|
||||
*///?}
|
||||
@@ -21,11 +21,6 @@ public class NeoComputersFabricClient implements ClientModInitializer {
|
||||
@Override
|
||||
public void onInitializeClient() {
|
||||
ModelLoadingPlugin.register(new ModelLoader());
|
||||
BlockEntityRenderers.register(BlockEntities.INSTANCE.getSCREEN_ENTITY().get(), ScreenEntityRenderer::new); // TODO: put this in common
|
||||
BlockEntityRenderers.register(BlockEntities.INSTANCE.getCASE_ENTITY().get(), CaseEntityRenderer::new);
|
||||
BlockEntityRenderers.register(BlockEntities.INSTANCE.getRELAY_ENTITY().get(), RelayEntityRenderer::new);
|
||||
BlockEntityRenderers.register(BlockEntities.INSTANCE.getROBOT_ENTITY().get(), RobotEntityRenderer::new);
|
||||
BlockEntityRenderers.register(BlockEntities.INSTANCE.getRACK_ENTITY().get(), RackEntityRenderer::new);
|
||||
|
||||
ColorProviderRegistry.BLOCK.register((state, world, pos, index) -> {
|
||||
if (index == 0) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//? if neoforge {
|
||||
/*package org.neoflock.neocomputers.platforms.neoforge;
|
||||
package org.neoflock.neocomputers.platforms.neoforge;
|
||||
|
||||
import org.neoflock.neocomputers.ConfigScreen;
|
||||
import org.neoflock.neocomputers.ModPlatform;
|
||||
@@ -8,8 +8,8 @@ import net.neoforged.fml.ModLoadingContext;
|
||||
import net.neoforged.fml.common.Mod;
|
||||
import org.neoflock.neocomputers.NeoComputers;
|
||||
//? if <1.21 {
|
||||
/^import net.neoforged.neoforge.client.ConfigScreenHandler;
|
||||
^///?} else {
|
||||
/*import net.neoforged.neoforge.client.ConfigScreenHandler;
|
||||
*///?} else {
|
||||
import net.neoforged.neoforge.client.gui.IConfigScreenFactory;
|
||||
//?}
|
||||
@Mod("neocomputers")
|
||||
@@ -18,11 +18,11 @@ public class NeoComputersNeoForge {
|
||||
NeoComputers.INSTANCE.entrypoint(new NeoForgePlatform());
|
||||
ModLoadingContext.get().registerExtensionPoint(
|
||||
//? if <1.21 {
|
||||
/^ConfigScreenHandler.ConfigScreenFactory.class,
|
||||
/*ConfigScreenHandler.ConfigScreenFactory.class,
|
||||
() -> new ConfigScreenHandler.ConfigScreenFactory(
|
||||
((client, parent) -> ConfigScreen.createConfigScreen(parent))
|
||||
)
|
||||
^///?} else {
|
||||
*///?} else {
|
||||
IConfigScreenFactory.class,
|
||||
() -> (client, parent) -> ConfigScreen.createConfigScreen(parent)
|
||||
//?}
|
||||
@@ -40,4 +40,4 @@ public class NeoComputersNeoForge {
|
||||
}
|
||||
}
|
||||
}
|
||||
*///?}
|
||||
//?}
|
||||
@@ -13,8 +13,10 @@ import org.neoflock.neocomputers.gui.menu.Menus
|
||||
import dev.architectury.utils.Env
|
||||
import dev.architectury.utils.EnvExecutor
|
||||
import net.minecraft.client.Minecraft
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderers
|
||||
import net.minecraft.server.level.ServerPlayer
|
||||
import org.neoflock.neocomputers.block.DeviceBlockEntity
|
||||
import org.neoflock.neocomputers.entity.render.EntityRenderers
|
||||
import org.neoflock.neocomputers.gui.render.ScreenRenderer
|
||||
import org.neoflock.neocomputers.gui.widget.ComponentRoles
|
||||
import org.neoflock.neocomputers.item.Items
|
||||
@@ -59,6 +61,7 @@ object NeoComputers {
|
||||
Networking.allNodes.remove()
|
||||
Networking.wirelessNodes.remove()
|
||||
Networking.channels.remove()
|
||||
EntityRenderers.registerBlockEntityRenderers()
|
||||
}
|
||||
ClientLifecycleEvent.CLIENT_STARTED.register {
|
||||
FontProvider.load(ResourceLocation.fromNamespaceAndPath(MODID, "font/unscii.hex"))
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package org.neoflock.neocomputers.block
|
||||
|
||||
import net.minecraft.core.BlockPos
|
||||
import net.minecraft.world.level.block.EntityBlock
|
||||
import net.minecraft.world.level.block.entity.BlockEntity
|
||||
import net.minecraft.world.level.block.state.BlockState
|
||||
import org.neoflock.neocomputers.entity.AssemblerEntity
|
||||
|
||||
class AssemblerBlock : BaseBlock(), EntityBlock { // TODO: component stuff
|
||||
override fun newBlockEntity(
|
||||
pos: BlockPos,
|
||||
state: BlockState
|
||||
): BlockEntity? {
|
||||
return AssemblerEntity(pos, state)
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import dev.architectury.registry.registries.DeferredRegister
|
||||
import dev.architectury.registry.registries.Registrar
|
||||
import dev.architectury.registry.registries.RegistrarManager
|
||||
import dev.architectury.registry.registries.RegistrySupplier
|
||||
import net.minecraft.client.renderer.RenderType
|
||||
import net.minecraft.core.registries.Registries
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
import net.minecraft.resources.ResourceKey
|
||||
@@ -37,6 +38,7 @@ object Blocks {
|
||||
val RELAY_BLOCK: RegistrySupplier<Block> = BaseBlock.register("relay") { RelayBlock() }
|
||||
val ROBOT_BLOCK: RegistrySupplier<Block> = BaseBlock.register("robot") { RobotBlock() }
|
||||
val RACK_BLOCK: RegistrySupplier<Block> = BaseBlock.register("rack") { RackBlock() }
|
||||
val ASSEMBLER_BLOCK: RegistrySupplier<Block> = BaseBlock.register("assembler") { AssemblerBlock() }
|
||||
|
||||
fun registerBlockItems() {
|
||||
BLOCKS.forEach(Consumer { sup: RegistrySupplier<Block> ->
|
||||
|
||||
@@ -3,36 +3,23 @@ package org.neoflock.neocomputers.block;
|
||||
import dev.architectury.registry.menu.MenuRegistry
|
||||
import net.minecraft.core.BlockPos
|
||||
import net.minecraft.core.Direction
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
import net.minecraft.server.level.ServerPlayer
|
||||
import net.minecraft.sounds.SoundEvent
|
||||
import net.minecraft.sounds.SoundEvents
|
||||
import net.minecraft.sounds.SoundSource
|
||||
import net.minecraft.util.RandomSource
|
||||
import net.minecraft.world.Containers
|
||||
import net.minecraft.world.InteractionResult
|
||||
import net.minecraft.world.entity.LivingEntity
|
||||
import net.minecraft.world.entity.player.Player
|
||||
import net.minecraft.world.item.ItemStack
|
||||
import net.minecraft.world.item.context.BlockPlaceContext
|
||||
import net.minecraft.world.level.BlockGetter
|
||||
import net.minecraft.world.level.Level
|
||||
import net.minecraft.world.level.block.Block
|
||||
import net.minecraft.world.level.block.EntityBlock
|
||||
import net.minecraft.world.level.block.FurnaceBlock
|
||||
import net.minecraft.world.level.block.SoundType
|
||||
import net.minecraft.world.level.block.state.BlockState
|
||||
import net.minecraft.world.level.block.state.StateDefinition
|
||||
import net.minecraft.world.level.block.state.properties.BooleanProperty
|
||||
import net.minecraft.world.level.block.state.properties.EnumProperty
|
||||
import net.minecraft.world.phys.BlockHitResult
|
||||
import org.neoflock.neocomputers.NeoComputers
|
||||
import org.neoflock.neocomputers.block.CombustionGeneratorBlock.Companion.COMBUSTGEN_ACTIVE
|
||||
import org.neoflock.neocomputers.entity.BlockEntities
|
||||
import org.neoflock.neocomputers.entity.CaseBlockEntity
|
||||
import org.neoflock.neocomputers.entity.MachineEntity
|
||||
import org.neoflock.neocomputers.network.NodeSynchronizer
|
||||
import org.neoflock.neocomputers.sounds.Sounds
|
||||
|
||||
class CaseBlock() : DeviceBlock(Properties.of().sound(SoundType.METAL).lightLevel(CaseBlock::getLuminance).noOcclusion()) { // placeholder stuff
|
||||
companion object {
|
||||
@@ -71,7 +58,7 @@ class CaseBlock() : DeviceBlock(Properties.of().sound(SoundType.METAL).lightLeve
|
||||
}
|
||||
|
||||
override fun onPlace(
|
||||
blockState: BlockState,
|
||||
state: BlockState,
|
||||
level: Level,
|
||||
blockPos: BlockPos,
|
||||
blockState2: BlockState,
|
||||
@@ -81,7 +68,7 @@ class CaseBlock() : DeviceBlock(Properties.of().sound(SoundType.METAL).lightLeve
|
||||
level.updateNeighborsAt(blockPos, this)
|
||||
getMachine(level, blockPos).refetchAllRedstone()
|
||||
}
|
||||
super.onPlace(blockState, level, blockPos, blockState2, bl)
|
||||
super.onPlace(state, level, blockPos, blockState2, bl)
|
||||
}
|
||||
|
||||
override fun getStateForPlacement(context: BlockPlaceContext): BlockState? {
|
||||
|
||||
@@ -16,7 +16,7 @@ class ModelGenerator(output: FabricDataOutput) : FabricModelProvider(output) {
|
||||
}
|
||||
|
||||
override fun generateItemModels(itemModelGenerator: ItemModelGenerators) {
|
||||
itemModelGenerator.generateFlatItem(Items.SERVER0.get(), ModelTemplates.FLAT_ITEM)
|
||||
// itemModelGenerator.generateFlatItem(Items.SERVER0.get(), ModelTemplates.FLAT_ITEM)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package org.neoflock.neocomputers.entity
|
||||
|
||||
import net.minecraft.core.BlockPos
|
||||
import net.minecraft.world.level.block.entity.BlockEntity
|
||||
import net.minecraft.world.level.block.state.BlockState
|
||||
|
||||
class AssemblerEntity(pos: BlockPos, state: BlockState) : BlockEntity(BlockEntities.ASSEMBLER_ENTITY.get(), pos, state) {
|
||||
}
|
||||
@@ -106,6 +106,12 @@ object BlockEntities {
|
||||
)
|
||||
}
|
||||
|
||||
val ASSEMBLER_ENTITY: RegistrySupplier<BlockEntityType<AssemblerEntity>> = BLOCKENTITIES.register("assembler") {
|
||||
BlockEntityType(
|
||||
::AssemblerEntity, setOf(Blocks.ASSEMBLER_BLOCK.get()), BullshitFix()
|
||||
)
|
||||
}
|
||||
|
||||
fun registerPowerBlocks() {
|
||||
PowerManager.registerPowerDevice(CAPACITOR_ENTITY.get())
|
||||
PowerManager.registerPowerDevice(CAPACITOR2_ENTITY.get())
|
||||
|
||||
@@ -2,13 +2,17 @@ package org.neoflock.neocomputers.entity
|
||||
|
||||
import net.minecraft.client.model.geom.ModelPart
|
||||
import net.minecraft.core.BlockPos
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.world.Nameable
|
||||
import net.minecraft.world.level.block.entity.BlockEntity
|
||||
import net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity
|
||||
import net.minecraft.world.level.block.state.BlockState
|
||||
import org.neoflock.neocomputers.NeoComputers
|
||||
|
||||
class RobotEntity(pos: BlockPos, state: BlockState) : BlockEntity(BlockEntities.ROBOT_ENTITY.get(), pos, state,) {
|
||||
class RobotEntity(pos: BlockPos, state: BlockState) : BlockEntity(BlockEntities.ROBOT_ENTITY.get(), pos, state,), Nameable {
|
||||
val body: ModelPart? = null
|
||||
val name = "Diddyx" //TODO: names
|
||||
override fun getName(): Component? = Component.literal(name)
|
||||
|
||||
init {
|
||||
NeoComputers.LOGGER.info("yooo")
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package org.neoflock.neocomputers.entity.render
|
||||
|
||||
import com.mojang.blaze3d.vertex.DefaultVertexFormat
|
||||
import com.mojang.blaze3d.vertex.PoseStack
|
||||
import com.mojang.blaze3d.vertex.VertexFormat
|
||||
import com.mojang.math.Axis
|
||||
import net.minecraft.client.renderer.MultiBufferSource
|
||||
import net.minecraft.client.renderer.RenderStateShard
|
||||
import net.minecraft.client.renderer.RenderType
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
import org.neoflock.neocomputers.NeoComputers
|
||||
import org.neoflock.neocomputers.entity.AssemblerEntity
|
||||
|
||||
class AssemblerEntityRenderer(val context: BlockEntityRendererProvider.Context) : BlockEntityRenderer<AssemblerEntity> {
|
||||
val RENDER_TYPE = {l: ResourceLocation ->
|
||||
RenderType.create("nc_assembler", DefaultVertexFormat.POSITION_TEX, VertexFormat.Mode.QUADS, RenderType.TRANSIENT_BUFFER_SIZE, RenderType.CompositeState.builder()
|
||||
.setTextureState(RenderStateShard.TextureStateShard(l, false, false))
|
||||
.setShaderState(RenderStateShard.ShaderStateShard.POSITION_TEX_SHADER)
|
||||
.createCompositeState(false))
|
||||
}
|
||||
|
||||
override fun render(blockEntity: AssemblerEntity, partialTick: Float, poseStack: PoseStack, bufferSource: MultiBufferSource, packedLight: Int, packedOverlay: Int) {
|
||||
var buffer = bufferSource.getBuffer(RENDER_TYPE(ResourceLocation.fromNamespaceAndPath(NeoComputers.MODID, "textures/block/assembler_top_on.png")))
|
||||
val pose = poseStack.last()
|
||||
buffer.addVertex(pose, 0f, 17/16f, 1f).setUv(1f, 0f)
|
||||
buffer.addVertex(pose, 1f, 17/16f, 1f).setUv(1f, 1f)
|
||||
buffer.addVertex(pose, 1f, 17/16f, 0f).setUv(0f, 1f)
|
||||
buffer.addVertex(pose, 0f, 17/16f, 0f).setUv(0f, 0f)
|
||||
|
||||
// TODO: do assembling texture
|
||||
buffer = bufferSource.getBuffer(RENDER_TYPE(ResourceLocation.fromNamespaceAndPath(NeoComputers.MODID, "textures/block/assembler_side_on.png")))
|
||||
poseStack.pushPose()
|
||||
for (i in 0..3) {
|
||||
val pose = poseStack.last()
|
||||
buffer.addVertex(pose, 1.001f, 1f, 0f).setUv(0f, 0f)
|
||||
buffer.addVertex(pose, 1.001f, 1f, 1f).setUv(1f, 0f)
|
||||
buffer.addVertex(pose, 1.001f, 0f, 1f).setUv(1f, 1f)
|
||||
buffer.addVertex(pose, 1.001f, 0f, 0f).setUv(0f, 1f)
|
||||
poseStack.rotateAround(Axis.YP.rotationDegrees(90f), 0.5f, 0.5f, 0.5f)
|
||||
}
|
||||
poseStack.popPose()
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package org.neoflock.neocomputers.entity.render
|
||||
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderers
|
||||
import org.neoflock.neocomputers.entity.BlockEntities
|
||||
|
||||
object EntityRenderers {
|
||||
fun registerBlockEntityRenderers() {
|
||||
BlockEntityRenderers.register(BlockEntities.SCREEN_ENTITY.get(), ::ScreenEntityRenderer); // TODO: put this in common
|
||||
BlockEntityRenderers.register(BlockEntities.CASE_ENTITY.get(), ::CaseEntityRenderer);
|
||||
BlockEntityRenderers.register(BlockEntities.RELAY_ENTITY.get(), ::RelayEntityRenderer);
|
||||
BlockEntityRenderers.register(BlockEntities.ROBOT_ENTITY.get(), ::RobotEntityRenderer);
|
||||
BlockEntityRenderers.register(BlockEntities.RACK_ENTITY.get(), ::RackEntityRenderer);
|
||||
BlockEntityRenderers.register(BlockEntities.ASSEMBLER_ENTITY.get(), ::AssemblerEntityRenderer)
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,8 @@ import net.minecraft.client.renderer.block.ModelBlockRenderer
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider
|
||||
import net.minecraft.client.renderer.blockentity.ChestRenderer
|
||||
import net.minecraft.client.renderer.entity.EntityRenderer
|
||||
import net.minecraft.client.renderer.entity.LivingEntityRenderer
|
||||
import net.minecraft.client.renderer.texture.OverlayTexture
|
||||
import net.minecraft.client.renderer.texture.TextureAtlas
|
||||
@@ -33,6 +35,7 @@ import net.minecraft.network.chat.Component
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
import net.minecraft.util.RandomSource
|
||||
import net.minecraft.world.item.DyeColor
|
||||
import net.minecraft.world.level.block.entity.ChestBlockEntity
|
||||
import net.minecraft.world.phys.Vec3
|
||||
import org.neoflock.neocomputers.NeoComputers
|
||||
import org.neoflock.neocomputers.block.model.RobotModel
|
||||
@@ -51,6 +54,7 @@ class RobotEntityRenderer(val context: BlockEntityRendererProvider.Context) : Bl
|
||||
CompositeState.builder()
|
||||
.setShaderState(RenderStateShard.ShaderStateShard { GameRenderer.getPositionTexColorShader() })
|
||||
.setTransparencyState(RenderStateShard.ADDITIVE_TRANSPARENCY)
|
||||
.setCullState(RenderStateShard.CullStateShard.NO_CULL)
|
||||
.setTextureState(RenderStateShard.TextureStateShard(ResourceLocation.fromNamespaceAndPath(NeoComputers.MODID, "textures/block/robot.png"), false, false))
|
||||
.createCompositeState(false))
|
||||
|
||||
@@ -70,9 +74,10 @@ class RobotEntityRenderer(val context: BlockEntityRendererProvider.Context) : Bl
|
||||
|
||||
|
||||
// TODO: crafting table and chest little models
|
||||
// EntityRenderer
|
||||
|
||||
poseStack.popPose()
|
||||
renderTag(ent, Component.literal(ent.name), poseStack, bufferSource, packedLight, partialTick)
|
||||
poseStack.popPose()
|
||||
}
|
||||
|
||||
// offset is 0-15
|
||||
@@ -106,16 +111,18 @@ class RobotEntityRenderer(val context: BlockEntityRendererProvider.Context) : Bl
|
||||
|
||||
stack.pushPose()
|
||||
stack.translate(vec.x, vec.y, vec.z)
|
||||
// stack.mulPose(context.entityRenderer.cameraOrientation())
|
||||
stack.mulPose(context.entityRenderer.cameraOrientation())
|
||||
stack.scale(0.025F, -0.025F, 0.025F)
|
||||
val opacity = Minecraft.getInstance().options.getBackgroundOpacity(0.25F)
|
||||
val alpha: Int = (opacity * 255.0f).toInt() shl 24
|
||||
// val alpha = 255
|
||||
val halfwidth = (-context.font.width(name)) / 2;
|
||||
RenderSystem.disableDepthTest()
|
||||
context.font.drawInBatch(name, halfwidth.toFloat(), 2f, 0xFFFFFF, false, stack.last().pose(), source, Font.DisplayMode.SEE_THROUGH, alpha, light)
|
||||
// RenderSystem.enableDepthTest()
|
||||
// RenderSystem.enableBlend()
|
||||
// RenderSystem.depthMask(true)
|
||||
|
||||
RenderSystem.enableDepthTest()
|
||||
context.font.drawInBatch(name, halfwidth.toFloat(), 2f, 0xFFFFFF, false, stack.last().pose(), source, Font.DisplayMode.SEE_THROUGH, alpha, light)
|
||||
(source as MultiBufferSource.BufferSource).endBatch()
|
||||
stack.popPose()
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package org.neoflock.neocomputers.gui.menu
|
||||
|
||||
import net.fabricmc.fabric.mixin.item.client.HeldItemRendererMixin
|
||||
import net.minecraft.client.gui.MapRenderer
|
||||
import net.minecraft.client.renderer.entity.ItemRenderer
|
||||
import net.minecraft.world.Container
|
||||
import net.minecraft.world.SimpleContainer
|
||||
import net.minecraft.world.entity.player.Inventory
|
||||
import net.minecraft.world.item.ItemStack
|
||||
import org.neoflock.neocomputers.block.Blocks
|
||||
import org.neoflock.neocomputers.gui.widget.DynamicSlot
|
||||
import org.neoflock.neocomputers.utils.GenericContainer
|
||||
import org.neoflock.neocomputers.utils.GenericContainerMenu
|
||||
|
||||
class CaseSlot(container: Container, index: Int, x: Int, y: Int) : DynamicSlot(container, index, x, y) {
|
||||
val caseItems = listOf(Blocks.CASE_BLOCK.get().asItem())
|
||||
|
||||
override fun mayPlace(stack: ItemStack): Boolean = stack.item in caseItems
|
||||
}
|
||||
|
||||
class AssemblerMenu : GenericContainerMenu {
|
||||
|
||||
constructor(id: Int, inv: Inventory) : this(id, inv, SimpleContainer(1))
|
||||
constructor(id: Int, inv: Inventory, container: Container) : super(Menus.ASSEMBLER_MENU.get(), id, container) {
|
||||
this.addSlot(CaseSlot(container, 0, 12, 12))
|
||||
|
||||
this.addInventoryHotbar(inv, 8, 84)
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ import net.minecraft.world.flag.FeatureFlags
|
||||
import net.minecraft.world.inventory.MenuType
|
||||
import org.neoflock.neocomputers.NeoComputers
|
||||
import org.neoflock.neocomputers.gui.menu.ScreenMenu
|
||||
import org.neoflock.neocomputers.gui.screen.AssemblerScreen
|
||||
import org.neoflock.neocomputers.gui.screen.CaseScreen
|
||||
import org.neoflock.neocomputers.gui.screen.CombustionGeneratorScreen
|
||||
import org.neoflock.neocomputers.gui.screen.RackScreen
|
||||
@@ -24,6 +25,7 @@ object Menus {
|
||||
val CASE_MENU: RegistrySupplier<MenuType<CaseMenu>> = MENUS.register("case_menu") { MenuType(::CaseMenu, FeatureFlagSet.of() )}
|
||||
val RELAY_MENU: RegistrySupplier<MenuType<RelayMenu>> = MENUS.register("relay_menu") { MenuType(::RelayMenu, FeatureFlagSet.of() )}
|
||||
val RACK_MENU: RegistrySupplier<MenuType<RackMenu>> = MENUS.register("rack_menu") { MenuRegistry.ofExtended(::RackMenu) }
|
||||
val ASSEMBLER_MENU: RegistrySupplier<MenuType<AssemblerMenu>> = MENUS.register("assembler_menu") { MenuType(::AssemblerMenu, FeatureFlagSet.of() )}
|
||||
// val RACK_MENU: RegistrySupplier<MenuType<RackMenu>> = MENUS.register("rack_menu") { MenuType(::RackMenu, FeatureFlagSet.of() )}
|
||||
|
||||
fun registerScreens() {
|
||||
@@ -32,5 +34,6 @@ object Menus {
|
||||
MenuScreens.register(Menus.CASE_MENU.get(), ::CaseScreen)
|
||||
MenuScreens.register(Menus.RELAY_MENU.get(), ::RelayScreen)
|
||||
MenuScreens.register(Menus.RACK_MENU.get(), ::RackScreen)
|
||||
MenuScreens.register(Menus.ASSEMBLER_MENU.get(), ::AssemblerScreen)
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,7 @@ import org.neoflock.neocomputers.utils.GenericContainerMenu
|
||||
|
||||
class RackSlot(container: Container, slot: Int, x: Int, y: Int) : DynamicSlot(container, slot, x, y), GuiEventListener {
|
||||
// i hate that i made this, my regret is immeasurable
|
||||
// i genuinely cant help myself
|
||||
val MAIN_COLOURS = listOf(0xff8382d8.toInt(), 0xff75bdc1.toInt(), 0xffc8ca5f.toInt(), 0xffdb7d75.toInt(), 0xff7ec95f.toInt())
|
||||
val DARK_COLOURS = listOf(0xff6a6ab0.toInt(), 0xff60999d.toInt(), 0xffa2a44e.toInt(), 0xffb36660.toInt(), 0xff67a34e.toInt())
|
||||
val LIGHT_COLOURS = listOf(0xffdcdcf0.toInt(), 0xffdcdcf0.toInt(), 0xffececd4.toInt(), 0xfff0dbd9.toInt(), 0xffdbecd4.toInt())
|
||||
|
||||
@@ -13,7 +13,7 @@ import java.io.File
|
||||
import kotlin.experimental.and
|
||||
import kotlin.experimental.xor
|
||||
|
||||
class BufferRenderer(private var id: ResourceLocation, private var buffer: TextBuffer) { // TODO: NN buffer
|
||||
class BufferRenderer(private var id: ResourceLocation, var buffer: TextBuffer) { // TODO: NN buffer
|
||||
val CHARW = 8
|
||||
val CHARH = 16
|
||||
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package org.neoflock.neocomputers.gui.screen
|
||||
|
||||
import io.netty.buffer.Unpooled
|
||||
import net.minecraft.client.gui.GuiGraphics
|
||||
import net.minecraft.network.FriendlyByteBuf
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
import net.minecraft.world.entity.player.Inventory
|
||||
import org.neoflock.neocomputers.NeoComputers
|
||||
import org.neoflock.neocomputers.gui.menu.AssemblerMenu
|
||||
import org.neoflock.neocomputers.gui.menu.CaseMenu
|
||||
import org.neoflock.neocomputers.gui.widget.ButtonSprites
|
||||
import org.neoflock.neocomputers.gui.widget.ImagerButton
|
||||
import org.neoflock.neocomputers.network.NodeSynchronizer
|
||||
import org.neoflock.neocomputers.utils.GenericContainerScreen
|
||||
|
||||
class AssemblerScreen : GenericContainerScreen<AssemblerMenu> {
|
||||
private var btn: ImagerButton? = null
|
||||
private val PCB: ResourceLocation = ResourceLocation.fromNamespaceAndPath(NeoComputers.MODID, "textures/gui/computer.png")
|
||||
private val BTN: ResourceLocation = ResourceLocation.fromNamespaceAndPath(NeoComputers.MODID, "textures/gui/button_power.png")
|
||||
|
||||
constructor(abstractContainerMenu: AssemblerMenu, inventory: Inventory, component: Component) : super(abstractContainerMenu, inventory, component) {
|
||||
btn = ImagerButton(
|
||||
8, 104,
|
||||
18, 18,
|
||||
ButtonSprites(BTN, 18, 18, 36, 36)
|
||||
) {
|
||||
// val buf = FriendlyByteBuf(Unpooled.buffer())
|
||||
// buf.writeByte(if(isOn) 0x02 else 0x01)
|
||||
// NodeSynchronizer.sendScreenInteraction(buf)
|
||||
}
|
||||
|
||||
addWidget(btn!!)
|
||||
}
|
||||
|
||||
override fun renderbg(guiGraphics: GuiGraphics, f: Float, i: Int, j: Int) {
|
||||
guiGraphics.blit(PCB, 0, 0, 0, 0, this.imageWidth, this.imageHeight) // WE'RE FREE
|
||||
}
|
||||
}
|
||||
@@ -83,13 +83,10 @@ data class ComponentSlotRequirement(val tier: Int, val role: String) {
|
||||
|
||||
// Tier 0 allows ALL tiers, making it completely untiered.
|
||||
// Role determines what the role is.
|
||||
class ComponentSlot(container: Container, slot: Int, x: Int, y: Int, val machine: ComponentUser?, val requirement: ComponentSlotRequirement): DynamicSlot(container, slot, x, y) {
|
||||
class ComponentSlot(container: Container, slot: Int, x: Int, y: Int, val machine: ComponentUser?, var requirement: ComponentSlotRequirement): DynamicSlot(container, slot, x, y) {
|
||||
override fun draw(graphics: GuiGraphics, mouseX: Int, mouseY: Int) {
|
||||
super.draw(graphics, mouseX, mouseY)
|
||||
if(!hasItem()) {
|
||||
// RenderSystem.enableBlend()
|
||||
// RenderSystem.setShaderTexture(0, ComponentRoles.getTextureFor(requirement.role))
|
||||
// RenderSystem.setShader { GameRenderer.getPositionTexShader() }
|
||||
drawQuad(graphics, ComponentRoles.getTextureFor(requirement.role), x - 1, y - 1, 18, 18, 0F, 0F, 15F, 15F)
|
||||
if (requirement.tier > 0) {
|
||||
RenderSystem.setShaderTexture(
|
||||
|
||||
@@ -17,7 +17,7 @@ import net.minecraft.world.Container
|
||||
import net.minecraft.world.inventory.Slot
|
||||
import org.neoflock.neocomputers.NeoComputers
|
||||
|
||||
open class DynamicSlot(container: Container, slot: Int, x: Int, y: Int) : Slot(container, slot, x, y) {
|
||||
open class DynamicSlot(container: Container, slot: Int, x: Int, y: Int, var active: Boolean = true) : Slot(container, slot, x, y) {
|
||||
|
||||
val BACKGROUND: ResourceLocation = ResourceLocation.fromNamespaceAndPath(NeoComputers.MODID, "textures/gui/slots/slot.png")
|
||||
val RENDER_TYPE = { r: ResourceLocation ->
|
||||
@@ -42,4 +42,6 @@ open class DynamicSlot(container: Container, slot: Int, x: Int, y: Int) : Slot(c
|
||||
builder.addVertex(pose, x.toFloat(), y.toFloat(), 1f).setUv(u1/15F,v1/15F)
|
||||
}
|
||||
|
||||
override fun isActive() = active
|
||||
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package org.neoflock.neocomputers.item
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack
|
||||
import net.minecraft.client.renderer.MultiBufferSource
|
||||
import net.minecraft.client.renderer.entity.ItemRenderer
|
||||
import net.minecraft.client.renderer.item.ItemProperties
|
||||
import net.minecraft.world.item.Item
|
||||
import net.minecraft.world.item.ItemStack
|
||||
|
||||
@@ -23,39 +23,9 @@ object Tabs {
|
||||
ItemStack(Items.MEM0.get())
|
||||
}
|
||||
builder.displayItems { parameters, output ->
|
||||
// TODO: get rid of arch$tab and this shi and replace with loop over items registry
|
||||
output.accept(ItemStack(Items.CPU0.get()))
|
||||
output.accept(ItemStack(Items.CPU1.get()))
|
||||
output.accept(ItemStack(Items.CPU2.get()))
|
||||
|
||||
output.accept(ItemStack(Items.CBUS0.get()))
|
||||
output.accept(ItemStack(Items.CBUS1.get()))
|
||||
output.accept(ItemStack(Items.CBUS2.get()))
|
||||
output.accept(ItemStack(Items.CBUS_CREATIVE.get()))
|
||||
|
||||
output.accept(ItemStack(Items.DATA0.get()))
|
||||
output.accept(ItemStack(Items.DATA1.get()))
|
||||
output.accept(ItemStack(Items.DATA2.get()))
|
||||
|
||||
output.accept(ItemStack(Items.GPU0.get()))
|
||||
output.accept(ItemStack(Items.GPU1.get()))
|
||||
output.accept(ItemStack(Items.GPU2.get()))
|
||||
|
||||
output.accept(ItemStack(Items.HDD0.get()))
|
||||
output.accept(ItemStack(Items.HDD1.get()))
|
||||
output.accept(ItemStack(Items.HDD2.get()))
|
||||
|
||||
output.accept(ItemStack(Items.INET.get()))
|
||||
output.accept(ItemStack(Items.TUNNEL.get()))
|
||||
output.accept(ItemStack(Items.LAN.get()))
|
||||
output.accept(ItemStack(Items.WLAN0.get()))
|
||||
output.accept(ItemStack(Items.WLAN1.get()))
|
||||
|
||||
output.accept(ItemStack(Items.REDIO0.get()))
|
||||
output.accept(ItemStack(Items.REDIO1.get()))
|
||||
|
||||
output.accept(ItemStack(Items.EE0.get()))
|
||||
output.accept(ItemStack(Items.SERVER0.get()))
|
||||
Items.ITEMS.forEach {
|
||||
output.accept(ItemStack(it.get()))
|
||||
}
|
||||
|
||||
// Criminal black magic to put LuaBIOS EEPROM in the tabs
|
||||
do {
|
||||
|
||||
@@ -3,10 +3,10 @@ package org.neoflock.neocomputers.network
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType
|
||||
import org.neoflock.neocomputers.block.DeviceBlockEntity
|
||||
//? if fabric {
|
||||
import net.fabricmc.fabric.api.transfer.v1.transaction.TransactionContext
|
||||
/*import net.fabricmc.fabric.api.transfer.v1.transaction.TransactionContext
|
||||
import net.minecraft.core.Direction
|
||||
import team.reborn.energy.api.EnergyStorage;
|
||||
//?}
|
||||
*///?}
|
||||
|
||||
// our soul purpose is to fuse bullshit power APIs together
|
||||
// the NodeBlockEntity and Node given us a way to get power from a block, we just
|
||||
@@ -14,7 +14,7 @@ import team.reborn.energy.api.EnergyStorage;
|
||||
object PowerManager {
|
||||
fun<T: DeviceBlockEntity> registerPowerDevice(blockEntityType: BlockEntityType<T>) {
|
||||
//? if fabric {
|
||||
EnergyStorage.SIDED.registerForBlockEntity({
|
||||
/*EnergyStorage.SIDED.registerForBlockEntity({
|
||||
// TODO: as this is currently written, if the node instance changes and the mod cached the conversion, we're boned. Consider fixing it.
|
||||
entity, dir ->
|
||||
val node = entity.getNodeFromSide(dir ?: Direction.UP)
|
||||
@@ -41,6 +41,6 @@ object PowerManager {
|
||||
}
|
||||
}
|
||||
}, blockEntityType);
|
||||
//?}
|
||||
*///?}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,73 @@
|
||||
package org.neoflock.neocomputers.utils
|
||||
|
||||
import com.mojang.blaze3d.platform.NativeImage
|
||||
import net.minecraft.client.Minecraft
|
||||
import net.minecraft.client.renderer.texture.DynamicTexture
|
||||
import net.minecraft.network.FriendlyByteBuf
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
import net.minecraft.util.ResourceLocationPattern
|
||||
import org.neoflock.neocomputers.gui.widget.DynamicSlot
|
||||
import kotlin.experimental.and
|
||||
import kotlin.math.min
|
||||
|
||||
data class GPUChar(val c: Char, val fg: Int =0xFFFFFF, val bg: Int = 0) // all is bgr
|
||||
|
||||
// TODO: wrapper over NN buffer
|
||||
class TextBuffer(var width: Int, var height: Int) {
|
||||
// val CHARW = 8
|
||||
// val CHARH = 16
|
||||
//
|
||||
// val texwidth: Int
|
||||
// get() = width*CHARW
|
||||
//
|
||||
// val texheight: Int
|
||||
// get() = height*CHARH
|
||||
//
|
||||
// var image = NativeImage(texwidth, texheight, true)
|
||||
// var tex = DynamicTexture(image)
|
||||
|
||||
|
||||
val blank = GPUChar(' ')
|
||||
var buf = Array(width*height) { blank }
|
||||
// init {
|
||||
// Minecraft.getInstance().textureManager.register(this.id, tex)
|
||||
// }
|
||||
|
||||
// fun toRGBA(color: Int): Int {
|
||||
// // Minecaft lies, its AGBR
|
||||
// return java.lang.Integer.reverseBytes((color.toLong() * 256 + 0xFF).toInt())
|
||||
// }
|
||||
//
|
||||
// fun drawGlyph(x: Int, y: Int, c: Char, fg: Int) {
|
||||
// var glyph: ArrayList<Byte> = FontProvider.map[c]!!
|
||||
//
|
||||
// for (j in 0..<CHARH) {
|
||||
// for (i in 0..<CHARW) {
|
||||
// // var pixel = ((glyph[j] and ((1 shl (CHARW - i - 1)).toByte())).toInt()) ushr (CHARW - i - 1) // retardation
|
||||
// var pixel = (glyph[j] and (0b10000000 ushr i).toByte()).toInt()
|
||||
// if (pixel > 0) image.setPixelRGBA(x+i, y+j, toRGBA(fg))
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// fun drawBuffer() {
|
||||
// for (i in 0..<width) {
|
||||
// for (j in 0..<height) {
|
||||
// var char: GPUChar = buf[j*height+i]
|
||||
// var x = i*CHARW
|
||||
// var y = j*CHARH
|
||||
// image.fillRect(x, y, CHARW, CHARH, toRGBA(char.bg))
|
||||
// if (char.c != ' ' && char.c != '\u0000') drawGlyph(x, y, char.c, char.fg)
|
||||
// }
|
||||
// }
|
||||
// tex.upload()
|
||||
// }
|
||||
//
|
||||
// fun clean() {
|
||||
// Minecraft.getInstance().textureManager.release(this.id)
|
||||
// image.close()
|
||||
// tex.close()
|
||||
// }
|
||||
|
||||
fun encodeContents(buf: FriendlyByteBuf) {
|
||||
// 0x01 means set fg, 0x02 means set bg,
|
||||
@@ -75,16 +134,19 @@ class TextBuffer(var width: Int, var height: Int) {
|
||||
|
||||
fun inBounds(x: Int, y: Int) = x >= 0 && y >= 0 && x < width && y < height
|
||||
fun get(x: Int, y: Int) = if(inBounds(x, y)) buf[x+y*width] else blank
|
||||
fun set(x: Int, y: Int, pixel: GPUChar) {
|
||||
fun _set(x: Int, y: Int, pixel: GPUChar) {
|
||||
if(!inBounds(x, y)) return
|
||||
buf[x+y*width] = pixel
|
||||
// image.fillRect(x, y, CHARW, CHARH, toRGBA(pixel.bg))
|
||||
// if (pixel.c != ' ' && pixel.c != '\u0000') drawGlyph(x, y, pixel.c, pixel.fg)
|
||||
}
|
||||
fun set(x: Int, y: Int, text: String, fg: Int = 0xFFFFFF, bg: Int = 0x000000, vertical: Boolean = false) {
|
||||
for ((i, c) in text.toCharArray().withIndex()) {
|
||||
val cx = if(vertical) x else x + i
|
||||
val cy = if(vertical) y + i else y
|
||||
set(cx, cy, GPUChar(c, fg, bg))
|
||||
_set(cx, cy, GPUChar(c, fg, bg))
|
||||
}
|
||||
// tex.upload()
|
||||
}
|
||||
fun fill(x: Int, y: Int, w: Int, h: Int, pixel: GPUChar = blank) {
|
||||
// turn it into values we can fw
|
||||
@@ -92,8 +154,9 @@ class TextBuffer(var width: Int, var height: Int) {
|
||||
val fh = min(h, height)
|
||||
for(py in y..<y+fh) {
|
||||
for (px in x..<x + fw) {
|
||||
set(px, py, pixel)
|
||||
_set(px, py, pixel)
|
||||
}
|
||||
}
|
||||
// tex.upload()
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"sources": [
|
||||
{
|
||||
"type": "single",
|
||||
"source": "neocomputers:block/relay_top"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"variants": {
|
||||
"": { "model": "neocomputers:block/assembler" }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"parent": "block/block",
|
||||
"textures": {
|
||||
"bottom": "neocomputers:block/generic_top",
|
||||
"top": "neocomputers:block/assembler_top",
|
||||
"side": "neocomputers:block/assembler_side",
|
||||
"particle": "neocomputers:block/generic_top"
|
||||
},
|
||||
"elements": [
|
||||
{ "from": [ 0, 0, 0 ],
|
||||
"to": [ 16, 7, 16 ],
|
||||
"faces": {
|
||||
"up": { "uv": [ 0, 0, 16, 16 ], "texture": "#top" },
|
||||
"down": { "uv": [ 0, 0, 16, 16 ], "texture": "#bottom" },
|
||||
"north": { "uv": [ 0, 0, 16, 7 ], "texture": "#side" },
|
||||
"south": { "uv": [ 0, 0, 16, 7 ], "texture": "#side" },
|
||||
"west": { "uv": [ 0, 0, 16, 7 ], "texture": "#side" },
|
||||
"east": { "uv": [ 0, 0, 16, 7 ], "texture": "#side" }
|
||||
}
|
||||
},
|
||||
{ "from": [ 2, 7, 2 ],
|
||||
"to": [ 14, 9, 14 ],
|
||||
"faces": {
|
||||
"up": { "uv": [ 2, 2, 14, 14 ], "texture": "#top" },
|
||||
"down": { "uv": [ 2, 2, 14, 14 ], "texture": "#bottom" },
|
||||
"north": { "uv": [ 2, 7, 14, 9 ], "texture": "#side" },
|
||||
"south": { "uv": [ 2, 7, 14, 9 ], "texture": "#side" },
|
||||
"west": { "uv": [ 2, 7, 14, 9 ], "texture": "#side" },
|
||||
"east": { "uv": [ 2, 7, 14, 9 ], "texture": "#side" }
|
||||
}
|
||||
},
|
||||
{ "from": [ 0, 9, 0 ],
|
||||
"to": [ 16, 16, 16 ],
|
||||
"faces": {
|
||||
"up": { "uv": [ 0, 0, 16, 16 ], "texture": "#top" },
|
||||
"down": { "uv": [ 0, 0, 16, 16 ], "texture": "#bottom" },
|
||||
"north": { "uv": [ 0, 9, 16, 16 ], "texture": "#side" },
|
||||
"south": { "uv": [ 0, 9, 16, 16 ], "texture": "#side" },
|
||||
"west": { "uv": [ 0, 9, 16, 16 ], "texture": "#side" },
|
||||
"east": { "uv": [ 0, 9, 16, 16 ], "texture": "#side" }
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 470 B |
Binary file not shown.
|
After Width: | Height: | Size: 153 B |
Binary file not shown.
|
After Width: | Height: | Size: 361 B |
Binary file not shown.
|
After Width: | Height: | Size: 224 B |
Binary file not shown.
|
After Width: | Height: | Size: 329 B |
@@ -5,7 +5,7 @@ plugins {
|
||||
id("com.gradleup.shadow") version "9.3.0" apply false
|
||||
id("me.modmuss50.mod-publish-plugin") version "0.8.4" apply false
|
||||
}
|
||||
stonecutter active "1.21.1-fabric" /* [SC] DO NOT EDIT */
|
||||
stonecutter active "1.21.9-neoforge" /* [SC] DO NOT EDIT */
|
||||
stonecutter.automaticPlatformConstants = true
|
||||
|
||||
// Builds every version into `build/libs/{mod.version}/{loader}`
|
||||
|
||||
Reference in New Issue
Block a user