Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Dream-Master committed Jul 16, 2024
2 parents 514b571 + fe9bcb6 commit 0ca5e5b
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 4 deletions.
21 changes: 20 additions & 1 deletion src/main/java/com/mitchej123/hodgepodge/Hodgepodge.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.mitchej123.hodgepodge;

import java.util.Map;

import com.mitchej123.hodgepodge.client.HodgepodgeClient;
import com.mitchej123.hodgepodge.commands.DebugCommand;
import com.mitchej123.hodgepodge.net.NetworkHandler;
Expand All @@ -13,13 +15,15 @@
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLServerStartingEvent;
import cpw.mods.fml.common.network.NetworkCheckHandler;
import cpw.mods.fml.common.versioning.ArtifactVersion;
import cpw.mods.fml.common.versioning.DefaultArtifactVersion;
import cpw.mods.fml.relauncher.Side;

@Mod(
modid = Hodgepodge.MODID,
version = Hodgepodge.VERSION,
name = Hodgepodge.NAME,
acceptableRemoteVersions = "*",
dependencies = "required-after:gtnhmixins@[2.0.1,);" + "required-after:unimixins@[0.0.14,);"
+ "required-after:gtnhlib@[0.2.2,);",
guiFactory = "com.mitchej123.hodgepodge.config.gui.HodgepodgeGuiConfigFactory")
Expand All @@ -33,6 +37,8 @@ public class Hodgepodge {

public static final boolean isGTNH;

private final ArtifactVersion minimumClientJoinVersion = new DefaultArtifactVersion("2.5.36");

static {
isGTNH = true;
}
Expand Down Expand Up @@ -83,4 +89,17 @@ public void onServerStarting(FMLServerStartingEvent aEvent) {
// the variable
EVENT_HANDLER.setAidTriggerDisabled(false);
}

/**
* Block any clients older than 2.5.36 from joining servers to ensure the fastBlockPlacingDisableServerSide setting
* is respected
*/
@SuppressWarnings("unused")
@NetworkCheckHandler
public boolean checkModList(Map<String, String> versions, Side side) {
if (side == Side.CLIENT && versions.containsKey(Hodgepodge.MODID)) {
return minimumClientJoinVersion.compareTo(new DefaultArtifactVersion(versions.get(Hodgepodge.MODID))) <= 0;
}
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
@SideOnly(Side.CLIENT)
public class ClientKeyListener {

private static String fastBlockPlacingEnabled = StatCollector.translateToLocal("key.fastBlockPlacing.enabled");
private static String fastBlockPlacingDisabled = StatCollector.translateToLocal("key.fastBlockPlacing.disabled");
private static final String fastBlockPlacingEnabled = StatCollector
.translateToLocal("key.fastBlockPlacing.enabled");
private static final String fastBlockPlacingDisabled = StatCollector
.translateToLocal("key.fastBlockPlacing.disabled");

public static KeyBinding FastBlockPlacingKey = new KeyBinding(
"key.fastBlockPlacing.desc",
Expand All @@ -42,7 +44,7 @@ public void keyPressed(InputEvent.KeyInputEvent event) {
}
}
} else {
if (FastBlockPlacingKey.isPressed()) {
if (TweaksConfig.fastBlockPlacingServerSide && FastBlockPlacingKey.isPressed()) {
TweaksConfig.fastBlockPlacing = !TweaksConfig.fastBlockPlacing;
AboveHotbarHUD.renderTextAboveHotbar(
(TweaksConfig.fastBlockPlacing ? fastBlockPlacingEnabled : fastBlockPlacingDisabled),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ public class TweaksConfig {
@Config.RequiresMcRestart
public static boolean fastBlockPlacing;

@Config.Comment("Allow players on your server to use fast block placement")
@Config.DefaultBoolean(true)
public static boolean fastBlockPlacingServerSide;

@Config.Comment("Prevents the inventory from shifting when the player has active potion effects")
@Config.DefaultBoolean(true)
@Config.RequiresMcRestart
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public class MixinMinecraft_FastBlockPlacing {
remap = false,
shift = At.Shift.AFTER))
private void hodgepodge$func_147121_ag(CallbackInfo ci) {
if (!TweaksConfig.fastBlockPlacingServerSide) return;
if (!TweaksConfig.fastBlockPlacing) return;
if (thePlayer == null || thePlayer.isUsingItem()) return;
if (objectMouseOver == null) return;
Expand Down
19 changes: 19 additions & 0 deletions src/main/java/com/mitchej123/hodgepodge/net/MessageConfigSync.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,33 @@
public class MessageConfigSync implements IMessage, IMessageHandler<MessageConfigSync, IMessage> {

private boolean longerSentMessages;
private boolean fastBlockPlacingServerSide;

public MessageConfigSync() {
longerSentMessages = TweaksConfig.longerSentMessages;
fastBlockPlacingServerSide = TweaksConfig.fastBlockPlacingServerSide;
}

@Override
public void fromBytes(ByteBuf buf) {
longerSentMessages = buf.readBoolean();
// Ensures clients with the setting can still join servers without the setting (servers running older versions
// of the mod)
if (buf.readableBytes() < 1) {
fastBlockPlacingServerSide = true;
} else {
fastBlockPlacingServerSide = buf.readBoolean();
}
}

@Override
public void toBytes(ByteBuf buf) {
buf.writeBoolean(longerSentMessages);
buf.writeBoolean(fastBlockPlacingServerSide);
}

public boolean isFastBlockPlacingServerSide() {
return fastBlockPlacingServerSide;
}

public boolean isLongerSentMessages() {
Expand All @@ -33,6 +47,11 @@ public boolean isLongerSentMessages() {
public IMessage onMessage(MessageConfigSync message, MessageContext ctx) {
TweaksConfig.longerSentMessages = message.isLongerSentMessages();

if (!message.isFastBlockPlacingServerSide()) {
TweaksConfig.fastBlockPlacing = false;
TweaksConfig.fastBlockPlacingServerSide = false;
}

return null;
}
}

0 comments on commit 0ca5e5b

Please sign in to comment.