Skip to content

Commit

Permalink
Merge pull request #4 from MisterJulsen/dev-1.18.2
Browse files Browse the repository at this point in the history
Dev 1.18.2
  • Loading branch information
MisterJulsen authored Dec 28, 2023
2 parents 5bb3902 + 5d41678 commit f2ffaa5
Show file tree
Hide file tree
Showing 348 changed files with 6,787 additions and 9,163 deletions.
53 changes: 35 additions & 18 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ buildscript {
maven { url = 'https://maven.minecraftforge.net' }
maven { url = 'https://maven.parchmentmc.org' }
mavenCentral()

}
dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true
Expand All @@ -18,10 +19,11 @@ plugins {
apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'org.parchmentmc.librarian.forgegradle'

jarJar.enable()

version = '0.5.0-beta-1.18.2'
group = 'de.mrjulsen.trafficcraft' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = 'trafficcraft'
version = "${mod_version}-${mod_minecraft_version}"
group = "${mod_root_path}" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "${mod_filename}"

// Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17.
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
Expand All @@ -41,9 +43,9 @@ minecraft {
//
// Use non-default mappings at your own risk. They may not always work.
// Simply re-run your setup task after changing the mappings to update your workspace.
mappings channel: 'parchment', version: '1.18.1-2022.02.13-1.18.2'
mappings channel: 'parchment', version: "${parchment_version}"

// accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') // Currently, this location cannot be changed from the default.
accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') // Currently, this location cannot be changed from the default.

// Default run configurations.
// These can be tweaked, removed, or duplicated as needed.
Expand All @@ -64,13 +66,17 @@ minecraft {
property 'forge.logging.console.level', 'debug'

// Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
property 'forge.enabledGameTestNamespaces', 'trafficcraft'
property 'forge.enabledGameTestNamespaces', 'trafficcraft'

property 'mixin.env.remapRefMap', 'true'
property 'mixin.env.refMapRemappingFile', "${buildDir}/createSrgToMcp/output.srg"

mods {
trafficcraft {
source sourceSets.main
}
}

}

server {
Expand Down Expand Up @@ -144,25 +150,25 @@ repositories {
// Put repositories for dependencies here
// ForgeGradle automatically adds the Forge maven and Maven Central for you

// If you have mod jar dependencies in ./libs, you can declare them as a repository like so:
// flatDir {
// dir 'libs'
// }
maven {
url "https://cursemaven.com"
}
}

dependencies {
// Specify the version of Minecraft to use. If this is any group other than 'net.minecraft', it is assumed
// that the dep is a ForgeGradle 'patcher' dependency, and its patches will be applied.
// The userdev artifact is a special name and will get all sorts of transformations applied to it.
minecraft 'net.minecraftforge:forge:1.18.2-40.2.1'

minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
jarJar("curse.maven:dragonlib-${dragonlib_curseforge_projectid}:${dragonlib_curseforge_fileid}") {
jarJar.ranged(it, "[${dragonlib_version}-${minecraft_version},)")
}
implementation fg.deobf("curse.maven:dragonlib-${dragonlib_curseforge_projectid}:${dragonlib_curseforge_fileid}")
// Real mod deobf dependency examples - these get remapped to your current mappings
// compileOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}:api") // Adds JEI API as a compile dependency
// runtimeOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}") // Adds the full JEI mod as a runtime dependency
// implementation fg.deobf("com.tterrag.registrate:Registrate:MC${mc_version}-${registrate_version}") // Adds registrate as a dependency

// Examples using mod jars from ./libs
// implementation fg.deobf("blank:coolmod-${mc_version}:${coolmod_version}")

// For more info...
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
Expand All @@ -173,20 +179,31 @@ dependencies {
jar {
manifest {
attributes([
"Specification-Title" : "trafficcraft",
"Specification-Vendor" : "trafficcraftsareus",
"Specification-Version" : "1", // We are version 1 of ourselves
"Specification-Title" : "TrafficCraft",
"Specification-Vendor" : "MrJulsen",
"Specification-Version" : "${mod_version}-${mod_minecraft_version}", // We are version 1 of ourselves
"Implementation-Title" : project.name,
"Implementation-Version" : project.jar.archiveVersion,
"Implementation-Vendor" : "trafficcraftsareus",
"Implementation-Vendor" : "MrJulsen",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
])
}
}

task jarJarRelease {
group = 'jarjar'
doLast {
tasks.jarJar {
classifier = ''
}
}
finalizedBy tasks.jarJar
}

// Example configuration to allow publishing using the maven-publish plugin
// This is the preferred method to reobfuscate your jar file
jar.finalizedBy('reobfJar')
tasks.jarJar.finalizedBy('reobfJarJar')
// However if you are in a multi-project build, dev time needs unobfed jar files, so you can delay the obfuscation until publishing by doing
// publish.dependsOn('reobfJar')

Expand Down
18 changes: 17 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
# Sets default memory used for gradle commands. Can be overridden by user or command line properties.
# This is required to provide enough memory for the Minecraft decompilation process.
org.gradle.jvmargs=-Xmx6G
org.gradle.daemon=false
org.gradle.daemon=false

mod_version = 0.6.0-beta
mod_minecraft_version = 1.18.2
mod_filename = trafficcraft
mod_root_path = de.mrjulsen.trafficcraft

minecraft_version = 1.18.2
forge_version = 40.2.1

parchment_version = 1.18.1-2022.02.13-1.18.2


# dependency versions
dragonlib_curseforge_projectid = 946163
dragonlib_curseforge_fileid = 4990073
dragonlib_version = 0.1.12
18 changes: 13 additions & 5 deletions src/main/java/de/mrjulsen/trafficcraft/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,29 @@

import java.util.Random;

import de.mrjulsen.mcdragonlib.utils.Utils;
import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.server.MinecraftServer;

public class Constants {
public static final byte TPS = 1000 / MinecraftServer.MS_PER_TICK;
public static final int MAX_ASPHALT_PATTERNS = 323;
public static final int MAX_PAINT = 128;
public static final int TICKS_PER_DAY = 24000;

public static final int METAL_COLOR = 0xFF828282;
public static final int TRAFFIC_CONE_BASE_COLOR = 0xFFD12725;

public static final MutableComponent CREATIVE_MODE_ONLY_TOOLTIP = new TranslatableComponent("core.trafficcraft.creative_only.tooltip").withStyle(ChatFormatting.GOLD);
public static final MutableComponent CREATIVE_MODE_ONLY_TOOLTIP = Utils.translate("core.trafficcraft.creative_only.tooltip").withStyle(ChatFormatting.GOLD);

public static final Component textCopy = Utils.translate("core.trafficcraft.common.copy");
public static final Component textPaste = Utils.translate("core.trafficcraft.common.paste");

public static final String GERMAN_LOCAL_CODE = "de";

public static final String WIKIPEDIA_TRAFFIC_LIGHT_ID = "Q8004";
public static final String WIKIPEDIA_GERMAN_TRAM_SIGNAL_ID = "Q2354774";

public static final Random RANDOM = new Random();
}


21 changes: 5 additions & 16 deletions src/main/java/de/mrjulsen/trafficcraft/ModMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,17 @@

import de.mrjulsen.trafficcraft.client.screen.menu.ModMenuTypes;
import de.mrjulsen.trafficcraft.config.ModCommonConfig;
import de.mrjulsen.trafficcraft.init.ClientInitWrapper;
import de.mrjulsen.trafficcraft.init.ServerInit;
import de.mrjulsen.trafficcraft.network.NetworkManager;
import de.mrjulsen.trafficcraft.proxy.ClientProxy;
import de.mrjulsen.trafficcraft.proxy.IProxy;
import de.mrjulsen.trafficcraft.proxy.ServerProxy;
import de.mrjulsen.trafficcraft.registry.ModBlockEntities;
import de.mrjulsen.trafficcraft.registry.ModBlocks;
import de.mrjulsen.trafficcraft.registry.ModItems;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.DistExecutor;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.config.ModConfig;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;

import org.slf4j.Logger;
Expand All @@ -26,30 +23,22 @@
@Mod(ModMain.MOD_ID)
public class ModMain {
public static final String MOD_ID = "trafficcraft";
public final IProxy PROXY = DistExecutor.safeRunForDist(() -> ClientProxy::new, () -> ServerProxy::new);

// Directly reference a slf4j logger
public static final Logger LOGGER = LogUtils.getLogger();

public ModMain() {

IEventBus eventBus = FMLJavaModLoadingContext.get().getModEventBus();
eventBus.addListener(this::setup);
eventBus.addListener(ServerInit::setup);
eventBus.addListener(ClientInitWrapper::setup);

ModBlocks.register(eventBus);
ModItems.register(eventBus);
ModBlockEntities.register(eventBus);
ModMenuTypes.register(eventBus);
//ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, ModClientConfig.SPEC, MOD_ID + "-client.toml");
ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, ModCommonConfig.SPEC, MOD_ID + "-common.toml");
NetworkManager.registerNetworkPackets();
NetworkManager.create();
MinecraftForge.EVENT_BUS.register(this);
}

private void setup(final FMLCommonSetupEvent event) {
// some preinit code
LOGGER.info("Welcome to the TrafficCraft mod.");

PROXY.setup(event);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ public ConcreteBarrierBlock() {

@Override
public VoxelShape getShape(BlockState pState, BlockGetter pLevel, BlockPos pPos, CollisionContext pContext) {
//return pState.getValue(FACING) == Direction.NORTH || pState.getValue(FACING) == Direction.SOUTH ? SHAPE_SN : SHAPE_EW;
if ((pState.getValue(FACING) == Direction.NORTH || pState.getValue(FACING) == Direction.SOUTH) && !pState.getValue(NORTH) && !pState.getValue(SOUTH)) {
return Shapes.or(SHAPE_SIDE_EAST, SHAPE_SIDE_WEST);
} else if ((pState.getValue(FACING) == Direction.EAST || pState.getValue(FACING) == Direction.WEST) && !pState.getValue(EAST) && !pState.getValue(WEST)) {
Expand Down
19 changes: 15 additions & 4 deletions src/main/java/de/mrjulsen/trafficcraft/block/DelineatorBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,19 @@ public class DelineatorBlock extends WaterloggableBlock {
public static final DirectionProperty FACING = HorizontalDirectionalBlock.FACING;

public static final VoxelShape SHAPE_COMMON = Block.box(6, 0, 6, 10, 16, 10);
public static final VoxelShape SHAPE_SMALL = Block.box(6, 0, 6, 10, 11, 10);

public DelineatorBlock() {
public static final VoxelShape OCCLUSION_COMMON = Block.box(5, 0, 5, 9, 16, 9);
public static final VoxelShape OCCLUSION_SMALL = Block.box(5, 0, 5, 9, 11, 9);

private final boolean small;

public DelineatorBlock(boolean small) {
super(BlockBehaviour.Properties.of(Material.BAMBOO)
.sound(SoundType.BAMBOO)
.instabreak()
);
this.small = small;
this.registerDefaultState(this.stateDefinition.any()
.setValue(FACING, Direction.NORTH)
);
Expand All @@ -42,12 +49,12 @@ public DelineatorBlock() {

@Override
public VoxelShape getOcclusionShape(BlockState pState, BlockGetter pLevel, BlockPos pPos) {
return SHAPE_COMMON;
return isSmall() ? OCCLUSION_SMALL : OCCLUSION_COMMON;
}

@Override
public VoxelShape getShape(BlockState pState, BlockGetter pLevel, BlockPos pPos, CollisionContext pContext) {
return SHAPE_COMMON;
public VoxelShape getShape(BlockState pState, BlockGetter pLevel, BlockPos pPos, CollisionContext pContext) {
return isSmall() ? SHAPE_SMALL : SHAPE_COMMON;
}

@Override
Expand Down Expand Up @@ -86,5 +93,9 @@ public BlockState updateShape(BlockState pState, Direction pFacing, BlockState p
public boolean canSurvive(BlockState pState, LevelReader pLevel, BlockPos pPos) {
return canSupportCenter(pLevel, pPos.below(), Direction.UP);
}

public boolean isSmall() {
return small;
}

}
38 changes: 0 additions & 38 deletions src/main/java/de/mrjulsen/trafficcraft/block/DragonBlock.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package de.mrjulsen.trafficcraft.block;

import de.mrjulsen.mcdragonlib.utils.Utils;
import de.mrjulsen.trafficcraft.block.data.ColorableBlock;
import de.mrjulsen.trafficcraft.block.data.IColorBlockEntity;
import de.mrjulsen.trafficcraft.block.entity.ColoredBlockEntity;
import de.mrjulsen.trafficcraft.data.PaintColor;
import de.mrjulsen.trafficcraft.item.BrushItem;
import net.minecraft.ChatFormatting;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.InteractionHand;
Expand Down Expand Up @@ -108,7 +109,7 @@ public BlockState getStateForPlacement(BlockPlaceContext pContext) {
public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult result)
{
if (state.getValue(WATERLOGGED)) {
player.displayClientMessage(new TranslatableComponent("block.trafficcraft.paint_bucket.message.underwater"), true);
player.displayClientMessage(Utils.translate("block.trafficcraft.paint_bucket.message.underwater").withStyle(ChatFormatting.RED), true);
return InteractionResult.FAIL;
}

Expand All @@ -126,7 +127,7 @@ public InteractionResult use(BlockState state, Level level, BlockPos pos, Player
// Check if bucket is empty
if (paint <= 0) {
if(!level.isClientSide)
player.displayClientMessage(new TranslatableComponent("block.trafficcraft.paint_bucket.message.empty"), true);
player.displayClientMessage(Utils.translate("block.trafficcraft.paint_bucket.message.empty").withStyle(ChatFormatting.RED), true);
return InteractionResult.FAIL;
}

Expand All @@ -152,13 +153,13 @@ public InteractionResult use(BlockState state, Level level, BlockPos pos, Player

if (state.getValue(PAINT) > 0) {
if (!blockEntity.getColor().equals(dye.getDyeColor())) {
player.displayClientMessage(new TranslatableComponent("block.trafficcraft.paint_bucket.message.wrong_color"), true);
player.displayClientMessage(Utils.translate("block.trafficcraft.paint_bucket.message.wrong_color").withStyle(ChatFormatting.RED), true);
return InteractionResult.FAIL;
}
}

if (state.getValue(PAINT) >= MAX_PAINT) {
player.displayClientMessage(new TranslatableComponent("block.trafficcraft.paint_bucket.message.full"), true);
player.displayClientMessage(Utils.translate("block.trafficcraft.paint_bucket.message.full").withStyle(ChatFormatting.YELLOW), true);
return InteractionResult.FAIL;
}

Expand Down
Loading

0 comments on commit f2ffaa5

Please sign in to comment.