Skip to content

Commit

Permalink
Initial 1.20.4 port
Browse files Browse the repository at this point in the history
  • Loading branch information
XyperCode committed Apr 29, 2024
1 parent d0b738a commit 9c348ee
Show file tree
Hide file tree
Showing 55 changed files with 565 additions and 162 deletions.
6 changes: 5 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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/" }
}

Expand Down
2 changes: 2 additions & 0 deletions common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
27 changes: 13 additions & 14 deletions common/src/main/java/com/ultreon/devices/DeviceConfig.java
Original file line number Diff line number Diff line change
@@ -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);

Expand Down
6 changes: 6 additions & 0 deletions common/src/main/java/com/ultreon/devices/ModDeviceTypes.java
Original file line number Diff line number Diff line change
@@ -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<ModDeviceTypes> CODEC = Codec.STRING.xmap(
val -> ModDeviceTypes.valueOf(val.toUpperCase()),
val -> val.name().toLowerCase()
);

@Override
@Contract(pure = true, value = "-> this")
public ModDeviceTypes getDeviceType() {
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -152,5 +157,10 @@ public void setPlacedBy(@NotNull Level level, @NotNull BlockPos pos, @NotNull Bl
protected void createBlockStateDefinition(StateDefinition.@NotNull Builder<Block, BlockState> pBuilder) {
super.createBlockStateDefinition(pBuilder);
}

@Override
public ModDeviceTypes getDeviceType() {
return deviceType;
}
}
}
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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()) {
Expand Down
31 changes: 15 additions & 16 deletions common/src/main/java/com/ultreon/devices/block/LaptopBlock.java
Original file line number Diff line number Diff line change
@@ -1,46 +1,41 @@
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;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.List;
import java.util.Locale;

public class LaptopBlock extends ComputerBlock.Colored {
public static final EnumProperty<Type> TYPE = EnumProperty.create("type", Type.class);
public static final BooleanProperty OPEN = BooleanProperty.create("open");

public static final MapCodec<ComputerBlock.Colored> 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));
Expand All @@ -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
Expand Down Expand Up @@ -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<? extends HorizontalDirectionalBlock> codec() {
return CODEC;
}
}
19 changes: 15 additions & 4 deletions common/src/main/java/com/ultreon/devices/block/MacMaxXBlock.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand All @@ -30,10 +33,12 @@
import org.jetbrains.annotations.Nullable;

/**
* @author Qboi123
* @author XyperCode
*/
@SuppressWarnings("deprecation")
public class MacMaxXBlock extends ComputerBlock {
public static final MapCodec<MacMaxXBlock> 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),
Expand Down Expand Up @@ -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<? extends MacMaxXBlock> codec() {
return CODEC;
}

@Override
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down
Loading

0 comments on commit 9c348ee

Please sign in to comment.