Skip to content

Commit

Permalink
1.18 mod version
Browse files Browse the repository at this point in the history
  • Loading branch information
FXCourel committed Aug 18, 2024
1 parent b571757 commit f686737
Show file tree
Hide file tree
Showing 38 changed files with 548 additions and 579 deletions.
12 changes: 4 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ repositories {
// for more information about repositories.
}

fabricApi {
configureDataGeneration()
}

dependencies {
// To change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}"
Expand All @@ -30,7 +26,7 @@ dependencies {

// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"

}

processResources {
Expand All @@ -42,7 +38,7 @@ processResources {
}

tasks.withType(JavaCompile).configureEach {
it.options.release = 21
it.options.release = 17
}

java {
Expand All @@ -51,8 +47,8 @@ java {
// If you remove this line, sources will not be generated.
withSourcesJar()

sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

jar {
Expand Down
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ org.gradle.parallel=true

# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.21
minecraft_version=1.18.1
loader_version=0.15.11

# Mod Properties
mod_version=1.0.2
mod_version=1.0.2-mc1.18
maven_group=net.robofox.copperrails
archives_base_name=copperrails

# Dependencies
fabric_version=0.100.6+1.21
fabric_version=0.46.6+1.18
5 changes: 2 additions & 3 deletions src/main/java/net/robofox/copperrails/CopperRailsClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import net.fabricmc.loader.api.FabricLoader;
import net.fabricmc.loader.api.ModContainer;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.block.Block;
import net.robofox.copperrails.block.ModBlocks;
Expand All @@ -19,9 +18,9 @@ private static void cutout(Block block) {
}

private static void initializeResourcePack() {
ResourceLocation id = ResourceLocation.fromNamespaceAndPath(CopperRails.MOD_ID, "copperrails3d");
ResourceLocation id = new ResourceLocation(CopperRails.MOD_ID, "copperrails3d");
ModContainer modContainer = FabricLoader.getInstance().getModContainer(CopperRails.MOD_ID).orElseThrow();
ResourceManagerHelper.registerBuiltinResourcePack(id, modContainer, Component.nullToEmpty("CopperRails 3D Rails"), ResourcePackActivationType.NORMAL);
ResourceManagerHelper.registerBuiltinResourcePack(id, modContainer, ResourcePackActivationType.NORMAL);
}

@Override
Expand Down
48 changes: 16 additions & 32 deletions src/main/java/net/robofox/copperrails/block/ModBlocks.java
Original file line number Diff line number Diff line change
@@ -1,45 +1,34 @@
package net.robofox.copperrails.block;

import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents;
import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
import net.fabricmc.fabric.api.registry.OxidizableBlocksRegistry;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.level.block.Block;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.CreativeModeTabs;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.WeatheringCopper;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.material.MapColor;
import net.minecraft.world.level.material.MaterialColor;
import net.robofox.copperrails.CopperRails;
import net.robofox.copperrails.block.custom.CrossingRailBlock;
import net.robofox.copperrails.block.custom.GenericCopperRailBlock;
import net.robofox.copperrails.block.custom.OxidizableCopperRailBlock;

public class ModBlocks {

public static final Block COPPER_RAIL = register(new OxidizableCopperRailBlock(WeatheringCopper.WeatherState.UNAFFECTED, BlockBehaviour.Properties.ofFullCopy(Blocks.POWERED_RAIL).mapColor(MapColor.COLOR_ORANGE)), "copper_rail");
public static final Block EXPOSED_COPPER_RAIL = register(new OxidizableCopperRailBlock(WeatheringCopper.WeatherState.EXPOSED, BlockBehaviour.Properties.ofFullCopy(Blocks.POWERED_RAIL).mapColor(MapColor.TERRACOTTA_LIGHT_GRAY)), "exposed_copper_rail");
public static final Block WEATHERED_COPPER_RAIL = register(new OxidizableCopperRailBlock(WeatheringCopper.WeatherState.WEATHERED, BlockBehaviour.Properties.ofFullCopy(Blocks.POWERED_RAIL).mapColor(MapColor.WARPED_STEM)), "weathered_copper_rail");
public static final Block OXIDIZED_COPPER_RAIL = register(new OxidizableCopperRailBlock(WeatheringCopper.WeatherState.OXIDIZED, BlockBehaviour.Properties.ofFullCopy(Blocks.POWERED_RAIL).mapColor(MapColor.WARPED_NYLIUM)), "oxidized_copper_rail");
public static final Block WAXED_COPPER_RAIL = register(new GenericCopperRailBlock(BlockBehaviour.Properties.ofFullCopy(ModBlocks.COPPER_RAIL)), "waxed_copper_rail");
public static final Block WAXED_EXPOSED_COPPER_RAIL = register(new GenericCopperRailBlock(BlockBehaviour.Properties.ofFullCopy(ModBlocks.EXPOSED_COPPER_RAIL)), "waxed_exposed_copper_rail");
public static final Block WAXED_WEATHERED_COPPER_RAIL = register(new GenericCopperRailBlock(BlockBehaviour.Properties.ofFullCopy(ModBlocks.WEATHERED_COPPER_RAIL)), "waxed_weathered_copper_rail");
public static final Block WAXED_OXIDIZED_COPPER_RAIL = register(new GenericCopperRailBlock(BlockBehaviour.Properties.ofFullCopy(ModBlocks.OXIDIZED_COPPER_RAIL)), "waxed_oxidized_copper_rail");
public static final Block RAIL_CROSSING = register(new CrossingRailBlock(BlockBehaviour.Properties.ofFullCopy(Blocks.POWERED_RAIL)), "rail_crossing");
public static final Block COPPER_RAIL = register(new OxidizableCopperRailBlock(WeatheringCopper.WeatherState.UNAFFECTED, BlockBehaviour.Properties.copy(Blocks.POWERED_RAIL).color(MaterialColor.COLOR_ORANGE)), "copper_rail");
public static final Block EXPOSED_COPPER_RAIL = register(new OxidizableCopperRailBlock(WeatheringCopper.WeatherState.EXPOSED, BlockBehaviour.Properties.copy(Blocks.POWERED_RAIL).color(MaterialColor.TERRACOTTA_LIGHT_GRAY)), "exposed_copper_rail");
public static final Block WEATHERED_COPPER_RAIL = register(new OxidizableCopperRailBlock(WeatheringCopper.WeatherState.WEATHERED, BlockBehaviour.Properties.copy(Blocks.POWERED_RAIL).color(MaterialColor.WARPED_STEM)), "weathered_copper_rail");
public static final Block OXIDIZED_COPPER_RAIL = register(new OxidizableCopperRailBlock(WeatheringCopper.WeatherState.OXIDIZED, BlockBehaviour.Properties.copy(Blocks.POWERED_RAIL).color(MaterialColor.WARPED_NYLIUM)), "oxidized_copper_rail");
public static final Block WAXED_COPPER_RAIL = register(new GenericCopperRailBlock(BlockBehaviour.Properties.copy(ModBlocks.COPPER_RAIL)), "waxed_copper_rail");
public static final Block WAXED_EXPOSED_COPPER_RAIL = register(new GenericCopperRailBlock(BlockBehaviour.Properties.copy(ModBlocks.EXPOSED_COPPER_RAIL)), "waxed_exposed_copper_rail");
public static final Block WAXED_WEATHERED_COPPER_RAIL = register(new GenericCopperRailBlock(BlockBehaviour.Properties.copy(ModBlocks.WEATHERED_COPPER_RAIL)), "waxed_weathered_copper_rail");
public static final Block WAXED_OXIDIZED_COPPER_RAIL = register(new GenericCopperRailBlock(BlockBehaviour.Properties.copy(ModBlocks.OXIDIZED_COPPER_RAIL)), "waxed_oxidized_copper_rail");
public static final Block RAIL_CROSSING = register(new CrossingRailBlock(BlockBehaviour.Properties.copy(Blocks.POWERED_RAIL)), "rail_crossing");

public static void initialize() {
putInRedstoneTab(ModBlocks.COPPER_RAIL);
putInRedstoneTab(ModBlocks.EXPOSED_COPPER_RAIL);
putInRedstoneTab(ModBlocks.WEATHERED_COPPER_RAIL);
putInRedstoneTab(ModBlocks.OXIDIZED_COPPER_RAIL);
putInRedstoneTab(ModBlocks.WAXED_COPPER_RAIL);
putInRedstoneTab(ModBlocks.WAXED_EXPOSED_COPPER_RAIL);
putInRedstoneTab(ModBlocks.WAXED_WEATHERED_COPPER_RAIL);
putInRedstoneTab(ModBlocks.WAXED_OXIDIZED_COPPER_RAIL);
putInRedstoneTab(ModBlocks.RAIL_CROSSING);

// Register copper rails for oxidation
OxidizableBlocksRegistry.registerOxidizableBlockPair(ModBlocks.COPPER_RAIL, ModBlocks.EXPOSED_COPPER_RAIL);
Expand All @@ -51,15 +40,10 @@ public static void initialize() {
OxidizableBlocksRegistry.registerWaxableBlockPair(ModBlocks.OXIDIZED_COPPER_RAIL, ModBlocks.WAXED_OXIDIZED_COPPER_RAIL);
}

public static void putInRedstoneTab(Block block) {
ItemGroupEvents.modifyEntriesEvent(CreativeModeTabs.REDSTONE_BLOCKS)
.register((itemGroup) -> itemGroup.accept(block.asItem()));
}

private static Block register(Block block, String id) {
ResourceLocation blockID = ResourceLocation.fromNamespaceAndPath(CopperRails.MOD_ID, id);
BlockItem blockItem = new BlockItem(block, new Item.Properties());
Registry.register(BuiltInRegistries.ITEM, blockID, blockItem);
return Registry.register(BuiltInRegistries.BLOCK, blockID, block);
ResourceLocation blockID = new ResourceLocation(CopperRails.MOD_ID, id);
BlockItem blockItem = new BlockItem(block, new FabricItemSettings().group(CreativeModeTab.TAB_TRANSPORTATION));
Registry.register(Registry.ITEM, blockID, blockItem);
return Registry.register(Registry.BLOCK, new ResourceLocation(CopperRails.MOD_ID, id), block);
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package net.robofox.copperrails.block.custom;

import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.RandomSource;
import net.minecraft.world.level.block.WeatheringCopper;
import net.minecraft.world.level.block.state.BlockState;

Expand All @@ -16,12 +16,12 @@ public OxidizableCopperRailBlock(WeatherState oxidationLevel, Properties setting
}

@Override
protected void randomTick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) {
this.changeOverTime(state, world, pos, random);
public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
this.onRandomTick(state, world, pos, random);
}

@Override
protected boolean isRandomlyTicking(BlockState state) {
public boolean isRandomlyTicking(BlockState state) {
return WeatheringCopper.getNext(state.getBlock()).isPresent();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ private double convergeAbs(double speed, double targetSpeed) {
target = "Lnet/minecraft/world/entity/vehicle/AbstractMinecart;setDeltaMovement(Lnet/minecraft/world/phys/Vec3;)V",
ordinal = 9))
public void setVelocityClamp(AbstractMinecart minecart, Vec3 velocity) {
double maxSpeed = getMaxRailSpeed(minecart.getInBlockState());
double maxSpeed = getMaxRailSpeed(minecart.getLevel().getBlockState(minecart.blockPosition()));
minecart.setDeltaMovement(convergeAbs(velocity.x, maxSpeed), velocity.y, convergeAbs(velocity.z, maxSpeed));
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/copperrails.mixins.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"required": true,
"package": "net.robofox.copperrails.mixin",
"compatibilityLevel": "JAVA_21",
"compatibilityLevel": "JAVA_17",
"mixins": [
"AbstractMinecartMixin",
"RailStateMixin"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,32 +1,34 @@
{
"parent": "minecraft:recipes/root",
"rewards": {
"recipes": [
"copperrails:copper_rail"
]
},
"criteria": {
"has_rail": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{
"items": "minecraft:rail"
"items": [
"minecraft:rail"
]
}
]
},
"trigger": "minecraft:inventory_changed"
}
},
"has_the_recipe": {
"trigger": "minecraft:recipe_unlocked",
"conditions": {
"recipe": "copperrails:copper_rail"
},
"trigger": "minecraft:recipe_unlocked"
}
}
},
"requirements": [
[
"has_the_recipe",
"has_rail"
]
],
"rewards": {
"recipes": [
"copperrails:copper_rail"
"has_rail",
"has_the_recipe"
]
}
]
}
Original file line number Diff line number Diff line change
@@ -1,32 +1,34 @@
{
"parent": "copperrails:recipes/transportation/copper_rail",
"rewards": {
"recipes": [
"copperrails:waxed_copper_rail"
]
},
"criteria": {
"has_rail": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{
"items": "copperrails:copper_rail"
"items": [
"copperrails:copper_rail"
]
}
]
},
"trigger": "minecraft:inventory_changed"
}
},
"has_the_recipe": {
"trigger": "minecraft:recipe_unlocked",
"conditions": {
"recipe": "copperrails:waxed_copper_rail"
},
"trigger": "minecraft:recipe_unlocked"
}
}
},
"requirements": [
[
"has_the_recipe",
"has_rail"
]
],
"rewards": {
"recipes": [
"copperrails:waxed_copper_rail"
"has_rail",
"has_the_recipe"
]
}
]
}
Original file line number Diff line number Diff line change
@@ -1,32 +1,34 @@
{
"parent": "copperrails:recipes/transportation/copper_rail",
"rewards": {
"recipes": [
"copperrails:waxed_exposed_copper_rail"
]
},
"criteria": {
"has_rail": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{
"items": "copperrails:exposed_copper_rail"
"items": [
"copperrails:copper_rail"
]
}
]
},
"trigger": "minecraft:inventory_changed"
}
},
"has_the_recipe": {
"trigger": "minecraft:recipe_unlocked",
"conditions": {
"recipe": "copperrails:waxed_exposed_copper_rail"
},
"trigger": "minecraft:recipe_unlocked"
}
}
},
"requirements": [
[
"has_the_recipe",
"has_rail"
]
],
"rewards": {
"recipes": [
"copperrails:waxed_exposed_copper_rail"
"has_rail",
"has_the_recipe"
]
}
]
}
Original file line number Diff line number Diff line change
@@ -1,32 +1,34 @@
{
"parent": "copperrails:recipes/transportation/copper_rail",
"rewards": {
"recipes": [
"copperrails:waxed_oxidized_copper_rail"
]
},
"criteria": {
"has_rail": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{
"items": "copperrails:oxidized_copper_rail"
"items": [
"copperrails:copper_rail"
]
}
]
},
"trigger": "minecraft:inventory_changed"
}
},
"has_the_recipe": {
"trigger": "minecraft:recipe_unlocked",
"conditions": {
"recipe": "copperrails:waxed_oxidized_copper_rail"
},
"trigger": "minecraft:recipe_unlocked"
}
}
},
"requirements": [
[
"has_the_recipe",
"has_rail"
]
],
"rewards": {
"recipes": [
"copperrails:waxed_oxidized_copper_rail"
"has_rail",
"has_the_recipe"
]
}
]
}
Loading

0 comments on commit f686737

Please sign in to comment.