From 10c7c29a93b0079a82f829c291605155264ce81c Mon Sep 17 00:00:00 2001 From: Qboi123 Date: Tue, 1 Nov 2022 03:40:39 +0100 Subject: [PATCH 01/88] =?UTF-8?q?Mac=20Max=20X+!=F0=9F=96=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 38 +++ common/build.gradle | 2 + .../com/ultreon/devices/ClientModEvents.java | 11 +- .../com/ultreon/devices/DeviceConfig.java | 4 +- .../java/com/ultreon/devices/Devices.java | 4 +- .../com/ultreon/devices/ModDeviceTypes.java | 2 +- .../devices/block/ClientLaptopWrapper.java | 4 +- .../ultreon/devices/block/ColoredBlock.java | 6 + .../ultreon/devices/block/ComputerBlock.java | 157 ++++++++++++ .../ultreon/devices/block/DeviceBlock.java | 5 +- .../devices/block/DigitalClockBlock.java | 8 +- .../ultreon/devices/block/LaptopBlock.java | 101 +------- .../ultreon/devices/block/MacMaxXBlock.java | 66 +++++ .../devices/block/MacMaxXBlockPart.java | 145 +++++++++++ .../block/entity/ComputerBlockEntity.java | 225 ++++++++++++++++++ .../block/entity/LaptopBlockEntity.java | 196 +-------------- .../block/entity/MacMaxXBlockEntity.java | 24 ++ .../block/entity/renderer/LaptopRenderer.java | 4 +- .../java/com/ultreon/devices/core/Laptop.java | 10 +- .../ultreon/devices/core/io/FileSystem.java | 6 +- .../ultreon/devices/core/io/ServerFolder.java | 2 +- .../devices/core/io/task/TaskGetFiles.java | 4 +- .../core/io/task/TaskGetMainDrive.java | 4 +- .../core/io/task/TaskGetStructure.java | 4 +- .../devices/core/io/task/TaskSendAction.java | 4 +- .../core/io/task/TaskSetupFileBrowser.java | 4 +- .../devices/core/laptop/common/TaskBar.java | 22 +- .../devices/core/task/TaskInstallApp.java | 4 +- .../ultreon/devices/entity/SeatEntity.java | 5 +- .../devices/event/WorldDataHandler.java | 4 +- .../com/ultreon/devices/geo/MacMaxXModel.java | 23 ++ .../devices/init/DeviceBlockEntities.java | 1 + .../ultreon/devices/init/DeviceBlocks.java | 2 + .../com/ultreon/devices/init/DeviceItems.java | 39 +-- .../ultreon/devices/init/DeviceSounds.java | 2 +- .../devices/mixin/common/FontSetMixin.java | 10 +- .../devices/network/PacketHandler.java | 22 +- .../com/ultreon/devices/object/Player.java | 4 +- .../devices/programs/debug/TextAreaApp.java | 2 +- .../task/TaskUpdateApplicationData.java | 4 +- .../system/task/TaskUpdateSystemData.java | 4 +- .../devices/blockstates/mac_max_x_part.json | 7 + .../assets/devices/geo/mac_max_x.geo.json | 143 +++++++++++ .../resources/assets/devices/lang/en_us.json | 2 + .../assets/devices/models/block/void.json | 3 + .../assets/devices/models/item/mac_max_x.json | 38 +++ .../devices/textures/block/mac_max_x.png | Bin 0 -> 3151 bytes fabric/build.gradle | 1 + .../config/fabric_loader_dependencies.json | 11 + .../renderer/fabric/MacMaxXRenderer.java | 12 + .../devices/fabric/ClientModEventsImpl.java | 7 + forge/build.gradle | 3 + .../renderer/forge/MacMaxXRenderer.java | 12 + .../data/client/ModBlockStateProvider.java | 15 +- .../devices/forge/ClientModEventsImpl.java | 7 + gradle.properties | 7 +- 56 files changed, 1044 insertions(+), 412 deletions(-) create mode 100644 common/src/main/java/com/ultreon/devices/block/ColoredBlock.java create mode 100644 common/src/main/java/com/ultreon/devices/block/ComputerBlock.java create mode 100644 common/src/main/java/com/ultreon/devices/block/MacMaxXBlock.java create mode 100644 common/src/main/java/com/ultreon/devices/block/MacMaxXBlockPart.java create mode 100644 common/src/main/java/com/ultreon/devices/block/entity/ComputerBlockEntity.java create mode 100644 common/src/main/java/com/ultreon/devices/block/entity/MacMaxXBlockEntity.java create mode 100644 common/src/main/java/com/ultreon/devices/geo/MacMaxXModel.java create mode 100644 common/src/main/resources/assets/devices/blockstates/mac_max_x_part.json create mode 100644 common/src/main/resources/assets/devices/geo/mac_max_x.geo.json create mode 100644 common/src/main/resources/assets/devices/models/block/void.json create mode 100644 common/src/main/resources/assets/devices/models/item/mac_max_x.json create mode 100644 common/src/main/resources/assets/devices/textures/block/mac_max_x.png create mode 100644 fabric/run/config/fabric_loader_dependencies.json create mode 100644 fabric/src/main/java/com/ultreon/devices/block/entity/renderer/fabric/MacMaxXRenderer.java create mode 100644 forge/src/main/java/com/ultreon/devices/block/entity/renderer/forge/MacMaxXRenderer.java diff --git a/build.gradle b/build.gradle index cc7a9a9a9..08649538e 100644 --- a/build.gradle +++ b/build.gradle @@ -51,6 +51,44 @@ subprojects { silentMojangMappingsLicense() } + repositories { + mavenCentral() + + maven { + name = 'Sponge / Mixin' + url = 'https://repo.spongepowered.org/repository/maven-public/' + } + + maven { + name = 'BlameJared Maven (CrT / Bookshelf)' + url = 'https://maven.blamejared.com' + } + maven { + name = 'ParchmentMC' + url = 'https://maven.parchmentmc.org' + } + + maven { + name 'Quilt (Release)' + url 'https://maven.quiltmc.org/repository/release/' + } + + + maven { + url "https://cursemaven.com" + content { + includeGroup "curse.maven" + } + } + maven { + // location of the maven that hosts JEI files + name = "Progwml6 maven" + url = "https://dvs1.progwml6.com/files/maven/" + } + maven { url "https://maven.architectury.dev/" } + maven { url 'https://dl.cloudsmith.io/public/geckolib3/geckolib/maven/' } + } + dependencies { minecraft "com.mojang:minecraft:${rootProject.minecraft_version}" // The following line declares the mojmap mappings, you may use other mappings as well diff --git a/common/build.gradle b/common/build.gradle index 146061d6f..2409d11aa 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -18,6 +18,8 @@ dependencies { // Remove the next line if you don't want to depend on the API modApi "dev.architectury:architectury:${rootProject.architectury_version}" + modImplementation "software.bernie.geckolib:geckolib-fabric-1.19:${geckolib_version_fabric}" + implementation("org.jetbrains.kotlin:kotlin-reflect:1.7.10") implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.10") modApi("com.ultreon:ultranlang:0.1.0+6") diff --git a/common/src/main/java/com/ultreon/devices/ClientModEvents.java b/common/src/main/java/com/ultreon/devices/ClientModEvents.java index 5172f6a75..c17f4a526 100644 --- a/common/src/main/java/com/ultreon/devices/ClientModEvents.java +++ b/common/src/main/java/com/ultreon/devices/ClientModEvents.java @@ -1,8 +1,8 @@ package com.ultreon.devices; -import com.ultreon.devices.block.entity.renderer.*; import com.mojang.blaze3d.platform.NativeImage; import com.ultreon.devices.api.ApplicationManager; +import com.ultreon.devices.block.entity.renderer.*; import com.ultreon.devices.core.Laptop; import com.ultreon.devices.init.DeviceBlockEntities; import com.ultreon.devices.init.DeviceBlocks; @@ -33,7 +33,6 @@ import java.io.IOException; import java.io.InputStream; import java.nio.file.Paths; -import java.util.Objects; import java.util.concurrent.CompletableFuture; import java.util.concurrent.Executor; @@ -67,6 +66,7 @@ public static void clientSetup() { registerRenderLayers(); registerRenderers(); registerLayerDefinitions(); + registerGeoRenderers(); generateIconAtlas(); } @@ -195,7 +195,7 @@ public void finish() { } // @ExpectPlatform -// private static void updateIcon(AppInfo info, int iconU, int iconV) { +// private static void.json updateIcon(AppInfo info, int iconU, int iconV) { // throw new AssertionError(); //// ObfuscationReflectionHelper.setPrivateValue(AppInfo.class, info, iconU, "iconU"); //// ObfuscationReflectionHelper.setPrivateValue(AppInfo.class, info, iconV, "iconV"); @@ -206,6 +206,11 @@ public static void setRenderLayer(Block block, RenderType type) { throw new AssertionError(); } + @ExpectPlatform + public static void registerGeoRenderers() { + throw new AssertionError(); + } + public static void registerRenderers() { LOGGER.info("Registering renderers."); diff --git a/common/src/main/java/com/ultreon/devices/DeviceConfig.java b/common/src/main/java/com/ultreon/devices/DeviceConfig.java index f5034e437..27c7bc3ae 100644 --- a/common/src/main/java/com/ultreon/devices/DeviceConfig.java +++ b/common/src/main/java/com/ultreon/devices/DeviceConfig.java @@ -85,7 +85,7 @@ public static void register(Object context) { // @ExpectPlatform // @PlatformOnly("fabric") -// public static void register(ModLoadingContext context) { +// public static void.json register(ModLoadingContext context) { // throw new AssertionError(); // //context.registerConfig(ModConfig.Type.CLIENT, CONFIG); // } @@ -99,7 +99,7 @@ public void save() { } // @SubscribeEvent -// public static void onConfigChanged(ModConfigEvent.Reloading event) { +// public static void.json onConfigChanged(ModConfigEvent.Reloading event) { // // TODO // Implement config reloading if needed. // } } diff --git a/common/src/main/java/com/ultreon/devices/Devices.java b/common/src/main/java/com/ultreon/devices/Devices.java index f642b834e..c57314161 100644 --- a/common/src/main/java/com/ultreon/devices/Devices.java +++ b/common/src/main/java/com/ultreon/devices/Devices.java @@ -476,7 +476,7 @@ public static ResourceLocation res(String path) { return new ResourceLocation(Devices.MOD_ID, path); } -// private void enqueueIMC(final InterModEnqueueEvent event) { +// private void.json enqueueIMC(final InterModEnqueueEvent event) { // // Check for self availability. // InterModComms.sendTo(Reference.MOD_ID, "availability", () -> { // LOGGER.info("IMC is working correctly"); @@ -484,7 +484,7 @@ public static ResourceLocation res(String path) { // }); // } // -// private void processIMC(final InterModProcessEvent event) { +// private void.json processIMC(final InterModProcessEvent event) { // event.getIMCStream().forEachOrdered(imcMessage -> { // // Availability IMC handling. // if (imcMessage.method().equals("availability")) { diff --git a/common/src/main/java/com/ultreon/devices/ModDeviceTypes.java b/common/src/main/java/com/ultreon/devices/ModDeviceTypes.java index fcddf45fd..b850151f7 100644 --- a/common/src/main/java/com/ultreon/devices/ModDeviceTypes.java +++ b/common/src/main/java/com/ultreon/devices/ModDeviceTypes.java @@ -3,7 +3,7 @@ import org.jetbrains.annotations.Contract; public enum ModDeviceTypes implements IDeviceType { - LAPTOP, PRINTER, FLASH_DRIVE, ROUTER, SEAT; + COMPUTER, PRINTER, FLASH_DRIVE, ROUTER, SEAT; @Override @Contract(pure = true, value = "-> this") diff --git a/common/src/main/java/com/ultreon/devices/block/ClientLaptopWrapper.java b/common/src/main/java/com/ultreon/devices/block/ClientLaptopWrapper.java index 319ee0e43..57fbe6f92 100644 --- a/common/src/main/java/com/ultreon/devices/block/ClientLaptopWrapper.java +++ b/common/src/main/java/com/ultreon/devices/block/ClientLaptopWrapper.java @@ -1,12 +1,12 @@ package com.ultreon.devices.block; -import com.ultreon.devices.block.entity.LaptopBlockEntity; +import com.ultreon.devices.block.entity.ComputerBlockEntity; import com.ultreon.devices.core.Laptop; import net.minecraft.client.Minecraft; public class ClientLaptopWrapper { - public static void execute(LaptopBlockEntity laptop) { + public static void execute(ComputerBlockEntity laptop) { Minecraft.getInstance().setScreen(new Laptop(laptop)); } } diff --git a/common/src/main/java/com/ultreon/devices/block/ColoredBlock.java b/common/src/main/java/com/ultreon/devices/block/ColoredBlock.java new file mode 100644 index 000000000..b2e8fc284 --- /dev/null +++ b/common/src/main/java/com/ultreon/devices/block/ColoredBlock.java @@ -0,0 +1,6 @@ +package com.ultreon.devices.block; + +import com.ultreon.devices.util.Colored; + +public interface ColoredBlock extends Colored { +} diff --git a/common/src/main/java/com/ultreon/devices/block/ComputerBlock.java b/common/src/main/java/com/ultreon/devices/block/ComputerBlock.java new file mode 100644 index 000000000..565cdd6a9 --- /dev/null +++ b/common/src/main/java/com/ultreon/devices/block/ComputerBlock.java @@ -0,0 +1,157 @@ +package com.ultreon.devices.block; + +import com.ultreon.devices.ModDeviceTypes; +import com.ultreon.devices.block.entity.ComputerBlockEntity; +import com.ultreon.devices.block.entity.LaptopBlockEntity; +import com.ultreon.devices.item.FlashDriveItem; +import com.ultreon.devices.util.BlockEntityUtil; +import com.ultreon.devices.util.Colorable; +import dev.architectury.utils.Env; +import dev.architectury.utils.EnvExecutor; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.util.StringRepresentable; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.DyeColor; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.state.BlockBehaviour; +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.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.Locale; + +public abstract class ComputerBlock extends DeviceBlock { + public static final EnumProperty TYPE = EnumProperty.create("type", Type.class); + public static final BooleanProperty OPEN = BooleanProperty.create("open"); + + public ComputerBlock(BlockBehaviour.Properties properties) { + super(properties, ModDeviceTypes.COMPUTER); + registerDefaultState(this.getStateDefinition().any().setValue(TYPE, Type.BASE).setValue(OPEN, false)); + } + + @NotNull + @Override + @SuppressWarnings("deprecation") + public InteractionResult use(@NotNull BlockState state, @NotNull Level level, @NotNull BlockPos pos, @NotNull Player player, @NotNull InteractionHand hand, @NotNull BlockHitResult hit) { + BlockEntity blockEntity = level.getBlockEntity(pos); + if (blockEntity instanceof ComputerBlockEntity laptop) { + if (!isDesktopPC() && player.isCrouching()) { + if (!level.isClientSide) { + laptop.openClose(player); + } + return InteractionResult.SUCCESS; + } else { + if (isDesktopPC() && !laptop.isOpen()) { + laptop.openClose(player); + } + if (hit.getDirection() == state.getValue(FACING).getCounterClockWise(Direction.Axis.Y)) { + ItemStack heldItem = player.getItemInHand(hand); + if (!heldItem.isEmpty() && heldItem.getItem() instanceof FlashDriveItem) { + if (!level.isClientSide) { + if (laptop.getFileSystem().setAttachedDrive(heldItem.copy())) { + heldItem.shrink(1); + return InteractionResult.CONSUME; + } else { + return InteractionResult.FAIL; + } + } + return InteractionResult.PASS; + } + + if (!level.isClientSide) { + ItemStack stack = laptop.getFileSystem().removeAttachedDrive(); + if (stack != null) { + BlockPos summonPos = pos.relative(state.getValue(FACING).getCounterClockWise(Direction.Axis.Y)); + level.addFreshEntity(new ItemEntity(level, summonPos.getX() + 0.5, summonPos.getY(), summonPos.getZ() + 0.5, stack)); + BlockEntityUtil.markBlockForUpdate(level, pos); + } + } + return InteractionResult.SUCCESS; + } + + if (laptop.isOpen() && level.isClientSide) { + EnvExecutor.runInEnv(Env.CLIENT, () -> () -> { + ClientLaptopWrapper.execute(laptop); + }); + return InteractionResult.SUCCESS; + } + } + } + + return InteractionResult.PASS; + } + + public abstract boolean isDesktopPC(); + + public boolean isLaptop() { + return !isDesktopPC(); + } + + @Override + protected void removeTagsForDrop(CompoundTag tileEntityTag) { + tileEntityTag.remove("open"); + } + + @Override + public @Nullable BlockEntity newBlockEntity(@NotNull BlockPos pos, @NotNull BlockState state) { + return new LaptopBlockEntity(pos, state); + } + + @Override + protected void createBlockStateDefinition(StateDefinition.@NotNull Builder pBuilder) { + super.createBlockStateDefinition(pBuilder); + pBuilder.add(TYPE, OPEN, FACING); + } + + public enum Type implements StringRepresentable { + BASE, SCREEN; + + @NotNull + @Override + public String getSerializedName() { + return name().toLowerCase(Locale.ROOT); + } + } + + public static abstract class Colored extends ComputerBlock implements ColoredBlock { + private final DyeColor color; + + protected Colored(Properties properties, DyeColor color, ModDeviceTypes deviceType) { + super(properties); + this.color = color; + } + + @Override + public DyeColor getColor() { + return color; + } + + @Override + public void setPlacedBy(@NotNull Level level, @NotNull BlockPos pos, @NotNull BlockState state, @Nullable LivingEntity placer, @NotNull ItemStack stack) { + super.setPlacedBy(level, pos, state, placer, stack); + BlockEntity blockEntity = level.getBlockEntity(pos); + if (blockEntity instanceof Colorable colored) { + colored.setColor(color); + } + } + + // Todo - Implement onDestroyedByPlayer if colored, and needed to implement it. Needs to check if it works without it. + @Override + protected void createBlockStateDefinition(StateDefinition.@NotNull Builder pBuilder) { + super.createBlockStateDefinition(pBuilder); + } + } +} diff --git a/common/src/main/java/com/ultreon/devices/block/DeviceBlock.java b/common/src/main/java/com/ultreon/devices/block/DeviceBlock.java index 8cfcf8637..2bbf1d7bd 100644 --- a/common/src/main/java/com/ultreon/devices/block/DeviceBlock.java +++ b/common/src/main/java/com/ultreon/devices/block/DeviceBlock.java @@ -1,7 +1,7 @@ package com.ultreon.devices.block; -import com.ultreon.devices.ModDeviceTypes; import com.ultreon.devices.IDeviceType; +import com.ultreon.devices.ModDeviceTypes; import com.ultreon.devices.block.entity.DeviceBlockEntity; import com.ultreon.devices.util.BlockEntityUtil; import com.ultreon.devices.util.Colorable; @@ -132,7 +132,7 @@ public ModDeviceTypes getDeviceType() { return deviceType; } - public static abstract class Colored extends DeviceBlock { + public static abstract class Colored extends DeviceBlock implements ColoredBlock { private final DyeColor color; protected Colored(Properties properties, DyeColor color, ModDeviceTypes deviceType) { @@ -140,6 +140,7 @@ protected Colored(Properties properties, DyeColor color, ModDeviceTypes deviceTy this.color = color; } + @Override public DyeColor getColor() { return color; } diff --git a/common/src/main/java/com/ultreon/devices/block/DigitalClockBlock.java b/common/src/main/java/com/ultreon/devices/block/DigitalClockBlock.java index d24546455..4eb05116d 100644 --- a/common/src/main/java/com/ultreon/devices/block/DigitalClockBlock.java +++ b/common/src/main/java/com/ultreon/devices/block/DigitalClockBlock.java @@ -29,7 +29,7 @@ public class DigitalClockBlock{// extends Block { // } // // -//// public static void addInformation(ItemStack stack, @Nullable Level player, List tooltip, TooltipFlag advanced) +//// public static void.json addInformation(ItemStack stack, @Nullable Level player, List tooltip, TooltipFlag advanced) //// { //// if(Screen.hasShiftDown()) //// { @@ -42,7 +42,7 @@ public class DigitalClockBlock{// extends Block { //// } // // @Override -// public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB entityBox, List collidingBoxes, @Nullable Entity entityIn, boolean p_185477_7_) +// public void.json addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB entityBox, List collidingBoxes, @Nullable Entity entityIn, boolean p_185477_7_) // { // Block.addCollisionBoxToList(pos, entityBox, collidingBoxes, COLLISION_BOXES[state.getValue(FACING).getHorizontalIndex()]); // } @@ -66,7 +66,7 @@ public class DigitalClockBlock{// extends Block { // } // // @Override -// public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, @Nullable TileEntity tileEntity, ItemStack stack) +// public void.json harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, @Nullable TileEntity tileEntity, ItemStack stack) // { // if(tileEntity instanceof TileEntityDigitalClock) // { @@ -92,7 +92,7 @@ public class DigitalClockBlock{// extends Block { // } // // @Override -// public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) +// public void.json onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) // { // super.onBlockPlacedBy(worldIn, pos, state, placer, stack); // TileEntity tileEntity = worldIn.getTileEntity(pos); diff --git a/common/src/main/java/com/ultreon/devices/block/LaptopBlock.java b/common/src/main/java/com/ultreon/devices/block/LaptopBlock.java index 1a4f0711f..3e235e842 100644 --- a/common/src/main/java/com/ultreon/devices/block/LaptopBlock.java +++ b/common/src/main/java/com/ultreon/devices/block/LaptopBlock.java @@ -1,41 +1,21 @@ package com.ultreon.devices.block; import com.ultreon.devices.ModDeviceTypes; -import com.ultreon.devices.block.entity.LaptopBlockEntity; -import com.ultreon.devices.item.FlashDriveItem; -import com.ultreon.devices.util.BlockEntityUtil; -import dev.architectury.utils.Env; -import dev.architectury.utils.EnvExecutor; import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.util.StringRepresentable; -import net.minecraft.world.InteractionHand; -import net.minecraft.world.InteractionResult; -import net.minecraft.world.entity.item.ItemEntity; -import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.DyeColor; -import net.minecraft.world.item.ItemStack; 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.SoundType; -import net.minecraft.world.level.block.entity.BlockEntity; 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.level.material.Material; -import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.Shapes; import net.minecraft.world.phys.shapes.VoxelShape; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import java.util.Locale; - -public class LaptopBlock extends DeviceBlock.Colored { +public class LaptopBlock extends ComputerBlock.Colored { public static final EnumProperty TYPE = EnumProperty.create("type", Type.class); public static final BooleanProperty OPEN = BooleanProperty.create("open"); @@ -49,8 +29,7 @@ public class LaptopBlock extends DeviceBlock.Colored { private static final VoxelShape SHAPE_CLOSED_WEST = Block.box(1, 0, 1, 13, 2, 15); public LaptopBlock(DyeColor color) { - super(Properties.of(Material.HEAVY_METAL, color).strength(6f).sound(SoundType.METAL), color, ModDeviceTypes.LAPTOP); - registerDefaultState(this.getStateDefinition().any().setValue(TYPE, Type.BASE).setValue(OPEN, false)); + super(Properties.of(Material.HEAVY_METAL, color).strength(6f).sound(SoundType.METAL), color, ModDeviceTypes.COMPUTER); } @Override @@ -70,79 +49,7 @@ public LaptopBlock(DyeColor color) { }; } - @NotNull - @Override - @SuppressWarnings("deprecation") - public InteractionResult use(@NotNull BlockState state, @NotNull Level level, @NotNull BlockPos pos, @NotNull Player player, @NotNull InteractionHand hand, @NotNull BlockHitResult hit) { - - BlockEntity blockEntity = level.getBlockEntity(pos); - if (blockEntity instanceof LaptopBlockEntity laptop) { - if (player.isCrouching()) { - if (!level.isClientSide) { - laptop.openClose(player); - } - return InteractionResult.SUCCESS; - } else { - if (hit.getDirection() == state.getValue(FACING).getCounterClockWise(Direction.Axis.Y)) { - ItemStack heldItem = player.getItemInHand(hand); - if (!heldItem.isEmpty() && heldItem.getItem() instanceof FlashDriveItem) { - if (!level.isClientSide) { - if (laptop.getFileSystem().setAttachedDrive(heldItem.copy())) { - heldItem.shrink(1); - return InteractionResult.CONSUME; - } else { - return InteractionResult.FAIL; - } - } - return InteractionResult.PASS; - } - - if (!level.isClientSide) { - ItemStack stack = laptop.getFileSystem().removeAttachedDrive(); - if (stack != null) { - BlockPos summonPos = pos.relative(state.getValue(FACING).getCounterClockWise(Direction.Axis.Y)); - level.addFreshEntity(new ItemEntity(level, summonPos.getX() + 0.5, summonPos.getY(), summonPos.getZ() + 0.5, stack)); - BlockEntityUtil.markBlockForUpdate(level, pos); - } - } - return InteractionResult.SUCCESS; - } - - if (laptop.isOpen() && level.isClientSide) { - EnvExecutor.runInEnv(Env.CLIENT, () -> () -> { - ClientLaptopWrapper.execute(laptop); - }); - return InteractionResult.SUCCESS; - } - } - } - - return InteractionResult.PASS; - } - - @Override - protected void removeTagsForDrop(CompoundTag tileEntityTag) { - tileEntityTag.remove("open"); - } - - @Override - public @Nullable BlockEntity newBlockEntity(@NotNull BlockPos pos, @NotNull BlockState state) { - return new LaptopBlockEntity(pos, state); - } - - @Override - protected void createBlockStateDefinition(StateDefinition.@NotNull Builder pBuilder) { - super.createBlockStateDefinition(pBuilder); - pBuilder.add(TYPE, OPEN); - } - - public enum Type implements StringRepresentable { - BASE, SCREEN; - - @NotNull - @Override - public String getSerializedName() { - return name().toLowerCase(Locale.ROOT); - } + public boolean isDesktopPC() { + return false; } } diff --git a/common/src/main/java/com/ultreon/devices/block/MacMaxXBlock.java b/common/src/main/java/com/ultreon/devices/block/MacMaxXBlock.java new file mode 100644 index 000000000..703d6f7f8 --- /dev/null +++ b/common/src/main/java/com/ultreon/devices/block/MacMaxXBlock.java @@ -0,0 +1,66 @@ +package com.ultreon.devices.block; + +import com.ultreon.devices.block.entity.MacMaxXBlockEntity; +import dev.architectury.platform.Platform; +import net.minecraft.core.BlockPos; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.MutableComponent; +import net.minecraft.world.item.DyeColor; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.RenderShape; +import net.minecraft.world.level.block.SoundType; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.state.BlockBehaviour; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class MacMaxXBlock extends ComputerBlock { + private static final VoxelShape SHAPE_NORTH = Block.box(-16, 0, 7, 32, 35.25, 11); + private static final VoxelShape SHAPE_EAST = Block.box(-16, 0, 7, 32, 35.25, 11); + private static final VoxelShape SHAPE_SOUTH = Block.box(-16, 0, 7, 32, 35.25, 11); + private static final VoxelShape SHAPE_WEST = Block.box(-16, 0, 7, 32, 35.25, 11); + + public MacMaxXBlock() { + super(BlockBehaviour.Properties.of(Material.HEAVY_METAL, DyeColor.WHITE).strength(6f).sound(SoundType.METAL)); + } + + @Override + public @NotNull VoxelShape getShape(@NotNull BlockState pState, @NotNull BlockGetter pLevel, @NotNull BlockPos pPos, @NotNull CollisionContext pContext) { + return switch (pState.getValue(FACING)) { + case NORTH -> SHAPE_NORTH; + case EAST -> SHAPE_EAST; + case SOUTH -> SHAPE_SOUTH; + case WEST -> SHAPE_WEST; + default -> throw new IllegalStateException("Unexpected value: " + pState.getValue(FACING)); + }; + } + + @Override + public boolean isDesktopPC() { + return true; + } + + @Override + public MutableComponent getName() { + MutableComponent normalName = Component.translatable("block.devices.mac_max_x"); + if (Platform.isModLoaded("emojiful")) { + return Component.translatable("block.devices.mac_max_x_emoji"); + } + return normalName; + } + + @Override + public RenderShape getRenderShape(@NotNull BlockState state) { + return RenderShape.ENTITYBLOCK_ANIMATED; + } + + @Override + public @Nullable BlockEntity newBlockEntity(@NotNull BlockPos pos, @NotNull BlockState state) { + return new MacMaxXBlockEntity(pos, state); + } +} diff --git a/common/src/main/java/com/ultreon/devices/block/MacMaxXBlockPart.java b/common/src/main/java/com/ultreon/devices/block/MacMaxXBlockPart.java new file mode 100644 index 000000000..ccca2c9f9 --- /dev/null +++ b/common/src/main/java/com/ultreon/devices/block/MacMaxXBlockPart.java @@ -0,0 +1,145 @@ +package com.ultreon.devices.block; + +import com.ultreon.devices.block.entity.MacMaxXBlockEntity; +import dev.architectury.platform.Platform; +import net.minecraft.core.BlockPos; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.MutableComponent; +import net.minecraft.util.StringRepresentable; +import net.minecraft.world.item.DyeColor; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.RenderShape; +import net.minecraft.world.level.block.SoundType; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class MacMaxXBlockPart extends ComputerBlock { + private static EnumProperty PART = EnumProperty.create("part", Part.class); + + private static final VoxelShape BL_SHAPE_NORTH = Block.box(-16 + 16, 0, 7, 32 + 16, 35.25, 11); + private static final VoxelShape BL_SHAPE_EAST = Block.box(-16 + 16, 0, 7, 32 + 16, 35.25, 11); + private static final VoxelShape BL_SHAPE_SOUTH = Block.box(-16 + 16, 0, 7, 32 + 16, 35.25, 11); + private static final VoxelShape BL_SHAPE_WEST = Block.box(-16 + 16, 0, 7, 32 + 16, 35.25, 11); + + private static final VoxelShape BR_SHAPE_NORTH = Block.box(-16 - 16, 0, 7, 32 - 16, 35.25, 11); + private static final VoxelShape BR_SHAPE_EAST = Block.box(-16 - 16, 0, 7, 32 - 16, 35.25, 11); + private static final VoxelShape BR_SHAPE_SOUTH = Block.box(-16 - 16, 0, 7, 32 - 16, 35.25, 11); + private static final VoxelShape BR_SHAPE_WEST = Block.box(-16 - 16, 0, 7, 32 - 16, 35.25, 11); + + private static final VoxelShape TL_SHAPE_NORTH = Block.box(-16 + 16, -16, 7, 32 + 16, 19.25, 11); + private static final VoxelShape TL_SHAPE_EAST = Block.box(-16 + 16, -16, 7, 32 + 16, 19.25, 11); + private static final VoxelShape TL_SHAPE_SOUTH = Block.box(-16 + 16, -16, 7, 32 + 16, 19.25, 11); + private static final VoxelShape TL_SHAPE_WEST = Block.box(-16 + 16, -16, 7, 32 + 16, 19.25, 11); + + private static final VoxelShape T_SHAPE_NORTH = Block.box(-16, -16, 7, 32, 19.25, 11); + private static final VoxelShape T_SHAPE_EAST = Block.box(-16, -16, 7, 32, 19.25, 11); + private static final VoxelShape T_SHAPE_SOUTH = Block.box(-16, -16, 7, 32, 19.25, 11); + private static final VoxelShape T_SHAPE_WEST = Block.box(-16, -16, 7, 32, 19.25, 11); + + private static final VoxelShape TR_SHAPE_NORTH = Block.box(-16 - 16, -16, 7, 32 - 16, 19.25, 11); + private static final VoxelShape TR_SHAPE_EAST = Block.box(-16 - 16, -16, 7, 32 - 16, 19.25, 11); + private static final VoxelShape TR_SHAPE_SOUTH = Block.box(-16 - 16, -16, 7, 32 - 16, 19.25, 11); + private static final VoxelShape TR_SHAPE_WEST = Block.box(-16 - 16, -16, 7, 32 - 16, 19.25, 11); + + public MacMaxXBlockPart() { + super(Properties.of(Material.HEAVY_METAL, DyeColor.WHITE).strength(6f).sound(SoundType.METAL)); + } + + @Override + public @NotNull VoxelShape getShape(@NotNull BlockState pState, @NotNull BlockGetter pLevel, @NotNull BlockPos pPos, @NotNull CollisionContext pContext) { + switch (pState.getValue(PART)) { + case BL -> { + return switch (pState.getValue(FACING)) { + case NORTH -> BL_SHAPE_NORTH; + case EAST -> BL_SHAPE_EAST; + case SOUTH -> BL_SHAPE_SOUTH; + case WEST -> BL_SHAPE_WEST; + default -> throw new IllegalStateException("Unexpected value: " + pState.getValue(FACING)); + }; + } + case BR -> { + return switch (pState.getValue(FACING)) { + case NORTH -> BR_SHAPE_NORTH; + case EAST -> BR_SHAPE_EAST; + case SOUTH -> BR_SHAPE_SOUTH; + case WEST -> BR_SHAPE_WEST; + default -> throw new IllegalStateException("Unexpected value: " + pState.getValue(FACING)); + }; + } + case TL -> { + return switch (pState.getValue(FACING)) { + case NORTH -> TL_SHAPE_NORTH; + case EAST -> TL_SHAPE_EAST; + case SOUTH -> TL_SHAPE_SOUTH; + case WEST -> TL_SHAPE_WEST; + default -> throw new IllegalStateException("Unexpected value: " + pState.getValue(FACING)); + }; + } + case T -> { + return switch (pState.getValue(FACING)) { + case NORTH -> T_SHAPE_NORTH; + case EAST -> T_SHAPE_EAST; + case SOUTH -> T_SHAPE_SOUTH; + case WEST -> T_SHAPE_WEST; + default -> throw new IllegalStateException("Unexpected value: " + pState.getValue(FACING)); + }; + } + case TR -> { + return switch (pState.getValue(FACING)) { + case NORTH -> TR_SHAPE_NORTH; + case EAST -> TR_SHAPE_EAST; + case SOUTH -> TR_SHAPE_SOUTH; + case WEST -> TR_SHAPE_WEST; + default -> throw new IllegalStateException("Unexpected value: " + pState.getValue(FACING)); + }; + } + }; + throw new IllegalStateException("Unexpected value: " + pState.getValue(PART)); + } + + @Override + public boolean isDesktopPC() { + return true; + } + + @Override + public MutableComponent getName() { + MutableComponent normalName = Component.translatable("block.devices.mac_max_x"); + if (Platform.isModLoaded("emojiful")) { + return Component.translatable("block.devices.mac_max_x_emoji"); + } + return normalName; + } + + @Override + public RenderShape getRenderShape(@NotNull BlockState state) { + return RenderShape.ENTITYBLOCK_ANIMATED; + } + + @Override + public @Nullable BlockEntity newBlockEntity(@NotNull BlockPos pos, @NotNull BlockState state) { + return new MacMaxXBlockEntity(pos, state); + } + + public enum Part implements StringRepresentable { + BL, BR, TL, T, TR; + + @Override + public String getSerializedName() { + return switch (this) { + case BL -> "bottom_left"; + case BR -> "bottom_right"; + case TL -> "top_left"; + case T -> "top"; + case TR -> "top_right"; + }; + } + } +} diff --git a/common/src/main/java/com/ultreon/devices/block/entity/ComputerBlockEntity.java b/common/src/main/java/com/ultreon/devices/block/entity/ComputerBlockEntity.java new file mode 100644 index 000000000..ed0a67e45 --- /dev/null +++ b/common/src/main/java/com/ultreon/devices/block/entity/ComputerBlockEntity.java @@ -0,0 +1,225 @@ +package com.ultreon.devices.block.entity; + +import com.ultreon.devices.block.LaptopBlock; +import com.ultreon.devices.core.io.FileSystem; +import com.ultreon.devices.util.BlockEntityUtil; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.minecraft.core.BlockPos; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.Tag; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.item.DyeColor; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.gameevent.GameEvent; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public abstract class ComputerBlockEntity extends NetworkDeviceBlockEntity.Colored { + private static final int OPENED_ANGLE = 102; + + private boolean open = false; + + private CompoundTag applicationData = new CompoundTag(); + private CompoundTag systemData = new CompoundTag(); + private FileSystem fileSystem; + + @Environment(EnvType.CLIENT) + private int rotation; + + @Environment(EnvType.CLIENT) + private int prevRotation; + + private DyeColor externalDriveColor; + + protected ComputerBlockEntity(BlockEntityType type, BlockPos pWorldPosition, BlockState pBlockState) { + super(type, pWorldPosition, pBlockState); + } + + @Override + public String getDeviceName() { + return "Laptop"; + } + + @Override + public void tick() { + super.tick(); + assert level != null; + if (level.isClientSide) { + prevRotation = rotation; + if (!open) { + if (rotation > 0) { + rotation -= 10F; + } + } else { + if (rotation < OPENED_ANGLE) { + rotation += 10F; + } + } + } + } + + @Override + public void load(@NotNull CompoundTag compound) { + super.load(compound); + if (compound.contains("open")) { + this.open = compound.getBoolean("open"); + this.getBlockState().setValue(LaptopBlock.OPEN, open); + } + if (compound.contains("system_data", Tag.TAG_COMPOUND)) { + this.systemData = compound.getCompound("system_data"); + } + if (compound.contains("application_data", Tag.TAG_COMPOUND)) { + this.applicationData = compound.getCompound("application_data"); + } + if (compound.contains("file_system")) { + this.fileSystem = new FileSystem(this, compound.getCompound("file_system")); + } + if (compound.contains("external_drive_color", Tag.TAG_BYTE)) { + this.externalDriveColor = null; + if (compound.getByte("external_drive_color") != -1) { + this.externalDriveColor = DyeColor.byId(compound.getByte("external_drive_color")); + } + } + } + + @Override + public void saveAdditional(@NotNull CompoundTag compound) { + super.saveAdditional(compound); + compound.putBoolean("open", open); + + if (systemData != null) { + compound.put("system_data", systemData); + } + + if (applicationData != null) { + compound.put("application_data", applicationData); + } + + if (fileSystem != null) { + compound.put("file_system", fileSystem.toTag()); + } + } + + @Override + public CompoundTag saveSyncTag() { + CompoundTag tag = super.saveSyncTag(); + tag.putBoolean("open", open); + tag.put("system_data", getSystemData()); + + if (getFileSystem().getAttachedDrive() != null) { + tag.putByte("external_drive_color", (byte) getFileSystem().getAttachedDriveColor().getId()); + } else { + tag.putByte("external_drive_color", (byte) -1); + } + + return tag; + } + + // Todo: Port to 1.18.2 if possible +// @Override +// public double getMaxRenderDistanceSquared() { +// return 16384; +// } +// +// public AxisAlignedBB getRenderBoundingBox() { +// return INFINITE_EXTENT_AABB; +// } + + public void openClose(@Nullable Entity entity) { + Level level = this.level; + if (level != null) { + level.gameEvent(!open ? GameEvent.BLOCK_OPEN : GameEvent.BLOCK_CLOSE, getBlockPos(), GameEvent.Context.of(entity, this.getBlockState())); + } + boolean oldOpen = open; + open = !getBlockState().getValue(LaptopBlock.OPEN); + if (oldOpen != open) { + pipeline.putBoolean("open", open); + var d = getBlockState().setValue(LaptopBlock.OPEN, open); + this.level.setBlock(this.getBlockPos(), d, 18); + sync(); + } + + if (level != null) { + markUpdated(); + doNeighborUpdates(level, this.getBlockPos(), this.getBlockState()); + } + } + + public void open(@Nullable Entity entity, boolean open) { + Level level = this.level; + if (level != null) { + level.gameEvent(open ? GameEvent.BLOCK_OPEN : GameEvent.BLOCK_CLOSE, getBlockPos(), GameEvent.Context.of(entity, this.getBlockState())); + } + boolean oldOpen = open; + open = !getBlockState().getValue(LaptopBlock.OPEN); + if (oldOpen != open) { + pipeline.putBoolean("open", open); + var d = getBlockState().setValue(LaptopBlock.OPEN, open); + this.level.setBlock(this.getBlockPos(), d, 18); + sync(); + } + + if (level != null) { + markUpdated(); + doNeighborUpdates(level, this.getBlockPos(), this.getBlockState()); + } + } + + private static void doNeighborUpdates(Level level, BlockPos pos, BlockState state) { + state.updateNeighbourShapes(level, pos, 3); + } + + public boolean isOpen() { + return open; + } + + public CompoundTag getApplicationData() { + return applicationData != null ? applicationData : new CompoundTag(); + } + + public CompoundTag getSystemData() { + if (systemData == null) { + systemData = new CompoundTag(); + } + return systemData; + } + + public void setSystemData(CompoundTag systemData) { + this.systemData = systemData; + setChanged(); + assert level != null; + BlockEntityUtil.markBlockForUpdate(level, worldPosition); + } + + public FileSystem getFileSystem() { + if (fileSystem == null) { + fileSystem = new FileSystem(this, new CompoundTag()); + } + return fileSystem; + } + + public void setApplicationData(String appId, CompoundTag applicationData) { + this.applicationData = applicationData; + setChanged(); + assert level != null; + BlockEntityUtil.markBlockForUpdate(level, worldPosition); + } + + @Environment(EnvType.CLIENT) + public float getScreenAngle(float partialTicks) { + return -OPENED_ANGLE * ((prevRotation + (rotation - prevRotation) * partialTicks) / OPENED_ANGLE); + } + + @Environment(EnvType.CLIENT) + public boolean isExternalDriveAttached() { + return externalDriveColor != null; + } + + @Environment(EnvType.CLIENT) + public DyeColor getExternalDriveColor() { + return externalDriveColor; + } +} diff --git a/common/src/main/java/com/ultreon/devices/block/entity/LaptopBlockEntity.java b/common/src/main/java/com/ultreon/devices/block/entity/LaptopBlockEntity.java index a6f1c1332..35385b5e2 100644 --- a/common/src/main/java/com/ultreon/devices/block/entity/LaptopBlockEntity.java +++ b/common/src/main/java/com/ultreon/devices/block/entity/LaptopBlockEntity.java @@ -1,205 +1,11 @@ package com.ultreon.devices.block.entity; -import com.ultreon.devices.block.LaptopBlock; -import com.ultreon.devices.core.io.FileSystem; import com.ultreon.devices.init.DeviceBlockEntities; -import com.ultreon.devices.util.BlockEntityUtil; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; import net.minecraft.core.BlockPos; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.Tag; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.item.DyeColor; -import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.gameevent.GameEvent; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public class LaptopBlockEntity extends NetworkDeviceBlockEntity.Colored { - private static final int OPENED_ANGLE = 102; - - private boolean open = false; - - private CompoundTag applicationData = new CompoundTag(); - private CompoundTag systemData = new CompoundTag(); - private FileSystem fileSystem; - - @Environment(EnvType.CLIENT) - private int rotation; - - @Environment(EnvType.CLIENT) - private int prevRotation; - - private DyeColor externalDriveColor; +public class LaptopBlockEntity extends ComputerBlockEntity { public LaptopBlockEntity(BlockPos pWorldPosition, BlockState pBlockState) { super(DeviceBlockEntities.LAPTOP.get(), pWorldPosition, pBlockState); } - - @Override - public String getDeviceName() { - return "Laptop"; - } - - @Override - public void tick() { - super.tick(); - assert level != null; - if (level.isClientSide) { - prevRotation = rotation; - if (!open) { - if (rotation > 0) { - rotation -= 10F; - } - } else { - if (rotation < OPENED_ANGLE) { - rotation += 10F; - } - } - } - } - - @Override - public void load(@NotNull CompoundTag compound) { - super.load(compound); - if (compound.contains("open")) { - this.open = compound.getBoolean("open"); - this.getBlockState().setValue(LaptopBlock.OPEN, open); - } - if (compound.contains("system_data", Tag.TAG_COMPOUND)) { - this.systemData = compound.getCompound("system_data"); - } - if (compound.contains("application_data", Tag.TAG_COMPOUND)) { - this.applicationData = compound.getCompound("application_data"); - } - if (compound.contains("file_system")) { - this.fileSystem = new FileSystem(this, compound.getCompound("file_system")); - } - if (compound.contains("external_drive_color", Tag.TAG_BYTE)) { - this.externalDriveColor = null; - if (compound.getByte("external_drive_color") != -1) { - this.externalDriveColor = DyeColor.byId(compound.getByte("external_drive_color")); - } - } - } - - @Override - public void saveAdditional(@NotNull CompoundTag compound) { - super.saveAdditional(compound); - compound.putBoolean("open", open); - - if (systemData != null) { - compound.put("system_data", systemData); - } - - if (applicationData != null) { - compound.put("application_data", applicationData); - } - - if (fileSystem != null) { - compound.put("file_system", fileSystem.toTag()); - } - } - - @Override - public CompoundTag saveSyncTag() { - CompoundTag tag = super.saveSyncTag(); - tag.putBoolean("open", open); - tag.put("system_data", getSystemData()); - - if (getFileSystem().getAttachedDrive() != null) { - tag.putByte("external_drive_color", (byte) getFileSystem().getAttachedDriveColor().getId()); - } else { - tag.putByte("external_drive_color", (byte) -1); - } - - return tag; - } - - // Todo: Port to 1.18.2 if possible -// @Override -// public double getMaxRenderDistanceSquared() { -// return 16384; -// } -// -// public AxisAlignedBB getRenderBoundingBox() { -// return INFINITE_EXTENT_AABB; -// } - - public void openClose(@Nullable Entity entity) { - Level level = this.level; - if (level != null) { - level.gameEvent(!open ? GameEvent.BLOCK_OPEN : GameEvent.BLOCK_CLOSE, getBlockPos(), GameEvent.Context.of(entity, this.getBlockState())); - } - boolean oldOpen = open; - open = !getBlockState().getValue(LaptopBlock.OPEN); - if (oldOpen != open) { - pipeline.putBoolean("open", open); - var d = getBlockState().setValue(LaptopBlock.OPEN, open); - this.level.setBlock(this.getBlockPos(), d, 18); - sync(); - } - - if (level != null) { - markUpdated(); - doNeighborUpdates(level, this.getBlockPos(), this.getBlockState()); - } - } - - private static void doNeighborUpdates(Level level, BlockPos pos, BlockState state) { - state.updateNeighbourShapes(level, pos, 3); - } - - public boolean isOpen() { - return open; - } - - public CompoundTag getApplicationData() { - return applicationData != null ? applicationData : new CompoundTag(); - } - - public CompoundTag getSystemData() { - if (systemData == null) { - systemData = new CompoundTag(); - } - return systemData; - } - - public void setSystemData(CompoundTag systemData) { - this.systemData = systemData; - setChanged(); - assert level != null; - BlockEntityUtil.markBlockForUpdate(level, worldPosition); - } - - public FileSystem getFileSystem() { - if (fileSystem == null) { - fileSystem = new FileSystem(this, new CompoundTag()); - } - return fileSystem; - } - - public void setApplicationData(String appId, CompoundTag applicationData) { - this.applicationData = applicationData; - setChanged(); - assert level != null; - BlockEntityUtil.markBlockForUpdate(level, worldPosition); - } - - @Environment(EnvType.CLIENT) - public float getScreenAngle(float partialTicks) { - return -OPENED_ANGLE * ((prevRotation + (rotation - prevRotation) * partialTicks) / OPENED_ANGLE); - } - - @Environment(EnvType.CLIENT) - public boolean isExternalDriveAttached() { - return externalDriveColor != null; - } - - @Environment(EnvType.CLIENT) - public DyeColor getExternalDriveColor() { - return externalDriveColor; - } } diff --git a/common/src/main/java/com/ultreon/devices/block/entity/MacMaxXBlockEntity.java b/common/src/main/java/com/ultreon/devices/block/entity/MacMaxXBlockEntity.java new file mode 100644 index 000000000..be2f852bd --- /dev/null +++ b/common/src/main/java/com/ultreon/devices/block/entity/MacMaxXBlockEntity.java @@ -0,0 +1,24 @@ +package com.ultreon.devices.block.entity; + +import com.ultreon.devices.init.DeviceBlockEntities; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.block.state.BlockState; +import software.bernie.geckolib3.core.IAnimatable; +import software.bernie.geckolib3.core.manager.AnimationData; +import software.bernie.geckolib3.core.manager.AnimationFactory; + +public class MacMaxXBlockEntity extends ComputerBlockEntity implements IAnimatable { + public MacMaxXBlockEntity(BlockPos pWorldPosition, BlockState pBlockState) { + super(DeviceBlockEntities.MAC_MAX_X.get(), pWorldPosition, pBlockState); + } + + @Override + public void registerControllers(AnimationData animationData) { + + } + + @Override + public AnimationFactory getFactory() { + return new AnimationFactory(this); + } +} diff --git a/common/src/main/java/com/ultreon/devices/block/entity/renderer/LaptopRenderer.java b/common/src/main/java/com/ultreon/devices/block/entity/renderer/LaptopRenderer.java index d5262ad9c..4da2cbdc3 100644 --- a/common/src/main/java/com/ultreon/devices/block/entity/renderer/LaptopRenderer.java +++ b/common/src/main/java/com/ultreon/devices/block/entity/renderer/LaptopRenderer.java @@ -5,9 +5,9 @@ import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.math.Quaternion; import com.mojang.math.Vector3f; +import com.ultreon.devices.block.ComputerBlock; import com.ultreon.devices.block.LaptopBlock; import com.ultreon.devices.block.entity.LaptopBlockEntity; -import com.ultreon.devices.core.laptop.client.ClientLaptop; import com.ultreon.devices.init.DeviceItems; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.MultiBufferSource; @@ -42,7 +42,7 @@ public void render(LaptopBlockEntity blockEntity, float partialTick, PoseStack p // poseStack.popPose(); var direction = blockEntity.getBlockState().getValue(LaptopBlock.FACING).getClockWise().toYRot(); ItemEntity entityItem = new ItemEntity(Minecraft.getInstance().level, 0D, 0D, 0D, ItemStack.EMPTY); - BlockState state = blockEntity.getBlock().defaultBlockState().setValue(LaptopBlock.TYPE, LaptopBlock.Type.SCREEN); + BlockState state = blockEntity.getBlock().defaultBlockState().setValue(ComputerBlock.TYPE, LaptopBlock.Type.SCREEN); BlockPos pos = blockEntity.getBlockPos(); RenderSystem.setShaderTexture(0, InventoryMenu.BLOCK_ATLAS); diff --git a/common/src/main/java/com/ultreon/devices/core/Laptop.java b/common/src/main/java/com/ultreon/devices/core/Laptop.java index 4fbb6f7b3..66a112d4e 100644 --- a/common/src/main/java/com/ultreon/devices/core/Laptop.java +++ b/common/src/main/java/com/ultreon/devices/core/Laptop.java @@ -15,7 +15,7 @@ import com.ultreon.devices.api.task.Callback; import com.ultreon.devices.api.task.Task; import com.ultreon.devices.api.task.TaskManager; -import com.ultreon.devices.block.entity.LaptopBlockEntity; +import com.ultreon.devices.block.entity.ComputerBlockEntity; import com.ultreon.devices.core.task.TaskInstallApp; import com.ultreon.devices.object.AppInfo; import com.ultreon.devices.programs.system.DiagnosticsApp; @@ -48,8 +48,10 @@ import java.awt.*; import java.io.ByteArrayOutputStream; import java.io.PrintStream; +import java.util.ArrayList; import java.util.List; -import java.util.*; +import java.util.Objects; +import java.util.Optional; import java.util.concurrent.CopyOnWriteArrayList; //TODO Intro message (created by mrcrayfish, donate here) @@ -117,7 +119,7 @@ public static Font getFont() { * * @param laptop the block entity of the laptop in-game, if the laptop is not in-game, the level passed to it should be null. */ - public Laptop(LaptopBlockEntity laptop) { + public Laptop(ComputerBlockEntity laptop) { this(laptop, false); } @@ -126,7 +128,7 @@ public Laptop(LaptopBlockEntity laptop) { * * @param laptop the block entity of the laptop in-game, if the laptop is not in-game, the level passed to it should be null. */ - public Laptop(LaptopBlockEntity laptop, boolean worldLess) { + public Laptop(ComputerBlockEntity laptop, boolean worldLess) { super(Component.literal("Laptop")); instance = this; diff --git a/common/src/main/java/com/ultreon/devices/core/io/FileSystem.java b/common/src/main/java/com/ultreon/devices/core/io/FileSystem.java index d42a73f4d..02629d67a 100644 --- a/common/src/main/java/com/ultreon/devices/core/io/FileSystem.java +++ b/common/src/main/java/com/ultreon/devices/core/io/FileSystem.java @@ -7,7 +7,7 @@ import com.ultreon.devices.api.task.Callback; import com.ultreon.devices.api.task.Task; import com.ultreon.devices.api.task.TaskManager; -import com.ultreon.devices.block.entity.LaptopBlockEntity; +import com.ultreon.devices.block.entity.ComputerBlockEntity; import com.ultreon.devices.core.Laptop; import com.ultreon.devices.core.io.action.FileAction; import com.ultreon.devices.core.io.drive.AbstractDrive; @@ -50,9 +50,9 @@ public class FileSystem { private AbstractDrive attachedDrive = null; private DyeColor attachedDriveColor = DyeColor.RED; - private final LaptopBlockEntity blockEntity; + private final ComputerBlockEntity blockEntity; - public FileSystem(LaptopBlockEntity blockEntity, CompoundTag tag) { + public FileSystem(ComputerBlockEntity blockEntity, CompoundTag tag) { this.blockEntity = blockEntity; load(tag); diff --git a/common/src/main/java/com/ultreon/devices/core/io/ServerFolder.java b/common/src/main/java/com/ultreon/devices/core/io/ServerFolder.java index 1933887d1..5ebce4e3f 100644 --- a/common/src/main/java/com/ultreon/devices/core/io/ServerFolder.java +++ b/common/src/main/java/com/ultreon/devices/core/io/ServerFolder.java @@ -187,7 +187,7 @@ public ServerFolder copyStructure() { return folder; } - /*public void print(int startingDepth) + /*public void.json print(int startingDepth) { String indent = ""; for(int i = 0; i < startingDepth; i++) diff --git a/common/src/main/java/com/ultreon/devices/core/io/task/TaskGetFiles.java b/common/src/main/java/com/ultreon/devices/core/io/task/TaskGetFiles.java index 7b8c122a4..0aad4a4fe 100644 --- a/common/src/main/java/com/ultreon/devices/core/io/task/TaskGetFiles.java +++ b/common/src/main/java/com/ultreon/devices/core/io/task/TaskGetFiles.java @@ -2,7 +2,7 @@ import com.ultreon.devices.api.io.Folder; import com.ultreon.devices.api.task.Task; -import com.ultreon.devices.block.entity.LaptopBlockEntity; +import com.ultreon.devices.block.entity.ComputerBlockEntity; import com.ultreon.devices.core.io.FileSystem; import com.ultreon.devices.core.io.ServerFile; import com.ultreon.devices.core.io.ServerFolder; @@ -65,7 +65,7 @@ public void prepareRequest(CompoundTag tag) { @Override public void processRequest(CompoundTag tag, Level level, Player player) { BlockEntity tileEntity = level.getChunkAt(BlockPos.of(tag.getLong("pos"))).getBlockEntity(BlockPos.of(tag.getLong("pos")), LevelChunk.EntityCreationType.IMMEDIATE); - if (tileEntity instanceof LaptopBlockEntity laptop) { + if (tileEntity instanceof ComputerBlockEntity laptop) { FileSystem fileSystem = laptop.getFileSystem(); UUID uuid = UUID.fromString(tag.getString("uuid")); AbstractDrive serverDrive = fileSystem.getAvailableDrives(level, true).get(uuid); diff --git a/common/src/main/java/com/ultreon/devices/core/io/task/TaskGetMainDrive.java b/common/src/main/java/com/ultreon/devices/core/io/task/TaskGetMainDrive.java index bc1735c46..0a75c4789 100644 --- a/common/src/main/java/com/ultreon/devices/core/io/task/TaskGetMainDrive.java +++ b/common/src/main/java/com/ultreon/devices/core/io/task/TaskGetMainDrive.java @@ -3,7 +3,7 @@ import com.ultreon.devices.api.io.Drive; import com.ultreon.devices.api.io.Folder; import com.ultreon.devices.api.task.Task; -import com.ultreon.devices.block.entity.LaptopBlockEntity; +import com.ultreon.devices.block.entity.ComputerBlockEntity; import com.ultreon.devices.core.Laptop; import com.ultreon.devices.core.io.FileSystem; import com.ultreon.devices.core.io.drive.AbstractDrive; @@ -39,7 +39,7 @@ public void prepareRequest(CompoundTag tag) { @Override public void processRequest(CompoundTag tag, Level level, Player player) { BlockEntity tileEntity = level.getBlockEntity(BlockPos.of(tag.getLong("pos"))); - if (tileEntity instanceof LaptopBlockEntity laptop) { + if (tileEntity instanceof ComputerBlockEntity laptop) { FileSystem fileSystem = laptop.getFileSystem(); mainDrive = fileSystem.getMainDrive(); this.setSuccessful(); diff --git a/common/src/main/java/com/ultreon/devices/core/io/task/TaskGetStructure.java b/common/src/main/java/com/ultreon/devices/core/io/task/TaskGetStructure.java index e4ca329f3..1e501e96b 100644 --- a/common/src/main/java/com/ultreon/devices/core/io/task/TaskGetStructure.java +++ b/common/src/main/java/com/ultreon/devices/core/io/task/TaskGetStructure.java @@ -2,7 +2,7 @@ import com.ultreon.devices.api.io.Drive; import com.ultreon.devices.api.task.Task; -import com.ultreon.devices.block.entity.LaptopBlockEntity; +import com.ultreon.devices.block.entity.ComputerBlockEntity; import com.ultreon.devices.core.io.FileSystem; import com.ultreon.devices.core.io.ServerFolder; import com.ultreon.devices.core.io.drive.AbstractDrive; @@ -42,7 +42,7 @@ public void prepareRequest(CompoundTag tag) { @Override public void processRequest(CompoundTag tag, Level level, Player player) { BlockEntity tileEntity = level.getBlockEntity(BlockPos.of(tag.getLong("pos"))); - if (tileEntity instanceof LaptopBlockEntity laptop) { + if (tileEntity instanceof ComputerBlockEntity laptop) { FileSystem fileSystem = laptop.getFileSystem(); UUID uuid = UUID.fromString(tag.getString("uuid")); AbstractDrive serverDrive = fileSystem.getAvailableDrives(level, true).get(uuid); diff --git a/common/src/main/java/com/ultreon/devices/core/io/task/TaskSendAction.java b/common/src/main/java/com/ultreon/devices/core/io/task/TaskSendAction.java index e96933324..5756d4767 100644 --- a/common/src/main/java/com/ultreon/devices/core/io/task/TaskSendAction.java +++ b/common/src/main/java/com/ultreon/devices/core/io/task/TaskSendAction.java @@ -2,7 +2,7 @@ import com.ultreon.devices.api.io.Drive; import com.ultreon.devices.api.task.Task; -import com.ultreon.devices.block.entity.LaptopBlockEntity; +import com.ultreon.devices.block.entity.ComputerBlockEntity; import com.ultreon.devices.core.Laptop; import com.ultreon.devices.core.io.FileSystem; import com.ultreon.devices.core.io.action.FileAction; @@ -45,7 +45,7 @@ public void prepareRequest(CompoundTag tag) { public void processRequest(CompoundTag tag, Level level, Player player) { FileAction action = FileAction.fromTag(tag.getCompound("action")); BlockEntity tileEntity = level.getChunkAt(BlockPos.of(tag.getLong("pos"))).getBlockEntity(BlockPos.of(tag.getLong("pos")), LevelChunk.EntityCreationType.IMMEDIATE); - if (tileEntity instanceof LaptopBlockEntity laptop) { + if (tileEntity instanceof ComputerBlockEntity laptop) { response = laptop.getFileSystem().readAction(tag.getString("uuid"), action, level); this.setSuccessful(); } diff --git a/common/src/main/java/com/ultreon/devices/core/io/task/TaskSetupFileBrowser.java b/common/src/main/java/com/ultreon/devices/core/io/task/TaskSetupFileBrowser.java index 944c86ca3..67939a427 100644 --- a/common/src/main/java/com/ultreon/devices/core/io/task/TaskSetupFileBrowser.java +++ b/common/src/main/java/com/ultreon/devices/core/io/task/TaskSetupFileBrowser.java @@ -1,7 +1,7 @@ package com.ultreon.devices.core.io.task; import com.ultreon.devices.api.task.Task; -import com.ultreon.devices.block.entity.LaptopBlockEntity; +import com.ultreon.devices.block.entity.ComputerBlockEntity; import com.ultreon.devices.core.io.FileSystem; import com.ultreon.devices.core.io.drive.AbstractDrive; import net.minecraft.core.BlockPos; @@ -44,7 +44,7 @@ public void prepareRequest(CompoundTag tag) { @Override public void processRequest(CompoundTag tag, Level level, Player player) { BlockEntity tileEntity = level.getChunkAt(BlockPos.of(tag.getLong("pos"))).getBlockEntity(BlockPos.of(tag.getLong("pos")), LevelChunk.EntityCreationType.IMMEDIATE); - if (tileEntity instanceof LaptopBlockEntity laptop) { + if (tileEntity instanceof ComputerBlockEntity laptop) { FileSystem fileSystem = laptop.getFileSystem(); if (tag.getBoolean("include_main")) { mainDrive = fileSystem.getMainDrive(); diff --git a/common/src/main/java/com/ultreon/devices/core/laptop/common/TaskBar.java b/common/src/main/java/com/ultreon/devices/core/laptop/common/TaskBar.java index 59f740569..99ab39c09 100644 --- a/common/src/main/java/com/ultreon/devices/core/laptop/common/TaskBar.java +++ b/common/src/main/java/com/ultreon/devices/core/laptop/common/TaskBar.java @@ -3,31 +3,15 @@ import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.PoseStack; import com.ultreon.devices.Devices; -import com.ultreon.devices.api.TrayItemAdder; -import com.ultreon.devices.api.app.Application; -import com.ultreon.devices.api.event.LaptopEvent; -import com.ultreon.devices.api.utils.RenderUtil; import com.ultreon.devices.core.laptop.client.ClientLaptop; -import com.ultreon.devices.core.network.TrayItemWifi; -import com.ultreon.devices.object.AppInfo; -import com.ultreon.devices.object.TrayItem; -import com.ultreon.devices.programs.system.AppStore; -import com.ultreon.devices.programs.system.FileBrowserApp; -import com.ultreon.devices.programs.system.SettingsApp; -import com.ultreon.devices.programs.system.SystemApp; import com.ultreon.devices.programs.system.object.ColorScheme; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.GuiComponent; -import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import org.slf4j.Marker; import org.slf4j.MarkerFactory; import java.awt.*; -import java.util.ArrayList; -import java.util.List; -import java.util.function.Predicate; public class TaskBar { public static final ResourceLocation APP_BAR_GUI = new ResourceLocation("devices:textures/gui/application_bar.png"); @@ -44,15 +28,15 @@ public TaskBar(ClientLaptop laptop) { this.laptop = laptop; } -// public void init() { +// public void.json init() { // this.trayItems.forEach(TrayItem::init); // } -// public void init(int posX, int posY) { +// public void.json init(int posX, int posY) { // init(); // } // -// public void onTick() { +// public void.json onTick() { // trayItems.forEach(TrayItem::tick); // } diff --git a/common/src/main/java/com/ultreon/devices/core/task/TaskInstallApp.java b/common/src/main/java/com/ultreon/devices/core/task/TaskInstallApp.java index bef35408d..67b7bb43d 100644 --- a/common/src/main/java/com/ultreon/devices/core/task/TaskInstallApp.java +++ b/common/src/main/java/com/ultreon/devices/core/task/TaskInstallApp.java @@ -1,7 +1,7 @@ package com.ultreon.devices.core.task; import com.ultreon.devices.api.task.Task; -import com.ultreon.devices.block.entity.LaptopBlockEntity; +import com.ultreon.devices.block.entity.ComputerBlockEntity; import com.ultreon.devices.object.AppInfo; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; @@ -47,7 +47,7 @@ public void processRequest(CompoundTag tag, Level level, Player player) { System.out.println(level.getBlockState(BlockPos.of(tag.getLong("pos"))).getBlock().toString()); BlockEntity tileEntity = level.getChunkAt(BlockPos.of(tag.getLong("pos"))).getBlockEntity(BlockPos.of(tag.getLong("pos")), LevelChunk.EntityCreationType.IMMEDIATE); System.out.println(tileEntity); - if (tileEntity instanceof LaptopBlockEntity laptop) { + if (tileEntity instanceof ComputerBlockEntity laptop) { System.out.println("laptop is made out of laptop"); CompoundTag systemData = laptop.getSystemData(); ListTag list = systemData.getList("InstalledApps", Tag.TAG_STRING); diff --git a/common/src/main/java/com/ultreon/devices/entity/SeatEntity.java b/common/src/main/java/com/ultreon/devices/entity/SeatEntity.java index ef245fd36..52cd77b25 100644 --- a/common/src/main/java/com/ultreon/devices/entity/SeatEntity.java +++ b/common/src/main/java/com/ultreon/devices/entity/SeatEntity.java @@ -9,9 +9,6 @@ import net.minecraft.world.entity.EntityDimensions; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.Pose; -import net.minecraft.world.entity.decoration.ArmorStand; -import net.minecraft.world.entity.vehicle.Boat; -import net.minecraft.world.entity.vehicle.Minecart; import net.minecraft.world.level.Level; import net.minecraft.world.phys.AABB; @@ -83,7 +80,7 @@ public Packet getAddEntityPacket() { } // @Override -// protected void init() {} +// protected void.json init() {} @Override protected void readAdditionalSaveData(CompoundTag compound) {} diff --git a/common/src/main/java/com/ultreon/devices/event/WorldDataHandler.java b/common/src/main/java/com/ultreon/devices/event/WorldDataHandler.java index 2f7ee3b0f..a96b1f08d 100644 --- a/common/src/main/java/com/ultreon/devices/event/WorldDataHandler.java +++ b/common/src/main/java/com/ultreon/devices/event/WorldDataHandler.java @@ -13,7 +13,7 @@ public class WorldDataHandler { private static final LevelResource DEVICES_MOD_DATA = new LevelResource("data/devices-mod"); // @SubscribeEvent -// public void load(final LifecycleEvent.START event) { +// public void.json load(final LifecycleEvent.START event) { //// LifecycleEvent.SERVER_STARTING; // final File modData = Objects.requireNonNull(event.getServer(), "World loaded without server").getWorldPath(DEVICES_MOD_DATA).toFile(); // if (!modData.exists()) { @@ -29,7 +29,7 @@ public class WorldDataHandler { // } // @SubscribeEvent -// public void save(final WorldEvent.Save event) { +// public void.json save(final WorldEvent.Save event) { // LifecycleEvent.SERVER_LEVEL_SAVE // final MinecraftServer server = event.getWorld().getServer(); // if (server == null) { diff --git a/common/src/main/java/com/ultreon/devices/geo/MacMaxXModel.java b/common/src/main/java/com/ultreon/devices/geo/MacMaxXModel.java new file mode 100644 index 000000000..dddfca252 --- /dev/null +++ b/common/src/main/java/com/ultreon/devices/geo/MacMaxXModel.java @@ -0,0 +1,23 @@ +package com.ultreon.devices.geo; + +import com.ultreon.devices.Devices; +import com.ultreon.devices.block.entity.MacMaxXBlockEntity; +import net.minecraft.resources.ResourceLocation; +import software.bernie.geckolib3.model.AnimatedGeoModel; + +public class MacMaxXModel extends AnimatedGeoModel { + @Override + public ResourceLocation getModelResource(MacMaxXBlockEntity object) { + return Devices.res("geo/mac_max_x.geo.json"); + } + + @Override + public ResourceLocation getTextureResource(MacMaxXBlockEntity object) { + return Devices.res("textures/block/mac_max_x.png"); + } + + @Override + public ResourceLocation getAnimationResource(MacMaxXBlockEntity animatable) { + return Devices.res("animations/mac_max_x.animation.json"); + } +} \ No newline at end of file diff --git a/common/src/main/java/com/ultreon/devices/init/DeviceBlockEntities.java b/common/src/main/java/com/ultreon/devices/init/DeviceBlockEntities.java index d357f8780..cec393d67 100644 --- a/common/src/main/java/com/ultreon/devices/init/DeviceBlockEntities.java +++ b/common/src/main/java/com/ultreon/devices/init/DeviceBlockEntities.java @@ -14,6 +14,7 @@ public class DeviceBlockEntities { public static final RegistrySupplier> PAPER = REGISTER.register(Devices.id("paper"), () -> BlockEntityType.Builder.of(PaperBlockEntity::new, DeviceBlocks.PAPER.get()).build(null)); public static final RegistrySupplier> LAPTOP = REGISTER.register(Devices.id("laptop"), () -> BlockEntityType.Builder.of(LaptopBlockEntity::new, DeviceBlocks.getAllLaptops().toArray(new Block[]{})).build(null)); + public static final RegistrySupplier> MAC_MAX_X = REGISTER.register(Devices.id("mac_max_x"), () -> BlockEntityType.Builder.of(MacMaxXBlockEntity::new, DeviceBlocks.MAC_MAX_X.get()).build(null)); public static final RegistrySupplier> PRINTER = REGISTER.register(Devices.id("printer"), () -> BlockEntityType.Builder.of(PrinterBlockEntity::new, DeviceBlocks.getAllPrinters().toArray(new Block[]{})).build(null)); public static final RegistrySupplier> ROUTER = REGISTER.register(Devices.id("router"), () -> BlockEntityType.Builder.of(RouterBlockEntity::new, DeviceBlocks.getAllRouters().toArray(new Block[]{})).build(null)); public static final RegistrySupplier> SEAT = REGISTER.register(Devices.id("seat"), () -> BlockEntityType.Builder.of(OfficeChairBlockEntity::new, DeviceBlocks.getAllOfficeChairs().toArray(new Block[]{})).build(null)); diff --git a/common/src/main/java/com/ultreon/devices/init/DeviceBlocks.java b/common/src/main/java/com/ultreon/devices/init/DeviceBlocks.java index 829f44145..7c38161fc 100644 --- a/common/src/main/java/com/ultreon/devices/init/DeviceBlocks.java +++ b/common/src/main/java/com/ultreon/devices/init/DeviceBlocks.java @@ -34,6 +34,8 @@ public static void register() { public static final RegistrySupplier RED_LAPTOP = REGISTER.register(Devices.id("red_laptop"), () -> new LaptopBlock(DyeColor.RED)); public static final RegistrySupplier BLACK_LAPTOP = REGISTER.register(Devices.id("black_laptop"), () -> new LaptopBlock(DyeColor.BLACK)); + public static final RegistrySupplier MAC_MAX_X = REGISTER.register(Devices.id("mac_max_x"), MacMaxXBlock::new); + public static final RegistrySupplier WHITE_PRINTER = REGISTER.register(Devices.id("white_printer"), () -> new PrinterBlock(DyeColor.WHITE)); public static final RegistrySupplier ORANGE_PRINTER = REGISTER.register(Devices.id("orange_printer"), () -> new PrinterBlock(DyeColor.ORANGE)); public static final RegistrySupplier MAGENTA_PRINTER = REGISTER.register(Devices.id("magenta_printer"), () -> new PrinterBlock(DyeColor.MAGENTA)); diff --git a/common/src/main/java/com/ultreon/devices/init/DeviceItems.java b/common/src/main/java/com/ultreon/devices/init/DeviceItems.java index 7d9a82149..add6a3a84 100644 --- a/common/src/main/java/com/ultreon/devices/init/DeviceItems.java +++ b/common/src/main/java/com/ultreon/devices/init/DeviceItems.java @@ -1,7 +1,7 @@ package com.ultreon.devices.init; -import com.ultreon.devices.ModDeviceTypes; import com.ultreon.devices.Devices; +import com.ultreon.devices.ModDeviceTypes; import com.ultreon.devices.item.*; import dev.architectury.registry.registries.Registrar; import dev.architectury.registry.registries.RegistrySupplier; @@ -19,22 +19,25 @@ public class DeviceItems { private static final Registrar REGISTER = Devices.REGISTRIES.get().get(Registry.ITEM_REGISTRY); // Laptops - public static final RegistrySupplier WHITE_LAPTOP = REGISTER.register(Devices.id("white_laptop"), () -> new ColoredDeviceItem(DeviceBlocks.WHITE_LAPTOP.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.WHITE, ModDeviceTypes.LAPTOP)); - public static final RegistrySupplier ORANGE_LAPTOP = REGISTER.register(Devices.id("orange_laptop"), () -> new ColoredDeviceItem(DeviceBlocks.ORANGE_LAPTOP.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.ORANGE, ModDeviceTypes.LAPTOP)); - public static final RegistrySupplier MAGENTA_LAPTOP = REGISTER.register(Devices.id("magenta_laptop"), () -> new ColoredDeviceItem(DeviceBlocks.MAGENTA_LAPTOP.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.MAGENTA, ModDeviceTypes.LAPTOP)); - public static final RegistrySupplier LIGHT_BLUE_LAPTOP = REGISTER.register(Devices.id("light_blue_laptop"), () -> new ColoredDeviceItem(DeviceBlocks.LIGHT_BLUE_LAPTOP.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.LIGHT_BLUE, ModDeviceTypes.LAPTOP)); - public static final RegistrySupplier YELLOW_LAPTOP = REGISTER.register(Devices.id("yellow_laptop"), () -> new ColoredDeviceItem(DeviceBlocks.YELLOW_LAPTOP.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.YELLOW, ModDeviceTypes.LAPTOP)); - public static final RegistrySupplier LIME_LAPTOP = REGISTER.register(Devices.id("lime_laptop"), () -> new ColoredDeviceItem(DeviceBlocks.LIME_LAPTOP.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.LIME, ModDeviceTypes.LAPTOP)); - public static final RegistrySupplier PINK_LAPTOP = REGISTER.register(Devices.id("pink_laptop"), () -> new ColoredDeviceItem(DeviceBlocks.PINK_LAPTOP.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.PINK, ModDeviceTypes.LAPTOP)); - public static final RegistrySupplier GRAY_LAPTOP = REGISTER.register(Devices.id("gray_laptop"), () -> new ColoredDeviceItem(DeviceBlocks.GRAY_LAPTOP.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.GRAY, ModDeviceTypes.LAPTOP)); - public static final RegistrySupplier LIGHT_GRAY_LAPTOP = REGISTER.register(Devices.id("light_gray_laptop"), () -> new ColoredDeviceItem(DeviceBlocks.LIGHT_GRAY_LAPTOP.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.LIGHT_GRAY, ModDeviceTypes.LAPTOP)); - public static final RegistrySupplier CYAN_LAPTOP = REGISTER.register(Devices.id("cyan_laptop"), () -> new ColoredDeviceItem(DeviceBlocks.CYAN_LAPTOP.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.CYAN, ModDeviceTypes.LAPTOP)); - public static final RegistrySupplier PURPLE_LAPTOP = REGISTER.register(Devices.id("purple_laptop"), () -> new ColoredDeviceItem(DeviceBlocks.PURPLE_LAPTOP.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.PURPLE, ModDeviceTypes.LAPTOP)); - public static final RegistrySupplier BLUE_LAPTOP = REGISTER.register(Devices.id("blue_laptop"), () -> new ColoredDeviceItem(DeviceBlocks.BLUE_LAPTOP.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.BLUE, ModDeviceTypes.LAPTOP)); - public static final RegistrySupplier BROWN_LAPTOP = REGISTER.register(Devices.id("brown_laptop"), () -> new ColoredDeviceItem(DeviceBlocks.BROWN_LAPTOP.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.BROWN, ModDeviceTypes.LAPTOP)); - public static final RegistrySupplier GREEN_LAPTOP = REGISTER.register(Devices.id("green_laptop"), () -> new ColoredDeviceItem(DeviceBlocks.GREEN_LAPTOP.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.GREEN, ModDeviceTypes.LAPTOP)); - public static final RegistrySupplier RED_LAPTOP = REGISTER.register(Devices.id("red_laptop"), () -> new ColoredDeviceItem(DeviceBlocks.RED_LAPTOP.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.RED, ModDeviceTypes.LAPTOP)); - public static final RegistrySupplier BLACK_LAPTOP = REGISTER.register(Devices.id("black_laptop"), () -> new ColoredDeviceItem(DeviceBlocks.BLACK_LAPTOP.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.BLACK, ModDeviceTypes.LAPTOP)); + public static final RegistrySupplier WHITE_LAPTOP = REGISTER.register(Devices.id("white_laptop"), () -> new ColoredDeviceItem(DeviceBlocks.WHITE_LAPTOP.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.WHITE, ModDeviceTypes.COMPUTER)); + public static final RegistrySupplier ORANGE_LAPTOP = REGISTER.register(Devices.id("orange_laptop"), () -> new ColoredDeviceItem(DeviceBlocks.ORANGE_LAPTOP.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.ORANGE, ModDeviceTypes.COMPUTER)); + public static final RegistrySupplier MAGENTA_LAPTOP = REGISTER.register(Devices.id("magenta_laptop"), () -> new ColoredDeviceItem(DeviceBlocks.MAGENTA_LAPTOP.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.MAGENTA, ModDeviceTypes.COMPUTER)); + public static final RegistrySupplier LIGHT_BLUE_LAPTOP = REGISTER.register(Devices.id("light_blue_laptop"), () -> new ColoredDeviceItem(DeviceBlocks.LIGHT_BLUE_LAPTOP.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.LIGHT_BLUE, ModDeviceTypes.COMPUTER)); + public static final RegistrySupplier YELLOW_LAPTOP = REGISTER.register(Devices.id("yellow_laptop"), () -> new ColoredDeviceItem(DeviceBlocks.YELLOW_LAPTOP.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.YELLOW, ModDeviceTypes.COMPUTER)); + public static final RegistrySupplier LIME_LAPTOP = REGISTER.register(Devices.id("lime_laptop"), () -> new ColoredDeviceItem(DeviceBlocks.LIME_LAPTOP.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.LIME, ModDeviceTypes.COMPUTER)); + public static final RegistrySupplier PINK_LAPTOP = REGISTER.register(Devices.id("pink_laptop"), () -> new ColoredDeviceItem(DeviceBlocks.PINK_LAPTOP.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.PINK, ModDeviceTypes.COMPUTER)); + public static final RegistrySupplier GRAY_LAPTOP = REGISTER.register(Devices.id("gray_laptop"), () -> new ColoredDeviceItem(DeviceBlocks.GRAY_LAPTOP.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.GRAY, ModDeviceTypes.COMPUTER)); + public static final RegistrySupplier LIGHT_GRAY_LAPTOP = REGISTER.register(Devices.id("light_gray_laptop"), () -> new ColoredDeviceItem(DeviceBlocks.LIGHT_GRAY_LAPTOP.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.LIGHT_GRAY, ModDeviceTypes.COMPUTER)); + public static final RegistrySupplier CYAN_LAPTOP = REGISTER.register(Devices.id("cyan_laptop"), () -> new ColoredDeviceItem(DeviceBlocks.CYAN_LAPTOP.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.CYAN, ModDeviceTypes.COMPUTER)); + public static final RegistrySupplier PURPLE_LAPTOP = REGISTER.register(Devices.id("purple_laptop"), () -> new ColoredDeviceItem(DeviceBlocks.PURPLE_LAPTOP.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.PURPLE, ModDeviceTypes.COMPUTER)); + public static final RegistrySupplier BLUE_LAPTOP = REGISTER.register(Devices.id("blue_laptop"), () -> new ColoredDeviceItem(DeviceBlocks.BLUE_LAPTOP.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.BLUE, ModDeviceTypes.COMPUTER)); + public static final RegistrySupplier BROWN_LAPTOP = REGISTER.register(Devices.id("brown_laptop"), () -> new ColoredDeviceItem(DeviceBlocks.BROWN_LAPTOP.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.BROWN, ModDeviceTypes.COMPUTER)); + public static final RegistrySupplier GREEN_LAPTOP = REGISTER.register(Devices.id("green_laptop"), () -> new ColoredDeviceItem(DeviceBlocks.GREEN_LAPTOP.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.GREEN, ModDeviceTypes.COMPUTER)); + public static final RegistrySupplier RED_LAPTOP = REGISTER.register(Devices.id("red_laptop"), () -> new ColoredDeviceItem(DeviceBlocks.RED_LAPTOP.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.RED, ModDeviceTypes.COMPUTER)); + public static final RegistrySupplier BLACK_LAPTOP = REGISTER.register(Devices.id("black_laptop"), () -> new ColoredDeviceItem(DeviceBlocks.BLACK_LAPTOP.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.BLACK, ModDeviceTypes.COMPUTER)); + + // Custom Computers + public static final RegistrySupplier MAC_MAX_X = REGISTER.register(Devices.id("mac_max_x"), () -> new ColoredDeviceItem(DeviceBlocks.MAC_MAX_X.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.BLACK, ModDeviceTypes.COMPUTER)); // Printers public static final RegistrySupplier WHITE_PRINTER = REGISTER.register(Devices.id("white_printer"), () -> new ColoredDeviceItem(DeviceBlocks.WHITE_PRINTER.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.WHITE, ModDeviceTypes.PRINTER)); @@ -137,7 +140,7 @@ public static List getAllLaptops() { return getAllItems() .filter(item -> item.asItem() instanceof ColoredDeviceItem) .map(item -> (ColoredDeviceItem) item.asItem()) - .filter(item -> item.getDeviceType() == ModDeviceTypes.LAPTOP) + .filter(item -> item.getDeviceType() == ModDeviceTypes.COMPUTER) .toList(); } diff --git a/common/src/main/java/com/ultreon/devices/init/DeviceSounds.java b/common/src/main/java/com/ultreon/devices/init/DeviceSounds.java index 247d8cc10..88778f431 100644 --- a/common/src/main/java/com/ultreon/devices/init/DeviceSounds.java +++ b/common/src/main/java/com/ultreon/devices/init/DeviceSounds.java @@ -33,7 +33,7 @@ public static void register() { // @Mod.EventBusSubscriber(modid = Reference.MOD_ID) // public static class RegistrationHandler { // @SubscribeEvent -// public static void registerSounds(final RegistryEvent.Register event) { +// public static void.json registerSounds(final RegistryEvent.Register event) { // event.getRegistry().register(PRINTER_PRINTING); // event.getRegistry().register(PRINTER_LOADING_PAPER); // } diff --git a/common/src/main/java/com/ultreon/devices/mixin/common/FontSetMixin.java b/common/src/main/java/com/ultreon/devices/mixin/common/FontSetMixin.java index eafb64c7a..7f39778de 100644 --- a/common/src/main/java/com/ultreon/devices/mixin/common/FontSetMixin.java +++ b/common/src/main/java/com/ultreon/devices/mixin/common/FontSetMixin.java @@ -1,15 +1,7 @@ package com.ultreon.devices.mixin.common; -import com.mojang.blaze3d.font.GlyphInfo; -import com.ultreon.devices.Devices; import net.minecraft.client.gui.font.FontSet; -import net.minecraft.resources.ResourceLocation; -import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(FontSet.class) public class FontSetMixin { @@ -17,7 +9,7 @@ public class FontSetMixin { // private static final GlyphInfo DEVICES_TAB_INFO = () -> 16.0f; // // @Inject(method = "getGlyphInfoForSpace", at = @At("HEAD")) -// public void getGlyphInfoForSpace(int i, CallbackInfoReturnable cir) { +// public void.json getGlyphInfoForSpace(int i, CallbackInfoReturnable cir) { // if (name.equals(Devices.res("laptop")) && i == 9) { // cir.setReturnValue(DEVICES_TAB_INFO); // } diff --git a/common/src/main/java/com/ultreon/devices/network/PacketHandler.java b/common/src/main/java/com/ultreon/devices/network/PacketHandler.java index bd3fc6b6d..646baf888 100644 --- a/common/src/main/java/com/ultreon/devices/network/PacketHandler.java +++ b/common/src/main/java/com/ultreon/devices/network/PacketHandler.java @@ -90,47 +90,47 @@ public static > void sendToDimension(Packet messageNotifi //INSTANCE.send(PacketDistributor.DIMENSION.with(() -> level), messageNotification); } -// public static > void sendToDimension(Packet messageNotification, Level level) { +// public static > void.json sendToDimension(Packet messageNotification, Level level) { // INSTANCE.send(PacketDistributor.DIMENSION.with(level::dimension), messageNotification); // } // -// public static > void sendToServer(Packet messageNotification) { +// public static > void.json sendToServer(Packet messageNotification) { // INSTANCE.send(PacketDistributor.SERVER.noArg(), messageNotification); // } // -// public static > void sendToAll(Packet messageNotification) { +// public static > void.json sendToAll(Packet messageNotification) { // INSTANCE.send(PacketDistributor.ALL.noArg(), messageNotification); // } // -// public static > void sendToAllAround(Packet messageNotification, ResourceKey level, double x, double y, double z, double radius) { +// public static > void.json sendToAllAround(Packet messageNotification, ResourceKey level, double x, double y, double z, double radius) { // INSTANCE.send(PacketDistributor.NEAR.with(() -> new PacketDistributor.TargetPoint(x, y, z, radius, level)), messageNotification); // } // -// public static > void sendToAllAround(Packet messageNotification, Level level, double x, double y, double z, double radius) { +// public static > void.json sendToAllAround(Packet messageNotification, Level level, double x, double y, double z, double radius) { // INSTANCE.send(PacketDistributor.NEAR.with(() -> new PacketDistributor.TargetPoint(x, y, z, radius, level.dimension())), messageNotification); // } // -// public static > void sendToTrackingChunk(Packet messageNotification, LevelChunk chunk) { +// public static > void.json sendToTrackingChunk(Packet messageNotification, LevelChunk chunk) { // INSTANCE.send(PacketDistributor.TRACKING_CHUNK.with(() -> chunk), messageNotification); // } // -// public static > void sendToTrackingChunk(Packet messageNotification, Level level, int x, int z) { +// public static > void.json sendToTrackingChunk(Packet messageNotification, Level level, int x, int z) { // INSTANCE.send(PacketDistributor.TRACKING_CHUNK.with(() -> level.getChunk(x, z)), messageNotification); // } // -// public static > void sendToTrackingEntity(Packet messageNotification, Entity entity) { +// public static > void.json sendToTrackingEntity(Packet messageNotification, Entity entity) { // INSTANCE.send(PacketDistributor.TRACKING_ENTITY.with(() -> entity), messageNotification); // } // -// public static > void sendToTrackingEntity(Packet messageNotification, Level level, int entityId) { +// public static > void.json sendToTrackingEntity(Packet messageNotification, Level level, int entityId) { // INSTANCE.send(PacketDistributor.TRACKING_ENTITY.with(() -> level.getEntity(entityId)), messageNotification); // } // -// public static > void sendToTrackingEntityAndSelf(Packet messageNotification, Entity entity) { +// public static > void.json sendToTrackingEntityAndSelf(Packet messageNotification, Entity entity) { // INSTANCE.send(PacketDistributor.TRACKING_ENTITY_AND_SELF.with(() -> entity), messageNotification); // } // -// public static > void sendToTrackingEntityAndSelf(Packet messageNotification, Level level, int entityId) { +// public static > void.json sendToTrackingEntityAndSelf(Packet messageNotification, Level level, int entityId) { // INSTANCE.send(PacketDistributor.TRACKING_ENTITY_AND_SELF.with(() -> level.getEntity(entityId)), messageNotification); // } } diff --git a/common/src/main/java/com/ultreon/devices/object/Player.java b/common/src/main/java/com/ultreon/devices/object/Player.java index 1d90f7965..72b96afd9 100644 --- a/common/src/main/java/com/ultreon/devices/object/Player.java +++ b/common/src/main/java/com/ultreon/devices/object/Player.java @@ -202,7 +202,7 @@ public void render(PoseStack pose, int x, int y, float partialTicks) { // this.bipedBodyWear.setRotationPoint(0f, 0f, 0f); // } // -// public void render(Entity entityIn, float p_78088_2_, float p_78088_3_, float p_78088_4_, float p_78088_5_, float p_78088_6_, float scale) { +// public void.json render(Entity entityIn, float p_78088_2_, float p_78088_3_, float p_78088_4_, float p_78088_5_, float p_78088_6_, float scale) { // this.setRotationAngles(p_78088_2_, p_78088_3_, p_78088_4_, p_78088_5_, p_78088_6_, scale, entityIn); // GlStateManager.pushMatrix(); // @@ -222,7 +222,7 @@ public void render(PoseStack pose, int x, int y, float partialTicks) { // GlStateManager.popMatrix(); // } // -// public void setRotationAngles(float p_78087_1_, float p_78087_2_, float p_78087_3_, float p_78087_4_, float p_78087_5_, float p_78087_6_, Entity entityIn) { +// public void.json setRotationAngles(float p_78087_1_, float p_78087_2_, float p_78087_3_, float p_78087_4_, float p_78087_5_, float p_78087_6_, Entity entityIn) { // super.setRotationAngles(p_78087_1_, p_78087_2_, p_78087_3_, p_78087_4_, p_78087_5_, p_78087_6_, entityIn); // copyModelAngles(this.bipedLeftLeg, this.bipedLeftLegwear); // copyModelAngles(this.bipedRightLeg, this.bipedRightLegwear); diff --git a/common/src/main/java/com/ultreon/devices/programs/debug/TextAreaApp.java b/common/src/main/java/com/ultreon/devices/programs/debug/TextAreaApp.java index c5f721ad8..a8c55f569 100644 --- a/common/src/main/java/com/ultreon/devices/programs/debug/TextAreaApp.java +++ b/common/src/main/java/com/ultreon/devices/programs/debug/TextAreaApp.java @@ -24,7 +24,7 @@ public class TextAreaApp extends Application { case "abstract", "continue", "for", "new", "switch", "assert", "default", "goto", "package", "synchronized", "boolean", "do", "if", "private", "this", "break", "double", "implements", "protected", "throw", "byte", "else", "import", "public", "throws", "case", "enum", "instanceof", "return", "transient", - "catch", "extends", "int", "short", "try", "char", "final", "interface", "static", "void", "class", + "catch", "extends", "int", "short", "try", "char", "final", "interface", "static", "void.json", "class", "finally", "long", "strictfp", "volatile", "const", "float", "native", "super", "while", "null", "record", "sealed" -> asArray(ChatFormatting.BLUE); default -> asArray(ChatFormatting.WHITE); diff --git a/common/src/main/java/com/ultreon/devices/programs/system/task/TaskUpdateApplicationData.java b/common/src/main/java/com/ultreon/devices/programs/system/task/TaskUpdateApplicationData.java index b91c90526..ce06db5ea 100644 --- a/common/src/main/java/com/ultreon/devices/programs/system/task/TaskUpdateApplicationData.java +++ b/common/src/main/java/com/ultreon/devices/programs/system/task/TaskUpdateApplicationData.java @@ -1,7 +1,7 @@ package com.ultreon.devices.programs.system.task; import com.ultreon.devices.api.task.Task; -import com.ultreon.devices.block.entity.LaptopBlockEntity; +import com.ultreon.devices.block.entity.ComputerBlockEntity; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.entity.player.Player; @@ -40,7 +40,7 @@ public void prepareRequest(CompoundTag tag) { @Override public void processRequest(CompoundTag tag, Level level, Player player) { BlockEntity tileEntity = level.getBlockEntity(new BlockPos(tag.getInt("posX"), tag.getInt("posY"), tag.getInt("posZ"))); - if (tileEntity instanceof LaptopBlockEntity laptop) { + if (tileEntity instanceof ComputerBlockEntity laptop) { laptop.setApplicationData(tag.getString("appId"), tag.getCompound("appData")); } this.setSuccessful(); diff --git a/common/src/main/java/com/ultreon/devices/programs/system/task/TaskUpdateSystemData.java b/common/src/main/java/com/ultreon/devices/programs/system/task/TaskUpdateSystemData.java index 2e335f9ef..8296ece08 100644 --- a/common/src/main/java/com/ultreon/devices/programs/system/task/TaskUpdateSystemData.java +++ b/common/src/main/java/com/ultreon/devices/programs/system/task/TaskUpdateSystemData.java @@ -1,7 +1,7 @@ package com.ultreon.devices.programs.system.task; import com.ultreon.devices.api.task.Task; -import com.ultreon.devices.block.entity.LaptopBlockEntity; +import com.ultreon.devices.block.entity.ComputerBlockEntity; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.entity.player.Player; @@ -33,7 +33,7 @@ public void prepareRequest(CompoundTag tag) { public void processRequest(CompoundTag tag, Level level, Player player) { BlockPos pos = BlockPos.of(tag.getLong("pos")); BlockEntity tileEntity = level.getChunkAt(pos).getBlockEntity(pos, LevelChunk.EntityCreationType.IMMEDIATE); - if (tileEntity instanceof LaptopBlockEntity laptop) + if (tileEntity instanceof ComputerBlockEntity laptop) laptop.setSystemData(tag.getCompound("data")); this.setSuccessful(); } diff --git a/common/src/main/resources/assets/devices/blockstates/mac_max_x_part.json b/common/src/main/resources/assets/devices/blockstates/mac_max_x_part.json new file mode 100644 index 000000000..c56dc52c3 --- /dev/null +++ b/common/src/main/resources/assets/devices/blockstates/mac_max_x_part.json @@ -0,0 +1,7 @@ +{ + "variants": { + "": { + "model": "devices:block/void" + } + } +} diff --git a/common/src/main/resources/assets/devices/geo/mac_max_x.geo.json b/common/src/main/resources/assets/devices/geo/mac_max_x.geo.json new file mode 100644 index 000000000..5d4d727f9 --- /dev/null +++ b/common/src/main/resources/assets/devices/geo/mac_max_x.geo.json @@ -0,0 +1,143 @@ +{ + "format_version": "1.12.0", + "minecraft:geometry": [ + { + "description": { + "identifier": "geometry.mac_max_x", + "texture_width": 128, + "texture_height": 128, + "visible_bounds_width": 4, + "visible_bounds_height": 3.5, + "visible_bounds_offset": [0, 1.25, 0] + }, + "bones": [ + { + "name": "bb_main", + "pivot": [0, 0, 0], + "cubes": [ + { + "origin": [-24, 34, -1], + "size": [48, 1, 2], + "uv": { + "north": {"uv": [58, 48], "uv_size": [48, 1]}, + "east": {"uv": [44, 62], "uv_size": [2, 1]}, + "south": {"uv": [58, 49], "uv_size": [48, 1]}, + "west": {"uv": [50, 63], "uv_size": [2, 1]}, + "up": {"uv": [46, 36], "uv_size": [48, 2]}, + "down": {"uv": [46, 40], "uv_size": [48, -2]} + } + }, + { + "origin": [-24, 3, -1], + "size": [48, 4, 2], + "uv": { + "north": {"uv": [46, 28], "uv_size": [48, 4]}, + "east": {"uv": [40, 62], "uv_size": [2, 4]}, + "south": {"uv": [46, 32], "uv_size": [48, 4]}, + "west": {"uv": [42, 62], "uv_size": [2, 4]}, + "up": {"uv": [46, 40], "uv_size": [48, 2]}, + "down": {"uv": [46, 44], "uv_size": [48, -2]} + } + }, + { + "origin": [23, 7, -1], + "size": [1, 27, 2], + "uv": { + "north": {"uv": [28, 56], "uv_size": [1, 27]}, + "east": {"uv": [4, 56], "uv_size": [2, 27]}, + "south": {"uv": [29, 56], "uv_size": [1, 27]}, + "west": {"uv": [6, 56], "uv_size": [2, 27]}, + "up": {"uv": [52, 63], "uv_size": [1, 2]}, + "down": {"uv": [53, 65], "uv_size": [1, -2]} + } + }, + { + "origin": [-24, 7, -1], + "size": [1, 27, 2], + "uv": { + "north": {"uv": [30, 56], "uv_size": [1, 27]}, + "east": {"uv": [8, 56], "uv_size": [2, 27]}, + "south": {"uv": [31, 56], "uv_size": [1, 27]}, + "west": {"uv": [10, 56], "uv_size": [2, 27]}, + "up": {"uv": [54, 63], "uv_size": [1, 2]}, + "down": {"uv": [55, 65], "uv_size": [1, -2]} + } + }, + { + "origin": [-23, 6, -0.5], + "size": [46, 28, 1.5], + "uv": { + "north": {"uv": [0, 0], "uv_size": [46, 28]}, + "east": {"uv": [24, 56], "uv_size": [1.5, 28]}, + "south": {"uv": [0, 28], "uv_size": [46, 28]}, + "west": {"uv": [26, 56], "uv_size": [1.5, 28]}, + "up": {"uv": [58, 44], "uv_size": [46, 1.5]}, + "down": {"uv": [58, 47.5], "uv_size": [46, -1.5]} + } + }, + { + "origin": [-10, 13, 0.5], + "size": [18, 14, 1.5], + "uv": { + "north": {"uv": [46, 0], "uv_size": [18, 14]}, + "east": {"uv": [32, 56], "uv_size": [1.5, 14]}, + "south": {"uv": [46, 14], "uv_size": [18, 14]}, + "west": {"uv": [34, 56], "uv_size": [1.5, 14]}, + "up": {"uv": [58, 50], "uv_size": [18, 1.5]}, + "down": {"uv": [58, 53.5], "uv_size": [18, -1.5]} + } + }, + { + "origin": [10, 0.5, 0.5], + "size": [4, 18.5, 2.5], + "uv": { + "north": {"uv": [46, 44], "uv_size": [4, 18.5]}, + "east": {"uv": [12, 56], "uv_size": [2.5, 18.5]}, + "south": {"uv": [50, 44], "uv_size": [4, 18.5]}, + "west": {"uv": [15, 56], "uv_size": [2.5, 18.5]}, + "up": {"uv": [42, 56], "uv_size": [4, 2.5]}, + "down": {"uv": [42, 61.5], "uv_size": [4, -2.5]} + } + }, + { + "origin": [9, 0, 0.5], + "size": [6, 0.5, 2.5], + "uv": { + "north": {"uv": [62, 62], "uv_size": [6, 0.5]}, + "east": {"uv": [62, 63], "uv_size": [2.5, 0.5]}, + "south": {"uv": [44, 63], "uv_size": [6, 0.5]}, + "west": {"uv": [64, 0], "uv_size": [2.5, 0.5]}, + "up": {"uv": [58, 57], "uv_size": [6, 2.5]}, + "down": {"uv": [36, 61.5], "uv_size": [6, -2.5]} + } + }, + { + "origin": [-16, 0.5, 0.5], + "size": [4, 18.5, 2.5], + "uv": { + "north": {"uv": [54, 44], "uv_size": [4, 18.5]}, + "east": {"uv": [18, 56], "uv_size": [2.5, 18.5]}, + "south": {"uv": [0, 56], "uv_size": [4, 18.5]}, + "west": {"uv": [21, 56], "uv_size": [2.5, 18.5]}, + "up": {"uv": [58, 60], "uv_size": [4, 2.5]}, + "down": {"uv": [36, 64.5], "uv_size": [4, -2.5]} + } + }, + { + "origin": [-17, 0, 0.5], + "size": [6, 0.5, 2.5], + "uv": { + "north": {"uv": [62, 60], "uv_size": [6, 0.5]}, + "east": {"uv": [56, 63], "uv_size": [2.5, 0.5]}, + "south": {"uv": [62, 61], "uv_size": [6, 0.5]}, + "west": {"uv": [59, 63], "uv_size": [2.5, 0.5]}, + "up": {"uv": [36, 56], "uv_size": [6, 2.5]}, + "down": {"uv": [58, 56.5], "uv_size": [6, -2.5]} + } + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/common/src/main/resources/assets/devices/lang/en_us.json b/common/src/main/resources/assets/devices/lang/en_us.json index 7a7f15a8c..2679f4c01 100644 --- a/common/src/main/resources/assets/devices/lang/en_us.json +++ b/common/src/main/resources/assets/devices/lang/en_us.json @@ -16,6 +16,8 @@ "block.devices.green_laptop": "Green Laptop", "block.devices.red_laptop": "Red Laptop", "block.devices.black_laptop": "Black Laptop", + "block.devices.mac_max_x": "Mac Max X+!", + "block.devices.mac_max_x_emoji": "Mac Max X+!:middle_finger:", "block.devices.white_router": "White Router", "block.devices.orange_router": "Orange Router", "block.devices.magenta_router": "Magenta Router", diff --git a/common/src/main/resources/assets/devices/models/block/void.json b/common/src/main/resources/assets/devices/models/block/void.json new file mode 100644 index 000000000..0e0dcd235 --- /dev/null +++ b/common/src/main/resources/assets/devices/models/block/void.json @@ -0,0 +1,3 @@ +{ + +} \ No newline at end of file diff --git a/common/src/main/resources/assets/devices/models/item/mac_max_x.json b/common/src/main/resources/assets/devices/models/item/mac_max_x.json new file mode 100644 index 000000000..0e4842af6 --- /dev/null +++ b/common/src/main/resources/assets/devices/models/item/mac_max_x.json @@ -0,0 +1,38 @@ +{ + "parent": "builtin/entity", + "textures": { + "particle": "block/quartz_block_bottom" + }, + "display": { + "gui": { + "rotation": [ 30, 45, 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 ] + }, + "head": { + "rotation": [ 0, 180, 0 ], + "translation": [ 0, 0, 0], + "scale":[ 1, 1, 1] + }, + "fixed": { + "rotation": [ 0, 180, 0 ], + "translation": [ 0, 0, 0], + "scale":[ 0.5, 0.5, 0.5 ] + }, + "thirdperson_righthand": { + "rotation": [ 75, 315, 0 ], + "translation": [ 0, 2.5, 0], + "scale": [ 0.375, 0.375, 0.375 ] + }, + "firstperson_righthand": { + "rotation": [ 0, 315, 0 ], + "translation": [ 0, 0, 0], + "scale": [ 0.4, 0.4, 0.4 ] + } + } +} diff --git a/common/src/main/resources/assets/devices/textures/block/mac_max_x.png b/common/src/main/resources/assets/devices/textures/block/mac_max_x.png new file mode 100644 index 0000000000000000000000000000000000000000..ce08c601cf37854ee9be9601b798a49a7c613149 GIT binary patch literal 3151 zcmeHIdr(t%7CuS9@CpH21YJZdjJueMR8vGC5DP1h%0sZ=n^@!_2n1778MUkfkBZ7coi{kPSC=lMk1(|^18WBkfHza$bg~6Fl|JYgEfA-GYx%Zwq_nh-P z-}jw!+SA>Mq_IW=07x#*j$QzG>=h4cE3n6_=K^!O>Idq#PA;!>9V>wB$5%RZZJ~jj12#Q}xQf z5nhiz<+<^Ljsm7PNznbB^TeKoO0j#phxBCKhAZN%`}H#~>V;BSLWrB2TbN!BJyG@~ z`DOe4aK6#C&ieTmY5ugbuF2aEZ8ezxydFY^G08nvP-s?%vwc|oO&Z?wEN~e0{SIY* zJw^alC$UrD)dAE@0gTT8aOl6MVFUkKY3YCoP``a=nZ3D0P9%D4#tqShHBMmhx~RYQFfR--jJP-fgu0@nBU%%lv#y zb==$uWcTRs-N+v=!1gmDj0fLlXNP9#w8WCz0#$+W$=o3@e26LHzY)UIUfkABOH0d; zEN0=1u$??ByRJapZSu+Ic43Jw$!#Vh1hw0{XD-XdHb|V^t_ps0bF&Y!9t`T-Z*&#W z2yFpmtnDk81Es{_#2VxG!otJLBx;a(RP}$vR5wib4<{waAlHc#QZpQm=mx({5oPAL zN;yab?M|`u%Y?kVJoC`d(1P<`fq{Wv$H^qD)aic-{j_J}D&k+xWgp-MS+(9+m)KoI zbJ&6d(wE~ur3{$x9&J+m%tCZWF|Z+NG58}R2)1f+O^Vck4hGwWFgB{ABpx0}?3u^g zGVQYdlsYZz_op1xQ-|QYGYAW-_Uzz97~g1pp2PA!P2o7HtdjQ)h*-kFY^sI1HV&gY z1&fNX2czIrk7%}plX+HeIkFO4y+(ac?Lo@(0Y4RDxBI ziCTk?fpPY)x|=Q*%%X2H76R;2BdPoL^Q1Uyw?CC;Vs0D2 zq|-3i9%%qIXG9g=bZ+U866gqSqGcsYqbRv3nMqZSEX>v6*u42mgt8THfqf|1!Sj3= zpBE!-Ph2f*AvCT8s$fo1EsYWEj9@jMgIyT(B>pSfD&FL4Jz@TiA}LC!%BtDP6EyY8 zQK3*slXy$% z)V)VIU7tcn^kX5>fQI9FUXqiTV)J>bn<9=AGlj$UrVki2x7mzn&63at{d@!!vREua zl|F{fWR%n{@%^3gnVd1JXEnG%OgxhKuW7*Bp#l!9Qu%_LhllU!6`V00*mXN4C1oO_ za5%h5qDFVXn5g7RhqE}QRdGg0j?#*Y-Q2KaMutv3`FB>($ilHFk}Ks3=EMRKN$Lwl z_o9(mllR4ANrpbaaP~Dn^cU>ztB$Xa4`=u_?v@g|8LAxbu%VHIg9!T?yE6-&rfdJw zY{Tz+MO=(vU6WI>iV^vA`2>Z8zmW}$;ByIf_B_*-pfx^M+2pX+KjFoLp!ywzJ;qp$ z7JIoZGgkc7BV};Rpq8H?>->&l+@4RfySW<#rz@32)`OyfzP>^lo^Fbxf7a5{g3a|) zrchWkh}3wkrK?JoZ=WTVDfiXlyjWUbziPNtM1!a(>nnTIdPYK7O?v^;VXrNB_ z;wGeMnjm~$MBrKN{Y~ekzrB^xIdb^waCk&!NRD*6Y-SrW4W7xrE#AePOJUxrf%@^3 z=Bt=Gexy* { + public MacMaxXRenderer(BlockEntityRendererProvider.Context rendererDispatcherIn) { + super(new MacMaxXModel()); + } +} \ No newline at end of file diff --git a/fabric/src/main/java/com/ultreon/devices/fabric/ClientModEventsImpl.java b/fabric/src/main/java/com/ultreon/devices/fabric/ClientModEventsImpl.java index 6b7240d6a..ed0171738 100644 --- a/fabric/src/main/java/com/ultreon/devices/fabric/ClientModEventsImpl.java +++ b/fabric/src/main/java/com/ultreon/devices/fabric/ClientModEventsImpl.java @@ -1,6 +1,9 @@ package com.ultreon.devices.fabric; +import com.ultreon.devices.block.entity.renderer.fabric.MacMaxXRenderer; +import com.ultreon.devices.init.DeviceBlockEntities; import com.ultreon.devices.object.AppInfo; +import dev.architectury.registry.client.rendering.BlockEntityRendererRegistry; import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap; import net.minecraft.client.renderer.RenderType; import net.minecraft.world.level.block.Block; @@ -14,4 +17,8 @@ public static void updateIcon(AppInfo info, int iconU, int iconV) { // info.setIconU(iconU); // info.setIconV(iconV); } + + public static void registerGeoRenderers() { + BlockEntityRendererRegistry.register(DeviceBlockEntities.MAC_MAX_X.get(), MacMaxXRenderer::new); + } } diff --git a/forge/build.gradle b/forge/build.gradle index 29dd5cb5d..84bc0fd7c 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -35,6 +35,9 @@ dependencies { common(project(path: ":common", configuration: "namedElements")) { transitive false } shadowCommon(project(path: ":common", configuration: "transformProductionForge")) { transitive = false } + modImplementation "software.bernie.geckolib:geckolib-forge-1.19:${geckolib_version_quilt}" + + modImplementation "curse.maven:emojiful-284324:4056367" forgeRuntimeLibrary "org.jetbrains.kotlin:kotlin-stdlib:1.7.10" forgeRuntimeLibrary "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.10" diff --git a/forge/src/main/java/com/ultreon/devices/block/entity/renderer/forge/MacMaxXRenderer.java b/forge/src/main/java/com/ultreon/devices/block/entity/renderer/forge/MacMaxXRenderer.java new file mode 100644 index 000000000..1aacf6ec2 --- /dev/null +++ b/forge/src/main/java/com/ultreon/devices/block/entity/renderer/forge/MacMaxXRenderer.java @@ -0,0 +1,12 @@ +package com.ultreon.devices.block.entity.renderer.forge; + +import com.ultreon.devices.block.entity.MacMaxXBlockEntity; +import com.ultreon.devices.geo.MacMaxXModel; +import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; +import software.bernie.geckolib3.renderers.geo.GeoBlockRenderer; + +public class MacMaxXRenderer extends GeoBlockRenderer { + public MacMaxXRenderer(BlockEntityRendererProvider.Context context) { + super(context, new MacMaxXModel()); + } +} \ No newline at end of file diff --git a/forge/src/main/java/com/ultreon/devices/data/client/ModBlockStateProvider.java b/forge/src/main/java/com/ultreon/devices/data/client/ModBlockStateProvider.java index 33ac75ef1..35606faab 100644 --- a/forge/src/main/java/com/ultreon/devices/data/client/ModBlockStateProvider.java +++ b/forge/src/main/java/com/ultreon/devices/data/client/ModBlockStateProvider.java @@ -1,25 +1,20 @@ package com.ultreon.devices.data.client; import com.ultreon.devices.Reference; -import com.ultreon.devices.block.LaptopBlock; -import com.ultreon.devices.block.OfficeChairBlock; -import com.ultreon.devices.block.PrinterBlock; -import com.ultreon.devices.block.RouterBlock; +import com.ultreon.devices.block.*; import com.ultreon.devices.init.DeviceBlocks; import dev.architectury.registry.registries.Registries; -import net.minecraft.core.BlockPos; import net.minecraft.core.Registry; import net.minecraft.data.DataGenerator; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.levelgen.feature.stateproviders.BlockStateProviderType; -import net.minecraftforge.client.model.generators.*; +import net.minecraftforge.client.model.generators.BlockStateProvider; +import net.minecraftforge.client.model.generators.ConfiguredModel; +import net.minecraftforge.client.model.generators.ModelFile; import net.minecraftforge.common.data.ExistingFileHelper; import org.jetbrains.annotations.NotNull; import java.util.Objects; -import java.util.Random; public class ModBlockStateProvider extends BlockStateProvider { public ModBlockStateProvider(DataGenerator gen, ExistingFileHelper exFileHelper) { @@ -63,7 +58,7 @@ public void simpleBlock(Block block) { private void laptop(LaptopBlock block) { getVariantBuilder(block).forAllStates(state -> { String name = Objects.requireNonNull(Registries.getId(block, Registry.BLOCK_REGISTRY)).getPath(); - var type = state.getValue(LaptopBlock.TYPE); + var type = state.getValue(ComputerBlock.TYPE); var a = ConfiguredModel.builder(); var q = a.modelFile(models().getBuilder(type == LaptopBlock.Type.BASE ? name : name + "_closed") .parent(new ModelFile.UncheckedModelFile(modLoc(type == LaptopBlock.Type.BASE ? "block/laptop_base" : "block/laptop_screen"))) diff --git a/forge/src/main/java/com/ultreon/devices/forge/ClientModEventsImpl.java b/forge/src/main/java/com/ultreon/devices/forge/ClientModEventsImpl.java index b869e81f9..f87fb2142 100644 --- a/forge/src/main/java/com/ultreon/devices/forge/ClientModEventsImpl.java +++ b/forge/src/main/java/com/ultreon/devices/forge/ClientModEventsImpl.java @@ -1,6 +1,9 @@ package com.ultreon.devices.forge; +import com.ultreon.devices.block.entity.renderer.forge.MacMaxXRenderer; +import com.ultreon.devices.init.DeviceBlockEntities; import com.ultreon.devices.object.AppInfo; +import dev.architectury.registry.client.rendering.BlockEntityRendererRegistry; import net.minecraft.client.renderer.ItemBlockRenderTypes; import net.minecraft.client.renderer.RenderType; import net.minecraft.world.level.block.Block; @@ -15,4 +18,8 @@ public static void updateIcon(AppInfo info, int iconU, int iconV) { ObfuscationReflectionHelper.setPrivateValue(AppInfo.class, info, iconU, "iconU"); ObfuscationReflectionHelper.setPrivateValue(AppInfo.class, info, iconV, "iconV"); } + + public static void registerGeoRenderers() { + BlockEntityRendererRegistry.register(DeviceBlockEntities.MAC_MAX_X.get(), MacMaxXRenderer::new); + } } diff --git a/gradle.properties b/gradle.properties index 97f26505f..4dcc97014 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,4 +8,9 @@ fabric_loader_version=0.14.8 fabric_api_version=0.60.0+1.19.2 forge_version=43.1.3 -mod_description=Adds working electronic devices into Minecraft! \ No newline at end of file +mod_description=Adds working electronic devices into Minecraft! + +# Geckolib +geckolib_version_fabric=3.1.20 +geckolib_version_quilt=3.1.20 +geckolib_version_forge=3.1.21 \ No newline at end of file From 06a7086a95fb0044813ed6a7ea0e9bbc66e99e1e Mon Sep 17 00:00:00 2001 From: Qboi123 Date: Tue, 1 Nov 2022 04:38:07 +0100 Subject: [PATCH 02/88] Yeah I failed --- .../ultreon/devices/geo/MacMaxXItemModel.java | 23 ++++++++++++++++++ .../com/ultreon/devices/init/DeviceItems.java | 2 +- .../com/ultreon/devices/item/MacMaxXItem.java | 23 ++++++++++++++++++ .../devices/textures/block/mac_max_x.png | Bin 3151 -> 6312 bytes .../devices/fabric/ClientModEventsImpl.java | 4 +++ .../devices/fabric/MacMaxXItemRenderer.java | 11 +++++++++ 6 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 common/src/main/java/com/ultreon/devices/geo/MacMaxXItemModel.java create mode 100644 common/src/main/java/com/ultreon/devices/item/MacMaxXItem.java create mode 100644 fabric/src/main/java/com/ultreon/devices/fabric/MacMaxXItemRenderer.java diff --git a/common/src/main/java/com/ultreon/devices/geo/MacMaxXItemModel.java b/common/src/main/java/com/ultreon/devices/geo/MacMaxXItemModel.java new file mode 100644 index 000000000..139cd760f --- /dev/null +++ b/common/src/main/java/com/ultreon/devices/geo/MacMaxXItemModel.java @@ -0,0 +1,23 @@ +package com.ultreon.devices.geo; + +import com.ultreon.devices.Devices; +import com.ultreon.devices.item.MacMaxXItem; +import net.minecraft.resources.ResourceLocation; +import software.bernie.geckolib3.model.AnimatedGeoModel; + +public class MacMaxXItemModel extends AnimatedGeoModel { + @Override + public ResourceLocation getModelResource(MacMaxXItem object) { + return Devices.res("geo/mac_max_x.geo.json"); + } + + @Override + public ResourceLocation getTextureResource(MacMaxXItem object) { + return Devices.res("textures/block/mac_max_x.png"); + } + + @Override + public ResourceLocation getAnimationResource(MacMaxXItem animatable) { + return Devices.res("animations/mac_max_x.animation.json"); + } +} \ No newline at end of file diff --git a/common/src/main/java/com/ultreon/devices/init/DeviceItems.java b/common/src/main/java/com/ultreon/devices/init/DeviceItems.java index add6a3a84..ebfdc6073 100644 --- a/common/src/main/java/com/ultreon/devices/init/DeviceItems.java +++ b/common/src/main/java/com/ultreon/devices/init/DeviceItems.java @@ -37,7 +37,7 @@ public class DeviceItems { public static final RegistrySupplier BLACK_LAPTOP = REGISTER.register(Devices.id("black_laptop"), () -> new ColoredDeviceItem(DeviceBlocks.BLACK_LAPTOP.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.BLACK, ModDeviceTypes.COMPUTER)); // Custom Computers - public static final RegistrySupplier MAC_MAX_X = REGISTER.register(Devices.id("mac_max_x"), () -> new ColoredDeviceItem(DeviceBlocks.MAC_MAX_X.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.BLACK, ModDeviceTypes.COMPUTER)); + public static final RegistrySupplier MAC_MAX_X = REGISTER.register(Devices.id("mac_max_x"), () -> new MacMaxXItem(DeviceBlocks.MAC_MAX_X.get(), new Item.Properties().tab(Devices.TAB_DEVICE))); // Printers public static final RegistrySupplier WHITE_PRINTER = REGISTER.register(Devices.id("white_printer"), () -> new ColoredDeviceItem(DeviceBlocks.WHITE_PRINTER.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.WHITE, ModDeviceTypes.PRINTER)); diff --git a/common/src/main/java/com/ultreon/devices/item/MacMaxXItem.java b/common/src/main/java/com/ultreon/devices/item/MacMaxXItem.java new file mode 100644 index 000000000..902b6b37d --- /dev/null +++ b/common/src/main/java/com/ultreon/devices/item/MacMaxXItem.java @@ -0,0 +1,23 @@ +package com.ultreon.devices.item; + +import com.ultreon.devices.ModDeviceTypes; +import net.minecraft.world.level.block.Block; +import software.bernie.geckolib3.core.IAnimatable; +import software.bernie.geckolib3.core.manager.AnimationData; +import software.bernie.geckolib3.core.manager.AnimationFactory; + +public class MacMaxXItem extends DeviceItem implements IAnimatable { + public MacMaxXItem(Block block, Properties properties) { + super(block, properties, ModDeviceTypes.COMPUTER); + } + + @Override + public void registerControllers(AnimationData animationData) { + + } + + @Override + public AnimationFactory getFactory() { + return new AnimationFactory(); + } +} diff --git a/common/src/main/resources/assets/devices/textures/block/mac_max_x.png b/common/src/main/resources/assets/devices/textures/block/mac_max_x.png index ce08c601cf37854ee9be9601b798a49a7c613149..7774eb51ec993dce141cf8dda26960679dc852b6 100644 GIT binary patch literal 6312 zcmeHLXIPWlmi|H)DG>-LO`6iA_m1?A0un$v(mSC;5CxE?4`s*2Z>R9+NxOuqR*gIJ>c>1|nGg$lD+W>&?+;*Cy$D%k%*d+|| z4rlj@hghKg2NIiO)RULwtnTB;L#@fPM)!Jab&4zB0DS!Fw9Df|{>yJX5k9vS28s(j zcd69a-tIA)t?tlnL(r#-qexqsOc7Tq+CoX?$J_;eF?Al&ZSxEZ((}^UBI7&Ods6Y| zmEV`Wtj_~uhYl6KWTDU(E`xA0Vr@j@Wpj{rfcC|4063G63AMm1(t1F(V+h?nnLi#B z8&tA~wSJ&-gK@`5oMkF)<+}_ z8OkDk`y}|q7_lSejBgIWDq)fl(EYuNy9q|^0E$>kq4~f)kjSMoWBQ55yy*ZbUSi-!-NHVa>7I zKRYFvSdvc>2j?7rVYwPSc}bhnA7LTr9@?YerVNk4^|E+S>Z z*xxBW;Jp6a zcf&FN1&OxZ&2UeT&i35egz~JHM#u_>D;-HVWsc8yh#=6=;4=1QYjtgY+bV0DtV~!E zb;}#1)<|7ByOh0Ov;Xd?ap`H(u?1kWe=ImL!TSLr^@DGef8Jy&v*db>gHwB@o!qMq z?c@Q2qp?xBR0REEFnD_{%ubcKJ6$l|bdk0J{4Rdzg-U~EsEaj?e zpmU;h_ym$ME=)iAkvf!FwZrU%9k4Z_QBe_;T9}bD6?$i=dRWsyZ-g4bS#P@4?SF`k}D($y=z6Y#mzR@YEEamsxF{Yjl1_`rQrmlAx55LYMN{ zJ_nVSN9l?8U&|}%azJ=q+~+5-HB5kH;2a*-E%21O`6sa4Rf2_zTFZqz+2?he>2<9p z@~Erezsj9ph^@DJ+jO96$P=xxjQ`E$?X|&}<|0R-8}E;(Hhb2Ep{86rFTj>8t2VD5 zIuFfL@b*2dNCm_Jubtk`!(mEv8RWrbwGiP-tBxW%yde$u|ihdIG#j>@_f zC}71LbgJjSr;Kv>&Xox= zKwoz=yB%?(BhbJ+TVn>#F4eM=@9S$H15;&q`j^1$%M?m_?6!su$v(OD=rZKN)gCO< zxKvl8>-zOCxNU31tP6w-;HDqX9^`Dr$O-k{Iwe7MaXlG^7O8iuI)`W)S?Gv8sm|L5 zUrkfn6;|iWeeE@RU*;p;7v+8*=s=HHYa;xtj5LzDSft$t?$=~A6!>dFedLM+VUlFn~)Au?ra`~tp!za8! zLDbMeOmh%Pr70OKinjEUki+ zEI}V4kttb&h3!2xPxauIq}dmNM=(FyGn;4Lg@`z-XT7==_mBgpw@t44x{0elSDV#9 zq90)MJ-s{I1oeD!xK~s7(NaL@^X`|hg~dTc6qzEfJokaIpf+^JvCL%OLN!RL4^>nc zy|PI-Ke{^^a~QpnM2AgT$->BgO-EC8);=!t1=$RqQ8I&8TSXe#`zq>_aT;~H*d@9o z0|E6M&OTCQ`;B)o)Sa>Ez>_@SdSaqszS;}f7sfOhC9%)@ygnLUAs33S`6%#t+zEnk zv2jAuw|!*2Q#PUfoQ5uUsp9}Hm($X_gw~X|n-`pznUcFL!W3%y$XQpgeUatO4`92> zo^sJ_7(MPG7$yoHVLZeT@nPhLsi4ZA0KeL=92*;lR+RqrbW;vOt& zq#tP=L7&uSl!L^NN6M4uK zx1QI`q5QJL^!5bkJ3a$5d(jb&m$muc)B>YftrhxQWo#W^hg!>0F(=Ba2t_Hsc`M8& zk;up`x($K$TRcgx}xwmi8l&P&0>cgu}LXuhafQ zrF1qE!$YUHFuKx$l!4?*R{c<)&8++Tc8T14{aQ&}fgbw`s5mW{#t9i~vc5RFcn&P2 zw%n1!XD zu1;o;?fhY%`=z%KA)f^KCm6TDU1p=T1;R7nQMgu=^2wsUgD!GgT6%#W5rsp+sG%%{ zVn>@yL)Y;~eDUv)J(o7H{^~Zj{7io2@L5JzUL&2J7cI^HwZSmKh_<=-lKeC`Bu>+_ zXDri4uQd?E9#9XXTcy(N15?N9)zM;${%9Fyx@_2F?ZT?5lsqkxLe2PKV>`~6m__MY zONR@0TodhnLHh_x@agVC+VSx^^++Be*(&vqJOELY#yrSi&+hf6^TR$tZl3q)*t`(`(`br0bG#JiY3G{#5DpfrcWU1RkAZf`hv9yHP_(P3Yb%R_AH zRfqD(E+Z8i(+FHHZtq>;X6>xoSgz)fCT`QzV_Vh3yTIx5CJv=MYG4|VBn_9v#U%{a z?@v4TNx17g7B2fk*#WXqf=9>2Zh}*u!Ki$0n0ZTqMpsrA9!E`aMz7w)(sA#_L6KEf z-b4VAEVliq3!w2{RV>Q+p~0A(WEg)@miYzQNz`h^o#S0KL(o7u?63Pbqg)T%m};&up0c@K%8v?jII_zlrn za#|FVqPH(vWQV=DL|(>6roN`qnquQI+kZn*8@r%Jd^f6CL?zW@Vpdv zpCPL?Zo>OdnYh$5CIxHZSv4JR|Es?vYi;-M$ zQ!#`A05|i`3*`G+#v3EV_f*wX#9z4z!r~_{-sy<~0764mg}Zu~;~%m;I?;!=W7k#f zE1m@MBW-3)C^_q@qzI&7;)%@f?4# zE(B!7sEb?gSt-VCpP;T`nJqcGDRcw1=#fMFSz>-QW0il_sg8=_iLkJ6Cu((+*bt}Wz__)wb-g!A;r=61KpzO^IUQ=(;|S9!_N2v< zZF%$pFesqnF%5-Qn1+GnW)KJgFc^@f{&Fl6bS4@Kmdm|IP;12X$)UEgzMjfuzRg({ z%uE6TuAVNNaU{j?v$Vd0)&wkC&8QKu{xIX8j3*nQ2O`A!)IcDB-6}<} z@(w2X!4QB!%cC(91;iO;Y4s7NLjElO)EAiTtR@{MF%hyw5xvL!v-Jy;;a+;c+*$Gd z66~8f?w{uWz>&cukPxsO=Jx5p=woKbUya%AYgkBfvix^duYXcCpIrr2c4Ck?f)7aoZc8TP6VQRKlZIu5asa*<g?nKZPlLBL2$ zPmg|9L37ahfFtSWEiLVS^6`;OOMu`W?8{>(_${`qj?T==OkEY_pW?26hL5zN^ULhmK|c)$@*Jfn!&E z?#Fg@M8ueesk*EI@2JL<@6Tct-L3zbEg%>Z9R@01>;NF5)?TLX@m>o=`jqr1I+a)* zc|C9{zsuq0|H({FK&eAA`CRN^ucG}1e=xxCq7L>j$E)3YHERJx02s)Oe8RsIjVU3_ z;)K_TZ4zVYZCX%Qz1hLEjHu|EChXGY-3_@TPwCLaSa;OQhu0(1gt$M6S_S~_U+KjE z*b}g?+(HQ&SYRAhUqqb&Siz~0rxG0tCi|v0gSEFX>YM;?#yO48s((1#cXOlvl7})H zJEe4TLnBrq@KVuWUkvMw`l<|0yP10wB4!@ucr^&s0$mbE8wCQ(SOD=g?@3 zmIt0=S{Ej`VBge()XUJ*Q7@vF_7wBasN>V&uM4sH%I!qPZSJe9k<+mVY`(I`W$-zx zlbnD644ZggBVo2(-y7fcrPRY7VxKZ;HPd6n!*;Vf#;``?GVd{-Q#6Lp07h7#TR1Ur zcBtjQbkKfz3>|$5fMhwupfVT?t+VN+GB>ZI7RpP%+{ONh;=wc~XQUMonch;tK(G*O zz0-#rDvMDQWMN3gP!t1KN6Ms2JuyfYh!Z~WM}jd4wAbZM$tor>$NdQq=JUU4AzDd7 zPd%ga*aSuo{;LE1s;u8u42rsQ@LwUewOVKo`|$sPIKMT2Kgi;EXVqROq^*KH8jW3( z<~zzpWnAk2dXX%Kewem_Vc>5=zhuAd{hKKQ0P}O^U&IThnf1H*YGVD-n?@4~#W$@u zT__pn5mWr1d8MUkfkBZ7coi{kPSC=lMk1(|^18WBkfHza$bg~6Fl|JYgEfA-GYx%Zwq_nh-P z-}jw!+SA>Mq_IW=07x#*j$QzG>=h4cE3n6_=K^!O>Idq#PA;!>9V>wB$5%RZZJ~jj12#Q}xQf z5nhiz<+<^Ljsm7PNznbB^TeKoO0j#phxBCKhAZN%`}H#~>V;BSLWrB2TbN!BJyG@~ z`DOe4aK6#C&ieTmY5ugbuF2aEZ8ezxydFY^G08nvP-s?%vwc|oO&Z?wEN~e0{SIY* zJw^alC$UrD)dAE@0gTT8aOl6MVFUkKY3YCoP``a=nZ3D0P9%D4#tqShHBMmhx~RYQFfR--jJP-fgu0@nBU%%lv#y zb==$uWcTRs-N+v=!1gmDj0fLlXNP9#w8WCz0#$+W$=o3@e26LHzY)UIUfkABOH0d; zEN0=1u$??ByRJapZSu+Ic43Jw$!#Vh1hw0{XD-XdHb|V^t_ps0bF&Y!9t`T-Z*&#W z2yFpmtnDk81Es{_#2VxG!otJLBx;a(RP}$vR5wib4<{waAlHc#QZpQm=mx({5oPAL zN;yab?M|`u%Y?kVJoC`d(1P<`fq{Wv$H^qD)aic-{j_J}D&k+xWgp-MS+(9+m)KoI zbJ&6d(wE~ur3{$x9&J+m%tCZWF|Z+NG58}R2)1f+O^Vck4hGwWFgB{ABpx0}?3u^g zGVQYdlsYZz_op1xQ-|QYGYAW-_Uzz97~g1pp2PA!P2o7HtdjQ)h*-kFY^sI1HV&gY z1&fNX2czIrk7%}plX+HeIkFO4y+(ac?Lo@(0Y4RDxBI ziCTk?fpPY)x|=Q*%%X2H76R;2BdPoL^Q1Uyw?CC;Vs0D2 zq|-3i9%%qIXG9g=bZ+U866gqSqGcsYqbRv3nMqZSEX>v6*u42mgt8THfqf|1!Sj3= zpBE!-Ph2f*AvCT8s$fo1EsYWEj9@jMgIyT(B>pSfD&FL4Jz@TiA}LC!%BtDP6EyY8 zQK3*slXy$% z)V)VIU7tcn^kX5>fQI9FUXqiTV)J>bn<9=AGlj$UrVki2x7mzn&63at{d@!!vREua zl|F{fWR%n{@%^3gnVd1JXEnG%OgxhKuW7*Bp#l!9Qu%_LhllU!6`V00*mXN4C1oO_ za5%h5qDFVXn5g7RhqE}QRdGg0j?#*Y-Q2KaMutv3`FB>($ilHFk}Ks3=EMRKN$Lwl z_o9(mllR4ANrpbaaP~Dn^cU>ztB$Xa4`=u_?v@g|8LAxbu%VHIg9!T?yE6-&rfdJw zY{Tz+MO=(vU6WI>iV^vA`2>Z8zmW}$;ByIf_B_*-pfx^M+2pX+KjFoLp!ywzJ;qp$ z7JIoZGgkc7BV};Rpq8H?>->&l+@4RfySW<#rz@32)`OyfzP>^lo^Fbxf7a5{g3a|) zrchWkh}3wkrK?JoZ=WTVDfiXlyjWUbziPNtM1!a(>nnTIdPYK7O?v^;VXrNB_ z;wGeMnjm~$MBrKN{Y~ekzrB^xIdb^waCk&!NRD*6Y-SrW4W7xrE#AePOJUxrf%@^3 z=Bt=Gexy* { + public MacMaxXItemRenderer() { + super(new MacMaxXItemModel()); + } +} From 45b5a17d4c4b253d6eb7958e0d6ea07fcd9fedfd Mon Sep 17 00:00:00 2001 From: Qboi123 Date: Tue, 1 Nov 2022 12:06:37 +0100 Subject: [PATCH 03/88] Basically don't use Geckolib --- common/build.gradle | 2 - .../com/ultreon/devices/ClientModEvents.java | 6 - .../ultreon/devices/block/MacMaxXBlock.java | 66 +++++- .../block/entity/MacMaxXBlockEntity.java | 15 +- .../ultreon/devices/geo/MacMaxXItemModel.java | 23 --- .../com/ultreon/devices/geo/MacMaxXModel.java | 23 --- .../com/ultreon/devices/init/DeviceItems.java | 4 +- .../com/ultreon/devices/item/MacMaxXItem.java | 23 --- .../assets/devices/blockstates/mac_max_x.json | 68 +++++++ .../assets/devices/blockstates/printer.json | 1 - .../devices/models/block/mac_max_x.json | 189 ++++++++++++++++++ fabric/build.gradle | 1 - .../renderer/fabric/MacMaxXRenderer.java | 12 -- .../devices/fabric/ClientModEventsImpl.java | 12 -- .../devices/fabric/MacMaxXItemRenderer.java | 11 - forge/build.gradle | 2 - .../renderer/forge/MacMaxXRenderer.java | 12 -- .../devices/forge/ClientModEventsImpl.java | 6 - 18 files changed, 315 insertions(+), 161 deletions(-) delete mode 100644 common/src/main/java/com/ultreon/devices/geo/MacMaxXItemModel.java delete mode 100644 common/src/main/java/com/ultreon/devices/geo/MacMaxXModel.java delete mode 100644 common/src/main/java/com/ultreon/devices/item/MacMaxXItem.java create mode 100644 common/src/main/resources/assets/devices/blockstates/mac_max_x.json create mode 100644 common/src/main/resources/assets/devices/models/block/mac_max_x.json delete mode 100644 fabric/src/main/java/com/ultreon/devices/block/entity/renderer/fabric/MacMaxXRenderer.java delete mode 100644 fabric/src/main/java/com/ultreon/devices/fabric/MacMaxXItemRenderer.java delete mode 100644 forge/src/main/java/com/ultreon/devices/block/entity/renderer/forge/MacMaxXRenderer.java diff --git a/common/build.gradle b/common/build.gradle index 2409d11aa..146061d6f 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -18,8 +18,6 @@ dependencies { // Remove the next line if you don't want to depend on the API modApi "dev.architectury:architectury:${rootProject.architectury_version}" - modImplementation "software.bernie.geckolib:geckolib-fabric-1.19:${geckolib_version_fabric}" - implementation("org.jetbrains.kotlin:kotlin-reflect:1.7.10") implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.10") modApi("com.ultreon:ultranlang:0.1.0+6") diff --git a/common/src/main/java/com/ultreon/devices/ClientModEvents.java b/common/src/main/java/com/ultreon/devices/ClientModEvents.java index c17f4a526..161faad14 100644 --- a/common/src/main/java/com/ultreon/devices/ClientModEvents.java +++ b/common/src/main/java/com/ultreon/devices/ClientModEvents.java @@ -66,7 +66,6 @@ public static void clientSetup() { registerRenderLayers(); registerRenderers(); registerLayerDefinitions(); - registerGeoRenderers(); generateIconAtlas(); } @@ -206,11 +205,6 @@ public static void setRenderLayer(Block block, RenderType type) { throw new AssertionError(); } - @ExpectPlatform - public static void registerGeoRenderers() { - throw new AssertionError(); - } - public static void registerRenderers() { LOGGER.info("Registering renderers."); diff --git a/common/src/main/java/com/ultreon/devices/block/MacMaxXBlock.java b/common/src/main/java/com/ultreon/devices/block/MacMaxXBlock.java index 703d6f7f8..ce5fca978 100644 --- a/common/src/main/java/com/ultreon/devices/block/MacMaxXBlock.java +++ b/common/src/main/java/com/ultreon/devices/block/MacMaxXBlock.java @@ -8,25 +8,69 @@ import net.minecraft.world.item.DyeColor; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.RenderShape; import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.state.BlockBehaviour; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Material; import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.Shapes; import net.minecraft.world.phys.shapes.VoxelShape; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; public class MacMaxXBlock extends ComputerBlock { - private static final VoxelShape SHAPE_NORTH = Block.box(-16, 0, 7, 32, 35.25, 11); - private static final VoxelShape SHAPE_EAST = Block.box(-16, 0, 7, 32, 35.25, 11); - private static final VoxelShape SHAPE_SOUTH = Block.box(-16, 0, 7, 32, 35.25, 11); - private static final VoxelShape SHAPE_WEST = Block.box(-16, 0, 7, 32, 35.25, 11); + private static final VoxelShape SHAPE_NORTH = Shapes.or( + Block.box(-16, 31, 5, 32, 32, 7), + Block.box(-15, 4, 5.5, 31, 32, 7), + Block.box(-16, 5, 5, -15, 32, 7), + Block.box(-16, 3, 5, 32, 7, 7), + Block.box(31, 5, 5, 32, 32, 7), + Block.box(-6, 0.5, 6.5, -2, 19, 9), + Block.box(20, 0.5, 6.5, 24, 19, 9), + Block.box(0, 13, 6.5, 18, 27, 8), + Block.box(19, 0, 6.5, 25, 0.5, 9), + Block.box(-7, 0, 6.5, -1, 0.5, 9) + ); + private static final VoxelShape SHAPE_EAST = Shapes.or( + Block.box(9, 31, -16, 11, 32, 32), + Block.box(9, 4, -15, 10.5, 32, 31), + Block.box(9, 5, -16, 11, 32, -15), + Block.box(9, 3, -16, 11, 7, 32), + Block.box(9, 5, 31, 11, 32, 32), + Block.box(7, 0.5, -6, 9.5, 19, -2), + Block.box(7, 0.5, 20, 9.5, 19, 24), + Block.box(8, 13, 0, 9.5, 27, 18), + Block.box(7, 0, 19, 9.5, 0.5, 25), + Block.box(7, 0, -7, 9.5, 0.5, -1) + ); + private static final VoxelShape SHAPE_SOUTH = Shapes.or( + Block.box(-16, 31, 9, 32, 32, 11), + Block.box(-15, 4, 9, 31, 32, 10.5), + Block.box(31, 5, 9, 32, 32, 11), + Block.box(-16, 3, 9, 32, 7, 11), + Block.box(-16, 5, 9, -15, 32, 11), + Block.box(18, 0.5, 7, 22, 19, 9.5), + Block.box(-8, 0.5, 7, -4, 19, 9.5), + Block.box(-2, 13, 8, 16, 27, 9.5), + Block.box(-9, 0, 7, -3, 0.5, 9.5), + Block.box(17, 0, 7, 23, 0.5, 9.5) + ); + private static final VoxelShape SHAPE_WEST = Shapes.or( + Block.box(5, 31, -16, 7, 32, 32), + Block.box(5.5, 4, -15, 7, 32, 31), + Block.box(5, 5, 31, 7, 32, 32), + Block.box(5, 3, -16, 7, 7, 32), + Block.box(5, 5, -16, 7, 32, -15), + Block.box(6.5, 0.5, 18, 9, 19, 22), + Block.box(6.5, 0.5, -8, 9, 19, -4), + Block.box(6.5, 13, -2, 8, 27, 16), + Block.box(6.5, 0, -9, 9, 0.5, -3), + Block.box(6.5, 0, 17, 9, 0.5, 23) + ); public MacMaxXBlock() { - super(BlockBehaviour.Properties.of(Material.HEAVY_METAL, DyeColor.WHITE).strength(6f).sound(SoundType.METAL)); + super(BlockBehaviour.Properties.of(Material.HEAVY_METAL, DyeColor.WHITE).strength(6f).sound(SoundType.METAL).noOcclusion().dynamicShape()); } @Override @@ -40,6 +84,11 @@ public MacMaxXBlock() { }; } + @Override + public float getShadeBrightness(BlockState state, BlockGetter level, BlockPos pos) { + return 1.0f; + } + @Override public boolean isDesktopPC() { return true; @@ -54,11 +103,6 @@ public MutableComponent getName() { return normalName; } - @Override - public RenderShape getRenderShape(@NotNull BlockState state) { - return RenderShape.ENTITYBLOCK_ANIMATED; - } - @Override public @Nullable BlockEntity newBlockEntity(@NotNull BlockPos pos, @NotNull BlockState state) { return new MacMaxXBlockEntity(pos, state); diff --git a/common/src/main/java/com/ultreon/devices/block/entity/MacMaxXBlockEntity.java b/common/src/main/java/com/ultreon/devices/block/entity/MacMaxXBlockEntity.java index be2f852bd..ef113a926 100644 --- a/common/src/main/java/com/ultreon/devices/block/entity/MacMaxXBlockEntity.java +++ b/common/src/main/java/com/ultreon/devices/block/entity/MacMaxXBlockEntity.java @@ -3,22 +3,9 @@ import com.ultreon.devices.init.DeviceBlockEntities; import net.minecraft.core.BlockPos; import net.minecraft.world.level.block.state.BlockState; -import software.bernie.geckolib3.core.IAnimatable; -import software.bernie.geckolib3.core.manager.AnimationData; -import software.bernie.geckolib3.core.manager.AnimationFactory; -public class MacMaxXBlockEntity extends ComputerBlockEntity implements IAnimatable { +public class MacMaxXBlockEntity extends ComputerBlockEntity { public MacMaxXBlockEntity(BlockPos pWorldPosition, BlockState pBlockState) { super(DeviceBlockEntities.MAC_MAX_X.get(), pWorldPosition, pBlockState); } - - @Override - public void registerControllers(AnimationData animationData) { - - } - - @Override - public AnimationFactory getFactory() { - return new AnimationFactory(this); - } } diff --git a/common/src/main/java/com/ultreon/devices/geo/MacMaxXItemModel.java b/common/src/main/java/com/ultreon/devices/geo/MacMaxXItemModel.java deleted file mode 100644 index 139cd760f..000000000 --- a/common/src/main/java/com/ultreon/devices/geo/MacMaxXItemModel.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.ultreon.devices.geo; - -import com.ultreon.devices.Devices; -import com.ultreon.devices.item.MacMaxXItem; -import net.minecraft.resources.ResourceLocation; -import software.bernie.geckolib3.model.AnimatedGeoModel; - -public class MacMaxXItemModel extends AnimatedGeoModel { - @Override - public ResourceLocation getModelResource(MacMaxXItem object) { - return Devices.res("geo/mac_max_x.geo.json"); - } - - @Override - public ResourceLocation getTextureResource(MacMaxXItem object) { - return Devices.res("textures/block/mac_max_x.png"); - } - - @Override - public ResourceLocation getAnimationResource(MacMaxXItem animatable) { - return Devices.res("animations/mac_max_x.animation.json"); - } -} \ No newline at end of file diff --git a/common/src/main/java/com/ultreon/devices/geo/MacMaxXModel.java b/common/src/main/java/com/ultreon/devices/geo/MacMaxXModel.java deleted file mode 100644 index dddfca252..000000000 --- a/common/src/main/java/com/ultreon/devices/geo/MacMaxXModel.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.ultreon.devices.geo; - -import com.ultreon.devices.Devices; -import com.ultreon.devices.block.entity.MacMaxXBlockEntity; -import net.minecraft.resources.ResourceLocation; -import software.bernie.geckolib3.model.AnimatedGeoModel; - -public class MacMaxXModel extends AnimatedGeoModel { - @Override - public ResourceLocation getModelResource(MacMaxXBlockEntity object) { - return Devices.res("geo/mac_max_x.geo.json"); - } - - @Override - public ResourceLocation getTextureResource(MacMaxXBlockEntity object) { - return Devices.res("textures/block/mac_max_x.png"); - } - - @Override - public ResourceLocation getAnimationResource(MacMaxXBlockEntity animatable) { - return Devices.res("animations/mac_max_x.animation.json"); - } -} \ No newline at end of file diff --git a/common/src/main/java/com/ultreon/devices/init/DeviceItems.java b/common/src/main/java/com/ultreon/devices/init/DeviceItems.java index ebfdc6073..5d2a3fe41 100644 --- a/common/src/main/java/com/ultreon/devices/init/DeviceItems.java +++ b/common/src/main/java/com/ultreon/devices/init/DeviceItems.java @@ -37,7 +37,7 @@ public class DeviceItems { public static final RegistrySupplier BLACK_LAPTOP = REGISTER.register(Devices.id("black_laptop"), () -> new ColoredDeviceItem(DeviceBlocks.BLACK_LAPTOP.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.BLACK, ModDeviceTypes.COMPUTER)); // Custom Computers - public static final RegistrySupplier MAC_MAX_X = REGISTER.register(Devices.id("mac_max_x"), () -> new MacMaxXItem(DeviceBlocks.MAC_MAX_X.get(), new Item.Properties().tab(Devices.TAB_DEVICE))); + public static final RegistrySupplier MAC_MAX_X = REGISTER.register(Devices.id("mac_max_x"), () -> new DeviceItem(DeviceBlocks.MAC_MAX_X.get(), new Item.Properties().tab(Devices.TAB_DEVICE), ModDeviceTypes.COMPUTER)); // Printers public static final RegistrySupplier WHITE_PRINTER = REGISTER.register(Devices.id("white_printer"), () -> new ColoredDeviceItem(DeviceBlocks.WHITE_PRINTER.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.WHITE, ModDeviceTypes.PRINTER)); @@ -114,7 +114,7 @@ public class DeviceItems { public static final RegistrySupplier COMPONENT_SMALL_ELECTRIC_MOTOR = REGISTER.register(Devices.id("small_electric_motor"), () -> new ComponentItem(new Item.Properties().tab(Devices.TAB_DEVICE))); public static final RegistrySupplier COMPONENT_CARRIAGE = REGISTER.register(Devices.id("carriage"), () -> new ComponentItem(new Item.Properties().tab(Devices.TAB_DEVICE))); - public static final RegistrySupplier ETHERNET_CABLE = REGISTER.register(Devices.id("ethernet_cable"), () -> new EthernetCableItem()); + public static final RegistrySupplier ETHERNET_CABLE = REGISTER.register(Devices.id("ethernet_cable"), EthernetCableItem::new); public static Stream getAllItems() { diff --git a/common/src/main/java/com/ultreon/devices/item/MacMaxXItem.java b/common/src/main/java/com/ultreon/devices/item/MacMaxXItem.java deleted file mode 100644 index 902b6b37d..000000000 --- a/common/src/main/java/com/ultreon/devices/item/MacMaxXItem.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.ultreon.devices.item; - -import com.ultreon.devices.ModDeviceTypes; -import net.minecraft.world.level.block.Block; -import software.bernie.geckolib3.core.IAnimatable; -import software.bernie.geckolib3.core.manager.AnimationData; -import software.bernie.geckolib3.core.manager.AnimationFactory; - -public class MacMaxXItem extends DeviceItem implements IAnimatable { - public MacMaxXItem(Block block, Properties properties) { - super(block, properties, ModDeviceTypes.COMPUTER); - } - - @Override - public void registerControllers(AnimationData animationData) { - - } - - @Override - public AnimationFactory getFactory() { - return new AnimationFactory(); - } -} diff --git a/common/src/main/resources/assets/devices/blockstates/mac_max_x.json b/common/src/main/resources/assets/devices/blockstates/mac_max_x.json new file mode 100644 index 000000000..b9bffbbcc --- /dev/null +++ b/common/src/main/resources/assets/devices/blockstates/mac_max_x.json @@ -0,0 +1,68 @@ +{ + "variants": { + "facing=north,open=true,type=base": { + "model": "devices:block/mac_max_x", + "y": 0 + }, + "facing=east,open=true,type=base": { + "model": "devices:block/mac_max_x", + "y": 90 + }, + "facing=south,open=true,type=base": { + "model": "devices:block/mac_max_x", + "y": 180 + }, + "facing=west,open=true,type=base": { + "model": "devices:block/mac_max_x", + "y": 270 + }, + "facing=north,open=false,type=base": { + "model": "devices:block/mac_max_x", + "y": 0 + }, + "facing=east,open=false,type=base": { + "model": "devices:block/mac_max_x", + "y": 90 + }, + "facing=south,open=false,type=base": { + "model": "devices:block/mac_max_x", + "y": 180 + }, + "facing=west,open=false,type=base": { + "model": "devices:block/mac_max_x", + "y": 270 + }, + "facing=north,open=true,type=screen": { + "model": "devices:block/mac_max_x", + "y": 0 + }, + "facing=east,open=true,type=screen": { + "model": "devices:block/mac_max_x", + "y": 90 + }, + "facing=south,open=true,type=screen": { + "model": "devices:block/mac_max_x", + "y": 180 + }, + "facing=west,open=true,type=screen": { + "model": "devices:block/mac_max_x", + "y": 270 + }, + "facing=north,open=false,type=screen": { + "model": "devices:block/mac_max_x", + "y": 0 + }, + "facing=east,open=false,type=screen": { + "model": "devices:block/mac_max_x", + "y": 90 + }, + "facing=south,open=false,type=screen": { + "model": "devices:block/mac_max_x", + "y": 180 + }, + "facing=west,open=false,type=screen": { + "model": "devices:block/mac_max_x", + "y": 270 + } + } +} diff --git a/common/src/main/resources/assets/devices/blockstates/printer.json b/common/src/main/resources/assets/devices/blockstates/printer.json index e9f2b2ef7..a2fe3c70d 100644 --- a/common/src/main/resources/assets/devices/blockstates/printer.json +++ b/common/src/main/resources/assets/devices/blockstates/printer.json @@ -102,4 +102,3 @@ } } } - diff --git a/common/src/main/resources/assets/devices/models/block/mac_max_x.json b/common/src/main/resources/assets/devices/models/block/mac_max_x.json new file mode 100644 index 000000000..730a57193 --- /dev/null +++ b/common/src/main/resources/assets/devices/models/block/mac_max_x.json @@ -0,0 +1,189 @@ +{ + "credit": "Made with Blockbench", + "texture_size": [128, 128], + "textures": { + "0": "devices:block/mac_max_x" + }, + "elements": [ + { + "from": [-16, 31, 5], + "to": [32, 32, 7], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 0, 8]}, + "faces": { + "north": {"uv": [7.254, 6.004, 13.246, 6.121], "texture": "#0"}, + "east": {"uv": [5.504, 7.754, 5.746, 7.871], "texture": "#0"}, + "south": {"uv": [7.254, 6.129, 13.246, 6.246], "texture": "#0"}, + "west": {"uv": [6.254, 7.879, 6.496, 7.996], "texture": "#0"}, + "up": {"uv": [11.746, 4.746, 5.754, 4.504], "texture": "#0"}, + "down": {"uv": [11.746, 4.754, 5.754, 4.996], "texture": "#0"} + } + }, + { + "from": [-15, 4, 5.5], + "to": [31, 32, 7], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 0, 8]}, + "faces": { + "north": {"uv": [0.004, 0.004, 5.746, 3.496], "texture": "#0"}, + "east": {"uv": [3.004, 7.004, 3.1875, 10.496], "texture": "#0"}, + "south": {"uv": [0.004, 3.504, 5.746, 6.996], "texture": "#0"}, + "west": {"uv": [3.254, 7.004, 3.4375, 10.496], "texture": "#0"}, + "up": {"uv": [12.996, 5.6875, 7.254, 5.504], "texture": "#0"}, + "down": {"uv": [12.996, 5.754, 7.254, 5.9375], "texture": "#0"} + } + }, + { + "from": [-16, 5, 5], + "to": [-15, 32, 7], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 0, 8]}, + "faces": { + "north": {"uv": [3.504, 7.004, 3.621, 10.371], "texture": "#0"}, + "east": {"uv": [0.504, 7.004, 0.746, 10.371], "texture": "#0"}, + "south": {"uv": [3.629, 7.004, 3.746, 10.371], "texture": "#0"}, + "west": {"uv": [0.754, 7.004, 0.996, 10.371], "texture": "#0"}, + "up": {"uv": [6.621, 8.121, 6.504, 7.879], "texture": "#0"}, + "down": {"uv": [6.746, 7.879, 6.629, 8.121], "texture": "#0"} + } + }, + { + "from": [-16, 3, 5], + "to": [32, 7, 7], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 0, 8]}, + "faces": { + "north": {"uv": [5.754, 3.504, 11.746, 3.996], "texture": "#0"}, + "east": {"uv": [5.004, 7.754, 5.246, 8.246], "texture": "#0"}, + "south": {"uv": [5.754, 4.004, 11.746, 4.496], "texture": "#0"}, + "west": {"uv": [5.254, 7.754, 5.496, 8.246], "texture": "#0"}, + "up": {"uv": [11.746, 5.246, 5.754, 5.004], "texture": "#0"}, + "down": {"uv": [11.746, 5.254, 5.754, 5.496], "texture": "#0"} + } + }, + { + "from": [31, 5, 5], + "to": [32, 32, 7], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 0, 8]}, + "faces": { + "north": {"uv": [3.754, 7.004, 3.871, 10.371], "texture": "#0"}, + "east": {"uv": [1.004, 7.004, 1.246, 10.371], "texture": "#0"}, + "south": {"uv": [3.879, 7.004, 3.996, 10.371], "texture": "#0"}, + "west": {"uv": [1.254, 7.004, 1.496, 10.371], "texture": "#0"}, + "up": {"uv": [6.871, 8.121, 6.754, 7.879], "texture": "#0"}, + "down": {"uv": [6.996, 7.879, 6.879, 8.121], "texture": "#0"} + } + }, + { + "from": [-6, 0.5, 6.5], + "to": [-2, 19, 9], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 0, 8]}, + "faces": { + "north": {"uv": [5.754, 5.504, 6.246, 7.8125], "texture": "#0"}, + "east": {"uv": [1.504, 7.004, 1.8125, 9.3125], "texture": "#0"}, + "south": {"uv": [6.254, 5.504, 6.746, 7.8125], "texture": "#0"}, + "west": {"uv": [1.879, 7.004, 2.1875, 9.3125], "texture": "#0"}, + "up": {"uv": [5.746, 7.3125, 5.254, 7.004], "texture": "#0"}, + "down": {"uv": [5.746, 7.379, 5.254, 7.6875], "texture": "#0"} + } + }, + { + "from": [20, 0.5, 6.5], + "to": [24, 19, 9], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 0, 8]}, + "faces": { + "north": {"uv": [6.754, 5.504, 7.246, 7.8125], "texture": "#0"}, + "east": {"uv": [2.254, 7.004, 2.5625, 9.3125], "texture": "#0"}, + "south": {"uv": [0.004, 7.004, 0.496, 9.3125], "texture": "#0"}, + "west": {"uv": [2.629, 7.004, 2.9375, 9.3125], "texture": "#0"}, + "up": {"uv": [7.746, 7.8125, 7.254, 7.504], "texture": "#0"}, + "down": {"uv": [4.996, 7.754, 4.504, 8.0625], "texture": "#0"} + } + }, + { + "from": [0, 13, 6.5], + "to": [18, 27, 8], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 0, 8]}, + "faces": { + "north": {"uv": [5.754, 0.004, 7.996, 1.746], "texture": "#0"}, + "east": {"uv": [4.004, 7.004, 4.1875, 8.746], "texture": "#0"}, + "south": {"uv": [5.754, 1.754, 7.996, 3.496], "texture": "#0"}, + "west": {"uv": [4.254, 7.004, 4.4375, 8.746], "texture": "#0"}, + "up": {"uv": [9.496, 6.4375, 7.254, 6.254], "texture": "#0"}, + "down": {"uv": [9.496, 6.504, 7.254, 6.6875], "texture": "#0"} + } + }, + { + "from": [19, 0, 6.5], + "to": [25, 0.5, 9], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 0, 8]}, + "faces": { + "north": {"uv": [7.754, 7.504, 8.496, 7.5625], "texture": "#0"}, + "east": {"uv": [7.004, 7.879, 7.3125, 7.9375], "texture": "#0"}, + "south": {"uv": [7.754, 7.629, 8.496, 7.6875], "texture": "#0"}, + "west": {"uv": [7.379, 7.879, 7.6875, 7.9375], "texture": "#0"}, + "up": {"uv": [5.246, 7.3125, 4.504, 7.004], "texture": "#0"}, + "down": {"uv": [7.996, 6.754, 7.254, 7.0625], "texture": "#0"} + } + }, + { + "from": [-7, 0, 6.5], + "to": [-1, 0.5, 9], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 0, 8]}, + "faces": { + "north": {"uv": [7.754, 7.754, 8.496, 7.8125], "texture": "#0"}, + "east": {"uv": [7.754, 7.879, 8.0625, 7.9375], "texture": "#0"}, + "south": {"uv": [5.504, 7.879, 6.246, 7.9375], "texture": "#0"}, + "west": {"uv": [8.004, 0.004, 8.3125, 0.0625], "texture": "#0"}, + "up": {"uv": [7.996, 7.4375, 7.254, 7.129], "texture": "#0"}, + "down": {"uv": [5.246, 7.379, 4.504, 7.6875], "texture": "#0"} + } + } + ], + "display": { + "thirdperson_righthand": { + "rotation": [0, 180, 0], + "translation": [0.5, -0.5, 0.75], + "scale": [0.3, 0.3, 0.3] + }, + "thirdperson_lefthand": { + "rotation": [0, 180, 0], + "translation": [-0.5, -0.5, 0.75], + "scale": [0.3, 0.3, 0.3] + }, + "firstperson_righthand": { + "rotation": [0, 160, 0], + "translation": [0, 1.5, 0], + "scale": [0.3, 0.3, 0.3] + }, + "firstperson_lefthand": { + "rotation": [0, 160, 0], + "translation": [0, 1.5, 0], + "scale": [0.3, 0.3, 0.3] + }, + "ground": { + "translation": [0, 3.5, 0], + "scale": [0.45, 0.45, 0.45] + }, + "gui": { + "rotation": [0, 180, 0], + "translation": [0, -2.5, 4.75], + "scale": [0.35, 0.35, 0.35] + }, + "head": { + "rotation": [85, 0, 0], + "translation": [0, 5.75, -5.25], + "scale": [0.8, 0.8, 0.8] + }, + "fixed": { + "translation": [0, -6.25, -0.5], + "scale": [0.66, 0.66, 0.66] + } + }, + "groups": [ + { + "name": "VoxelShapes", + "origin": [8, 8, 8], + "color": 0, + "nbt": "{}", + "armAnimationEnabled": false, + "children": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] + } + ] +} \ No newline at end of file diff --git a/fabric/build.gradle b/fabric/build.gradle index a72861087..6db3de38a 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -36,7 +36,6 @@ dependencies { modImplementation "curse.maven:forgeapiportfabric-547434:3946675" modImplementation 'com.electronwill.night-config:core:3.6.5' modImplementation 'com.electronwill.night-config:toml:3.6.5' - modImplementation "software.bernie.geckolib:geckolib-fabric-1.19:${geckolib_version_quilt}" // include(implementation("org.jetbrains.kotlin:kotlin-reflect:1.7.10")) // include(implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.10")) diff --git a/fabric/src/main/java/com/ultreon/devices/block/entity/renderer/fabric/MacMaxXRenderer.java b/fabric/src/main/java/com/ultreon/devices/block/entity/renderer/fabric/MacMaxXRenderer.java deleted file mode 100644 index 6e58b9db9..000000000 --- a/fabric/src/main/java/com/ultreon/devices/block/entity/renderer/fabric/MacMaxXRenderer.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.ultreon.devices.block.entity.renderer.fabric; - -import com.ultreon.devices.block.entity.MacMaxXBlockEntity; -import com.ultreon.devices.geo.MacMaxXModel; -import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; -import software.bernie.geckolib3.renderers.geo.GeoBlockRenderer; - -public class MacMaxXRenderer extends GeoBlockRenderer { - public MacMaxXRenderer(BlockEntityRendererProvider.Context rendererDispatcherIn) { - super(new MacMaxXModel()); - } -} \ No newline at end of file diff --git a/fabric/src/main/java/com/ultreon/devices/fabric/ClientModEventsImpl.java b/fabric/src/main/java/com/ultreon/devices/fabric/ClientModEventsImpl.java index 2ecbc075a..8060549c8 100644 --- a/fabric/src/main/java/com/ultreon/devices/fabric/ClientModEventsImpl.java +++ b/fabric/src/main/java/com/ultreon/devices/fabric/ClientModEventsImpl.java @@ -1,14 +1,9 @@ package com.ultreon.devices.fabric; -import com.ultreon.devices.block.entity.renderer.fabric.MacMaxXRenderer; -import com.ultreon.devices.init.DeviceBlockEntities; -import com.ultreon.devices.init.DeviceItems; import com.ultreon.devices.object.AppInfo; -import dev.architectury.registry.client.rendering.BlockEntityRendererRegistry; import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap; import net.minecraft.client.renderer.RenderType; import net.minecraft.world.level.block.Block; -import software.bernie.geckolib3.renderers.geo.GeoItemRenderer; public class ClientModEventsImpl { public static void setRenderLayer(Block block, RenderType renderType) { @@ -16,13 +11,6 @@ public static void setRenderLayer(Block block, RenderType renderType) { } public static void updateIcon(AppInfo info, int iconU, int iconV) { -// info.setIconU(iconU); -// info.setIconV(iconV); } - public static void registerGeoRenderers() { - BlockEntityRendererRegistry.register(DeviceBlockEntities.MAC_MAX_X.get(), MacMaxXRenderer::new); - - GeoItemRenderer.registerItemRenderer(DeviceItems.MAC_MAX_X.get(), new MacMaxXItemRenderer()); - } } diff --git a/fabric/src/main/java/com/ultreon/devices/fabric/MacMaxXItemRenderer.java b/fabric/src/main/java/com/ultreon/devices/fabric/MacMaxXItemRenderer.java deleted file mode 100644 index 6ba4cd74b..000000000 --- a/fabric/src/main/java/com/ultreon/devices/fabric/MacMaxXItemRenderer.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.ultreon.devices.fabric; - -import com.ultreon.devices.geo.MacMaxXItemModel; -import com.ultreon.devices.item.MacMaxXItem; -import software.bernie.geckolib3.renderers.geo.GeoItemRenderer; - -public class MacMaxXItemRenderer extends GeoItemRenderer { - public MacMaxXItemRenderer() { - super(new MacMaxXItemModel()); - } -} diff --git a/forge/build.gradle b/forge/build.gradle index 84bc0fd7c..5201d3123 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -35,8 +35,6 @@ dependencies { common(project(path: ":common", configuration: "namedElements")) { transitive false } shadowCommon(project(path: ":common", configuration: "transformProductionForge")) { transitive = false } - modImplementation "software.bernie.geckolib:geckolib-forge-1.19:${geckolib_version_quilt}" - modImplementation "curse.maven:emojiful-284324:4056367" forgeRuntimeLibrary "org.jetbrains.kotlin:kotlin-stdlib:1.7.10" diff --git a/forge/src/main/java/com/ultreon/devices/block/entity/renderer/forge/MacMaxXRenderer.java b/forge/src/main/java/com/ultreon/devices/block/entity/renderer/forge/MacMaxXRenderer.java deleted file mode 100644 index 1aacf6ec2..000000000 --- a/forge/src/main/java/com/ultreon/devices/block/entity/renderer/forge/MacMaxXRenderer.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.ultreon.devices.block.entity.renderer.forge; - -import com.ultreon.devices.block.entity.MacMaxXBlockEntity; -import com.ultreon.devices.geo.MacMaxXModel; -import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; -import software.bernie.geckolib3.renderers.geo.GeoBlockRenderer; - -public class MacMaxXRenderer extends GeoBlockRenderer { - public MacMaxXRenderer(BlockEntityRendererProvider.Context context) { - super(context, new MacMaxXModel()); - } -} \ No newline at end of file diff --git a/forge/src/main/java/com/ultreon/devices/forge/ClientModEventsImpl.java b/forge/src/main/java/com/ultreon/devices/forge/ClientModEventsImpl.java index f87fb2142..2e964c3af 100644 --- a/forge/src/main/java/com/ultreon/devices/forge/ClientModEventsImpl.java +++ b/forge/src/main/java/com/ultreon/devices/forge/ClientModEventsImpl.java @@ -1,9 +1,6 @@ package com.ultreon.devices.forge; -import com.ultreon.devices.block.entity.renderer.forge.MacMaxXRenderer; -import com.ultreon.devices.init.DeviceBlockEntities; import com.ultreon.devices.object.AppInfo; -import dev.architectury.registry.client.rendering.BlockEntityRendererRegistry; import net.minecraft.client.renderer.ItemBlockRenderTypes; import net.minecraft.client.renderer.RenderType; import net.minecraft.world.level.block.Block; @@ -19,7 +16,4 @@ public static void updateIcon(AppInfo info, int iconU, int iconV) { ObfuscationReflectionHelper.setPrivateValue(AppInfo.class, info, iconV, "iconV"); } - public static void registerGeoRenderers() { - BlockEntityRendererRegistry.register(DeviceBlockEntities.MAC_MAX_X.get(), MacMaxXRenderer::new); - } } From 912586755c3dd8048c0e9dcf831eb74d55086f45 Mon Sep 17 00:00:00 2001 From: Qboi123 Date: Fri, 4 Nov 2022 05:30:03 +0100 Subject: [PATCH 04/88] Did something? --- .../ultreon/devices/block/ComputerBlock.java | 6 - .../ultreon/devices/block/LaptopBlock.java | 8 + .../ultreon/devices/block/MacMaxXBlock.java | 129 ++++++- .../devices/block/MacMaxXBlockPart.java | 356 ++++++++++++++++-- .../block/entity/ComputerBlockEntity.java | 12 +- .../ultreon/devices/init/DeviceBlocks.java | 1 + .../com/ultreon/devices/init/DeviceItems.java | 20 +- .../assets/devices/geo/mac_max_x.geo.json | 143 ------- .../devices/models/block/mac_max_x.json | 1 + .../assets/devices/models/item/mac_max_x.json | 37 +- .../devices/loot_tables/blocks/mac_max_x.json | 20 + forge/build.gradle | 2 +- 12 files changed, 508 insertions(+), 227 deletions(-) delete mode 100644 common/src/main/resources/assets/devices/geo/mac_max_x.geo.json create mode 100644 common/src/main/resources/data/devices/loot_tables/blocks/mac_max_x.json diff --git a/common/src/main/java/com/ultreon/devices/block/ComputerBlock.java b/common/src/main/java/com/ultreon/devices/block/ComputerBlock.java index 565cdd6a9..3f081d42b 100644 --- a/common/src/main/java/com/ultreon/devices/block/ComputerBlock.java +++ b/common/src/main/java/com/ultreon/devices/block/ComputerBlock.java @@ -2,7 +2,6 @@ import com.ultreon.devices.ModDeviceTypes; import com.ultreon.devices.block.entity.ComputerBlockEntity; -import com.ultreon.devices.block.entity.LaptopBlockEntity; import com.ultreon.devices.item.FlashDriveItem; import com.ultreon.devices.util.BlockEntityUtil; import com.ultreon.devices.util.Colorable; @@ -105,11 +104,6 @@ protected void removeTagsForDrop(CompoundTag tileEntityTag) { tileEntityTag.remove("open"); } - @Override - public @Nullable BlockEntity newBlockEntity(@NotNull BlockPos pos, @NotNull BlockState state) { - return new LaptopBlockEntity(pos, state); - } - @Override protected void createBlockStateDefinition(StateDefinition.@NotNull Builder pBuilder) { super.createBlockStateDefinition(pBuilder); diff --git a/common/src/main/java/com/ultreon/devices/block/LaptopBlock.java b/common/src/main/java/com/ultreon/devices/block/LaptopBlock.java index 3e235e842..57afd3833 100644 --- a/common/src/main/java/com/ultreon/devices/block/LaptopBlock.java +++ b/common/src/main/java/com/ultreon/devices/block/LaptopBlock.java @@ -1,11 +1,13 @@ package com.ultreon.devices.block; import com.ultreon.devices.ModDeviceTypes; +import com.ultreon.devices.block.entity.LaptopBlockEntity; import net.minecraft.core.BlockPos; import net.minecraft.world.item.DyeColor; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.SoundType; +import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.properties.BooleanProperty; import net.minecraft.world.level.block.state.properties.EnumProperty; @@ -14,6 +16,7 @@ import net.minecraft.world.phys.shapes.Shapes; import net.minecraft.world.phys.shapes.VoxelShape; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; public class LaptopBlock extends ComputerBlock.Colored { public static final EnumProperty TYPE = EnumProperty.create("type", Type.class); @@ -49,6 +52,11 @@ public LaptopBlock(DyeColor color) { }; } + @Override + public @Nullable BlockEntity newBlockEntity(@NotNull BlockPos pos, @NotNull BlockState state) { + return new LaptopBlockEntity(pos, state); + } + public boolean isDesktopPC() { return false; } diff --git a/common/src/main/java/com/ultreon/devices/block/MacMaxXBlock.java b/common/src/main/java/com/ultreon/devices/block/MacMaxXBlock.java index ce5fca978..5d2536472 100644 --- a/common/src/main/java/com/ultreon/devices/block/MacMaxXBlock.java +++ b/common/src/main/java/com/ultreon/devices/block/MacMaxXBlock.java @@ -1,13 +1,21 @@ package com.ultreon.devices.block; import com.ultreon.devices.block.entity.MacMaxXBlockEntity; +import com.ultreon.devices.init.DeviceBlocks; import dev.architectury.platform.Platform; import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.MutableComponent; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.DyeColor; +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.Blocks; import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.state.BlockBehaviour; @@ -19,6 +27,10 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +/** + * @author Qboi123 + */ +@SuppressWarnings("deprecation") public class MacMaxXBlock extends ComputerBlock { private static final VoxelShape SHAPE_NORTH = Shapes.or( Block.box(-16, 31, 5, 32, 32, 7), @@ -85,10 +97,125 @@ public MacMaxXBlock() { } @Override - public float getShadeBrightness(BlockState state, BlockGetter level, BlockPos pos) { + public float getShadeBrightness(@NotNull BlockState state, @NotNull BlockGetter level, @NotNull BlockPos pos) { return 1.0f; } + @Override + public @Nullable BlockState getStateForPlacement(@NotNull BlockPlaceContext context) { + return canPlace(context.getLevel(), context.getClickedPos(), context.getHorizontalDirection()) ? super.getStateForPlacement(context) : null; + } + + public boolean canPlace(Level level, BlockPos pos, Direction face) { + BlockState partState = DeviceBlocks.MAC_MAX_X_PART.get().defaultBlockState(); + hasBlock(level, pos.above()); + switch (face) { + case NORTH -> { + if (hasBlock(level, pos.above().west())) return false; + if (hasBlock(level, pos.above().east())) return false; + if (hasBlock(level, pos.above())) return false; + if (hasBlock(level, pos.west())) return false; + if (hasBlock(level, pos.east())) return false; + } + case SOUTH -> { + if (hasBlock(level, pos.above().east())) return false; + if (hasBlock(level, pos.above().west())) return false; + if (hasBlock(level, pos.above())) return false; + if (hasBlock(level, pos.east())) return false; + if (hasBlock(level, pos.west())) return false; + } + case WEST -> { + if (hasBlock(level, pos.above().north())) return false; + if (hasBlock(level, pos.above().south())) return false; + if (hasBlock(level, pos.above())) return false; + if (hasBlock(level, pos.north())) return false; + if (hasBlock(level, pos.south())) return false; + } + case EAST -> { + if (hasBlock(level, pos.above().south())) return false; + if (hasBlock(level, pos.above().north())) return false; + if (hasBlock(level, pos.above())) return false; + if (hasBlock(level, pos.south())) return false; + if (hasBlock(level, pos.north())) return false; + } + default -> throw new IllegalStateException("Unexpected value: " + face); + } + return true; + } + + private boolean hasBlock(Level level, BlockPos pos) { + return !level.getBlockState(pos).isAir(); + } + + public void setPlacedBy(Level level, BlockPos pos, BlockState state, LivingEntity placer, @NotNull ItemStack stack) { + if (state.isAir()) return; + BlockState partState = DeviceBlocks.MAC_MAX_X_PART.get().defaultBlockState(); + partState = partState.setValue(FACING, state.getValue(FACING)); + level.setBlock(pos.above(), partState.setValue(MacMaxXBlockPart.PART, MacMaxXBlockPart.Part.T), 3); + switch (state.getValue(FACING)) { + case NORTH -> { + level.setBlock(pos.above().west(), partState.setValue(MacMaxXBlockPart.PART, MacMaxXBlockPart.Part.TL), 3); + level.setBlock(pos.above().east(), partState.setValue(MacMaxXBlockPart.PART, MacMaxXBlockPart.Part.TR), 3); + level.setBlock(pos.west(), partState.setValue(MacMaxXBlockPart.PART, MacMaxXBlockPart.Part.BL), 3); + level.setBlock(pos.east(), partState.setValue(MacMaxXBlockPart.PART, MacMaxXBlockPart.Part.BR), 3); + } + case SOUTH -> { + level.setBlock(pos.above().east(), partState.setValue(MacMaxXBlockPart.PART, MacMaxXBlockPart.Part.TL), 3); + level.setBlock(pos.above().west(), partState.setValue(MacMaxXBlockPart.PART, MacMaxXBlockPart.Part.TR), 3); + level.setBlock(pos.east(), partState.setValue(MacMaxXBlockPart.PART, MacMaxXBlockPart.Part.BL), 3); + level.setBlock(pos.west(), partState.setValue(MacMaxXBlockPart.PART, MacMaxXBlockPart.Part.BR), 3); + } + case WEST -> { + level.setBlock(pos.above().north(), partState.setValue(MacMaxXBlockPart.PART, MacMaxXBlockPart.Part.TL), 3); + level.setBlock(pos.above().south(), partState.setValue(MacMaxXBlockPart.PART, MacMaxXBlockPart.Part.TR), 3); + level.setBlock(pos.north(), partState.setValue(MacMaxXBlockPart.PART, MacMaxXBlockPart.Part.BL), 3); + level.setBlock(pos.south(), partState.setValue(MacMaxXBlockPart.PART, MacMaxXBlockPart.Part.BR), 3); + } + case EAST -> { + level.setBlock(pos.above().south(), partState.setValue(MacMaxXBlockPart.PART, MacMaxXBlockPart.Part.TL), 3); + level.setBlock(pos.above().north(), partState.setValue(MacMaxXBlockPart.PART, MacMaxXBlockPart.Part.TR), 3); + level.setBlock(pos.south(), partState.setValue(MacMaxXBlockPart.PART, MacMaxXBlockPart.Part.BL), 3); + level.setBlock(pos.north(), partState.setValue(MacMaxXBlockPart.PART, MacMaxXBlockPart.Part.BR), 3); + } + default -> throw new IllegalStateException("Unexpected value: " + state.getValue(FACING)); + } + } + + @Override + public void playerWillDestroy(@NotNull Level level, @NotNull BlockPos pos, BlockState state, @NotNull Player player) { + switch (state.getValue(FACING)) { + case NORTH -> { + level.setBlock(pos.above().west(), Blocks.AIR.defaultBlockState(), 3); + level.setBlock(pos.above().east(), Blocks.AIR.defaultBlockState(), 3); + level.setBlock(pos.above(), Blocks.AIR.defaultBlockState(), 3); + level.setBlock(pos.west(), Blocks.AIR.defaultBlockState(), 3); + level.setBlock(pos.east(), Blocks.AIR.defaultBlockState(), 3); + } + case SOUTH -> { + level.setBlock(pos.above().east(), Blocks.AIR.defaultBlockState(), 3); + level.setBlock(pos.above().west(), Blocks.AIR.defaultBlockState(), 3); + level.setBlock(pos.above(), Blocks.AIR.defaultBlockState(), 3); + level.setBlock(pos.east(), Blocks.AIR.defaultBlockState(), 3); + level.setBlock(pos.west(), Blocks.AIR.defaultBlockState(), 3); + } + case WEST -> { + level.setBlock(pos.above().north(), Blocks.AIR.defaultBlockState(), 3); + level.setBlock(pos.above().south(), Blocks.AIR.defaultBlockState(), 3); + level.setBlock(pos.above(), Blocks.AIR.defaultBlockState(), 3); + level.setBlock(pos.north(), Blocks.AIR.defaultBlockState(), 3); + level.setBlock(pos.south(), Blocks.AIR.defaultBlockState(), 3); + } + case EAST -> { + level.setBlock(pos.above().south(), Blocks.AIR.defaultBlockState(), 3); + level.setBlock(pos.above().north(), Blocks.AIR.defaultBlockState(), 3); + level.setBlock(pos.above(), Blocks.AIR.defaultBlockState(), 3); + level.setBlock(pos.south(), Blocks.AIR.defaultBlockState(), 3); + level.setBlock(pos.north(), Blocks.AIR.defaultBlockState(), 3); + } + default -> throw new IllegalStateException("Unexpected value: " + state.getValue(FACING)); + } + } + @Override public boolean isDesktopPC() { return true; diff --git a/common/src/main/java/com/ultreon/devices/block/MacMaxXBlockPart.java b/common/src/main/java/com/ultreon/devices/block/MacMaxXBlockPart.java index ccca2c9f9..9b752e4d4 100644 --- a/common/src/main/java/com/ultreon/devices/block/MacMaxXBlockPart.java +++ b/common/src/main/java/com/ultreon/devices/block/MacMaxXBlockPart.java @@ -1,55 +1,262 @@ package com.ultreon.devices.block; -import com.ultreon.devices.block.entity.MacMaxXBlockEntity; import dev.architectury.platform.Platform; import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.MutableComponent; import net.minecraft.util.StringRepresentable; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.DyeColor; import net.minecraft.world.level.BlockGetter; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.RenderShape; -import net.minecraft.world.level.block.SoundType; -import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.*; import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.world.level.block.state.properties.EnumProperty; import net.minecraft.world.level.material.Material; +import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.Shapes; import net.minecraft.world.phys.shapes.VoxelShape; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -public class MacMaxXBlockPart extends ComputerBlock { - private static EnumProperty PART = EnumProperty.create("part", Part.class); +/** + * @author Qboi123 + */ +public class MacMaxXBlockPart extends HorizontalDirectionalBlock { + public static final EnumProperty PART = EnumProperty.create("part", Part.class); - private static final VoxelShape BL_SHAPE_NORTH = Block.box(-16 + 16, 0, 7, 32 + 16, 35.25, 11); - private static final VoxelShape BL_SHAPE_EAST = Block.box(-16 + 16, 0, 7, 32 + 16, 35.25, 11); - private static final VoxelShape BL_SHAPE_SOUTH = Block.box(-16 + 16, 0, 7, 32 + 16, 35.25, 11); - private static final VoxelShape BL_SHAPE_WEST = Block.box(-16 + 16, 0, 7, 32 + 16, 35.25, 11); + private static final VoxelShape BL_SHAPE_NORTH = Shapes.or( + Block.box(-16 + 16, 31.0, 5.0, 32 + 16, 32.0, 7), + Block.box(-15 + 16, 4.0, 5.5, 31 + 16, 32.0, 7), + Block.box(-16 + 16, 5.0, 5.0, -15 + 16, 32.0, 7), + Block.box(-16 + 16, 3.0, 5.0, 32 + 16, 7.0, 7), + Block.box( 31 + 16, 5.0, 5.0, 32 + 16, 32.0, 7), + Block.box(- 6 + 16, 0.5, 6.5, - 2 + 16, 19.0, 9), + Block.box( 20 + 16, 0.5, 6.5, 24 + 16, 19.0, 9), + Block.box( 0 + 16, 13.0, 6.5, 18 + 16, 27.0, 8), + Block.box( 19 + 16, 0.0, 6.5, 25 + 16, 0.5, 9), + Block.box(- 7 + 16, 0.0, 6.5, - 1 + 16, 0.5, 9)); + private static final VoxelShape BL_SHAPE_EAST = Shapes.or( + Block.box(9, 31, -16 - 16, 11, 32, 32 - 16), + Block.box(9, 4, -15 - 16, 10.5, 32, 31 - 16), + Block.box(9, 5, -16 - 16, 11, 32, -15 - 16), + Block.box(9, 3, -16 - 16, 11, 7, 32 - 16), + Block.box(9, 5, 31 - 16, 11, 32, 32 - 16), + Block.box(7, 0.5, -6 - 16, 9.5, 19, -2 - 16), + Block.box(7, 0.5, 20 - 16, 9.5, 19, 24 - 16), + Block.box(8, 13, 0 - 16, 9.5, 27, 18 - 16), + Block.box(7, 0, 19 - 16, 9.5, 0.5, 25 - 16), + Block.box(7, 0, -7 - 16, 9.5, 0.5, -1 - 16)); + private static final VoxelShape BL_SHAPE_SOUTH = Shapes.or( + Block.box(-16 - 16, 31, 9, 32 - 16, 32, 11), + Block.box(-15 - 16, 4, 9, 31 - 16, 32, 10.5), + Block.box( 31 - 16, 5, 9, 32 - 16, 32, 11), + Block.box(-16 - 16, 3, 9, 32 - 16, 7, 11), + Block.box(-16 - 16, 5, 9, -15 - 16, 32, 11), + Block.box( 18 - 16, 0.5, 7, 22 - 16, 19, 9.5), + Block.box( -8 - 16, 0.5, 7, -4 - 16, 19, 9.5), + Block.box( -2 - 16, 13, 8, 16 - 16, 27, 9.5), + Block.box( -9 - 16, 0, 7, -3 - 16, 0.5, 9.5), + Block.box( 17 - 16, 0, 7, 23 - 16, 0.5, 9.5)); + private static final VoxelShape BL_SHAPE_WEST = Shapes.or( + Block.box( 5, 31, -16 + 16, 7, 32, 32 + 16), + Block.box(5.5, 4, -15 + 16, 7, 32, 31 + 16), + Block.box( 5, 5, 31 + 16, 7, 32, 32 + 16), + Block.box( 5, 3, -16 + 16, 7, 7, 32 + 16), + Block.box( 5, 5, -16 + 16, 7, 32, -15 + 16), + Block.box(6.5, 0.5, 18 + 16, 9, 19, 22 + 16), + Block.box(6.5, 0.5, -8 + 16, 9, 19, -4 + 16), + Block.box(6.5, 13, -2 + 16, 8, 27, 16 + 16), + Block.box(6.5, 0, -9 + 16, 9, 0.5, -3 + 16), + Block.box(6.5, 0, 17 + 16, 9, 0.5, 23 + 16)); - private static final VoxelShape BR_SHAPE_NORTH = Block.box(-16 - 16, 0, 7, 32 - 16, 35.25, 11); - private static final VoxelShape BR_SHAPE_EAST = Block.box(-16 - 16, 0, 7, 32 - 16, 35.25, 11); - private static final VoxelShape BR_SHAPE_SOUTH = Block.box(-16 - 16, 0, 7, 32 - 16, 35.25, 11); - private static final VoxelShape BR_SHAPE_WEST = Block.box(-16 - 16, 0, 7, 32 - 16, 35.25, 11); + private static final VoxelShape BR_SHAPE_NORTH = Shapes.or( + Block.box(-16 - 16, 31, 5, 32 - 16, 32, 7), + Block.box(-15 - 16, 4, 5.5, 31 - 16, 32, 7), + Block.box(-16 - 16, 5, 5, -15 - 16, 32, 7), + Block.box(-16 - 16, 3, 5, 32 - 16, 7, 7), + Block.box( 31 - 16, 5, 5, 32 - 16, 32, 7), + Block.box( -6 - 16, 0.5, 6.5, -2 - 16, 19, 9), + Block.box( 20 - 16, 0.5, 6.5, 24 - 16, 19, 9), + Block.box( 0 - 16, 13, 6.5, 18 - 16, 27, 8), + Block.box( 19 - 16, 0, 6.5, 25 - 16, 0.5, 9), + Block.box( -7 - 16, 0, 6.5, -1 - 16, 0.5, 9)); + private static final VoxelShape BR_SHAPE_EAST = Shapes.or( + Block.box(9, 31, -16 + 16, 11, 32, 32 + 16), + Block.box(9, 4, -15 + 16, 10.5, 32, 31 + 16), + Block.box(9, 5, -16 + 16, 11, 32, -15 + 16), + Block.box(9, 3, -16 + 16, 11, 7, 32 + 16), + Block.box(9, 5, 31 + 16, 11, 32, 32 + 16), + Block.box(7, 0.5, -6 + 16, 9.5, 19, -2 + 16), + Block.box(7, 0.5, 20 + 16, 9.5, 19, 24 + 16), + Block.box(8, 13, 0 + 16, 9.5, 27, 18 + 16), + Block.box(7, 0, 19 + 16, 9.5, 0.5, 25 + 16), + Block.box(7, 0, -7 + 16, 9.5, 0.5, -1 + 16)); + private static final VoxelShape BR_SHAPE_SOUTH = Shapes.or( + Block.box(-16 + 16, 31, 9, 32 + 16, 32, 11), + Block.box(-15 + 16, 4, 9, 31 + 16, 32, 10.5), + Block.box( 31 + 16, 5, 9, 32 + 16, 32, 11), + Block.box(-16 + 16, 3, 9, 32 + 16, 7, 11), + Block.box(-16 + 16, 5, 9, -15 + 16, 32, 11), + Block.box( 18 + 16, 0.5, 7, 22 + 16, 19, 9.5), + Block.box( -8 + 16, 0.5, 7, -4 + 16, 19, 9.5), + Block.box( -2 + 16, 13, 8, 16 + 16, 27, 9.5), + Block.box( -9 + 16, 0, 7, -3 + 16, 0.5, 9.5), + Block.box( 17 + 16, 0, 7, 23 + 16, 0.5, 9.5)); + private static final VoxelShape BR_SHAPE_WEST = Shapes.or( + Block.box( 5, 31, -16 - 16, 7, 32, 32 - 16), + Block.box(5.5, 4, -15 - 16, 7, 32, 31 - 16), + Block.box( 5, 5, 31 - 16, 7, 32, 32 - 16), + Block.box( 5, 3, -16 - 16, 7, 7, 32 - 16), + Block.box( 5, 5, -16 - 16, 7, 32, -15 - 16), + Block.box(6.5, 0.5, 18 - 16, 9, 19, 22 - 16), + Block.box(6.5, 0.5, -8 - 16, 9, 19, -4 - 16), + Block.box(6.5, 13, -2 - 16, 8, 27, 16 - 16), + Block.box(6.5, 0, -9 - 16, 9, 0.5, -3 - 16), + Block.box(6.5, 0, 17 - 16, 9, 0.5, 23 - 16)); - private static final VoxelShape TL_SHAPE_NORTH = Block.box(-16 + 16, -16, 7, 32 + 16, 19.25, 11); - private static final VoxelShape TL_SHAPE_EAST = Block.box(-16 + 16, -16, 7, 32 + 16, 19.25, 11); - private static final VoxelShape TL_SHAPE_SOUTH = Block.box(-16 + 16, -16, 7, 32 + 16, 19.25, 11); - private static final VoxelShape TL_SHAPE_WEST = Block.box(-16 + 16, -16, 7, 32 + 16, 19.25, 11); + private static final VoxelShape TL_SHAPE_NORTH = Shapes.or( + Block.box(-16 + 16, 31 - 16, 5, 32 + 16, 32 - 16, 7), + Block.box(-15 + 16, 4 - 16, 5.5, 31 + 16, 32 - 16, 7), + Block.box(-16 + 16, 5 - 16, 5, -15 + 16, 32 - 16, 7), + Block.box(-16 + 16, 3 - 16, 5, 32 + 16, 7 - 16, 7), + Block.box( 31 + 16, 5 - 16, 5, 32 + 16, 32 - 16, 7), + Block.box( -6 + 16, 0.5 - 16, 6.5, -2 + 16, 19 - 16, 9), + Block.box( 20 + 16, 0.5 - 16, 6.5, 24 + 16, 19 - 16, 9), + Block.box( 0 + 16, 13 - 16, 6.5, 18 + 16, 27 - 16, 8), + Block.box( 19 + 16, 0 - 16, 6.5, 25 + 16, 0.5 - 16, 9), + Block.box( -7 + 16, 0 - 16, 6.5, -1 + 16, 0.5 - 16, 9)); + private static final VoxelShape TL_SHAPE_EAST = Shapes.or( + Block.box(9, 31 - 16, -16 - 16, 11, 32 - 16, 32 - 16), + Block.box(9, 4 - 16, -15 - 16, 10.5, 32 - 16, 31 - 16), + Block.box(9, 5 - 16, -16 - 16, 11, 32 - 16, -15 - 16), + Block.box(9, 3 - 16, -16 - 16, 11, 7 - 16, 32 - 16), + Block.box(9, 5 - 16, 31 - 16, 11, 32 - 16, 32 - 16), + Block.box(7, 0.5 - 16, -6 - 16, 9.5, 19 - 16, -2 - 16), + Block.box(7, 0.5 - 16, 20 - 16, 9.5, 19 - 16, 24 - 16), + Block.box(8, 13 - 16, 0 - 16, 9.5, 27 - 16, 18 - 16), + Block.box(7, 0 - 16, 19 - 16, 9.5, 0.5 - 16, 25 - 16), + Block.box(7, 0 - 16, -7 - 16, 9.5, 0.5 - 16, -1 - 16)); + private static final VoxelShape TL_SHAPE_SOUTH = Shapes.or( + Block.box(-16 - 16, 31 - 16, 9, 32 - 16, 32 - 16, 11), + Block.box(-15 - 16, 4 - 16, 9, 31 - 16, 32 - 16, 10.5), + Block.box( 31 - 16, 5 - 16, 9, 32 - 16, 32 - 16, 11), + Block.box(-16 - 16, 3 - 16, 9, 32 - 16, 7 - 16, 11), + Block.box(-16 - 16, 5 - 16, 9, -15 - 16, 32 - 16, 11), + Block.box( 18 - 16, 0.5 - 16, 7, 22 - 16, 19 - 16, 9.5), + Block.box( -8 - 16, 0.5 - 16, 7, -4 - 16, 19 - 16, 9.5), + Block.box( -2 - 16, 13 - 16, 8, 16 - 16, 27 - 16, 9.5), + Block.box( -9 - 16, 0 - 16, 7, -3 - 16, 0.5 - 16, 9.5), + Block.box( 17 - 16, 0 - 16, 7, 23 - 16, 0.5 - 16, 9.5)); + private static final VoxelShape TL_SHAPE_WEST = Shapes.or( + Block.box( 5, 31 - 16, -16 + 16, 7, 32 - 16, 32 + 16), + Block.box(5.5, 4 - 16, -15 + 16, 7, 32 - 16, 31 + 16), + Block.box( 5, 5 - 16, 31 + 16, 7, 32 - 16, 32 + 16), + Block.box( 5, 3 - 16, -16 + 16, 7, 7 - 16, 32 + 16), + Block.box( 5, 5 - 16, -16 + 16, 7, 32 - 16, -15 + 16), + Block.box(6.5, 0.5 - 16, 18 + 16, 9, 19 - 16, 22 + 16), + Block.box(6.5, 0.5 - 16, -8 + 16, 9, 19 - 16, -4 + 16), + Block.box(6.5, 13 - 16, -2 + 16, 8, 27 - 16, 16 + 16), + Block.box(6.5, 0 - 16, -9 + 16, 9, 0.5 - 16, -3 + 16), + Block.box(6.5, 0 - 16, 17 + 16, 9, 0.5 - 16, 23 + 16)); - private static final VoxelShape T_SHAPE_NORTH = Block.box(-16, -16, 7, 32, 19.25, 11); - private static final VoxelShape T_SHAPE_EAST = Block.box(-16, -16, 7, 32, 19.25, 11); - private static final VoxelShape T_SHAPE_SOUTH = Block.box(-16, -16, 7, 32, 19.25, 11); - private static final VoxelShape T_SHAPE_WEST = Block.box(-16, -16, 7, 32, 19.25, 11); + private static final VoxelShape T_SHAPE_NORTH = Shapes.or( + Block.box(-16, 31 - 16, 5, 32, 32 - 16, 7), + Block.box(-15, 4 - 16, 5.5, 31, 32 - 16, 7), + Block.box(-16, 5 - 16, 5, -15, 32 - 16, 7), + Block.box(-16, 3 - 16, 5, 32, 7 - 16, 7), + Block.box( 31, 5 - 16, 5, 32, 32 - 16, 7), + Block.box( -6, 0.5 - 16, 6.5, -2, 19 - 16, 9), + Block.box( 20, 0.5 - 16, 6.5, 24, 19 - 16, 9), + Block.box( 0, 13 - 16, 6.5, 18, 27 - 16, 8), + Block.box( 19, 0 - 16, 6.5, 25, 0.5 - 16, 9), + Block.box( -7, 0 - 16, 6.5, -1, 0.5 - 16, 9)); + private static final VoxelShape T_SHAPE_EAST = Shapes.or( + Block.box(9, 31 - 16, -16, 11, 32 - 16, 32), + Block.box(9, 4 - 16, -15, 10.5, 32 - 16, 31), + Block.box(9, 5 - 16, -16, 11, 32 - 16, -15), + Block.box(9, 3 - 16, -16, 11, 7 - 16, 32), + Block.box(9, 5 - 16, 31, 11, 32 - 16, 32), + Block.box(7, 0.5 - 16, -6, 9.5, 19 - 16, -2), + Block.box(7, 0.5 - 16, 20, 9.5, 19 - 16, 24), + Block.box(8, 13 - 16, 0, 9.5, 27 - 16, 18), + Block.box(7, 0 - 16, 19, 9.5, 0.5 - 16, 25), + Block.box(7, 0 - 16, -7, 9.5, 0.5 - 16, -1)); + private static final VoxelShape T_SHAPE_SOUTH = Shapes.or( + Block.box(-16, 31 - 16, 9, 32, 32 - 16, 11), + Block.box(-15, 4 - 16, 9, 31, 32 - 16, 10.5), + Block.box( 31, 5 - 16, 9, 32, 32 - 16, 11), + Block.box(-16, 3 - 16, 9, 32, 7 - 16, 11), + Block.box(-16, 5 - 16, 9, -15, 32 - 16, 11), + Block.box( 18, 0.5 - 16, 7, 22, 19 - 16, 9.5), + Block.box( -8, 0.5 - 16, 7, -4, 19 - 16, 9.5), + Block.box( -2, 13 - 16, 8, 16, 27 - 16, 9.5), + Block.box( -9, 0 - 16, 7, -3, 0.5 - 16, 9.5), + Block.box( 17, 0 - 16, 7, 23, 0.5 - 16, 9.5)); + private static final VoxelShape T_SHAPE_WEST = Shapes.or( + Block.box( 5, 31 - 16, -16, 7, 32 - 16, 32), + Block.box(5.5, 4 - 16, -15, 7, 32 - 16, 31), + Block.box( 5, 5 - 16, 31, 7, 32 - 16, 32), + Block.box( 5, 3 - 16, -16, 7, 7 - 16, 32), + Block.box( 5, 5 - 16, -16, 7, 32 - 16, -15), + Block.box(6.5, 0.5 - 16, 18, 9, 19 - 16, 22), + Block.box(6.5, 0.5 - 16, -8, 9, 19 - 16, -4), + Block.box(6.5, 13 - 16, -2, 8, 27 - 16, 16), + Block.box(6.5, 0 - 16, -9, 9, 0.5 - 16, -3), + Block.box(6.5, 0 - 16, 17, 9, 0.5 - 16, 23)); - private static final VoxelShape TR_SHAPE_NORTH = Block.box(-16 - 16, -16, 7, 32 - 16, 19.25, 11); - private static final VoxelShape TR_SHAPE_EAST = Block.box(-16 - 16, -16, 7, 32 - 16, 19.25, 11); - private static final VoxelShape TR_SHAPE_SOUTH = Block.box(-16 - 16, -16, 7, 32 - 16, 19.25, 11); - private static final VoxelShape TR_SHAPE_WEST = Block.box(-16 - 16, -16, 7, 32 - 16, 19.25, 11); + private static final VoxelShape TR_SHAPE_NORTH = Shapes.or( + Block.box(-16 - 16, 31 - 16, 5, 32 - 16, 32 - 16, 7), + Block.box(-15 - 16, 4 - 16, 5.5, 31 - 16, 32 - 16, 7), + Block.box(-16 - 16, 5 - 16, 5, -15 - 16, 32 - 16, 7), + Block.box(-16 - 16, 3 - 16, 5, 32 - 16, 7 - 16, 7), + Block.box( 31 - 16, 5 - 16, 5, 32 - 16, 32 - 16, 7), + Block.box( -6 - 16, 0.5 - 16, 6.5, -2 - 16, 19 - 16, 9), + Block.box( 20 - 16, 0.5 - 16, 6.5, 24 - 16, 19 - 16, 9), + Block.box( 0 - 16, 13 - 16, 6.5, 18 - 16, 27 - 16, 8), + Block.box( 19 - 16, 0 - 16, 6.5, 25 - 16, 0.5 - 16, 9), + Block.box( -7 - 16, 0 - 16, 6.5, -1 - 16, 0.5 - 16, 9)); + private static final VoxelShape TR_SHAPE_EAST = Shapes.or( + Block.box(9, 31 - 16, -16 + 16, 11, 32 - 16, 32 + 16), + Block.box(9, 4 - 16, -15 + 16, 10.5, 32 - 16, 31 + 16), + Block.box(9, 5 - 16, -16 + 16, 11, 32 - 16, -15 + 16), + Block.box(9, 3 - 16, -16 + 16, 11, 7 - 16, 32 + 16), + Block.box(9, 5 - 16, 31 + 16, 11, 32 - 16, 32 + 16), + Block.box(7, 0.5 - 16, -6 + 16, 9.5, 19 - 16, -2 + 16), + Block.box(7, 0.5 - 16, 20 + 16, 9.5, 19 - 16, 24 + 16), + Block.box(8, 13 - 16, 0 + 16, 9.5, 27 - 16, 18 + 16), + Block.box(7, 0 - 16, 19 + 16, 9.5, 0.5 - 16, 25 + 16), + Block.box(7, 0 - 16, -7 + 16, 9.5, 0.5 - 16, -1 + 16)); + private static final VoxelShape TR_SHAPE_SOUTH = Shapes.or( + Block.box(-16 + 16, 31 - 16, 9, 32 + 16, 32 - 16, 11), + Block.box(-15 + 16, 4 - 16, 9, 31 + 16, 32 - 16, 10.5), + Block.box( 31 + 16, 5 - 16, 9, 32 + 16, 32 - 16, 11), + Block.box(-16 + 16, 3 - 16, 9, 32 + 16, 7 - 16, 11), + Block.box(-16 + 16, 5 - 16, 9, -15 + 16, 32 - 16, 11), + Block.box( 18 + 16, 0.5 - 16, 7, 22 + 16, 19 - 16, 9.5), + Block.box( -8 + 16, 0.5 - 16, 7, -4 + 16, 19 - 16, 9.5), + Block.box( -2 + 16, 13 - 16, 8, 16 + 16, 27 - 16, 9.5), + Block.box( -9 + 16, 0 - 16, 7, -3 + 16, 0.5 - 16, 9.5), + Block.box( 17 + 16, 0 - 16, 7, 23 + 16, 0.5 - 16, 9.5)); + private static final VoxelShape TR_SHAPE_WEST = Shapes.or( + Block.box( 5, 31 - 16, -16 - 16, 7, 32 - 16, 32 - 16), + Block.box(5.5, 4 - 16, -15 - 16, 7, 32 - 16, 31 - 16), + Block.box( 5, 5 - 16, 31 - 16, 7, 32 - 16, 32 - 16), + Block.box( 5, 3 - 16, -16 - 16, 7, 7 - 16, 32 - 16), + Block.box( 5, 5 - 16, -16 - 16, 7, 32 - 16, -15 - 16), + Block.box(6.5, 0.5 - 16, 18 - 16, 9, 19 - 16, 22 - 16), + Block.box(6.5, 0.5 - 16, -8 - 16, 9, 19 - 16, -4 - 16), + Block.box(6.5, 13 - 16, -2 - 16, 8, 27 - 16, 16 - 16), + Block.box(6.5, 0 - 16, -9 - 16, 9, 0.5 - 16, -3 - 16), + Block.box(6.5, 0 - 16, 17 - 16, 9, 0.5 - 16, 23 - 16)); public MacMaxXBlockPart() { super(Properties.of(Material.HEAVY_METAL, DyeColor.WHITE).strength(6f).sound(SoundType.METAL)); + registerDefaultState(this.getStateDefinition().any().setValue(FACING, Direction.NORTH).setValue(PART, Part.T)); } @Override @@ -100,13 +307,95 @@ public MacMaxXBlockPart() { default -> throw new IllegalStateException("Unexpected value: " + pState.getValue(FACING)); }; } - }; + } throw new IllegalStateException("Unexpected value: " + pState.getValue(PART)); } @Override - public boolean isDesktopPC() { - return true; + public void playerWillDestroy(@NotNull Level level, @NotNull BlockPos pos, @NotNull BlockState state, @NotNull Player player) { + BlockPos originPos = getOriginPos(pos, state); + switch (state.getValue(FACING)) { + case NORTH -> { + destroyBlockExcept(level, pos, originPos.above().west(), Blocks.AIR.defaultBlockState(), 3); + destroyBlockExcept(level, pos, originPos.above().east(), Blocks.AIR.defaultBlockState(), 3); + destroyBlockExcept(level, pos, originPos.above(), Blocks.AIR.defaultBlockState(), 3); + destroyBlockExcept(level, pos, originPos.west(), Blocks.AIR.defaultBlockState(), 3); + destroyBlockExcept(level, pos, originPos.east(), Blocks.AIR.defaultBlockState(), 3); + } + case SOUTH -> { + destroyBlockExcept(level, pos, originPos.above().east(), Blocks.AIR.defaultBlockState(), 3); + destroyBlockExcept(level, pos, originPos.above().west(), Blocks.AIR.defaultBlockState(), 3); + destroyBlockExcept(level, pos, originPos.above(), Blocks.AIR.defaultBlockState(), 3); + destroyBlockExcept(level, pos, originPos.east(), Blocks.AIR.defaultBlockState(), 3); + destroyBlockExcept(level, pos, originPos.west(), Blocks.AIR.defaultBlockState(), 3); + } + case WEST -> { + destroyBlockExcept(level, pos, originPos.above().north(), Blocks.AIR.defaultBlockState(), 3); + destroyBlockExcept(level, pos, originPos.above().south(), Blocks.AIR.defaultBlockState(), 3); + destroyBlockExcept(level, pos, originPos.above(), Blocks.AIR.defaultBlockState(), 3); + destroyBlockExcept(level, pos, originPos.north(), Blocks.AIR.defaultBlockState(), 3); + destroyBlockExcept(level, pos, originPos.south(), Blocks.AIR.defaultBlockState(), 3); + } + case EAST -> { + destroyBlockExcept(level, pos, originPos.above().south(), Blocks.AIR.defaultBlockState(), 3); + destroyBlockExcept(level, pos, originPos.above().north(), Blocks.AIR.defaultBlockState(), 3); + destroyBlockExcept(level, pos, originPos.above(), Blocks.AIR.defaultBlockState(), 3); + destroyBlockExcept(level, pos, originPos.south(), Blocks.AIR.defaultBlockState(), 3); + destroyBlockExcept(level, pos, originPos.north(), Blocks.AIR.defaultBlockState(), 3); + } + default -> throw new IllegalStateException("Unexpected value: " + state.getValue(FACING)); + } + destroyBlockExcept(level, pos, originPos, Blocks.AIR.defaultBlockState(), 3); + } + + @SuppressWarnings("SameParameterValue") + private void destroyBlockExcept(Level level, BlockPos except, BlockPos pos, BlockState state, int flags) { + if (except.equals(pos)) return; + level.setBlock(pos, state, flags); + } + + private static BlockPos getOriginPos(@NotNull BlockPos pos, BlockState state) { + return switch (state.getValue(FACING)) { + case NORTH -> switch (state.getValue(PART)) { + case TL -> pos.east().below(); + case TR -> pos.west().below(); + case T -> pos.below(); + case BL -> pos.east(); + case BR -> pos.west(); + }; + case SOUTH -> switch (state.getValue(PART)) { + case TL -> pos.west().below(); + case TR -> pos.east().below(); + case T -> pos.below(); + case BL -> pos.west(); + case BR -> pos.east(); + }; + case WEST -> switch (state.getValue(PART)) { + case TL -> pos.south().below(); + case TR -> pos.north().below(); + case T -> pos.below(); + case BL -> pos.south(); + case BR -> pos.north(); + }; + case EAST -> switch (state.getValue(PART)) { + case TL -> pos.north().below(); + case TR -> pos.south().below(); + case T -> pos.below(); + case BL -> pos.north(); + case BR -> pos.south(); + }; + default -> throw new IllegalStateException("Unexpected value: " + state.getValue(FACING)); + }; + } + + @Override + public InteractionResult use(@NotNull BlockState state, Level level, @NotNull BlockPos pos, @NotNull Player player, @NotNull InteractionHand hand, @NotNull BlockHitResult hit) { + BlockPos originPos = getOriginPos(pos, state); + BlockState originState = level.getBlockState(originPos); + if (originState.getBlock() instanceof MacMaxXBlock block) { + return block.use(originState, level, originPos, player, hand, hit); + } + return InteractionResult.FAIL; } @Override @@ -124,8 +413,9 @@ public RenderShape getRenderShape(@NotNull BlockState state) { } @Override - public @Nullable BlockEntity newBlockEntity(@NotNull BlockPos pos, @NotNull BlockState state) { - return new MacMaxXBlockEntity(pos, state); + protected void createBlockStateDefinition(StateDefinition.@NotNull Builder pBuilder) { + super.createBlockStateDefinition(pBuilder); + pBuilder.add(PART, FACING); } public enum Part implements StringRepresentable { diff --git a/common/src/main/java/com/ultreon/devices/block/entity/ComputerBlockEntity.java b/common/src/main/java/com/ultreon/devices/block/entity/ComputerBlockEntity.java index ed0a67e45..68fa8429f 100644 --- a/common/src/main/java/com/ultreon/devices/block/entity/ComputerBlockEntity.java +++ b/common/src/main/java/com/ultreon/devices/block/entity/ComputerBlockEntity.java @@ -1,6 +1,6 @@ package com.ultreon.devices.block.entity; -import com.ultreon.devices.block.LaptopBlock; +import com.ultreon.devices.block.ComputerBlock; import com.ultreon.devices.core.io.FileSystem; import com.ultreon.devices.util.BlockEntityUtil; import net.fabricmc.api.EnvType; @@ -66,7 +66,7 @@ public void load(@NotNull CompoundTag compound) { super.load(compound); if (compound.contains("open")) { this.open = compound.getBoolean("open"); - this.getBlockState().setValue(LaptopBlock.OPEN, open); + this.getBlockState().setValue(ComputerBlock.OPEN, open); } if (compound.contains("system_data", Tag.TAG_COMPOUND)) { this.systemData = compound.getCompound("system_data"); @@ -134,10 +134,10 @@ public void openClose(@Nullable Entity entity) { level.gameEvent(!open ? GameEvent.BLOCK_OPEN : GameEvent.BLOCK_CLOSE, getBlockPos(), GameEvent.Context.of(entity, this.getBlockState())); } boolean oldOpen = open; - open = !getBlockState().getValue(LaptopBlock.OPEN); + open = !getBlockState().getValue(ComputerBlock.OPEN); if (oldOpen != open) { pipeline.putBoolean("open", open); - var d = getBlockState().setValue(LaptopBlock.OPEN, open); + var d = getBlockState().setValue(ComputerBlock.OPEN, open); this.level.setBlock(this.getBlockPos(), d, 18); sync(); } @@ -154,10 +154,10 @@ public void open(@Nullable Entity entity, boolean open) { level.gameEvent(open ? GameEvent.BLOCK_OPEN : GameEvent.BLOCK_CLOSE, getBlockPos(), GameEvent.Context.of(entity, this.getBlockState())); } boolean oldOpen = open; - open = !getBlockState().getValue(LaptopBlock.OPEN); + open = !getBlockState().getValue(ComputerBlock.OPEN); if (oldOpen != open) { pipeline.putBoolean("open", open); - var d = getBlockState().setValue(LaptopBlock.OPEN, open); + var d = getBlockState().setValue(ComputerBlock.OPEN, open); this.level.setBlock(this.getBlockPos(), d, 18); sync(); } diff --git a/common/src/main/java/com/ultreon/devices/init/DeviceBlocks.java b/common/src/main/java/com/ultreon/devices/init/DeviceBlocks.java index 7c38161fc..9eff9687c 100644 --- a/common/src/main/java/com/ultreon/devices/init/DeviceBlocks.java +++ b/common/src/main/java/com/ultreon/devices/init/DeviceBlocks.java @@ -35,6 +35,7 @@ public static void register() { public static final RegistrySupplier BLACK_LAPTOP = REGISTER.register(Devices.id("black_laptop"), () -> new LaptopBlock(DyeColor.BLACK)); public static final RegistrySupplier MAC_MAX_X = REGISTER.register(Devices.id("mac_max_x"), MacMaxXBlock::new); + public static final RegistrySupplier MAC_MAX_X_PART = REGISTER.register(Devices.id("mac_max_x_part"), MacMaxXBlockPart::new); public static final RegistrySupplier WHITE_PRINTER = REGISTER.register(Devices.id("white_printer"), () -> new PrinterBlock(DyeColor.WHITE)); public static final RegistrySupplier ORANGE_PRINTER = REGISTER.register(Devices.id("orange_printer"), () -> new PrinterBlock(DyeColor.ORANGE)); diff --git a/common/src/main/java/com/ultreon/devices/init/DeviceItems.java b/common/src/main/java/com/ultreon/devices/init/DeviceItems.java index 5d2a3fe41..5a6374268 100644 --- a/common/src/main/java/com/ultreon/devices/init/DeviceItems.java +++ b/common/src/main/java/com/ultreon/devices/init/DeviceItems.java @@ -3,12 +3,16 @@ import com.ultreon.devices.Devices; import com.ultreon.devices.ModDeviceTypes; import com.ultreon.devices.item.*; +import dev.architectury.platform.Platform; import dev.architectury.registry.registries.Registrar; import dev.architectury.registry.registries.RegistrySupplier; import net.minecraft.core.Registry; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.MutableComponent; import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.DyeColor; import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; import org.jetbrains.annotations.Nullable; import java.util.List; @@ -37,7 +41,21 @@ public class DeviceItems { public static final RegistrySupplier BLACK_LAPTOP = REGISTER.register(Devices.id("black_laptop"), () -> new ColoredDeviceItem(DeviceBlocks.BLACK_LAPTOP.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.BLACK, ModDeviceTypes.COMPUTER)); // Custom Computers - public static final RegistrySupplier MAC_MAX_X = REGISTER.register(Devices.id("mac_max_x"), () -> new DeviceItem(DeviceBlocks.MAC_MAX_X.get(), new Item.Properties().tab(Devices.TAB_DEVICE), ModDeviceTypes.COMPUTER)); + public static final RegistrySupplier MAC_MAX_X = REGISTER.register(Devices.id("mac_max_x"), () -> new DeviceItem(DeviceBlocks.MAC_MAX_X.get(), new Item.Properties().tab(Devices.TAB_DEVICE), ModDeviceTypes.COMPUTER) { + @Override + public Component getDescription() { + MutableComponent normalName = Component.translatable("block.devices.mac_max_x"); + if (Platform.isModLoaded("emojiful")) { + return Component.translatable("block.devices.mac_max_x_emoji"); + } + return normalName; + } + + @Override + public Component getName(ItemStack stack) { + return getDescription(); + } + }); // Printers public static final RegistrySupplier WHITE_PRINTER = REGISTER.register(Devices.id("white_printer"), () -> new ColoredDeviceItem(DeviceBlocks.WHITE_PRINTER.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.WHITE, ModDeviceTypes.PRINTER)); diff --git a/common/src/main/resources/assets/devices/geo/mac_max_x.geo.json b/common/src/main/resources/assets/devices/geo/mac_max_x.geo.json deleted file mode 100644 index 5d4d727f9..000000000 --- a/common/src/main/resources/assets/devices/geo/mac_max_x.geo.json +++ /dev/null @@ -1,143 +0,0 @@ -{ - "format_version": "1.12.0", - "minecraft:geometry": [ - { - "description": { - "identifier": "geometry.mac_max_x", - "texture_width": 128, - "texture_height": 128, - "visible_bounds_width": 4, - "visible_bounds_height": 3.5, - "visible_bounds_offset": [0, 1.25, 0] - }, - "bones": [ - { - "name": "bb_main", - "pivot": [0, 0, 0], - "cubes": [ - { - "origin": [-24, 34, -1], - "size": [48, 1, 2], - "uv": { - "north": {"uv": [58, 48], "uv_size": [48, 1]}, - "east": {"uv": [44, 62], "uv_size": [2, 1]}, - "south": {"uv": [58, 49], "uv_size": [48, 1]}, - "west": {"uv": [50, 63], "uv_size": [2, 1]}, - "up": {"uv": [46, 36], "uv_size": [48, 2]}, - "down": {"uv": [46, 40], "uv_size": [48, -2]} - } - }, - { - "origin": [-24, 3, -1], - "size": [48, 4, 2], - "uv": { - "north": {"uv": [46, 28], "uv_size": [48, 4]}, - "east": {"uv": [40, 62], "uv_size": [2, 4]}, - "south": {"uv": [46, 32], "uv_size": [48, 4]}, - "west": {"uv": [42, 62], "uv_size": [2, 4]}, - "up": {"uv": [46, 40], "uv_size": [48, 2]}, - "down": {"uv": [46, 44], "uv_size": [48, -2]} - } - }, - { - "origin": [23, 7, -1], - "size": [1, 27, 2], - "uv": { - "north": {"uv": [28, 56], "uv_size": [1, 27]}, - "east": {"uv": [4, 56], "uv_size": [2, 27]}, - "south": {"uv": [29, 56], "uv_size": [1, 27]}, - "west": {"uv": [6, 56], "uv_size": [2, 27]}, - "up": {"uv": [52, 63], "uv_size": [1, 2]}, - "down": {"uv": [53, 65], "uv_size": [1, -2]} - } - }, - { - "origin": [-24, 7, -1], - "size": [1, 27, 2], - "uv": { - "north": {"uv": [30, 56], "uv_size": [1, 27]}, - "east": {"uv": [8, 56], "uv_size": [2, 27]}, - "south": {"uv": [31, 56], "uv_size": [1, 27]}, - "west": {"uv": [10, 56], "uv_size": [2, 27]}, - "up": {"uv": [54, 63], "uv_size": [1, 2]}, - "down": {"uv": [55, 65], "uv_size": [1, -2]} - } - }, - { - "origin": [-23, 6, -0.5], - "size": [46, 28, 1.5], - "uv": { - "north": {"uv": [0, 0], "uv_size": [46, 28]}, - "east": {"uv": [24, 56], "uv_size": [1.5, 28]}, - "south": {"uv": [0, 28], "uv_size": [46, 28]}, - "west": {"uv": [26, 56], "uv_size": [1.5, 28]}, - "up": {"uv": [58, 44], "uv_size": [46, 1.5]}, - "down": {"uv": [58, 47.5], "uv_size": [46, -1.5]} - } - }, - { - "origin": [-10, 13, 0.5], - "size": [18, 14, 1.5], - "uv": { - "north": {"uv": [46, 0], "uv_size": [18, 14]}, - "east": {"uv": [32, 56], "uv_size": [1.5, 14]}, - "south": {"uv": [46, 14], "uv_size": [18, 14]}, - "west": {"uv": [34, 56], "uv_size": [1.5, 14]}, - "up": {"uv": [58, 50], "uv_size": [18, 1.5]}, - "down": {"uv": [58, 53.5], "uv_size": [18, -1.5]} - } - }, - { - "origin": [10, 0.5, 0.5], - "size": [4, 18.5, 2.5], - "uv": { - "north": {"uv": [46, 44], "uv_size": [4, 18.5]}, - "east": {"uv": [12, 56], "uv_size": [2.5, 18.5]}, - "south": {"uv": [50, 44], "uv_size": [4, 18.5]}, - "west": {"uv": [15, 56], "uv_size": [2.5, 18.5]}, - "up": {"uv": [42, 56], "uv_size": [4, 2.5]}, - "down": {"uv": [42, 61.5], "uv_size": [4, -2.5]} - } - }, - { - "origin": [9, 0, 0.5], - "size": [6, 0.5, 2.5], - "uv": { - "north": {"uv": [62, 62], "uv_size": [6, 0.5]}, - "east": {"uv": [62, 63], "uv_size": [2.5, 0.5]}, - "south": {"uv": [44, 63], "uv_size": [6, 0.5]}, - "west": {"uv": [64, 0], "uv_size": [2.5, 0.5]}, - "up": {"uv": [58, 57], "uv_size": [6, 2.5]}, - "down": {"uv": [36, 61.5], "uv_size": [6, -2.5]} - } - }, - { - "origin": [-16, 0.5, 0.5], - "size": [4, 18.5, 2.5], - "uv": { - "north": {"uv": [54, 44], "uv_size": [4, 18.5]}, - "east": {"uv": [18, 56], "uv_size": [2.5, 18.5]}, - "south": {"uv": [0, 56], "uv_size": [4, 18.5]}, - "west": {"uv": [21, 56], "uv_size": [2.5, 18.5]}, - "up": {"uv": [58, 60], "uv_size": [4, 2.5]}, - "down": {"uv": [36, 64.5], "uv_size": [4, -2.5]} - } - }, - { - "origin": [-17, 0, 0.5], - "size": [6, 0.5, 2.5], - "uv": { - "north": {"uv": [62, 60], "uv_size": [6, 0.5]}, - "east": {"uv": [56, 63], "uv_size": [2.5, 0.5]}, - "south": {"uv": [62, 61], "uv_size": [6, 0.5]}, - "west": {"uv": [59, 63], "uv_size": [2.5, 0.5]}, - "up": {"uv": [36, 56], "uv_size": [6, 2.5]}, - "down": {"uv": [58, 56.5], "uv_size": [6, -2.5]} - } - } - ] - } - ] - } - ] -} \ No newline at end of file diff --git a/common/src/main/resources/assets/devices/models/block/mac_max_x.json b/common/src/main/resources/assets/devices/models/block/mac_max_x.json index 730a57193..8f3de0c4d 100644 --- a/common/src/main/resources/assets/devices/models/block/mac_max_x.json +++ b/common/src/main/resources/assets/devices/models/block/mac_max_x.json @@ -1,6 +1,7 @@ { "credit": "Made with Blockbench", "texture_size": [128, 128], + "ambientocclusion": false, "textures": { "0": "devices:block/mac_max_x" }, diff --git a/common/src/main/resources/assets/devices/models/item/mac_max_x.json b/common/src/main/resources/assets/devices/models/item/mac_max_x.json index 0e4842af6..1a1dcef9c 100644 --- a/common/src/main/resources/assets/devices/models/item/mac_max_x.json +++ b/common/src/main/resources/assets/devices/models/item/mac_max_x.json @@ -1,38 +1,3 @@ { - "parent": "builtin/entity", - "textures": { - "particle": "block/quartz_block_bottom" - }, - "display": { - "gui": { - "rotation": [ 30, 45, 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 ] - }, - "head": { - "rotation": [ 0, 180, 0 ], - "translation": [ 0, 0, 0], - "scale":[ 1, 1, 1] - }, - "fixed": { - "rotation": [ 0, 180, 0 ], - "translation": [ 0, 0, 0], - "scale":[ 0.5, 0.5, 0.5 ] - }, - "thirdperson_righthand": { - "rotation": [ 75, 315, 0 ], - "translation": [ 0, 2.5, 0], - "scale": [ 0.375, 0.375, 0.375 ] - }, - "firstperson_righthand": { - "rotation": [ 0, 315, 0 ], - "translation": [ 0, 0, 0], - "scale": [ 0.4, 0.4, 0.4 ] - } - } + "parent": "devices:block/mac_max_x" } diff --git a/common/src/main/resources/data/devices/loot_tables/blocks/mac_max_x.json b/common/src/main/resources/data/devices/loot_tables/blocks/mac_max_x.json new file mode 100644 index 000000000..86b40ee3b --- /dev/null +++ b/common/src/main/resources/data/devices/loot_tables/blocks/mac_max_x.json @@ -0,0 +1,20 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "rolls": 1.0, + "bonus_rolls": 0.0, + "entries": [ + { + "type": "minecraft:item", + "name": "devices:mac_max_x" + } + ], + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ] + } + ] +} \ No newline at end of file diff --git a/forge/build.gradle b/forge/build.gradle index 5201d3123..3d2683ac2 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -35,7 +35,7 @@ dependencies { common(project(path: ":common", configuration: "namedElements")) { transitive false } shadowCommon(project(path: ":common", configuration: "transformProductionForge")) { transitive = false } - modImplementation "curse.maven:emojiful-284324:4056367" + modApi "curse.maven:emojiful-284324:3963433" forgeRuntimeLibrary "org.jetbrains.kotlin:kotlin-stdlib:1.7.10" forgeRuntimeLibrary "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.10" From 0cc481067931b641502663074f63f17f32ee527b Mon Sep 17 00:00:00 2001 From: Qboi123 Date: Fri, 4 Nov 2022 05:35:35 +0100 Subject: [PATCH 05/88] Add issues and sources. --- fabric/src/main/resources/fabric.mod.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index 6e5e5c05b..854630664 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -20,7 +20,6 @@ "jack jook", "Hunstagamez", "Techyy YT", - "MinecraftDoodler", "Norge100YT", "Cyberman2208", "CreepergamingsMC" @@ -28,7 +27,8 @@ "contact": { "website": "https://ultreon.github.io/web/", "repo": "https://github.com/Ultreon/devices-mod", - "issues": "https://github.com/Ultreon/devices-mod/issues" + "issues": "https://github.com/Ultreon/devices-mod/issues", + "sources": "https://github.com/Ultreon/devices-mod" }, "license": "GPL-3.0", "icon": "devices_mod.png", From 2ddb94d01a03c048fa1ca035a5e2623bd17b5886 Mon Sep 17 00:00:00 2001 From: Qboi123 Date: Fri, 4 Nov 2022 05:37:24 +0100 Subject: [PATCH 06/88] Add ModUpdater and ModMenu support. --- fabric/src/main/resources/fabric.mod.json | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index 854630664..ea521ca3a 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -48,5 +48,20 @@ "depends": { "fabricloader": ">=${loaderVersion}", "minecraft": ">=${minecraftVersion} <1.19.3" + }, + "custom": { + "modupdater": { + "strategy": "curseforge", + "projectID": 659048, + "strict": false + }, + "modmenu": { + "links": { + "modmenu.discord": "https://discord.gg/dtdc46g6ry", + "modmenu.youtube": "https://youtube.com/@ultreon", + "modmenu.curseforge": "https://www.curseforge.com/minecraft/mc-mods/devices-mod", + "modmenu.modrinth": "https://modrinth.com/mod/devices-mod" + } + } } } From 0976a73cf5521c9237db588b4c6b2921cf17b48b Mon Sep 17 00:00:00 2001 From: Qboi123 Date: Tue, 8 Nov 2022 04:50:11 +0100 Subject: [PATCH 07/88] Fix placing Mac on replaceable blocks. --- .../devices/block/FakeBlockPlaceContext.java | 13 +++++ .../ultreon/devices/block/MacMaxXBlock.java | 56 ++++++++++--------- 2 files changed, 42 insertions(+), 27 deletions(-) create mode 100644 common/src/main/java/com/ultreon/devices/block/FakeBlockPlaceContext.java diff --git a/common/src/main/java/com/ultreon/devices/block/FakeBlockPlaceContext.java b/common/src/main/java/com/ultreon/devices/block/FakeBlockPlaceContext.java new file mode 100644 index 000000000..5fa5ac78c --- /dev/null +++ b/common/src/main/java/com/ultreon/devices/block/FakeBlockPlaceContext.java @@ -0,0 +1,13 @@ +package com.ultreon.devices.block; + +import net.minecraft.world.InteractionHand; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.level.Level; +import net.minecraft.world.phys.BlockHitResult; + +public class FakeBlockPlaceContext extends BlockPlaceContext { + protected FakeBlockPlaceContext(Level level, InteractionHand interactionHand, ItemStack itemStack, BlockHitResult blockHitResult) { + super(level, null, interactionHand, itemStack, blockHitResult); + } +} diff --git a/common/src/main/java/com/ultreon/devices/block/MacMaxXBlock.java b/common/src/main/java/com/ultreon/devices/block/MacMaxXBlock.java index 5d2536472..8cfd0d10d 100644 --- a/common/src/main/java/com/ultreon/devices/block/MacMaxXBlock.java +++ b/common/src/main/java/com/ultreon/devices/block/MacMaxXBlock.java @@ -7,6 +7,7 @@ import net.minecraft.core.Direction; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.MutableComponent; +import net.minecraft.world.InteractionHand; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.DyeColor; @@ -21,6 +22,8 @@ import net.minecraft.world.level.block.state.BlockBehaviour; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Material; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.Shapes; import net.minecraft.world.phys.shapes.VoxelShape; @@ -103,51 +106,50 @@ public float getShadeBrightness(@NotNull BlockState state, @NotNull BlockGetter @Override public @Nullable BlockState getStateForPlacement(@NotNull BlockPlaceContext context) { - return canPlace(context.getLevel(), context.getClickedPos(), context.getHorizontalDirection()) ? super.getStateForPlacement(context) : null; + return canPlace(context.getLevel(), context.getClickedPos(), context.getHorizontalDirection(), context.getHand(), context.getItemInHand()) ? super.getStateForPlacement(context) : null; } - public boolean canPlace(Level level, BlockPos pos, Direction face) { - BlockState partState = DeviceBlocks.MAC_MAX_X_PART.get().defaultBlockState(); - hasBlock(level, pos.above()); + public boolean canPlace(Level level, BlockPos pos, Direction face, InteractionHand hand, ItemStack itemInHand) { + hasBlock(level, pos.above(), hand, itemInHand, face); switch (face) { case NORTH -> { - if (hasBlock(level, pos.above().west())) return false; - if (hasBlock(level, pos.above().east())) return false; - if (hasBlock(level, pos.above())) return false; - if (hasBlock(level, pos.west())) return false; - if (hasBlock(level, pos.east())) return false; + if (hasBlock(level, pos.above().west(), hand, itemInHand, face)) return false; + if (hasBlock(level, pos.above().east(), hand, itemInHand, face)) return false; + if (hasBlock(level, pos.above(), hand, itemInHand, face)) return false; + if (hasBlock(level, pos.west(), hand, itemInHand, face)) return false; + if (hasBlock(level, pos.east(), hand, itemInHand, face)) return false; } case SOUTH -> { - if (hasBlock(level, pos.above().east())) return false; - if (hasBlock(level, pos.above().west())) return false; - if (hasBlock(level, pos.above())) return false; - if (hasBlock(level, pos.east())) return false; - if (hasBlock(level, pos.west())) return false; + if (hasBlock(level, pos.above().east(), hand, itemInHand, face)) return false; + if (hasBlock(level, pos.above().west(), hand, itemInHand, face)) return false; + if (hasBlock(level, pos.above(), hand, itemInHand, face)) return false; + if (hasBlock(level, pos.east(), hand, itemInHand, face)) return false; + if (hasBlock(level, pos.west(), hand, itemInHand, face)) return false; } case WEST -> { - if (hasBlock(level, pos.above().north())) return false; - if (hasBlock(level, pos.above().south())) return false; - if (hasBlock(level, pos.above())) return false; - if (hasBlock(level, pos.north())) return false; - if (hasBlock(level, pos.south())) return false; + if (hasBlock(level, pos.above().north(), hand, itemInHand, face)) return false; + if (hasBlock(level, pos.above().south(), hand, itemInHand, face)) return false; + if (hasBlock(level, pos.above(), hand, itemInHand, face)) return false; + if (hasBlock(level, pos.north(), hand, itemInHand, face)) return false; + if (hasBlock(level, pos.south(), hand, itemInHand, face)) return false; } case EAST -> { - if (hasBlock(level, pos.above().south())) return false; - if (hasBlock(level, pos.above().north())) return false; - if (hasBlock(level, pos.above())) return false; - if (hasBlock(level, pos.south())) return false; - if (hasBlock(level, pos.north())) return false; + if (hasBlock(level, pos.above().south(), hand, itemInHand, face)) return false; + if (hasBlock(level, pos.above().north(), hand, itemInHand, face)) return false; + if (hasBlock(level, pos.above(), hand, itemInHand, face)) return false; + if (hasBlock(level, pos.south(), hand, itemInHand, face)) return false; + if (hasBlock(level, pos.north(), hand, itemInHand, face)) return false; } default -> throw new IllegalStateException("Unexpected value: " + face); } return true; } - private boolean hasBlock(Level level, BlockPos pos) { - return !level.getBlockState(pos).isAir(); + private boolean hasBlock(Level level, BlockPos pos, InteractionHand hand, ItemStack itemInHand, Direction face) { + return !(level.getBlockState(pos).isAir() || level.getBlockState(pos).canBeReplaced(new FakeBlockPlaceContext(level, hand, itemInHand, new BlockHitResult(Vec3.atCenterOf(pos), face, pos, false)))); } - public void setPlacedBy(Level level, BlockPos pos, BlockState state, LivingEntity placer, @NotNull ItemStack stack) { + public void setPlacedBy(@NotNull Level level, @NotNull BlockPos pos, BlockState state, LivingEntity placer, @NotNull ItemStack stack) { if (state.isAir()) return; BlockState partState = DeviceBlocks.MAC_MAX_X_PART.get().defaultBlockState(); partState = partState.setValue(FACING, state.getValue(FACING)); From 1362def13149f3892e1a23315cd078e9037df764 Mon Sep 17 00:00:00 2001 From: Qboi123 Date: Tue, 8 Nov 2022 05:19:44 +0100 Subject: [PATCH 08/88] Hmm, tasty Macaroni --- common/src/main/resources/assets/devices/lang/en_us.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/src/main/resources/assets/devices/lang/en_us.json b/common/src/main/resources/assets/devices/lang/en_us.json index 2679f4c01..ca19bb4e7 100644 --- a/common/src/main/resources/assets/devices/lang/en_us.json +++ b/common/src/main/resources/assets/devices/lang/en_us.json @@ -16,8 +16,8 @@ "block.devices.green_laptop": "Green Laptop", "block.devices.red_laptop": "Red Laptop", "block.devices.black_laptop": "Black Laptop", - "block.devices.mac_max_x": "Mac Max X+!", - "block.devices.mac_max_x_emoji": "Mac Max X+!:middle_finger:", + "block.devices.mac_max_x": "Macaroni Max X Pro 5G White Ultra Ex 3+!$", + "block.devices.mac_max_x_emoji": "Macaroni Max X Pro 5G White Ultra Ex 3+!:thinking:", "block.devices.white_router": "White Router", "block.devices.orange_router": "Orange Router", "block.devices.magenta_router": "Magenta Router", From cb6685ecb0a71f3bf7ed666875bc597c9c63e778 Mon Sep 17 00:00:00 2001 From: Qboi123 Date: Tue, 8 Nov 2022 05:22:04 +0100 Subject: [PATCH 09/88] :thinking_face: --- common/src/main/resources/assets/devices/lang/en_us.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/src/main/resources/assets/devices/lang/en_us.json b/common/src/main/resources/assets/devices/lang/en_us.json index ca19bb4e7..ecd80fdf5 100644 --- a/common/src/main/resources/assets/devices/lang/en_us.json +++ b/common/src/main/resources/assets/devices/lang/en_us.json @@ -17,7 +17,7 @@ "block.devices.red_laptop": "Red Laptop", "block.devices.black_laptop": "Black Laptop", "block.devices.mac_max_x": "Macaroni Max X Pro 5G White Ultra Ex 3+!$", - "block.devices.mac_max_x_emoji": "Macaroni Max X Pro 5G White Ultra Ex 3+!:thinking:", + "block.devices.mac_max_x_emoji": "Macaroni Max X Pro 5G White Ultra Ex 3+!:thinking_face:", "block.devices.white_router": "White Router", "block.devices.orange_router": "Orange Router", "block.devices.magenta_router": "Magenta Router", From c20996eaff7b5a8ccb00c626240271238a15d9a8 Mon Sep 17 00:00:00 2001 From: Qboi123 Date: Wed, 14 Dec 2022 05:16:22 +0100 Subject: [PATCH 10/88] Fix saving issue with Note Stash. --- .../src/main/java/com/ultreon/devices/core/io/FileSystem.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/src/main/java/com/ultreon/devices/core/io/FileSystem.java b/common/src/main/java/com/ultreon/devices/core/io/FileSystem.java index d42a73f4d..bc987ac62 100644 --- a/common/src/main/java/com/ultreon/devices/core/io/FileSystem.java +++ b/common/src/main/java/com/ultreon/devices/core/io/FileSystem.java @@ -37,8 +37,8 @@ import java.util.regex.Pattern; public class FileSystem { - public static final Pattern PATTERN_FILE_NAME = Pattern.compile("^[\\w'. ]{1,32}$"); - public static final Pattern PATTERN_DIRECTORY = Pattern.compile("^(/)|(/[\\w'. ]{1,32})*$"); + public static final Pattern PATTERN_FILE_NAME = Pattern.compile("^[\\w'.:_ ]{1,32}$"); + public static final Pattern PATTERN_DIRECTORY = Pattern.compile("^(/)|(/[\\w'.:_ ]{1,32})*$"); public static final String DIR_ROOT = "/"; public static final String DIR_APPLICATION_DATA = DIR_ROOT + "Application Data"; From edd236f8df5c70744f829c7685dc9c84dd88ccc8 Mon Sep 17 00:00:00 2001 From: Qboi123 Date: Wed, 14 Dec 2022 05:49:22 +0100 Subject: [PATCH 11/88] Fixes more... --- .../com/ultreon/devices/programs/NoteStashApp.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/common/src/main/java/com/ultreon/devices/programs/NoteStashApp.java b/common/src/main/java/com/ultreon/devices/programs/NoteStashApp.java index d3ecbb826..c3da8eef3 100644 --- a/common/src/main/java/com/ultreon/devices/programs/NoteStashApp.java +++ b/common/src/main/java/com/ultreon/devices/programs/NoteStashApp.java @@ -140,6 +140,16 @@ public void init(@Nullable CompoundTag intent) { data.putString("title", title.getText()); data.putString("content", textArea.getText()); + FileSystem.getApplicationFolder(this, (folder, success) -> { + if (success) { + assert folder != null; + folder.search(file -> file.isForApplication(this)).forEach(file -> notes.addItem(Note.fromFile(file))); + } else { + Devices.LOGGER.error(MARKER, "Failed to get application folder"); + //TODO error dialog + } + }); + Dialog.SaveFile dialog = new Dialog.SaveFile(NoteStashApp.this, data); dialog.setFolder(getApplicationFolderPath()); dialog.setResponseHandler((success, file) -> { From ab8f83cdc8f23ce07d11d4148430333ac1ded6ee Mon Sep 17 00:00:00 2001 From: Qboi123 Date: Mon, 13 Feb 2023 23:46:06 +0100 Subject: [PATCH 12/88] Fix merge --- .idea/discord.xml | 2 +- .../resources/assets/devices/lang/en_us.json | 2 + .../block/entity/ComputerBlockEntity.java | 32 +-- .../block/entity/LaptopBlockEntity.java | 189 ------------------ .../com/ultreon/devices/init/DeviceItems.java | 8 +- fabric/src/main/resources/en_us_existing.json | 2 + 6 files changed, 17 insertions(+), 218 deletions(-) diff --git a/.idea/discord.xml b/.idea/discord.xml index 2a4df454c..68631912d 100644 --- a/.idea/discord.xml +++ b/.idea/discord.xml @@ -4,6 +4,6 @@