Skip to content

Commit

Permalink
Fixed mods not working on servers
Browse files Browse the repository at this point in the history
  • Loading branch information
MisterJulsen committed Dec 28, 2023
1 parent 4adb401 commit 5d41678
Show file tree
Hide file tree
Showing 43 changed files with 252 additions and 631 deletions.
27 changes: 4 additions & 23 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@ buildscript {
repositories {
// These repositories are only for Gradle plugins, put any other repositories in the repository block further below
maven { url = 'https://maven.minecraftforge.net' }
maven { url = 'https://repo.spongepowered.org/maven' }
maven { url = 'https://maven.parchmentmc.org' }
mavenCentral()

}
dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true
classpath group: 'org.spongepowered', name: 'mixingradle', version: '0.7-SNAPSHOT'
classpath 'org.parchmentmc:librarian:1.+'
}
}
Expand All @@ -20,7 +18,6 @@ plugins {
}
apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'org.parchmentmc.librarian.forgegradle'
apply plugin: 'org.spongepowered.mixin'

jarJar.enable()

Expand Down Expand Up @@ -69,18 +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"

arg "-mixin.config=trafficcraft.mixin.json"

mods {
trafficcraft {
source sourceSets.main
}
}

}

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

maven { url 'https://jitpack.io' }
// 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"
}
Expand All @@ -171,12 +161,9 @@ dependencies {
// The userdev artifact is a special name and will get all sorts of transformations applied to it.
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
jarJar("curse.maven:dragonlib-${dragonlib_curseforge_projectid}:${dragonlib_curseforge_fileid}") {
jarJar.ranged(it, '[0.1.11-1.18.2,)')
jarJar.ranged(it, "[${dragonlib_version}-${minecraft_version},)")
}
implementation fg.deobf("curse.maven:dragonlib-${dragonlib_curseforge_projectid}:${dragonlib_curseforge_fileid}")
//implementation fg.deobf("com.github.MisterJulsen:MC-DragonLib:1.18.2-SNAPSHOT")

annotationProcessor 'org.spongepowered:mixin:0.8.5:processor'
// 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
Expand All @@ -188,11 +175,6 @@ dependencies {
// http://www.gradle.org/docs/current/userguide/dependency_management.html
}


mixin {
add sourceSets.main, "trafficcraft.refmap.json"
}

// Example for how to get properties into the manifest for reading at runtime.
jar {
manifest {
Expand All @@ -203,8 +185,7 @@ jar {
"Implementation-Title" : project.name,
"Implementation-Version" : project.jar.archiveVersion,
"Implementation-Vendor" : "MrJulsen",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
"MixinConfigs": "trafficcraft.mixin.json"
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
])
}
}
Expand Down
5 changes: 3 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
org.gradle.jvmargs=-Xmx6G
org.gradle.daemon=false

mod_version = 0.5.0-beta
mod_version = 0.6.0-beta
mod_minecraft_version = 1.18.2
mod_filename = trafficcraft
mod_root_path = de.mrjulsen.trafficcraft
Expand All @@ -16,4 +16,5 @@ parchment_version = 1.18.1-2022.02.13-1.18.2

# dependency versions
dragonlib_curseforge_projectid = 946163
dragonlib_curseforge_fileid = 4989867
dragonlib_curseforge_fileid = 4990073
dragonlib_version = 0.1.12
Empty file.
8 changes: 4 additions & 4 deletions src/main/java/de/mrjulsen/trafficcraft/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import java.util.Random;

import de.mrjulsen.mcdragonlib.client.gui.GuiUtils;
import de.mrjulsen.mcdragonlib.utils.Utils;
import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
Expand All @@ -14,10 +14,10 @@ public class Constants {
public static final int METAL_COLOR = 0xFF828282;
public static final int TRAFFIC_CONE_BASE_COLOR = 0xFFD12725;

public static final MutableComponent CREATIVE_MODE_ONLY_TOOLTIP = GuiUtils.translate("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 = GuiUtils.translate("core.trafficcraft.common.copy");
public static final Component textPaste = GuiUtils.translate("core.trafficcraft.common.paste");
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";

Expand Down
6 changes: 2 additions & 4 deletions src/main/java/de/mrjulsen/trafficcraft/ModMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
import com.mojang.logging.LogUtils;

import de.mrjulsen.trafficcraft.client.screen.menu.ModMenuTypes;
import de.mrjulsen.trafficcraft.config.ModClientConfig;
import de.mrjulsen.trafficcraft.config.ModCommonConfig;
import de.mrjulsen.trafficcraft.init.ClientInit;
import de.mrjulsen.trafficcraft.init.ClientInitWrapper;
import de.mrjulsen.trafficcraft.init.ServerInit;
import de.mrjulsen.trafficcraft.network.NetworkManager;
import de.mrjulsen.trafficcraft.registry.ModBlockEntities;
Expand All @@ -32,13 +31,12 @@ public ModMain() {

IEventBus eventBus = FMLJavaModLoadingContext.get().getModEventBus();
eventBus.addListener(ServerInit::setup);
eventBus.addListener(ClientInit::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.create();
MinecraftForge.EVENT_BUS.register(this);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package de.mrjulsen.trafficcraft.block;

import de.mrjulsen.mcdragonlib.client.gui.GuiUtils;
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;
Expand Down Expand Up @@ -109,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(GuiUtils.translate("block.trafficcraft.paint_bucket.message.underwater").withStyle(ChatFormatting.RED), true);
player.displayClientMessage(Utils.translate("block.trafficcraft.paint_bucket.message.underwater").withStyle(ChatFormatting.RED), true);
return InteractionResult.FAIL;
}

Expand All @@ -127,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(GuiUtils.translate("block.trafficcraft.paint_bucket.message.empty").withStyle(ChatFormatting.RED), true);
player.displayClientMessage(Utils.translate("block.trafficcraft.paint_bucket.message.empty").withStyle(ChatFormatting.RED), true);
return InteractionResult.FAIL;
}

Expand All @@ -153,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(GuiUtils.translate("block.trafficcraft.paint_bucket.message.wrong_color").withStyle(ChatFormatting.RED), 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(GuiUtils.translate("block.trafficcraft.paint_bucket.message.full").withStyle(ChatFormatting.YELLOW), true);
player.displayClientMessage(Utils.translate("block.trafficcraft.paint_bucket.message.full").withStyle(ChatFormatting.YELLOW), true);
return InteractionResult.FAIL;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import javax.annotation.Nullable;

import de.mrjulsen.mcdragonlib.client.gui.GuiUtils;
import de.mrjulsen.mcdragonlib.utils.Utils;
import de.mrjulsen.trafficcraft.block.data.ITrafficPostLike;
import de.mrjulsen.trafficcraft.block.entity.StreetLampBlockEntity;
import de.mrjulsen.trafficcraft.item.WrenchItem;
Expand Down Expand Up @@ -136,7 +136,7 @@ public InteractionResult use(BlockState pState, Level pLevel, BlockPos pPos, Pla
if (!pLevel.isClientSide) {
if (pLevel.getBlockEntity(pPos) instanceof StreetLampBlockEntity blockEntity && blockEntity.getOnTime() != blockEntity.getOffTime()) {
if (!pLevel.isClientSide) {
pPlayer.displayClientMessage(GuiUtils.translate("block.trafficcraft.street_lamp.use.error_scheduled"), true);
pPlayer.displayClientMessage(Utils.translate("block.trafficcraft.street_lamp.use.error_scheduled"), true);
return InteractionResult.FAIL;
}
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package de.mrjulsen.trafficcraft.block;

import de.mrjulsen.mcdragonlib.client.gui.GuiUtils;
import de.mrjulsen.mcdragonlib.utils.Utils;
import de.mrjulsen.trafficcraft.client.screen.menu.TrafficSignWorkbenchMenu;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
Expand Down Expand Up @@ -90,6 +90,6 @@ public InteractionResult use(BlockState pState, Level pLevel, BlockPos pPos, Pla
public MenuProvider getMenuProvider(BlockState pState, Level pLevel, BlockPos pPos) {
return new SimpleMenuProvider((containerId, inv, player) -> {
return new TrafficSignWorkbenchMenu(containerId, inv, ContainerLevelAccess.create(pLevel, pPos));
}, GuiUtils.text(""));
}, Utils.text(""));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public void setAndResetTexture(String base64) {
setBase64Texture(base64);
if (!this.level.isClientSide) {
for (ServerPlayer player : level.players().stream().filter(p -> p instanceof ServerPlayer).toArray(ServerPlayer[]::new)) {
NetworkManager.getInstance().send(new TrafficSignTextureResetPacket(ID), player);
NetworkManager.getInstance().sendToClient(new TrafficSignTextureResetPacket(ID), player);
}
}
}
Expand All @@ -103,7 +103,7 @@ public void onChunkUnloaded() {
private void clear() {
if (!this.level.isClientSide) {
for (ServerPlayer player : level.players().stream().filter(p -> p instanceof ServerPlayer).toArray(ServerPlayer[]::new)) {
NetworkManager.getInstance().send(new TrafficSignTextureResetPacket(ID), player);
NetworkManager.getInstance().sendToClient(new TrafficSignTextureResetPacket(ID), player);
}
}
}
Expand Down
Loading

0 comments on commit 5d41678

Please sign in to comment.