diff --git a/build.gradle b/build.gradle index 1034f3de7..8345d7f9f 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,6 @@ plugins { id "architectury-plugin" version "3.4-SNAPSHOT" - id "dev.architectury.loom" version "1.2-SNAPSHOT" apply false + id "dev.architectury.loom" version "1.6-SNAPSHOT" apply false id "org.jetbrains.kotlin.jvm" version "1.7.10" } repositories { @@ -99,8 +99,12 @@ allprojects { // Loom adds the essential maven repositories to download Minecraft and libraries from automatically. // See https://docs.gradle.org/current/userguide/declaring_repositories.html // for more information about repositories. + mavenCentral() maven { url "https://maven.parchmentmc.org" } maven { url "https://maven.jab125.dev" } + maven { url "https://raw.githubusercontent.com/Fuzss/modresources/main/maven/" } + maven { url "https://cursemaven.com" } + maven { url "https://maven.terraformersmc.com/releases" } flatDir { dir "$rootProject.projectDir/libs/" } } diff --git a/common/build.gradle b/common/build.gradle index d7641c8f2..132a036b9 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:$architectury_version" + modApi "fuzs.forgeconfigapiport:forgeconfigapiport-common-neoforgeapi:$forgeconfigapiport_version" + 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/jab125/classloader/impl/CustomClassLoader.java b/common/src/main/java/com/jab125/classloader/impl/CustomClassLoader.java index bd21e60fd..2cdeb3722 100644 --- a/common/src/main/java/com/jab125/classloader/impl/CustomClassLoader.java +++ b/common/src/main/java/com/jab125/classloader/impl/CustomClassLoader.java @@ -1,28 +1,13 @@ package com.jab125.classloader.impl; -import com.ultreon.devices.Devices; -import com.ultreon.devices.core.Device; -import net.fabricmc.loader.api.FabricLoader; import net.fabricmc.loader.impl.FabricLoaderImpl; -import net.fabricmc.loader.impl.launch.FabricLauncher; -import net.fabricmc.loader.impl.launch.knot.Knot; -import net.fabricmc.loader.launch.common.FabricLauncherBase; -import net.fabricmc.tinyremapper.TinyRemapper; import org.objectweb.asm.ClassReader; import org.objectweb.asm.ClassWriter; -import org.objectweb.asm.Type; -import org.objectweb.asm.tree.AbstractInsnNode; -import org.objectweb.asm.tree.AnnotationNode; import org.objectweb.asm.tree.ClassNode; -import org.objectweb.asm.tree.MethodNode; -import org.spongepowered.asm.util.asm.ASM; import java.io.IOException; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; import java.net.URL; import java.net.URLClassLoader; -import java.security.SecureClassLoader; import java.util.ArrayList; import java.util.HashMap; import java.util.Map; diff --git a/common/src/main/java/com/ultreon/devices/ClientModEvents.java b/common/src/main/java/com/ultreon/devices/ClientModEvents.java index 47318826d..8db2c934a 100644 --- a/common/src/main/java/com/ultreon/devices/ClientModEvents.java +++ b/common/src/main/java/com/ultreon/devices/ClientModEvents.java @@ -71,7 +71,7 @@ public static void clientSetup() { registerRenderLayers(); registerRenderers(); registerLayerDefinitions(); - if (Platform.isForge()) { // Note: Forge requires the icon atlas to be generator beforehand. + if (Platform.isForgeLike()) { // Note: Forge requires the icon atlas to be generator beforehand. generateIconAtlas(); } diff --git a/common/src/main/java/com/ultreon/devices/DeviceConfig.java b/common/src/main/java/com/ultreon/devices/DeviceConfig.java index cb9e04c77..e4e3c5889 100644 --- a/common/src/main/java/com/ultreon/devices/DeviceConfig.java +++ b/common/src/main/java/com/ultreon/devices/DeviceConfig.java @@ -1,36 +1,35 @@ package com.ultreon.devices; -import dev.architectury.injectables.annotations.ExpectPlatform; import dev.architectury.platform.Platform; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.Tag; -import net.minecraftforge.common.ForgeConfigSpec; +import net.neoforged.neoforge.common.ModConfigSpec; public class DeviceConfig { private static final String CATEGORY_LAPTOP = "laptopSettings"; - public static final ForgeConfigSpec.IntValue PING_RATE; + public static final ModConfigSpec.IntValue PING_RATE; private static final String CATEGORY_ROUTER = "routerSettings"; - public static final ForgeConfigSpec.IntValue SIGNAL_RANGE; - public static final ForgeConfigSpec.IntValue BEACON_INTERVAL; - public static final ForgeConfigSpec.IntValue MAX_DEVICES; + public static final ModConfigSpec.IntValue SIGNAL_RANGE; + public static final ModConfigSpec.IntValue BEACON_INTERVAL; + public static final ModConfigSpec.IntValue MAX_DEVICES; private static final String CATEGORY_PRINTING = "printerSettings"; - public static final ForgeConfigSpec.BooleanValue OVERRIDE_PRINT_SPEED; - public static final ForgeConfigSpec.IntValue CUSTOM_PRINT_SPEED; - public static final ForgeConfigSpec.IntValue MAX_PAPER_COUNT; + public static final ModConfigSpec.BooleanValue OVERRIDE_PRINT_SPEED; + public static final ModConfigSpec.IntValue CUSTOM_PRINT_SPEED; + public static final ModConfigSpec.IntValue MAX_PAPER_COUNT; private static final String CATEGORY_PIXEL_PAINTER = "pixelPainter"; - public static final ForgeConfigSpec.BooleanValue PIXEL_PAINTER_ENABLE; - public static final ForgeConfigSpec.BooleanValue RENDER_PRINTED_3D; + public static final ModConfigSpec.BooleanValue PIXEL_PAINTER_ENABLE; + public static final ModConfigSpec.BooleanValue RENDER_PRINTED_3D; public static final String CATEGORY_DEBUG = "debug"; - public static final ForgeConfigSpec.BooleanValue DEBUG_BUTTON; + public static final ModConfigSpec.BooleanValue DEBUG_BUTTON; - public static final ForgeConfigSpec CONFIG; + public static final ModConfigSpec CONFIG; static { - ForgeConfigSpec.Builder builder = new ForgeConfigSpec.Builder(); + ModConfigSpec.Builder builder = new ModConfigSpec.Builder(); PING_RATE = builder.comment("The amount of ticks the laptop waits until sending another ping to it's connected router.") .defineInRange(CATEGORY_LAPTOP + ".pingRate", 20, 1, 200); diff --git a/common/src/main/java/com/ultreon/devices/ModDeviceTypes.java b/common/src/main/java/com/ultreon/devices/ModDeviceTypes.java index b850151f7..708410d87 100644 --- a/common/src/main/java/com/ultreon/devices/ModDeviceTypes.java +++ b/common/src/main/java/com/ultreon/devices/ModDeviceTypes.java @@ -1,10 +1,16 @@ package com.ultreon.devices; +import com.mojang.serialization.Codec; import org.jetbrains.annotations.Contract; public enum ModDeviceTypes implements IDeviceType { COMPUTER, PRINTER, FLASH_DRIVE, ROUTER, SEAT; + public static final Codec CODEC = Codec.STRING.xmap( + val -> ModDeviceTypes.valueOf(val.toUpperCase()), + val -> val.name().toLowerCase() + ); + @Override @Contract(pure = true, value = "-> this") public ModDeviceTypes getDeviceType() { 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 f468115d5..ef1ba1c23 100644 --- a/common/src/main/java/com/ultreon/devices/block/ComputerBlock.java +++ b/common/src/main/java/com/ultreon/devices/block/ComputerBlock.java @@ -1,5 +1,7 @@ package com.ultreon.devices.block; +import com.mojang.serialization.MapCodec; +import com.mojang.serialization.codecs.RecordCodecBuilder; import com.ultreon.devices.ModDeviceTypes; import com.ultreon.devices.block.entity.LaptopBlockEntity; import com.ultreon.devices.debug.DebugLog; @@ -21,6 +23,7 @@ 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.ButtonBlock; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.state.BlockBehaviour; import net.minecraft.world.level.block.state.BlockState; @@ -127,10 +130,12 @@ public String getSerializedName() { public static abstract class Colored extends ComputerBlock implements ColoredBlock { private final DyeColor color; + private final ModDeviceTypes deviceType; - protected Colored(Properties properties, DyeColor color, ModDeviceTypes deviceType) { + protected Colored(DyeColor color, ModDeviceTypes deviceType, Properties properties) { super(properties); this.color = color; + this.deviceType = deviceType; } @Override @@ -152,5 +157,10 @@ public void setPlacedBy(@NotNull Level level, @NotNull BlockPos pos, @NotNull Bl protected void createBlockStateDefinition(StateDefinition.@NotNull Builder pBuilder) { super.createBlockStateDefinition(pBuilder); } + + @Override + public ModDeviceTypes getDeviceType() { + return deviceType; + } } } 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 2bbf1d7bd..5785fea5f 100644 --- a/common/src/main/java/com/ultreon/devices/block/DeviceBlock.java +++ b/common/src/main/java/com/ultreon/devices/block/DeviceBlock.java @@ -1,5 +1,6 @@ package com.ultreon.devices.block; +import com.mojang.serialization.MapCodec; import com.ultreon.devices.IDeviceType; import com.ultreon.devices.ModDeviceTypes; import com.ultreon.devices.block.entity.DeviceBlockEntity; @@ -71,7 +72,6 @@ public void setPlacedBy(@NotNull Level level, @NotNull BlockPos pos, @NotNull Bl } } - @Override public void destroy(LevelAccessor level, BlockPos pos, BlockState state) { if (!level.isClientSide()) { 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 6e5c30820..3bffb1e5a 100644 --- a/common/src/main/java/com/ultreon/devices/block/LaptopBlock.java +++ b/common/src/main/java/com/ultreon/devices/block/LaptopBlock.java @@ -1,33 +1,24 @@ package com.ultreon.devices.block; +import com.mojang.serialization.MapCodec; +import com.mojang.serialization.codecs.RecordCodecBuilder; 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.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.BlockItem; 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.HorizontalDirectionalBlock; 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; -import net.minecraft.world.level.storage.loot.LootContext; import net.minecraft.world.level.storage.loot.LootParams; import net.minecraft.world.level.storage.loot.parameters.LootContextParams; -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; @@ -35,12 +26,16 @@ import org.jetbrains.annotations.Nullable; import java.util.List; -import java.util.Locale; public class LaptopBlock extends ComputerBlock.Colored { public static final EnumProperty TYPE = EnumProperty.create("type", Type.class); public static final BooleanProperty OPEN = BooleanProperty.create("open"); + public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(instance -> instance.group( + DyeColor.CODEC.fieldOf("color").forGetter(Colored::getColor), + propertiesCodec() + ).apply(instance, LaptopBlock::new)); + private static final VoxelShape SHAPE_OPEN_NORTH = Shapes.or(Block.box(1, 0, 12.5, 15, 11.4, 17), Block.box(1, 0, 1, 15, 1.3, 12.5)); private static final VoxelShape SHAPE_OPEN_EAST = Shapes.or(Block.box(-1, 0, 1, 3.5, 11.4, 15), Block.box(3.5, 0, 1, 15, 1.3, 15)); private static final VoxelShape SHAPE_OPEN_SOUTH = Shapes.or(Block.box(1, 0, -1, 15, 11.4, 3.5), Block.box(1, 0, 3.5, 15, 1.3, 15)); @@ -49,9 +44,8 @@ public class LaptopBlock extends ComputerBlock.Colored { private static final VoxelShape SHAPE_CLOSED_EAST = Block.box(3, 0, 1, 15, 2, 15); private static final VoxelShape SHAPE_CLOSED_SOUTH = Block.box(1, 0, 3, 15, 2, 15); private static final VoxelShape SHAPE_CLOSED_WEST = Block.box(1, 0, 1, 13, 2, 15); - - public LaptopBlock(DyeColor color) { - super(Properties.of().mapColor(color).strength(6f).sound(SoundType.METAL), color, ModDeviceTypes.COMPUTER); + public LaptopBlock(DyeColor color, Properties properties) { + super(color, ModDeviceTypes.COMPUTER, properties); } @Override @@ -102,4 +96,9 @@ protected void removeTagsForDrop(CompoundTag tileEntityTag) { public @Nullable BlockEntity newBlockEntity(@NotNull BlockPos pos, @NotNull BlockState state) { return new LaptopBlockEntity(pos, state); } + + @Override + protected MapCodec codec() { + return CODEC; + } } 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 5ce8e2ccd..a8ed41295 100644 --- a/common/src/main/java/com/ultreon/devices/block/MacMaxXBlock.java +++ b/common/src/main/java/com/ultreon/devices/block/MacMaxXBlock.java @@ -1,5 +1,7 @@ package com.ultreon.devices.block; +import com.mojang.serialization.MapCodec; +import com.mojang.serialization.codecs.RecordCodecBuilder; import com.ultreon.devices.block.entity.MacMaxXBlockEntity; import com.ultreon.devices.init.DeviceBlocks; import dev.architectury.platform.Platform; @@ -17,6 +19,7 @@ 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.HorizontalDirectionalBlock; import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.state.BlockBehaviour; @@ -30,10 +33,12 @@ import org.jetbrains.annotations.Nullable; /** - * @author Qboi123 + * @author XyperCode */ @SuppressWarnings("deprecation") public class MacMaxXBlock extends ComputerBlock { + public static final MapCodec CODEC = simpleCodec(MacMaxXBlock::new); + 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), @@ -83,8 +88,13 @@ public class MacMaxXBlock extends ComputerBlock { Block.box(6.5, 0, 17, 9, 0.5, 23) ); - public MacMaxXBlock() { - super(BlockBehaviour.Properties.of().mapColor(DyeColor.WHITE).strength(6f).sound(SoundType.METAL).noOcclusion().dynamicShape()); + public MacMaxXBlock(Properties properties) { + super(properties); + } + + @Override + protected @NotNull MapCodec codec() { + return CODEC; } @Override @@ -183,7 +193,7 @@ public void setPlacedBy(@NotNull Level level, @NotNull BlockPos pos, BlockState } @Override - public void playerWillDestroy(@NotNull Level level, @NotNull BlockPos pos, BlockState state, @NotNull Player player) { + public BlockState 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); @@ -215,6 +225,7 @@ public void playerWillDestroy(@NotNull Level level, @NotNull BlockPos pos, Block } default -> throw new IllegalStateException("Unexpected value: " + state.getValue(FACING)); } + return state; } @Override 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 719af391c..19b87461e 100644 --- a/common/src/main/java/com/ultreon/devices/block/MacMaxXBlockPart.java +++ b/common/src/main/java/com/ultreon/devices/block/MacMaxXBlockPart.java @@ -1,5 +1,6 @@ package com.ultreon.devices.block; +import com.mojang.serialization.MapCodec; import dev.architectury.platform.Platform; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; @@ -9,7 +10,6 @@ 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.Level; import net.minecraft.world.level.block.*; @@ -23,11 +23,13 @@ import org.jetbrains.annotations.NotNull; /** - * @author Qboi123 + * @author XyperCode */ public class MacMaxXBlockPart extends HorizontalDirectionalBlock { public static final EnumProperty PART = EnumProperty.create("part", Part.class); + public static final MapCodec CODEC = simpleCodec(MacMaxXBlockPart::new); + 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), @@ -253,8 +255,8 @@ public class MacMaxXBlockPart extends HorizontalDirectionalBlock { 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().mapColor(DyeColor.WHITE).strength(6f).sound(SoundType.METAL)); + public MacMaxXBlockPart(Properties properties) { + super(properties); registerDefaultState(this.getStateDefinition().any().setValue(FACING, Direction.NORTH).setValue(PART, Part.T)); } @@ -311,7 +313,7 @@ public MacMaxXBlockPart() { } @Override - public void playerWillDestroy(@NotNull Level level, @NotNull BlockPos pos, @NotNull BlockState state, @NotNull Player player) { + public BlockState playerWillDestroy(@NotNull Level level, @NotNull BlockPos pos, @NotNull BlockState state, @NotNull Player player) { BlockPos originPos = getOriginPos(pos, state); switch (state.getValue(FACING)) { case NORTH -> { @@ -345,6 +347,7 @@ public void playerWillDestroy(@NotNull Level level, @NotNull BlockPos pos, @NotN default -> throw new IllegalStateException("Unexpected value: " + state.getValue(FACING)); } destroyBlockExcept(level, pos, originPos, Blocks.AIR.defaultBlockState(), 3); + return state; } @SuppressWarnings("SameParameterValue") @@ -417,6 +420,11 @@ protected void createBlockStateDefinition(StateDefinition.@NotNull Builder codec() { + return CODEC; + } + public enum Part implements StringRepresentable { BL, BR, TL, T, TR; diff --git a/common/src/main/java/com/ultreon/devices/block/OfficeChairBlock.java b/common/src/main/java/com/ultreon/devices/block/OfficeChairBlock.java index fac8d9021..26aab5550 100644 --- a/common/src/main/java/com/ultreon/devices/block/OfficeChairBlock.java +++ b/common/src/main/java/com/ultreon/devices/block/OfficeChairBlock.java @@ -1,5 +1,7 @@ package com.ultreon.devices.block; +import com.mojang.serialization.MapCodec; +import com.mojang.serialization.codecs.RecordCodecBuilder; import com.ultreon.devices.ModDeviceTypes; import com.ultreon.devices.block.entity.OfficeChairBlockEntity; import com.ultreon.devices.debug.DebugLog; @@ -19,6 +21,7 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.LevelReader; import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.HorizontalDirectionalBlock; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.state.BlockBehaviour; import net.minecraft.world.level.block.state.BlockState; @@ -33,17 +36,20 @@ import org.jetbrains.annotations.Nullable; -public class OfficeChairBlock extends DeviceBlock.Colored -{ +public class OfficeChairBlock extends DeviceBlock.Colored { public static final EnumProperty TYPE = EnumProperty.create("type", Type.class); + public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(instance -> instance.group( + DyeColor.CODEC.fieldOf("color").forGetter(OfficeChairBlock::getColor), + propertiesCodec() + ).apply(instance, OfficeChairBlock::new)); + private static final VoxelShape EMPTY_BOX = Shapes.box(0, 0, 0, 0, 0, 0); private static final VoxelShape SELECTION_BOX = Shapes.box(0.0625f, 0, 0.0625f, 0.9375f, /*1.6875f*/0.625f, 0.9375f); private static final VoxelShape SEAT_BOUNDING_BOX = Shapes.box(0.0625f, 0, 0.0625f, 0.9375f, 0.625f, 0.9375f); - public OfficeChairBlock(DyeColor color) - { - super(BlockBehaviour.Properties.of().mapColor(color), color, ModDeviceTypes.SEAT); + public OfficeChairBlock(DyeColor color, Properties properties) { + super(properties, color, ModDeviceTypes.SEAT); //this.setUnlocalizedName("office_chair"); //this.setRegistryName("office_chair"); //this.setCreativeTab(MrCrayfishDeviceMod.TAB_DEVICE); @@ -56,8 +62,7 @@ public OfficeChairBlock(DyeColor color) // } @Override - public boolean canSurvive(BlockState state, LevelReader reader, BlockPos pos) - { + public boolean canSurvive(BlockState state, LevelReader reader, BlockPos pos) { return false || true; } @@ -82,12 +87,10 @@ public VoxelShape getCollisionShape(BlockState state, BlockGetter level, BlockPo } @Override - public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) - { + public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) { //DebugLog.log(DeviceEntities.SEAT.get().create(level).toString()); DebugLog.log("OKOKJRTKFD"); - if(!level.isClientSide) - { + if (!level.isClientSide) { SeatUtil.createSeatAndSit(level, pos, player, -1); } return InteractionResult.SUCCESS; @@ -95,25 +98,26 @@ public InteractionResult use(BlockState state, Level level, BlockPos pos, Player @Nullable @Override - public BlockEntity newBlockEntity(BlockPos pos, BlockState state) - { + public BlockEntity newBlockEntity(BlockPos pos, BlockState state) { return new OfficeChairBlockEntity(pos, state); } @Override - protected void createBlockStateDefinition(StateDefinition.@NotNull Builder pBuilder) - { + protected void createBlockStateDefinition(StateDefinition.@NotNull Builder pBuilder) { super.createBlockStateDefinition(pBuilder); pBuilder.add(TYPE); } - public enum Type implements StringRepresentable - { + @Override + protected MapCodec codec() { + return CODEC; + } + + public enum Type implements StringRepresentable { LEGS, SEAT, FULL; @Override - public String getSerializedName() - { + public String getSerializedName() { return name().toLowerCase(); } } diff --git a/common/src/main/java/com/ultreon/devices/block/PaperBlock.java b/common/src/main/java/com/ultreon/devices/block/PaperBlock.java index 6faf19387..f9bb8c0c9 100644 --- a/common/src/main/java/com/ultreon/devices/block/PaperBlock.java +++ b/common/src/main/java/com/ultreon/devices/block/PaperBlock.java @@ -1,5 +1,7 @@ package com.ultreon.devices.block; +import com.mojang.serialization.MapCodec; +import com.mojang.serialization.codecs.RecordCodecBuilder; import com.ultreon.devices.api.print.IPrint; import com.ultreon.devices.block.entity.PaperBlockEntity; import net.minecraft.core.BlockPos; @@ -26,11 +28,14 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.awt.print.Paper; import java.util.ArrayList; import java.util.List; @SuppressWarnings("NullableProblems") public class PaperBlock extends HorizontalDirectionalBlock implements EntityBlock { + public static final MapCodec CODEC = simpleCodec(PaperBlock::new); + private static final VoxelShape SELECTION_BOUNDS = box(15, 0, 0, 16, 16, 16); private static final VoxelShape SELECTION_BOX_NORTH = box(15, 0, 0, 16, 16, 16); @@ -39,8 +44,8 @@ public class PaperBlock extends HorizontalDirectionalBlock implements EntityBloc private static final VoxelShape SELECTION_BOX_EAST = box(0, 0, 0, 16, 16, 1); private static final VoxelShape[] SELECTION_BOUNDING_BOX = {SELECTION_BOX_SOUTH, SELECTION_BOX_WEST, SELECTION_BOX_NORTH, SELECTION_BOX_EAST}; - public PaperBlock() { - super(Properties.of().noCollission().instabreak().noOcclusion().noLootTable()); + public PaperBlock(Properties properties) { + super(properties); registerDefaultState(getStateDefinition().any().setValue(FACING, Direction.NORTH)); } @@ -113,4 +118,9 @@ protected void createBlockStateDefinition(StateDefinition.Builder codec() { + return CODEC; + } } diff --git a/common/src/main/java/com/ultreon/devices/block/PrinterBlock.java b/common/src/main/java/com/ultreon/devices/block/PrinterBlock.java index 9ecf0cf4c..c94ad04b1 100644 --- a/common/src/main/java/com/ultreon/devices/block/PrinterBlock.java +++ b/common/src/main/java/com/ultreon/devices/block/PrinterBlock.java @@ -1,5 +1,7 @@ package com.ultreon.devices.block; +import com.mojang.serialization.MapCodec; +import com.mojang.serialization.codecs.RecordCodecBuilder; import com.ultreon.devices.ModDeviceTypes; import com.ultreon.devices.block.entity.PrinterBlockEntity; import com.ultreon.devices.util.Colored; @@ -12,6 +14,7 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.HorizontalDirectionalBlock; import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.state.BlockState; @@ -27,6 +30,11 @@ * @author MrCrayfish */ public class PrinterBlock extends DeviceBlock.Colored implements Colored { + public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(instance -> instance.group( + DyeColor.CODEC.fieldOf("color").forGetter(PrinterBlock::getColor), + propertiesCodec() + ).apply(instance, PrinterBlock::new)); + private static final VoxelShape SHAPE_NORTH = Shapes.or( box(2, 0, 7, 14, 5, 12), box(3.5, 0.1, 1, 12.5, 1.1, 7), @@ -76,7 +84,7 @@ public class PrinterBlock extends DeviceBlock.Colored implements Colored { box(5, 3, 1, 7, 5, 15), box(12, 3, 4, 16, 9.3, 12)); - public PrinterBlock(DyeColor color) { + public PrinterBlock(DyeColor color, Properties properties) { super(Properties.of().mapColor(color).strength(6f).sound(SoundType.METAL), color, ModDeviceTypes.PRINTER); this.registerDefaultState(getStateDefinition().any().setValue(FACING, Direction.NORTH)); } @@ -116,4 +124,9 @@ public InteractionResult use(@NotNull BlockState state, Level level, @NotNull Bl public @Nullable BlockEntity newBlockEntity(@NotNull BlockPos pos, @NotNull BlockState state) { return new PrinterBlockEntity(pos, state); } + + @Override + protected MapCodec codec() { + return CODEC; + } } diff --git a/common/src/main/java/com/ultreon/devices/block/RouterBlock.java b/common/src/main/java/com/ultreon/devices/block/RouterBlock.java index 74ddbcbd0..4e898fff6 100644 --- a/common/src/main/java/com/ultreon/devices/block/RouterBlock.java +++ b/common/src/main/java/com/ultreon/devices/block/RouterBlock.java @@ -1,5 +1,7 @@ package com.ultreon.devices.block; +import com.mojang.serialization.MapCodec; +import com.mojang.serialization.codecs.RecordCodecBuilder; import com.ultreon.devices.ModDeviceTypes; import com.ultreon.devices.block.entity.RouterBlockEntity; import com.ultreon.devices.network.PacketHandler; @@ -8,12 +10,15 @@ import net.minecraft.core.Direction; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; +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.HorizontalDirectionalBlock; import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.state.BlockState; @@ -22,13 +27,24 @@ import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.phys.BlockHitResult; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * @author MrCrayfish */ public class RouterBlock extends DeviceBlock.Colored { + public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(instance -> instance.group( + DyeColor.CODEC.fieldOf("color").forGetter(RouterBlock::getColor), + propertiesCodec() + ).apply(instance, RouterBlock::new)); + public static final BooleanProperty VERTICAL = BooleanProperty.create("vertical"); // Todo - do rotations for voxel shapes properly. @@ -57,8 +73,8 @@ public class RouterBlock extends DeviceBlock.Colored { box(13, 0, 1, 16, 10, 15) }; - public RouterBlock(DyeColor color) { - super(Properties.of().mapColor(color).strength(6f).sound(SoundType.METAL), color, ModDeviceTypes.ROUTER); + public RouterBlock(DyeColor color, Properties properties) { + super(properties, color, ModDeviceTypes.ROUTER); this.registerDefaultState(this.getStateDefinition().any().setValue(FACING, Direction.NORTH).setValue(VERTICAL, false)); } @@ -94,17 +110,6 @@ public InteractionResult use(BlockState state, Level level, BlockPos pos, Player return state != null ? state.setValue(FACING, pContext.getHorizontalDirection().getOpposite()).setValue(VERTICAL, pContext.getClickLocation().y - pContext.getClickLocation().y > 0.5) : null; } -// @Override -// public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer, EnumHand hand) { -// IBlockState state = super.getStateForPlacement(world, pos, facing, hitX, hitY, hitZ, meta, placer, hand); -// return state.withProperty(VERTICAL, facing.getHorizontalIndex() != -1); -// } - -// @Override -// public boolean canPlaceBlockOnSide(World worldIn, BlockPos pos, EnumFacing side) { -// return side != EnumFacing.DOWN; -// } - @NotNull @Override @Contract("_, _ -> new") @@ -117,4 +122,9 @@ protected void createBlockStateDefinition(StateDefinition.@NotNull Builder codec() { + return CODEC; + } } 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 d2d170356..251054e01 100644 --- a/common/src/main/java/com/ultreon/devices/core/Laptop.java +++ b/common/src/main/java/com/ultreon/devices/core/Laptop.java @@ -64,7 +64,7 @@ /** * Laptop GUI class. * - * @author MrCrayfish, Qboi123 + * @author MrCrayfish, XyperCode */ public class Laptop extends Screen implements System { public static final int ID = 1; @@ -395,8 +395,14 @@ public void render(final @NotNull GuiGraphics graphics, final int mouseX, final PoseStack.Pose last = graphics.pose().last(); + this.renderBackground(graphics, mouseX, mouseY, partialTicks); + try { + graphics.pose().pushPose(); + graphics.pose().translate(0, 0, 1000); + renderLaptop(graphics, mouseX, mouseY, partialTicks); + graphics.pose().popPose(); } catch (NullPointerException e) { while (graphics.pose().last() != last) { graphics.pose().popPose(); @@ -410,6 +416,15 @@ public void render(final @NotNull GuiGraphics graphics, final int mouseX, final RenderSystem.disableScissor(); bsod(e); } + + while (graphics.pose().last() != last) { + Devices.LOGGER.warn("Pose stack leakage: {}", graphics.pose().last()); + graphics.pose().popPose(); + } + + if (GLHelper.clearScissorStack()) { + Devices.LOGGER.debug("Scissor stack leakage!"); + } } public void renderBsod(final @NotNull GuiGraphics graphics, final int mouseX, final int mouseY, float partialTicks) { @@ -454,10 +469,7 @@ public static void drawLines(GuiGraphics graphics, Font font, String text, int x public void renderBezels(final @NotNull GuiGraphics graphics, final int mouseX, final int mouseY, float partialTicks) { tasks.clear(); - this.renderBackground(graphics); - RenderSystem.setShaderColor(1f, 1f, 1f, 1f); - RenderSystem.setShaderTexture(0, LAPTOP_GUI); //*************************// // Physical Screen // @@ -503,7 +515,7 @@ public void renderLaptop(final @NotNull GuiGraphics graphics, final int mouseX, renderBezels(graphics, mouseX, mouseY, partialTicks); - GLHelper.pushScissor(posX, posY, videoInfo.getResolution().width() + BORDER, videoInfo.getResolution().height() + BORDER); + GLHelper.pushScissor(posX + BORDER, posY + BORDER, videoInfo.getResolution().width(), videoInfo.getResolution().height()); //*******************// // Wallpaper // //*******************// @@ -578,7 +590,6 @@ public void renderLaptop(final @NotNull GuiGraphics graphics, final int mouseX, return false; }); - super.render(graphics, mouseX, mouseY, frameTime); GLHelper.popScissor(); GLHelper.clearScissorStack(); @@ -838,7 +849,7 @@ public void mouseMoved(double pMouseX, double pMouseY) { } @Override - public boolean mouseScrolled(double mouseX, double mouseY, double delta) { + public boolean mouseScrolled(double mouseX, double mouseY, double deltaX, double delta) { if (delta != 0) { try { if (windows.get(0) != null) { diff --git a/common/src/main/java/com/ultreon/devices/core/client/LaptopFontSet.java b/common/src/main/java/com/ultreon/devices/core/client/LaptopFontSet.java index a64597f3d..2a2d93576 100644 --- a/common/src/main/java/com/ultreon/devices/core/client/LaptopFontSet.java +++ b/common/src/main/java/com/ultreon/devices/core/client/LaptopFontSet.java @@ -11,7 +11,7 @@ import java.util.function.Function; /** - * @author Qboi123 + * @author XyperCode */ public class LaptopFontSet extends FontSet { // private static final GlyphInfo TAB_INFO = new GlyphInfo() { diff --git a/common/src/main/java/com/ultreon/devices/core/laptop/client/ClientLaptopScreen.java b/common/src/main/java/com/ultreon/devices/core/laptop/client/ClientLaptopScreen.java index b490f059f..097855a9b 100644 --- a/common/src/main/java/com/ultreon/devices/core/laptop/client/ClientLaptopScreen.java +++ b/common/src/main/java/com/ultreon/devices/core/laptop/client/ClientLaptopScreen.java @@ -1,10 +1,8 @@ package com.ultreon.devices.core.laptop.client; import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.PoseStack; import com.ultreon.devices.Reference; import com.ultreon.devices.debug.DebugLog; -import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.screens.Screen; import net.minecraft.network.chat.Component; @@ -26,7 +24,7 @@ public ClientLaptopScreen(ClientLaptop laptop) { } public void renderBezels(final @NotNull GuiGraphics graphics, final int mouseX, final int mouseY, float partialTicks) { - this.renderBackground(graphics); + this.renderBackground(graphics, mouseX, mouseY, partialTicks); RenderSystem.setShaderColor(1f, 1f, 1f, 1f); RenderSystem.setShaderTexture(0, LAPTOP_GUI); 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 a96b1f08d..f3b26f98e 100644 --- a/common/src/main/java/com/ultreon/devices/event/WorldDataHandler.java +++ b/common/src/main/java/com/ultreon/devices/event/WorldDataHandler.java @@ -2,6 +2,7 @@ import com.ultreon.devices.api.WorldSavedData; import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtAccounter; import net.minecraft.nbt.NbtIo; import net.minecraft.world.level.storage.LevelResource; @@ -58,7 +59,7 @@ private void loadData(File modData, String fileName, WorldSavedData data) { return; } try { - CompoundTag nbt = NbtIo.readCompressed(dataFile); + CompoundTag nbt = NbtIo.readCompressed(dataFile.toPath(), NbtAccounter.unlimitedHeap()); data.load(nbt); } catch (IOException e) { throw new RuntimeException(e); @@ -74,7 +75,7 @@ private void saveData(File modData, String fileName, WorldSavedData data) { CompoundTag nbt = new CompoundTag(); data.save(nbt); - NbtIo.writeCompressed(nbt, dataFile); + NbtIo.writeCompressed(nbt, dataFile.toPath()); } catch (IOException e) { throw new RuntimeException(e); } diff --git a/common/src/main/java/com/ultreon/devices/gui/GuiButtonClose.java b/common/src/main/java/com/ultreon/devices/gui/GuiButtonClose.java index b84092726..83383bb46 100644 --- a/common/src/main/java/com/ultreon/devices/gui/GuiButtonClose.java +++ b/common/src/main/java/com/ultreon/devices/gui/GuiButtonClose.java @@ -1,19 +1,16 @@ package com.ultreon.devices.gui; import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.PoseStack; import com.ultreon.devices.core.Window; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.Button; import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.ComponentContents; -import net.minecraft.network.chat.MutableComponent; import org.jetbrains.annotations.NotNull; public class GuiButtonClose extends Button { public GuiButtonClose(int x, int y) { super(x, y, 11, 11, Component.literal(""), - (button) -> { }, (output)-> MutableComponent.create(ComponentContents.EMPTY)); + (button) -> { }, (output)-> Component.empty()); } @Override 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 419cedb33..5fb65d0af 100644 --- a/common/src/main/java/com/ultreon/devices/init/DeviceBlocks.java +++ b/common/src/main/java/com/ultreon/devices/init/DeviceBlocks.java @@ -8,6 +8,9 @@ import net.minecraft.core.registries.Registries; import net.minecraft.world.item.DyeColor; import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.SoundType; +import net.minecraft.world.level.block.state.BlockBehaviour; +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; import java.util.List; import java.util.stream.Stream; @@ -21,7 +24,7 @@ public static void register() { public static final DyeableRegistration LAPTOPS = new DyeableRegistration<>() { @Override public RegistrySupplier register(Registrar registrar, DyeColor color) { - return registrar.register(Devices.id(color.getName() + "_laptop"), () -> new LaptopBlock(color)); + return registrar.register(Devices.id(color.getName() + "_laptop"), () -> new LaptopBlock(color, Properties.of().mapColor(color).strength(6f).sound(SoundType.METAL))); } @Override @@ -30,13 +33,13 @@ protected Registrar autoInit() { } }; - 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 MAC_MAX_X = REGISTER.register(Devices.id("mac_max_x"), () -> new MacMaxXBlock(Properties.of().mapColor(DyeColor.WHITE).strength(6f).sound(SoundType.METAL).noOcclusion().dynamicShape())); + public static final RegistrySupplier MAC_MAX_X_PART = REGISTER.register(Devices.id("mac_max_x_part"), () -> new MacMaxXBlockPart(Properties.of().mapColor(DyeColor.WHITE).strength(6f).sound(SoundType.METAL))); public static final DyeableRegistration PRINTERS = new DyeableRegistration<>() { @Override public RegistrySupplier register(Registrar registrar, DyeColor color) { - return registrar.register(Devices.id(color.getName() + "_printer"), () -> new PrinterBlock(color)); + return registrar.register(Devices.id(color.getName() + "_printer"), () -> new PrinterBlock(color, Properties.of().mapColor(color).strength(6f).sound(SoundType.METAL))); } @Override @@ -48,7 +51,7 @@ protected Registrar autoInit() { public static final DyeableRegistration ROUTERS = new DyeableRegistration<>() { @Override public RegistrySupplier register(Registrar registrar, DyeColor color) { - return registrar.register(Devices.id(color.getName() + "_router"), () -> new RouterBlock(color)); + return registrar.register(Devices.id(color.getName() + "_router"), () -> new RouterBlock(color, Properties.of().mapColor(color).strength(6f).sound(SoundType.METAL))); } @Override @@ -60,7 +63,7 @@ protected Registrar autoInit() { public static final DyeableRegistration OFFICE_CHAIRS = new DyeableRegistration<>() { @Override public RegistrySupplier register(Registrar registrar, DyeColor color) { - return registrar.register(Devices.id(color.getName() + "_office_chair"), () -> new OfficeChairBlock(color)); + return registrar.register(Devices.id(color.getName() + "_office_chair"), () -> new OfficeChairBlock(color, BlockBehaviour.Properties.of().mapColor(color))); } @Override @@ -70,7 +73,7 @@ protected Registrar autoInit() { }; - public static final RegistrySupplier PAPER = REGISTER.register(Devices.id("paper"), PaperBlock::new); + public static final RegistrySupplier PAPER = REGISTER.register(Devices.id("paper"), () -> new PaperBlock(Properties.of().noCollission().instabreak().noOcclusion().noLootTable())); public static Stream getAllBlocks() { 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 359e4f603..940f6bf5f 100644 --- a/common/src/main/java/com/ultreon/devices/object/Player.java +++ b/common/src/main/java/com/ultreon/devices/object/Player.java @@ -14,6 +14,7 @@ import net.minecraft.client.renderer.entity.BoatRenderer; import net.minecraft.client.renderer.entity.EntityRenderDispatcher; import net.minecraft.client.renderer.entity.EntityRendererProvider; +import net.minecraft.client.resources.PlayerSkin; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.vehicle.Boat; import org.joml.Quaternionf; @@ -49,7 +50,7 @@ public Player(Game game) { this.velocity = new Vec2d(0, 0); this.boatModel = new BoatRenderer(createEntityRendererContext(), false); assert Minecraft.getInstance().player != null; - boolean slim = Minecraft.getInstance().player.getModelName().equals("slim"); + boolean slim = Minecraft.getInstance().player.getSkin().model() == PlayerSkin.Model.SLIM; if (!Laptop.isWorldLess()) { boat = new Boat(Objects.requireNonNull(Minecraft.getInstance().level), 0, 0, 0); } diff --git a/common/src/main/java/com/ultreon/devices/programs/system/SettingsApp.java b/common/src/main/java/com/ultreon/devices/programs/system/SettingsApp.java index a4939dce1..5321fca19 100644 --- a/common/src/main/java/com/ultreon/devices/programs/system/SettingsApp.java +++ b/common/src/main/java/com/ultreon/devices/programs/system/SettingsApp.java @@ -148,7 +148,7 @@ private Button createAboutButton(Menu layoutMain) { // // Credits: // - MrCrayfish (https://mrcrayfish.com/) -// - Qboi123 +// - XyperCode // - Jab125 // - lizterzapzap // - MrBean6000 diff --git a/common/src/main/java/com/ultreon/devices/util/GLHelper.java b/common/src/main/java/com/ultreon/devices/util/GLHelper.java index 028175d06..73bd37c51 100644 --- a/common/src/main/java/com/ultreon/devices/util/GLHelper.java +++ b/common/src/main/java/com/ultreon/devices/util/GLHelper.java @@ -59,9 +59,13 @@ public static boolean isScissorStackEmpty() { /** * Do not call! Used for core only. + * + * @return true if the scissor stack was cleared */ - public static void clearScissorStack() { + public static boolean clearScissorStack() { + if (scissorStack.isEmpty()) return false; scissorStack.clear(); + return true; } public static Color getPixel(int x, int y) { diff --git a/common/src/main/resources/assets/devices/apps/bank.json b/common/src/main/resources/assets/devices/apps/bank.json index ae0857474..d2ee194ad 100644 --- a/common/src/main/resources/assets/devices/apps/bank.json +++ b/common/src/main/resources/assets/devices/apps/bank.json @@ -1,7 +1,7 @@ { "schemaVersion": 2, "name": "Bank", - "authors": ["MrCrayfish", "Jab125", "Qboi123"], + "authors": ["MrCrayfish", "Jab125", "XyperCode"], "description": "${desc}", "version": "1.0", "screenshots": [ diff --git a/common/src/main/resources/assets/devices/apps/boat_racers.json b/common/src/main/resources/assets/devices/apps/boat_racers.json index 2b92126f4..ed4755328 100644 --- a/common/src/main/resources/assets/devices/apps/boat_racers.json +++ b/common/src/main/resources/assets/devices/apps/boat_racers.json @@ -1,7 +1,7 @@ { "schemaVersion": 2, "name": "Boat Racers", - "authors": ["MrCrayfish", "MinecraftDoodler", "Jab125", "Qboi123"], + "authors": ["MrCrayfish", "MinecraftDoodler", "Jab125", "XyperCode"], "description": "VERY VERY WIP", "version": "0.0.1", "screenshots": [ diff --git a/common/src/main/resources/assets/devices/apps/diagnostics.json b/common/src/main/resources/assets/devices/apps/diagnostics.json index 8ca9535f2..a4953adbb 100644 --- a/common/src/main/resources/assets/devices/apps/diagnostics.json +++ b/common/src/main/resources/assets/devices/apps/diagnostics.json @@ -1,7 +1,7 @@ { "schemaVersion": 2, "name": "App Diagnostics", - "authors": ["Qboi123"], + "authors": ["XyperCode"], "description": "", "version": "1.0", "screenshots": [ diff --git a/common/src/main/resources/assets/devices/apps/gitweb.json b/common/src/main/resources/assets/devices/apps/gitweb.json index 4c1a0bbf2..ce34af2e3 100644 --- a/common/src/main/resources/assets/devices/apps/gitweb.json +++ b/common/src/main/resources/assets/devices/apps/gitweb.json @@ -1,7 +1,7 @@ { "schemaVersion": 2, "name": "GitWeb", - "authors": ["MrCrayfish", "MinecraftDoodler", "Jab125", "Qboi123"], + "authors": ["MrCrayfish", "MinecraftDoodler", "Jab125", "XyperCode"], "description": "GitWeb is a web browser powered by GitHub. It is community driven, which means websites you browse are created by other players.", "version": "0.0.2", "screenshots": [ diff --git a/common/src/main/resources/assets/devices/apps/mine_bay.json b/common/src/main/resources/assets/devices/apps/mine_bay.json index 7003e8fc4..54226667a 100644 --- a/common/src/main/resources/assets/devices/apps/mine_bay.json +++ b/common/src/main/resources/assets/devices/apps/mine_bay.json @@ -1,7 +1,7 @@ { "schemaVersion": 2, "name": "MineBay", - "authors": ["MrCrayfish", "Jab125", "Qboi123"], + "authors": ["MrCrayfish", "Jab125", "XyperCode"], "description": "Just a description", "version": "1.0", "screenshots": [ diff --git a/fabric-datagen-helper/build.gradle b/fabric-datagen-helper/build.gradle index a5dd41de3..539831927 100644 --- a/fabric-datagen-helper/build.gradle +++ b/fabric-datagen-helper/build.gradle @@ -28,7 +28,7 @@ dependencies { //include(project(":fabric")) modImplementation "net.fabricmc:fabric-loader:$fabric_loader_version" modApi "net.fabricmc.fabric-api:fabric-api:$fabric_api_version" - modImplementation "com.terraformersmc:modmenu:4.0.6", { + modImplementation "com.terraformersmc:modmenu:$modmenu_version", { exclude module: "fabric-api" } } diff --git a/fabric-testmod/build.gradle b/fabric-testmod/build.gradle index 13c6ed6a6..46bc2e49f 100644 --- a/fabric-testmod/build.gradle +++ b/fabric-testmod/build.gradle @@ -30,12 +30,10 @@ dependencies { common(project(path: ":common", configuration: "transformProductionFabric")) { transitive false } modImplementation "net.fabricmc:fabric-loader:$fabric_loader_version" modApi "net.fabricmc.fabric-api:fabric-api:$fabric_api_version" - modImplementation "com.terraformersmc:modmenu:4.0.6", { + modImplementation "com.terraformersmc:modmenu:$modmenu_version", { exclude module: "fabric-api" } - modRuntimeOnly "curse.maven:forgeapiportfabric-547434:3946675" - modRuntimeOnly 'com.electronwill.night-config:core:3.6.3' modRuntimeOnly 'com.electronwill.night-config:toml:3.6.3' } diff --git a/fabric/build.gradle b/fabric/build.gradle index 42a0d8fed..8f749d207 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -24,12 +24,6 @@ loom { } } -repositories { - maven { url = "https://cursemaven.com" } - maven { url "https://maven.terraformersmc.com/releases" } - mavenCentral() -} - configurations { common shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this. @@ -44,7 +38,7 @@ dependencies { // Remove the next line if you don't want to depend on the API modApi "dev.architectury:architectury-fabric:$architectury_version" - modApi "fuzs.forgeconfigapiport:forgeconfigapiport-fabric:8.0.0" + modApi "fuzs.forgeconfigapiport:forgeconfigapiport-fabric:$forgeconfigapiport_version" modImplementation 'com.electronwill.night-config:core:3.6.5' modImplementation 'com.electronwill.night-config:toml:3.6.5' @@ -61,11 +55,11 @@ dependencies { common(project(path: ":common", configuration: "namedElements")) { transitive false } shadowCommon(project(path: ":common", configuration: "transformProductionFabric")) { transitive false } - modCompileOnly "com.terraformersmc:modmenu:4.0.6", { + modCompileOnly "com.terraformersmc:modmenu:$modmenu_version", { exclude module: "fabric-api" } - modRuntimeOnly "me.shedaniel:RoughlyEnoughItems-fabric:12.0.684", { + modRuntimeOnly "me.shedaniel:RoughlyEnoughItems-fabric:$rei_version", { exclude module: "fabric-api" } diff --git a/fabric/src/main/java/com/ultreon/devices/datagen/DevicesLanguageGenerator.java b/fabric/src/main/java/com/ultreon/devices/datagen/DevicesLanguageGenerator.java index d75ad4a27..a3a0382a1 100644 --- a/fabric/src/main/java/com/ultreon/devices/datagen/DevicesLanguageGenerator.java +++ b/fabric/src/main/java/com/ultreon/devices/datagen/DevicesLanguageGenerator.java @@ -109,7 +109,7 @@ private void createTranslationsForLOLCAT(TranslationBuilder translationBuilder) createTranslationsFromTemplate(translationBuilder, "lol"); } - private void createTranslationsForDutch(TranslationBuilder translationBuilder) { // TODO: @Qboi123 + private void createTranslationsForDutch(TranslationBuilder translationBuilder) { // TODO: @XyperCode createTranslationsFromTemplate(translationBuilder, "nl"); } diff --git a/fabric/src/main/java/com/ultreon/devices/datagen/DevicesRecipeProvider.java b/fabric/src/main/java/com/ultreon/devices/datagen/DevicesRecipeProvider.java index 10dd72745..1262fa07f 100644 --- a/fabric/src/main/java/com/ultreon/devices/datagen/DevicesRecipeProvider.java +++ b/fabric/src/main/java/com/ultreon/devices/datagen/DevicesRecipeProvider.java @@ -17,18 +17,15 @@ import net.minecraft.world.item.DyeItem; import net.minecraft.world.item.Items; import net.minecraft.world.item.crafting.Ingredient; -import net.minecraft.world.item.crafting.SmeltingRecipe; import net.minecraft.world.level.ItemLike; -import java.util.function.Consumer; - public class DevicesRecipeProvider extends FabricRecipeProvider { public DevicesRecipeProvider(FabricDataOutput dataGenerator) { super(dataGenerator); } @Override - public void buildRecipes(Consumer exporter) { + public void buildRecipes(RecipeOutput exporter) { DeviceBlocks.LAPTOPS.getMap().forEach(((dyeColor, blockRegistrySupplier) -> laptop(exporter, blockRegistrySupplier.get(), dyeColor))); //***********************// @@ -230,7 +227,7 @@ public void buildRecipes(Consumer exporter) { .save(exporter); } - public static void laptop(Consumer exporter, ItemLike laptop, DyeColor color) { + public static void laptop(RecipeOutput exporter, ItemLike laptop, DyeColor color) { ShapedRecipeBuilder.shaped(RecipeCategory.DECORATIONS, laptop) .define('+', DyeUtils.getWoolFromDye(color)) .define('/', Items.IRON_INGOT) diff --git a/fabric/src/main/java/com/ultreon/devices/fabric/DevicesFabric.java b/fabric/src/main/java/com/ultreon/devices/fabric/DevicesFabric.java index 399f66d75..9d86f87f8 100644 --- a/fabric/src/main/java/com/ultreon/devices/fabric/DevicesFabric.java +++ b/fabric/src/main/java/com/ultreon/devices/fabric/DevicesFabric.java @@ -7,14 +7,14 @@ import com.ultreon.devices.api.print.PrintingManager; import com.ultreon.devices.core.Laptop; import com.ultreon.devices.init.RegistrationHandler; -import fuzs.forgeconfigapiport.api.config.v2.ForgeConfigRegistry; +import fuzs.forgeconfigapiport.fabric.api.neoforge.v4.NeoForgeConfigRegistry; import net.fabricmc.api.ModInitializer; import net.fabricmc.loader.api.FabricLoader; import net.fabricmc.loader.api.entrypoint.EntrypointContainer; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.RecipeType; import net.minecraft.world.level.block.entity.AbstractFurnaceBlockEntity; -import net.minecraftforge.fml.config.ModConfig; +import net.neoforged.fml.config.ModConfig; import java.util.ArrayList; import java.util.List; @@ -23,7 +23,7 @@ public class DevicesFabric extends Devices implements ModInitializer { @Override public void onInitialize() { - ForgeConfigRegistry.INSTANCE.register(Devices.MOD_ID, ModConfig.Type.CLIENT, DeviceConfig.CONFIG); + NeoForgeConfigRegistry.INSTANCE.register(Devices.MOD_ID, ModConfig.Type.CLIENT, DeviceConfig.CONFIG); this.init(); diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index bc79489dc..f5fc2c706 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -8,7 +8,7 @@ "Ultreon Team" ], "contributors": [ - "Qboi123", + "XyperCode", "Jab125", "MrCrayfish", "MinecraftDoodler", @@ -51,8 +51,8 @@ ], "depends": { "fabricloader": ">=${loaderVersion}", - "minecraft": [">=1.20 <=1.20.1"], - "architectury": ">=9.1 <10" + "minecraft": ["1.20.4"], + "architectury": ">=11 <12" }, "custom": { "modmenu": { diff --git a/forge/build.gradle b/forge/build.gradle index 170840229..b5fc1b10e 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -33,6 +33,8 @@ dependencies { // Remove the next line if you don't want to depend on the API modApi "dev.architectury:architectury-forge:$architectury_version" + modApi "fuzs.forgeconfigapiport:forgeconfigapiport-forge:$forgeconfigapiport_version" + common(project(path: ":common", configuration: "namedElements")) { transitive false } shadowCommon(project(path: ":common", configuration: "transformProductionForge")) { transitive = false } diff --git a/forge/src/main/java/com/ultreon/devices/forge/DevicesForge.java b/forge/src/main/java/com/ultreon/devices/forge/DevicesForge.java index bce90f5da..ce8be7d3a 100644 --- a/forge/src/main/java/com/ultreon/devices/forge/DevicesForge.java +++ b/forge/src/main/java/com/ultreon/devices/forge/DevicesForge.java @@ -12,6 +12,7 @@ import com.ultreon.devices.event.WorldDataHandler; import com.ultreon.devices.init.RegistrationHandler; import dev.architectury.platform.forge.EventBuses; +import fuzs.forgeconfigapiport.forge.api.neoforge.v4.NeoForgeConfigRegistry; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.RecipeType; import net.minecraftforge.api.distmarker.Dist; @@ -87,7 +88,7 @@ public DevicesForge() throws LaunchException { // Common side stuff LOGGER.info("Initializing registration handler and mod config."); RegistrationHandler.register(); - context.registerConfig(ModConfig.Type.CLIENT, DeviceConfig.CONFIG); + NeoForgeConfigRegistry.INSTANCE.register(ModConfig.Type.CLIENT, DeviceConfig.CONFIG); forgeEventBus.register(this); forgeEventBus.register(new WorldDataHandler()); diff --git a/forge/src/main/resources/META-INF/mods.toml b/forge/src/main/resources/META-INF/mods.toml index f76b37787..535815f11 100644 --- a/forge/src/main/resources/META-INF/mods.toml +++ b/forge/src/main/resources/META-INF/mods.toml @@ -15,7 +15,7 @@ displayName = "Devices Mod" displayURL = "https://github.com/Ultreon/devices-mod" logoFile="devices_mod.png" credits = "Thanks to MrCrayfish for the idea and the original mod that was made in 1.12.2. Thank you to MinecraftDoodler for helping with textures. Thank you to lizterzapzap for the Devices Mod icon. Cheers to these people for donating during the development: Mastef Chief, Haunted Corpse, Jake Crowley, fabbe50, PlayDashGaming, jack jook, Hunstagamez, Techyy YT, MinecraftDoodler, Norge100YT, Cyberman2208, CreepergamingsMC" -authors = "Qboi123, Jab125" +authors = "XyperCode, Jab125" description = "${description}" itemIcon = "devices:red_laptop" @@ -30,13 +30,13 @@ side = "BOTH" [[dependencies.devices]] modId = "minecraft" mandatory = true -versionRange = "[1.20,1.20.1]" +versionRange = "1.20.4" ordering = "NONE" side = "BOTH" [[dependencies.devices]] modId = "architectury" mandatory = true -versionRange = "[9.1,10)" +versionRange = "[11,12)" ordering = "NONE" side = "BOTH" diff --git a/gradle.properties b/gradle.properties index 3536c4890..e386daa4f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,19 +1,20 @@ org.gradle.jvmargs=-Xmx5G # Platform related -minecraft_version=1.20.1 +minecraft_version=1.20.4 platforms=forge,fabric # Project related archives_base_name=devices maven_group=com.ultreon.mods -mod_version=0.8.2 +mod_version=0.9.0 mod_description=Adds working electronic devices into Minecraft!\\nCurseForge: https://curseforge.com/minecraft/mc-mods/devices-mod\\nModrinth: https://modrinth.com/mod/devices-mod\\nSource Code: https://github.com/Ultreon/devices-mod\\n\\nOriginal mod made by MrCrayfish called \\"MrCrayfish's Device Mod\\".\\nAvailable at: https://mrcrayfish.com/mods/cdm\\nSource Code: https://github.com/MrCrayfish/MrCrayfishDeviceMod # Modloader related -fabric_loader_version=0.14.22 -forge_version=47.1.3 +fabric_loader_version=0.15.3 +forge_version=49.0.49 +neoforge_version=20.4.233 # Geckolib geckolib_version_fabric=4.2.1 @@ -21,5 +22,8 @@ geckolib_version_quilt=4.2.1 geckolib_version_forge=4.2.1 # Dependency related -architectury_version=9.1.12 -fabric_api_version=0.86.1+1.20.1 +architectury_version=11.1.17 +fabric_api_version=0.97.0+1.20.4 +modmenu_version=9.2.0-beta.2 +rei_version=14.1.720 +forgeconfigapiport_version=20.4.2 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 59bc51a20..17655d0ef 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/licenses/ultreon-api-1.0.txt b/licenses/ultreon-api-1.0.txt index 809c50e5f..871a9ee05 100644 --- a/licenses/ultreon-api-1.0.txt +++ b/licenses/ultreon-api-1.0.txt @@ -1,4 +1,4 @@ -Copyright (c) 2022 Qboi123 (https://github.com/Qboi123) +Copyright (c) 2022 XyperCode (https://github.com/XyperCode) Ultreon API License (v1.0) --------------------------- diff --git a/neoforge/build.gradle b/neoforge/build.gradle new file mode 100644 index 000000000..5484376ad --- /dev/null +++ b/neoforge/build.gradle @@ -0,0 +1,102 @@ +//file:noinspection GrDeprecatedAPIUsage +//file:noinspection GroovyAssignabilityCheck +plugins { + id "com.github.johnrengelman.shadow" version "7.1.2" +} + +version rootProject.version + +architectury { + platformSetupLoomIde() + neoForge() +} + +loom { + accessWidenerPath = project(":common").loom.accessWidenerPath +} + +configurations { + common + shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this. + compileClasspath.extendsFrom common + runtimeClasspath.extendsFrom common + developmentNeoForge.extendsFrom common +} + +repositories { + maven { url "https://maven.neoforged.net/releases/" } +} + +dependencies { + neoForge "net.neoforged:neoforge:$neoforge_version" + // Remove the next line if you don't want to depend on the API + modApi "dev.architectury:architectury-neoforge:$architectury_version" + + common(project(path: ":common", configuration: "namedElements")) { transitive false } + shadowCommon(project(path: ":common", configuration: "transformProductionNeoForge")) { transitive = false } +} + +processResources { + inputs.property "version", rootProject.getIngameVersion() + inputs.property "description", rootProject.getModDescription() + System.out.println(inputs.getProperties()) + + filesMatching("META-INF/neoforge.mods.toml") { + HashMap p = new HashMap<>() + p.put("version", rootProject.getIngameVersion()) + p.put("description", rootProject.getModDescription()) + //noinspection GroovyAssignabilityCheck + p.put("loaderVersion", rootProject.neoforge_version.split("\\.")[0]) + p.put("forgeVersion", rootProject.neoforge_version) + p.put("minecraftVersion", rootProject.architectury.minecraft) + expand(p) + } +} + +shadowJar { + exclude "fabric.mod.json" + exclude "architectury.common.json" + + configurations = [project.configurations.shadowCommon] + archiveClassifier = "dev-shadow" +} + +remapJar { + input.set shadowJar.archiveFile + dependsOn shadowJar + archiveClassifier = null +} + +jar { + archiveClassifier = "dev" +} + +sourcesJar { + def commonSources = project(":common").sourcesJar + dependsOn commonSources + from commonSources.archiveFile.map { zipTree(it) } +} + +components.java { + withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) { + skip() + } +} + +publishing { + publications { + mavenNeoForge(MavenPublication) { + System.out.println(artifactId) + artifactId = rootProject.archivesBaseName + "-neoForge" + //artifactId = rootProject.archivesBaseName + "-neoForge" + //project.name + from components.java + } + } + + // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. + repositories { + // Add repositories to publish to here. + } + rootProject.setupRepositories(repositories) +} + diff --git a/neoforge/gradle.properties b/neoforge/gradle.properties new file mode 100644 index 000000000..2914393db --- /dev/null +++ b/neoforge/gradle.properties @@ -0,0 +1 @@ +loom.platform=neoforge \ No newline at end of file diff --git a/neoforge/src/main/java/com/ultreon/devices/block/entity/forge/RouterBlockEntityImpl.java b/neoforge/src/main/java/com/ultreon/devices/block/entity/forge/RouterBlockEntityImpl.java new file mode 100644 index 000000000..39277c458 --- /dev/null +++ b/neoforge/src/main/java/com/ultreon/devices/block/entity/forge/RouterBlockEntityImpl.java @@ -0,0 +1,11 @@ +package com.ultreon.devices.block.entity.forge; + +import net.minecraft.world.phys.AABB; + +import static net.neoforged.neoforge.client.extensions.IBlockEntityRendererExtension.INFINITE_EXTENT_AABB; + +public class RouterBlockEntityImpl { + public AABB getRenderBoundingBox() { + return INFINITE_EXTENT_AABB; + } +} diff --git a/neoforge/src/main/java/com/ultreon/devices/forge/BuiltinAppsRegistration.java b/neoforge/src/main/java/com/ultreon/devices/forge/BuiltinAppsRegistration.java new file mode 100644 index 000000000..327359f5a --- /dev/null +++ b/neoforge/src/main/java/com/ultreon/devices/forge/BuiltinAppsRegistration.java @@ -0,0 +1,12 @@ +package com.ultreon.devices.forge; + +import com.ultreon.devices.BuiltinApps; +import net.neoforged.bus.api.EventPriority; +import net.neoforged.bus.api.SubscribeEvent; + +public class BuiltinAppsRegistration { + @SubscribeEvent(priority = EventPriority.HIGHEST) + public static void registerBuiltinApps(NeoForgeApplicationRegistration event) { + BuiltinApps.registerBuiltinApps(); + } +} diff --git a/neoforge/src/main/java/com/ultreon/devices/forge/DevicesNeoForge.java b/neoforge/src/main/java/com/ultreon/devices/forge/DevicesNeoForge.java new file mode 100644 index 000000000..5cd390879 --- /dev/null +++ b/neoforge/src/main/java/com/ultreon/devices/forge/DevicesNeoForge.java @@ -0,0 +1,122 @@ +package com.ultreon.devices.forge; + +import com.mojang.logging.LogUtils; +import com.ultreon.devices.DeviceConfig; +import com.ultreon.devices.Devices; +import com.ultreon.devices.LaunchException; +import com.ultreon.devices.Reference; +import com.ultreon.devices.api.app.Application; +import com.ultreon.devices.api.print.IPrint; +import com.ultreon.devices.api.print.PrintingManager; +import com.ultreon.devices.core.Laptop; +import com.ultreon.devices.event.WorldDataHandler; +import com.ultreon.devices.init.RegistrationHandler; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.RecipeType; +import net.neoforged.api.distmarker.Dist; +import net.neoforged.api.distmarker.OnlyIn; +import net.neoforged.bus.api.IEventBus; +import net.neoforged.fml.ModContainer; +import net.neoforged.fml.ModList; +import net.neoforged.fml.ModLoadingContext; +import net.neoforged.fml.common.Mod; +import net.neoforged.fml.config.ModConfig; +import net.neoforged.fml.event.IModBusEvent; +import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent; +import net.neoforged.fml.event.lifecycle.FMLDedicatedServerSetupEvent; +import net.neoforged.fml.event.lifecycle.FMLLoadCompleteEvent; +import net.neoforged.fml.util.ObfuscationReflectionHelper; +import net.neoforged.neoforge.common.NeoForge; +import net.neoforged.neoforge.data.loading.DatagenModLoader; +import net.neoforged.neoforgespi.language.IModInfo; +import org.slf4j.Logger; + +import java.util.List; +import java.util.Map; + +// The value here should match an entry in the META-INF/neoforge.mods.toml file +@Mod(Reference.MOD_ID) +public final class DevicesNeoForge { + public static final Logger LOGGER = LogUtils.getLogger(); + private final Devices instance = new Devices() { + @Override + protected void registerApplicationEvent() { + DevicesNeoForge.this.modEventBus.post(new NeoForgeApplicationRegistration()); + } + + @Override + public int getBurnTime(ItemStack stack, RecipeType type) { + return stack.getBurnTime(type); + } + + @Override + protected List getApplications() { + return ObfuscationReflectionHelper.getPrivateValue(Laptop.class, null, "APPLICATIONS"); + } + + @Override + @OnlyIn(Dist.CLIENT) + @SuppressWarnings("DataFlowIssue") + protected void setRegisteredRenders(Map map) { + ObfuscationReflectionHelper.setPrivateValue(PrintingManager.class, null, map, "registeredRenders"); + } + + @Override + @OnlyIn(Dist.CLIENT) + protected Map getRegisteredRenders() { + return ObfuscationReflectionHelper.getPrivateValue(PrintingManager.class, null, "registeredRenders"); + } + }; + + public IEventBus modEventBus; + + public DevicesNeoForge(IEventBus modEventBus) throws LaunchException { + super(); + + this.modEventBus = modEventBus; + this.modEventBus.register(BuiltinAppsRegistration.class); + + Devices.preInit(); + + ModLoadingContext context = ModLoadingContext.get(); + IEventBus forgeEventBus = NeoForge.EVENT_BUS; + + // Common side stuff + LOGGER.info("Initializing registration handler and mod config."); + RegistrationHandler.register(); + context.registerConfig(ModConfig.Type.CLIENT, DeviceConfig.CONFIG); + + forgeEventBus.register(this); + forgeEventBus.register(new WorldDataHandler()); + + LOGGER.info("Registering common setup handler, and load complete handler."); + this.modEventBus.addListener(this::fmlCommonSetup); + this.modEventBus.addListener(this::fmlLoadComplete); + + // Server side stuff + LOGGER.info("Registering server setup handler."); + this.modEventBus.addListener(this::fmlServerSetup); + + // Client side stuff + if (!DatagenModLoader.isRunningDataGen()) { + LOGGER.info("Registering the reload listener."); +// ((ReloadableResourceManager) Minecraft.getInstance().getResourceManager()).registerReloadListener(this); + } + + // Register ourselves for server and other game events we are interested in + LOGGER.info("Registering mod class to forge events."); + forgeEventBus.register(this); + } + + private void fmlCommonSetup(FMLCommonSetupEvent t) { + this.instance.init(); + } + + private void fmlLoadComplete(FMLLoadCompleteEvent t) { + this.instance.loadComplete(); + } + + private void fmlServerSetup(FMLDedicatedServerSetupEvent t) { + this.instance.serverSetup(); + } +} diff --git a/neoforge/src/main/java/com/ultreon/devices/forge/NeoForgeApplicationRegistration.java b/neoforge/src/main/java/com/ultreon/devices/forge/NeoForgeApplicationRegistration.java new file mode 100644 index 000000000..ea294e58c --- /dev/null +++ b/neoforge/src/main/java/com/ultreon/devices/forge/NeoForgeApplicationRegistration.java @@ -0,0 +1,7 @@ +package com.ultreon.devices.forge; + +import net.neoforged.bus.api.Event; +import net.neoforged.fml.event.IModBusEvent; + +public class NeoForgeApplicationRegistration extends Event implements IModBusEvent { +} diff --git a/neoforge/src/main/java/com/ultreon/devices/forge/client/ForgeRenderRegistry.java b/neoforge/src/main/java/com/ultreon/devices/forge/client/ForgeRenderRegistry.java new file mode 100644 index 000000000..9884dbe24 --- /dev/null +++ b/neoforge/src/main/java/com/ultreon/devices/forge/client/ForgeRenderRegistry.java @@ -0,0 +1,13 @@ +package com.ultreon.devices.forge.client; + +import com.ultreon.devices.client.RenderRegistry; +import dev.architectury.registry.client.rendering.RenderTypeRegistry; +import net.minecraft.client.renderer.RenderType; +import net.minecraft.world.level.block.Block; + +public class ForgeRenderRegistry extends RenderRegistry { + @Override + public void onRegister(Block block, RenderType renderType) { + RenderTypeRegistry.register(renderType, block); + } +} diff --git a/neoforge/src/main/resources/META-INF/neoforge.mods.toml b/neoforge/src/main/resources/META-INF/neoforge.mods.toml new file mode 100644 index 000000000..535815f11 --- /dev/null +++ b/neoforge/src/main/resources/META-INF/neoforge.mods.toml @@ -0,0 +1,42 @@ +# Mods.toml for the devices mod by ultreon (originally created my MrCrayfish) +# Copyright (c) 2022 - Ultreon Team, GPLv3 License. See the license at https://www.gnu.org/licenses/gpl-3.0-standalone.html + +modLoader = "javafml" +loaderVersion = "[${loaderVersion},)" +license = "GPL-3.0" +issueTrackerURL = "https://github.com/Ultreon/devices-mod/issues" + +# The main mod, and all sub-mods. +[[mods]] +modId = "devices" +version = "${version}" +displayName = "Devices Mod" +#updateJSONURL="http://myurl.me/" +displayURL = "https://github.com/Ultreon/devices-mod" +logoFile="devices_mod.png" +credits = "Thanks to MrCrayfish for the idea and the original mod that was made in 1.12.2. Thank you to MinecraftDoodler for helping with textures. Thank you to lizterzapzap for the Devices Mod icon. Cheers to these people for donating during the development: Mastef Chief, Haunted Corpse, Jake Crowley, fabbe50, PlayDashGaming, jack jook, Hunstagamez, Techyy YT, MinecraftDoodler, Norge100YT, Cyberman2208, CreepergamingsMC" +authors = "XyperCode, Jab125" +description = "${description}" +itemIcon = "devices:red_laptop" + +# Dependencies for the main mod. +[[dependencies.devices]] +modId = "forge" +mandatory = true +versionRange = "[${forgeVersion},)" +ordering = "NONE" +side = "BOTH" + +[[dependencies.devices]] +modId = "minecraft" +mandatory = true +versionRange = "1.20.4" +ordering = "NONE" +side = "BOTH" + +[[dependencies.devices]] +modId = "architectury" +mandatory = true +versionRange = "[11,12)" +ordering = "NONE" +side = "BOTH" diff --git a/neoforge/src/main/resources/META-INF/services/com.ultreon.devices.client.RenderRegistry b/neoforge/src/main/resources/META-INF/services/com.ultreon.devices.client.RenderRegistry new file mode 100644 index 000000000..49246736a --- /dev/null +++ b/neoforge/src/main/resources/META-INF/services/com.ultreon.devices.client.RenderRegistry @@ -0,0 +1 @@ +com.ultreon.devices.forge.client.ForgeRenderRegistry \ No newline at end of file diff --git a/neoforge/src/main/resources/devices.mixins.json b/neoforge/src/main/resources/devices.mixins.json new file mode 100644 index 000000000..7a404d86a --- /dev/null +++ b/neoforge/src/main/resources/devices.mixins.json @@ -0,0 +1,13 @@ +{ + "required": true, + "minVersion": "0.8", + "package": "com.ultreon.devices.devices.mixin.forge", + "compatibilityLevel": "JAVA_17", + "mixins": [ + ], + "client": [ + ], + "injectors": { + "defaultRequire": 1 + } +} diff --git a/neoforge/src/main/resources/devices_mod.png b/neoforge/src/main/resources/devices_mod.png new file mode 100644 index 000000000..6624851fd Binary files /dev/null and b/neoforge/src/main/resources/devices_mod.png differ diff --git a/neoforge/src/main/resources/pack.mcmeta b/neoforge/src/main/resources/pack.mcmeta new file mode 100644 index 000000000..e6b7f33f5 --- /dev/null +++ b/neoforge/src/main/resources/pack.mcmeta @@ -0,0 +1,6 @@ +{ + "pack": { + "description": "devices resources", + "pack_format": 8 + } +} diff --git a/settings.gradle b/settings.gradle index 90beba93d..5e3d29043 100644 --- a/settings.gradle +++ b/settings.gradle @@ -10,5 +10,6 @@ pluginManagement { include("common") include("fabric") include("forge") +include("neoforge") include("fabric-datagen-helper") include("fabric-testmod") \ No newline at end of file