Skip to content

Commit

Permalink
Merge pull request #26 from telvarost/mp-support-with-gcapi
Browse files Browse the repository at this point in the history
Add multiplayer support with gcapi 2.0+
  • Loading branch information
telvarost authored Mar 18, 2024
2 parents 5adaff6 + bb07db0 commit e001ba7
Show file tree
Hide file tree
Showing 18 changed files with 154 additions and 131 deletions.
12 changes: 4 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
## Mod Info:

All fixes are disabled by default. You will need ModMenu and GlassConfigAPI to enable them. See installation instructions below.
* Mod now works on Multiplayer with GlassConfigAPI version 2.0+ used to sync configs!

### Implemented
* Allow player crafting grid (2x2 grid) to be used as inventory slots.
Expand All @@ -22,13 +23,8 @@ All fixes are disabled by default. You will need ModMenu and GlassConfigAPI to e
* Punch Sheep For Wool
* Punch TNT To Ignite
* [Water ladders](https://minecraft.fandom.com/wiki/Tutorials/Water_ladder): entities can get into fluids through the south-east corner or into some sides via signs/ladders

### Optional
Use version 1.3.0 to EXCLUDE this tweak.
Use version 1.2.0-fire to INCLUDE this tweak.
* Infinite Fire Spread And Selectable Tick Rate
* WARNING: Please be careful with this setting, always make sure it is false when editing configs unless if you really want it true
* Note: There currently seems to be a bug with GlassConfigAPI where Integer configs need to be saved twice to take effect

### Not Implemented
* Inventory Dragging Shortcuts (implemented in [InventoryTweaks](https://modrinth.com/mod/inventorytweaks) instead)
Expand All @@ -38,9 +34,9 @@ Use version 1.2.0-fire to INCLUDE this tweak.

1. Download an instance of Babric for Prism Launcher: https://github.com/babric/prism-instance
2. Install Java 17, set the instance to use it, and disable compatibility checks on the instance: https://adoptium.net/temurin/releases/
3. Add StationAPI to the mod folder for the instance: https://jenkins.glass-launcher.net/job/StationAPI/lastSuccessfulBuild/
4. (Required) Add Mod Menu to the mod folder for the instance: https://github.com/calmilamsy/ModMenu/releases
5. (Required) Add GlassConfigAPI 1.1.6+ to the mod folder for the instance: https://maven.glass-launcher.net/#/releases/net/glasslauncher/mods/GlassConfigAPI
3. Add StationAPI to the mod folder for the instance: https://modrinth.com/mod/stationapi
4. (Required) Add Mod Menu to the mod folder for the instance: https://modrinth.com/mod/modmenu-beta
5. (Required) Add GlassConfigAPI 2.0+ to the mod folder for the instance: https://modrinth.com/mod/glass-config-api
6. Add this mod to the mod folder for the instance: https://github.com/telvarost/BetaTweaks-StationAPI/releases
7. Run and enjoy! 👍

Expand Down
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ dependencies {
modImplementation("net.glasslauncher:HowManyItems-Fabric-Unofficial:${project.howmanyitems_version}") {
transitive false
}
modImplementation("com.github.paulevsGitch:BHCreative:0.4.2") {
transitive false
}
// modImplementation("com.github.paulevsGitch:BHCreative:0.4.2") {
// transitive false
// }
}

processResources {
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ yarn_mappings=b1.7.3-build.2
loader_version=0.14.24-babric.1

# Mod Properties
mod_version=1.3.0
mod_version=2.0.0
maven_group=com.github.telvarost
archives_base_name=BetaTweaks

# Dependencies
stapi_version=2.0-alpha.1.1

# Extra Dependencies
gcapi_version=1.2.0
gcapi_version=2.0.1
howmanyitems_version=5.1.1
modmenu_version=dcef643
70 changes: 47 additions & 23 deletions src/main/java/com/github/telvarost/betatweaks/Config.java
Original file line number Diff line number Diff line change
@@ -1,67 +1,91 @@
package com.github.telvarost.betatweaks;

import blue.endless.jankson.Comment;
import net.glasslauncher.mods.api.gcapi.api.ConfigName;
import net.glasslauncher.mods.api.gcapi.api.GConfig;
import net.glasslauncher.mods.api.gcapi.api.*;

public class Config {

@GConfig(value = "config", visibleName = "BetaTweaks Config")
@GConfig(value = "config", visibleName = "BetaTweaks")
public static ConfigFields config = new ConfigFields();

public static class ConfigFields {

/** - These are a part of the InventoryTweaks mod. See: https://github.com/telvarost/InventoryTweaks-StationAPI */
// @ConfigName("Inventory Dragging Shortcuts")
// public static Boolean inventoryDraggingShortcuts = true;
// public Boolean inventoryDraggingShortcuts = true;

/** - FOV added to the StationAPI version of FinalBeta instead */
// @ConfigName("FOV Slider")
// public static Boolean fovSlider = true;
// public Boolean fovSlider = true;

/** - There are also title screen settings that are missing that the original BetaTweaks had */
// Dany added some of these to UniTweaks

@ConfigName("Allow Gaps In Ladders")
public static Boolean allowGapsInLadders = false;
@MultiplayerSynced
@ValueOnVanillaServer(booleanValue = TriBoolean.FALSE)
public Boolean allowGapsInLadders = false;

@ConfigName("Enter Fluids By South-East Corner")
public static Boolean allowSouthEastRule = false;
@MultiplayerSynced
@ValueOnVanillaServer(booleanValue = TriBoolean.FALSE)
public Boolean allowSouthEastRule = false;

@ConfigName("Elevator Boats")
public static Boolean elevatorBoats = false;
@MultiplayerSynced
@ValueOnVanillaServer(booleanValue = TriBoolean.FALSE)
public Boolean elevatorBoats = false;

@ConfigName("Hide Achievement Notifications")
public static Boolean hideAchievementNotifications = false;
public Boolean hideAchievementNotifications = false;

@ConfigName("Hide Dead Shrubs")
@Comment("Reload world for changes to take effect")
public static Boolean hideDeadShrubs = false;
@MultiplayerSynced
@ValueOnVanillaServer(booleanValue = TriBoolean.FALSE)
public Boolean hideDeadShrubs = false;

@ConfigName("Hide Long Grass")
@Comment("Reload world for changes to take effect")
public static Boolean hideLongGrass = false;
@MultiplayerSynced
@ValueOnVanillaServer(booleanValue = TriBoolean.FALSE)
public Boolean hideLongGrass = false;

@ConfigName("Hoe Grass For Seeds")
public static Boolean hoeGrassForSeeds = false;
@MultiplayerSynced
@ValueOnVanillaServer(booleanValue = TriBoolean.FALSE)
public Boolean hoeGrassForSeeds = false;

@ConfigName("Minecart Boosters")
public static Boolean minecartBoosters = false;
@MultiplayerSynced
@ValueOnVanillaServer(booleanValue = TriBoolean.FALSE)
public Boolean minecartBoosters = false;

@ConfigName("Punch Sheep For Wool")
public static Boolean punchSheepForWool = false;
@MultiplayerSynced
@ValueOnVanillaServer(booleanValue = TriBoolean.FALSE)
public Boolean punchSheepForWool = false;

@ConfigName("Punch TNT To Ignite")
public static Boolean punchTntToIgnite = false;

// @ConfigName("Spread Fire Infinitely")
// public static Boolean infiniteFireSpread = false;
//
// /** - There is a bug that won't let the config go above 32, also Integer configs don't seem to save unless saved twice */
// @ConfigName("Spread Fire Tick Rate * 10 (Def: 4, Alpha: 1)")
// public static Integer fireTickRate = 4;
@MultiplayerSynced
@ValueOnVanillaServer(booleanValue = TriBoolean.FALSE)
public Boolean punchTntToIgnite = false;

@ConfigName("Spread Fire Infinitely")
@MultiplayerSynced
@ValueOnVanillaServer(booleanValue = TriBoolean.FALSE)
public Boolean infiniteFireSpread = false;

@ConfigName("Spread Fire Tick Rate")
@Comment("Default: 40, Alpha: 10")
@MaxLength(36863)
@MultiplayerSynced
@ValueOnVanillaServer(booleanValue = TriBoolean.FALSE)
public Integer fireSpreadTickRate = 40;

@ConfigName("Use Player 2x2 Crafting Grid As Inventory")
public static Boolean allowCraftingInventorySlots = false;
@MultiplayerSynced
@ValueOnVanillaServer(booleanValue = TriBoolean.FALSE)
public Boolean allowCraftingInventorySlots = false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public AchievementMixin(Minecraft minecraft) {
cancellable = true
)
public void setAchievementGet(net.minecraft.achievement.Achievement arg, CallbackInfo ci) {
if (Config.ConfigFields.hideAchievementNotifications)
if (Config.config.hideAchievementNotifications)
{
ci.cancel();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public BoatMixin(Level level) {
@ModifyConstant(method = "tick", constant = @Constant(doubleValue = 1.0, ordinal = 1))
private double betaTweaks_elevatorBoatCondition(double d)
{
if (Config.ConfigFields.elevatorBoats)
if (Config.config.elevatorBoats)
{
return Double.MAX_VALUE;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public DeadBushMixin(int i, int j) {
cancellable = true
)
public void getDropId(int i, Random random, CallbackInfoReturnable<Integer> cir) {
if (Config.ConfigFields.hideDeadShrubs) {
if (Config.config.hideDeadShrubs) {
cir.setReturnValue(-1);
}
}
Expand All @@ -39,7 +39,7 @@ public boolean isSideRendered(BlockView arg, int i, int j, int k, int l) {
@Override
@Environment(EnvType.CLIENT)
public int getRenderType() {
if (Config.ConfigFields.hideLongGrass) {
if (Config.config.hideLongGrass) {
return 0;
}
else
Expand All @@ -50,7 +50,7 @@ public int getRenderType() {

@Override
public void updateBoundingBox(BlockView blockView, int x, int y, int z) {
if (Config.ConfigFields.hideDeadShrubs) {
if (Config.config.hideDeadShrubs) {
this.setBoundingBox(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F);
}
else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class EntityMixin
@Inject(method = "method_1393", at = @At("HEAD"), cancellable = true)
private void betaTweaks_handleWaterMovement(@NotNull CallbackInfoReturnable<Boolean> cir)
{
if (!Config.ConfigFields.allowSouthEastRule)
if (!Config.config.allowSouthEastRule)
{
return;
}
Expand All @@ -35,7 +35,7 @@ private void betaTweaks_handleWaterMovement(@NotNull CallbackInfoReturnable<Bool
@Inject(method = "method_1335", at = @At("HEAD"), cancellable = true)
private void betaTweaks_handleLavaMovement(@NotNull CallbackInfoReturnable<Boolean> cir)
{
if (!Config.ConfigFields.allowSouthEastRule)
if (!Config.config.allowSouthEastRule)
{
return;
}
Expand Down
104 changes: 52 additions & 52 deletions src/main/java/com/github/telvarost/betatweaks/mixin/FireMixin.java
Original file line number Diff line number Diff line change
@@ -1,58 +1,58 @@
//package com.github.telvarost.betatweaks.mixin;
//
//import com.github.telvarost.betatweaks.Config;
//import net.minecraft.block.BlockBase;
//import net.minecraft.block.Fire;
//import net.minecraft.block.material.Material;
//import net.minecraft.level.Level;
//import org.jetbrains.annotations.NotNull;
//import org.spongepowered.asm.mixin.Mixin;
//import org.spongepowered.asm.mixin.injection.*;
//
//
///*
// * Thanks to Amb0s for the original solution: https://github.com/Amb0s
// */
//@Mixin(Fire.class)
//public class FireMixin extends BlockBase
//{
// public FireMixin(int i, int j) {
// super(i, j, Material.FIRE);
// this.setTicksRandomly(true);
// }
//
// @ModifyConstant(method = "getTickrate", constant = @Constant(intValue = 40))
// private int betaTweaks_getTickrate(int a)
// {
// // It is 10 in beta before 1.6:
// return (Config.ConfigFields.fireTickRate * 10);
// }
//
//
package com.github.telvarost.betatweaks.mixin;

import com.github.telvarost.betatweaks.Config;
import net.minecraft.block.BlockBase;
import net.minecraft.block.Fire;
import net.minecraft.block.material.Material;
import net.minecraft.level.Level;
import org.jetbrains.annotations.NotNull;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.*;


/*
* Thanks to Amb0s for the original solution: https://github.com/Amb0s
*/
@Mixin(Fire.class)
public class FireMixin extends BlockBase
{
public FireMixin(int i, int j) {
super(i, j, Material.FIRE);
this.setTicksRandomly(true);
}

@ModifyConstant(method = "getTickrate", constant = @Constant(intValue = 40))
private int betaTweaks_getTickrate(int a)
{
/** - Tick rate is 10 before beta 1.6 */
return (Config.config.fireSpreadTickRate);
}


@Redirect(
method = "fireTick",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/level/Level;placeBlockWithMetaData(IIIII)Z")
)
private boolean betaTweaks_fireTick(@NotNull Level level, int x, int y, int z, int id, int meta)
{
// Make new fire blocks spawn with zero old:
if (Config.config.infiniteFireSpread)
{
level.placeBlockWithMetaData(x, y, z, BlockBase.FIRE.id, 0);
}

return false;
}

/** - I couldn't figure out what this was supposed to be targeting */
// @Redirect(
// method = "fireTick",
// at = @At(value = "INVOKE",
// target = "Lnet/minecraft/level/Level;placeBlockWithMetaData(IIIII)Z")
// target = "Lnet/minecraft/src/BlockFire;setBurnResult(Lnet/minecraft/src/World;III)V")
// )
// private boolean betaTweaks_fireTick(@NotNull Level level, int x, int y, int z, int id, int meta)
// private void cancelSetBurnResult(BlockFire instance, World world, int x, int y, int z)
// {
// // Make new fire blocks spawn with zero old:
// if (Config.ConfigFields.infiniteFireSpread)
// {
// level.placeBlockWithMetaData(x, y, z, BlockBase.FIRE.id, 0);
// }
//
// return false;
// // Remove a chance to burn a block before the fire block old will reach 15.
// }
//
// /** - I couldn't figure out what this was supposed to be targeting */
//// @Redirect(
//// method = "fireTick",
//// at = @At(value = "INVOKE",
//// target = "Lnet/minecraft/src/BlockFire;setBurnResult(Lnet/minecraft/src/World;III)V")
//// )
//// private void cancelSetBurnResult(BlockFire instance, World world, int x, int y, int z)
//// {
//// // Remove a chance to burn a block before the fire block old will reach 15.
//// }
//}
}
Loading

0 comments on commit e001ba7

Please sign in to comment.