Skip to content

Commit

Permalink
Add 1.20 support
Browse files Browse the repository at this point in the history
  • Loading branch information
zbx1425 committed Jul 19, 2023
1 parent 7c3b6e8 commit 3463d83
Show file tree
Hide file tree
Showing 14 changed files with 149 additions and 283 deletions.
22 changes: 14 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ int minecraft_main_version = minecraft_version.split("\\.")[1] as int
String minecraft_version_int = minecraft_version.split("\\.")[0] +
minecraft_version.split("\\.")[1].padLeft(2, '0') +
(minecraft_version.split("\\.").length > 2 ? minecraft_version.split("\\.")[2].padLeft(2, '0') : "00")
boolean parchment_not_avail = false
String parchment_version = parchment_not_avail ? "N/A" : new XmlSlurper().parse("https://ldtteam.jfrog.io/artifactory/parchmentmc-internal/org/parchmentmc/data/parchment-${minecraft_version}/maven-metadata.xml").versioning.release
def is_1_19_3 = minecraft_version == "1.19.3" || minecraft_version == "1.19.4"
String parchment_version = new XmlSlurper().parse("https://ldtteam.jfrog.io/artifactory/parchmentmc-internal/org/parchmentmc/data/parchment-${is_1_19_3 ? "1.19.3" : minecraft_version}/maven-metadata.xml").versioning.release

def is_1_20 = minecraft_version == "1.20" || minecraft_version == "1.20.1"

rootProject.ext.fabric_loader_version = new JsonSlurper().parse(("https://meta.fabricmc.net/v2/versions/loader/" + minecraft_version).toURL())[0]["loader"]["version"]
rootProject.ext.forge_version = minecraft_version + "-" + new JsonSlurper().parse(("https://files.minecraftforge.net/net/minecraftforge/forge/promotions_slim.json").toURL())["promos"][minecraft_version + "-latest"]
rootProject.ext.forge_version = minecraft_version + "-" + new JsonSlurper().parse(("https://files.minecraftforge.net/net/minecraftforge/forge/promotions_slim.json").toURL())["promos"][minecraft_version + "-recommended"]
rootProject.ext.fabric_api_version = getModrinthVersion("fabric", minecraft_version, "fabric-api")
rootProject.ext.mod_menu_version = getModrinthVersion("fabric", minecraft_version, "modmenu")
rootProject.ext.architectury_version = getModrinthVersion("forge", minecraft_version, "architectury-api").split("\\+")[0]
Expand Down Expand Up @@ -63,7 +64,7 @@ subprojects {
dependencies {
annotationProcessor 'systems.manifold:manifold-preprocessor:2023.1.10'
minecraft "com.mojang:minecraft:${minecraft_version}"
mappings is_1_19_3 ? loom.officialMojangMappings() : loom.layered() {
mappings parchment_not_avail ? loom.officialMojangMappings() : loom.layered() {
officialMojangMappings()
parchment("org.parchmentmc.data:parchment-${minecraft_version}:${parchment_version}@zip")
}
Expand All @@ -80,27 +81,32 @@ subprojects {

task setupLibrary() {
doLast {

String baseURL = is_1_20 ? "https://storage.zbx1425.cn/mtr-artifacts/libs/" : "https://www.minecrafttransitrailway.com/libs/"

download {
src "https://www.minecrafttransitrailway.com/libs/${rootProject.mtr_version}/MTR-common-${minecraft_version}-${rootProject.mtr_version}-dev.jar"
src "${baseURL}${rootProject.mtr_version}/MTR-common-${minecraft_version}-${rootProject.mtr_version}-dev.jar"
dest "checkouts/mtr-common.jar"
overwrite true
}

download {
src "https://www.minecrafttransitrailway.com/libs/${rootProject.mtr_version}/MTR-fabric-${minecraft_version}-${rootProject.mtr_version}-dev-shadow.jar"
src "${baseURL}${rootProject.mtr_version}/MTR-fabric-${minecraft_version}-${rootProject.mtr_version}-dev-shadow.jar"
dest "checkouts/mtr-fabric.jar"
overwrite true
}

download {
src "https://www.minecrafttransitrailway.com/libs/${rootProject.mtr_version}/MTR-forge-${minecraft_version}-${rootProject.mtr_version}-dev-shadow.jar"
src "${baseURL}${rootProject.mtr_version}/MTR-forge-${minecraft_version}-${rootProject.mtr_version}-dev-shadow.jar"
dest "checkouts/mtr-forge.jar"
overwrite true
}
}

String minecraftMappingsBaseURL = is_1_20 ? "https://storage.zbx1425.cn/mtr-artifacts/Minecraft-Mappings/" : "https://github.com/jonafanho/Minecraft-Mappings/archive/refs/heads/"

download {
src "https://github.com/jonafanho/Minecraft-Mappings/archive/refs/heads/1.${minecraft_main_version}${is_1_19_3 ? ".3" : ""}.zip"
src "${minecraftMappingsBaseURL}${is_1_19_3 ? minecraft_version : "1." + minecraft_main_version}.zip"
dest "common/src/main/java/cn/zbx1425/mtrsteamloco/mappings/files.zip"
overwrite true
}
Expand Down
20 changes: 0 additions & 20 deletions common/src/main/java/cn/zbx1425/mtrsteamloco/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import cn.zbx1425.mtrsteamloco.block.BlockDepartureBell;
import cn.zbx1425.mtrsteamloco.block.BlockEyeCandy;
import cn.zbx1425.mtrsteamloco.block.BlockFeedbackBox;
import cn.zbx1425.mtrsteamloco.block.BlockStatisticTurnstile;
import cn.zbx1425.mtrsteamloco.network.PacketUpdateBlockEntity;
import cn.zbx1425.mtrsteamloco.network.PacketUpdateHoldingItem;
import cn.zbx1425.mtrsteamloco.network.PacketUpdateRail;
Expand Down Expand Up @@ -56,20 +54,6 @@ public class Main {
BlockEyeCandy.BlockEntityEyeCandy::new,
BLOCK_EYE_CANDY.get()
));
public static final RegistryObject<Block> BLOCK_STATISTIC_TURNSTILE = new RegistryObject<>(BlockStatisticTurnstile::new);
public static final RegistryObject<BlockEntityType<BlockStatisticTurnstile.BlockEntityStatisticTurnstile>>
BLOCK_ENTITY_TYPE_STATISTIC_TURNSTILE = new RegistryObject<>(() ->
RegistryUtilities.getBlockEntityType(
BlockStatisticTurnstile.BlockEntityStatisticTurnstile::new,
BLOCK_STATISTIC_TURNSTILE.get()
));
public static final RegistryObject<Block> BLOCK_FEEDBACK_BOX = new RegistryObject<>(BlockFeedbackBox::new);
public static final RegistryObject<BlockEntityType<BlockFeedbackBox.BlockEntityFeedbackBox>>
BLOCK_ENTITY_TYPE_FEEDBACK_BOX = new RegistryObject<>(() ->
RegistryUtilities.getBlockEntityType(
BlockFeedbackBox.BlockEntityFeedbackBox::new,
BLOCK_FEEDBACK_BOX.get()
));

public static final SoundEvent SOUND_EVENT_BELL = RegistryUtilities.createSoundEvent(new ResourceLocation("mtrsteamloco:bell"));

Expand All @@ -84,10 +68,6 @@ public static void init(
+ DateTimeFormatter.ISO_DATE_TIME.withZone(ZoneId.systemDefault()).format(BuildConfig.BUILD_TIME));
if (enableRegistry) {
registerBlockItem.accept("departure_bell", BLOCK_DEPARTURE_BELL, CreativeModeTabs.RAILWAY_FACILITIES);
// registerBlockItem.accept("statistic_turnstile", BLOCK_STATISTIC_TURNSTILE, ItemGroups.RAILWAY_FACILITIES);
// registerBlockEntityType.accept("statistic_turnstile", BLOCK_ENTITY_TYPE_STATISTIC_TURNSTILE);
// registerBlockItem.accept("feedback_box", BLOCK_FEEDBACK_BOX, ItemGroups.RAILWAY_FACILITIES);
// registerBlockEntityType.accept("feedback_box", BLOCK_ENTITY_TYPE_FEEDBACK_BOX);
registerBlockItem.accept("eye_candy", BLOCK_EYE_CANDY, CreativeModeTabs.STATION_BUILDING_BLOCKS);
registerBlockEntityType.accept("eye_candy", BLOCK_ENTITY_TYPE_EYE_CANDY);
registerSoundEvent.accept("bell", SOUND_EVENT_BELL);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,25 @@
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
#if MC_VERSION < "12000"
import net.minecraft.world.level.material.Material;
import net.minecraft.world.level.material.MaterialColor;
#endif
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;

public class BlockDepartureBell extends BlockDirectionalMapper {

public BlockDepartureBell() {
super(BlockBehaviour.Properties.of(Material.METAL, MaterialColor.COLOR_GRAY).strength(2));
super(
#if MC_VERSION < "12000"
BlockBehaviour.Properties.of(Material.METAL, MaterialColor.COLOR_GRAY)
#else
BlockBehaviour.Properties.of()
#endif
.strength(2)
);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
#if MC_VERSION < "12000"
import net.minecraft.world.level.material.Material;
import net.minecraft.world.level.material.MaterialColor;
#endif
import net.minecraft.world.phys.BlockHitResult;
import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;
Expand All @@ -29,7 +31,11 @@ public class BlockEyeCandy extends BlockDirectionalMapper implements EntityBlock

public BlockEyeCandy() {
super(
#if MC_VERSION < "12000"
BlockBehaviour.Properties.of(Material.METAL, MaterialColor.COLOR_GRAY)
#else
BlockBehaviour.Properties.of()
#endif
.strength(2)
.noCollission()
);
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit 3463d83

Please sign in to comment.