Skip to content

Commit

Permalink
Port to SNAP
Browse files Browse the repository at this point in the history
  • Loading branch information
sakura-ryoko committed Jan 9, 2025
1 parent 828ac33 commit 9582eab
Show file tree
Hide file tree
Showing 16 changed files with 172 additions and 121 deletions.
32 changes: 10 additions & 22 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,25 +1,11 @@
import org.gradle.api.tasks.bundling.AbstractArchiveTask

plugins {
id 'fabric-loom' version '1.9-SNAPSHOT'
}

//sourceCompatibility = JavaVersion.VERSION_21
//targetCompatibility = JavaVersion.VERSION_21

repositories {
//maven { url 'https://masa.dy.fi/maven' }
maven {
url 'https://masa.dy.fi/maven'
mavenLocal()
}
//maven { url 'https://maven.terraformersmc.com/releases/' }
maven {
url 'https://maven.terraformersmc.com/releases/'
mavenLocal()
}
maven { url 'https://jitpack.io' }
flatDir { dirs 'libs' }
maven { url = 'https://masa.dy.fi/maven' }
maven { url = 'https://maven.terraformersmc.com/releases/' }
maven { url = 'https://jitpack.io' }
}

dependencies {
Expand All @@ -37,12 +23,14 @@ dependencies {
modCompileOnly "com.terraformersmc:modmenu:${project.mod_menu_version}"
}

group = project.group + "." + project.mod_id
base.archivesName = project.mod_file_name + '-' + project.minecraft_version_out
version = project.mod_version
base {
group = project.group + "." + project.mod_id
archivesName = project.mod_file_name + '-' + project.minecraft_version_out
version = project.mod_version

if (version.endsWith('-dev')) {
version += "." + new Date().format('yyyyMMdd.HHmmss')
if (version.endsWith('-dev')) {
version += "." + new Date().format('yyyyMMdd.HHmmss')
}
}

processResources {
Expand Down
14 changes: 7 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ author = masa
mod_file_name = tweakeroo-fabric

# Current mod version
mod_version = 0.23.1
mod_version = SNAP

# Required malilib version
malilib_version = 1.21.4-0.23.1
malilib_version = e6e1b721d6

# Minecraft, Fabric Loader and API and mappings versions
minecraft_version_out = 1.21.4
minecraft_version = 1.21.4
mappings_version = 1.21.4+build.1
minecraft_version_out = 25w02a
minecraft_version = 25w02a
mappings_version = 25w02a+build.5

fabric_loader_version = 0.16.9
fabric_loader_version = 0.16.10
mod_menu_version = 13.0.0-beta.1
# fabric_api_version = 0.110.5+1.21.4
# fabric_api_version = 0.114.1+1.21.4
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/fi/dy/masa/tweakeroo/data/DataManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class DataManager implements IServerListener
private boolean hasCarpetServer;
private boolean hasServuxServer;
public static final Identifier CARPET_HELLO = Identifier.of("carpet", "hello");
public static final Identifier SERVUX_ENTITY_DATA = Identifier.of("servux", "entity_data");
public static final Identifier SERVUX_LITEMATIC_DATA = Identifier.of("servux", "litematics");
//private IntegratedServer integratedServer;
//private DynamicRegistryManager.Immutable registryManager = DynamicRegistryManager.EMPTY;
private boolean hasIntegratedServer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@
import fi.dy.masa.malilib.interfaces.IDataSyncer;
import fi.dy.masa.malilib.network.ClientPlayHandler;
import fi.dy.masa.malilib.network.IPluginClientPlayHandler;
import fi.dy.masa.malilib.util.Constants;
import fi.dy.masa.malilib.util.InventoryUtils;
import fi.dy.masa.malilib.util.WorldUtils;
import fi.dy.masa.malilib.util.data.Constants;
import fi.dy.masa.malilib.util.nbt.NbtKeys;
import fi.dy.masa.tweakeroo.Reference;
import fi.dy.masa.tweakeroo.Tweakeroo;
Expand Down
19 changes: 10 additions & 9 deletions src/main/java/fi/dy/masa/tweakeroo/event/InputHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -334,35 +334,36 @@ else if (mc.options.rightKey.matchesKey(eventKey, scanCode))
}
}

public void handleMovementKeys(Input m)
public void handleMovementKeys(Input input)
{
GameOptions settings = MinecraftClient.getInstance().options;
PlayerInput m = input.playerInput;

if (settings.leftKey.isPressed() && settings.rightKey.isPressed())
{
if (this.lastSidewaysInput == LeftRight.LEFT)
{
m.movementSideways = 1;
m.playerInput = new PlayerInput(m.playerInput.forward(), m.playerInput.backward(), true, false, m.playerInput.jump(), m.playerInput.sneak(), m.playerInput.sprint());
//m.movementSideways = 1;
input.playerInput = new PlayerInput(m.forward(), m.backward(), true, false, m.jump(), m.sneak(), m.sprint());
}
else if (this.lastSidewaysInput == LeftRight.RIGHT)
{
m.movementSideways = -1;
m.playerInput = new PlayerInput(m.playerInput.forward(), m.playerInput.backward(), false, true, m.playerInput.jump(), m.playerInput.sneak(), m.playerInput.sprint());
//m.movementSideways = -1;
input.playerInput = new PlayerInput(m.forward(), m.backward(), false, true, m.jump(), m.sneak(), m.sprint());
}
}

if (settings.backKey.isPressed() && settings.forwardKey.isPressed())
{
if (this.lastForwardInput == ForwardBack.FORWARD)
{
m.movementForward = 1;
m.playerInput = new PlayerInput(true, false, m.playerInput.left(), m.playerInput.right(), m.playerInput.jump(), m.playerInput.sneak(), m.playerInput.sprint());
//m.movementForward = 1;
input.playerInput = new PlayerInput(true, false, m.left(), m.right(), m.jump(), m.sneak(), m.sprint());
}
else if (this.lastForwardInput == ForwardBack.BACK)
{
m.movementForward = -1;
m.playerInput = new PlayerInput(false, true, m.playerInput.left(), m.playerInput.right(), m.playerInput.jump(), m.playerInput.sneak(), m.playerInput.sprint());
//m.movementForward = -1;
input.playerInput = new PlayerInput(false, true, m.left(), m.right(), m.jump(), m.sneak(), m.sprint());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
import fi.dy.masa.malilib.gui.GuiBase;
import fi.dy.masa.malilib.interfaces.IRenderer;
import fi.dy.masa.malilib.util.ActiveMode;
import fi.dy.masa.malilib.util.Color4f;
import fi.dy.masa.malilib.util.InventoryUtils;
import fi.dy.masa.malilib.util.WorldUtils;
import fi.dy.masa.malilib.util.data.Color4f;
import fi.dy.masa.malilib.util.nbt.NbtKeys;
import fi.dy.masa.tweakeroo.config.Configs;
import fi.dy.masa.tweakeroo.config.FeatureToggle;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import net.minecraft.command.CommandSource;
import net.minecraft.util.hit.HitResult;
import net.minecraft.util.math.BlockPos;

import fi.dy.masa.malilib.util.position.PositionUtils;
import fi.dy.masa.tweakeroo.config.FeatureToggle;

@Mixin(ClientCommandSource.class)
Expand All @@ -26,7 +28,8 @@ private void onGetBlockPositionSuggestions(CallbackInfoReturnable<Collection<Com
if (FeatureToggle.TWEAK_TAB_COMPLETE_COORDINATE.getBooleanValue() &&
mc.player != null && (mc.crosshairTarget == null || mc.crosshairTarget.getType() == HitResult.Type.MISS))
{
BlockPos pos = fi.dy.masa.malilib.util.PositionUtils.getEntityBlockPos(mc.player);
BlockPos pos = PositionUtils.getEntityBlockPos(mc.player);
//System.out.printf("onGetBlockPositionSuggestions(): suggestedPos: [%s]\n", pos.toShortString());
cir.setReturnValue(Collections.singleton(new CommandSource.RelativePosition(formatInt(pos.getX()), formatInt(pos.getY()), formatInt(pos.getZ()))));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ private void tweakeroo_onCustomPayload(CustomPayloadS2CPacket packet, CallbackIn
{
DataManager.getInstance().setHasCarpetServer(true);
}
else if (packet.payload().getId().id().equals(DataManager.SERVUX_ENTITY_DATA))
else if (packet.payload().getId().id().equals(DataManager.SERVUX_LITEMATIC_DATA))
{
DataManager.getInstance().setHasServuxServer(true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ private void tweakeroo_onCustomPayload(CustomPayload payload, CallbackInfo ci)
{
DataManager.getInstance().setHasCarpetServer(true);
}
else if (payload.getId().id().equals(DataManager.SERVUX_ENTITY_DATA))
else if (payload.getId().id().equals(DataManager.SERVUX_LITEMATIC_DATA))
{
DataManager.getInstance().setHasServuxServer(true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ private void disableNauseaEffectPost(CallbackInfo ci)
private void overrideSprint(CallbackInfo ci)
{
if (FeatureToggle.TWEAK_PERMANENT_SPRINT.getBooleanValue() &&
! this.isSprinting() && ! this.isUsingItem() && this.input.movementForward >= 0.8F &&
//! this.isSprinting() && ! this.isUsingItem() && this.input.movementForward >= 0.8F &&
! this.isSprinting() && ! this.isUsingItem() && this.input.hasForwardMovement() &&
(this.getHungerManager().getFoodLevel() > 6.0F || this.getAbilities().allowFlying) &&
! this.hasStatusEffect(StatusEffects.BLINDNESS) && ! this.isTouchingWater())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@
import fi.dy.masa.malilib.interfaces.IDataSyncer;
import fi.dy.masa.malilib.interfaces.IInventoryOverlayHandler;
import fi.dy.masa.malilib.render.InventoryOverlay;
import fi.dy.masa.malilib.util.Constants;
import fi.dy.masa.malilib.util.EntityUtils;
import fi.dy.masa.malilib.util.InventoryUtils;
import fi.dy.masa.malilib.util.WorldUtils;
import fi.dy.masa.malilib.util.data.Constants;
import fi.dy.masa.malilib.util.nbt.NbtBlockUtils;
import fi.dy.masa.malilib.util.nbt.NbtKeys;
import fi.dy.masa.tweakeroo.Reference;
Expand Down
47 changes: 24 additions & 23 deletions src/main/java/fi/dy/masa/tweakeroo/tweaks/PlacementTweaks.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,7 @@
package fi.dy.masa.tweakeroo.tweaks;

import java.util.Optional;

import fi.dy.masa.malilib.gui.Message;
import fi.dy.masa.malilib.util.*;
import fi.dy.masa.malilib.util.PositionUtils.HitPart;
import fi.dy.masa.malilib.util.restrictions.BlockRestriction;
import fi.dy.masa.malilib.util.restrictions.ItemRestriction;
import fi.dy.masa.tweakeroo.config.Configs;
import fi.dy.masa.tweakeroo.config.FeatureToggle;
import fi.dy.masa.tweakeroo.config.Hotkeys;
import fi.dy.masa.tweakeroo.mixin.IMixinAbstractBlock;
import fi.dy.masa.tweakeroo.util.*;
import fi.dy.masa.tweakeroo.util.InventoryUtils;
import javax.annotation.Nullable;

import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
Expand All @@ -36,14 +25,26 @@
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;

import javax.annotation.Nullable;
import fi.dy.masa.malilib.gui.Message;
import fi.dy.masa.malilib.util.EquipmentUtils;
import fi.dy.masa.malilib.util.GuiUtils;
import fi.dy.masa.malilib.util.InfoUtils;
import fi.dy.masa.malilib.util.MessageOutputType;
import fi.dy.masa.malilib.util.position.PositionUtils;
import fi.dy.masa.malilib.util.restrictions.BlockRestriction;
import fi.dy.masa.malilib.util.restrictions.ItemRestriction;
import fi.dy.masa.tweakeroo.config.Configs;
import fi.dy.masa.tweakeroo.config.FeatureToggle;
import fi.dy.masa.tweakeroo.config.Hotkeys;
import fi.dy.masa.tweakeroo.mixin.IMixinAbstractBlock;
import fi.dy.masa.tweakeroo.util.*;

public class PlacementTweaks
{
private static BlockPos posFirst = null;
private static BlockPos posFirstBreaking = null;
private static BlockPos posLast = null;
private static HitPart hitPartFirst = null;
private static PositionUtils.HitPart hitPartFirst = null;
private static Hand handFirst = Hand.MAIN_HAND;
private static Vec3d hitVecFirst = null;
private static Direction sideFirst = null;
Expand Down Expand Up @@ -178,7 +179,7 @@ private static void onAttackTick(MinecraftClient mc)
if (FeatureToggle.TWEAK_FAST_LEFT_CLICK.getBooleanValue())
{
if (mc.player.getAbilities().creativeMode ||
(Configs.Generic.FAST_LEFT_CLICK_ALLOW_TOOLS.getBooleanValue() || (mc.player.getMainHandStack().getItem() instanceof MiningToolItem) == false))
(Configs.Generic.FAST_LEFT_CLICK_ALLOW_TOOLS.getBooleanValue() || (EquipmentUtils.isAnyTool(mc.player.getMainHandStack())) == false))
{
final int count = Configs.Generic.FAST_LEFT_CLICK_COUNT.getIntegerValue();

Expand Down Expand Up @@ -330,7 +331,7 @@ public static ActionResult onProcessRightClickBlock(
Direction sideIn = hitResult.getSide();
Vec3d hitVec = hitResult.getPos();
Direction playerFacingH = player.getHorizontalFacing();
HitPart hitPart = PositionUtils.getHitPart(sideIn, playerFacingH, posIn, hitVec);
PositionUtils.HitPart hitPart = PositionUtils.getHitPart(sideIn, playerFacingH, posIn, hitVec);
Direction sideRotated = getRotatedFacing(sideIn, playerFacingH, hitPart);
float yaw = player.getYaw();

Expand Down Expand Up @@ -390,7 +391,7 @@ private static ActionResult tryPlaceBlock(
float playerYaw,
Vec3d hitVec,
Hand hand,
HitPart hitPart,
PositionUtils.HitPart hitPart,
boolean isFirstClick)
{
Direction side = sideIn;
Expand All @@ -412,7 +413,7 @@ private static ActionResult tryPlaceBlock(
posNew = isFirstClick && (rotation || offset || adjacent) ? getPlacementPositionForTargetedPosition(world, posIn, sideIn, ctx) : posIn;

// Place the block into the adjacent position
if (adjacent && hitPart != null && hitPart != HitPart.CENTER)
if (adjacent && hitPart != null && hitPart != PositionUtils.HitPart.CENTER)
{
posNew = posNew.offset(sideRotatedIn.getOpposite()).offset(sideIn.getOpposite());
hitVec = hitVec.add(Vec3d.of(sideRotatedIn.getOpposite().getVector().add(sideIn.getOpposite().getVector())));
Expand Down Expand Up @@ -897,21 +898,21 @@ private static ActionResult handleFlexibleBlockPlacement(
float playerYaw,
Vec3d hitVec,
Hand hand,
@Nullable HitPart hitPart)
@Nullable PositionUtils.HitPart hitPart)
{
Direction facing = Direction.fromHorizontalQuarterTurns(MathHelper.floor((playerYaw * 4.0F / 360.0F) + 0.5D) & 3);
Direction facingOrig = facing;
float yawOrig = player.getYaw();

if (hitPart == HitPart.CENTER)
if (hitPart == PositionUtils.HitPart.CENTER)
{
facing = facing.getOpposite();
}
else if (hitPart == HitPart.LEFT)
else if (hitPart == PositionUtils.HitPart.LEFT)
{
facing = facing.rotateYCounterclockwise();
}
else if (hitPart == HitPart.RIGHT)
else if (hitPart == PositionUtils.HitPart.RIGHT)
{
facing = facing.rotateYClockwise();
}
Expand Down Expand Up @@ -951,7 +952,7 @@ private static void clearClickedBlockInfoAttack()
sideFirstBreaking = null;
}

private static Direction getRotatedFacing(Direction originalSide, Direction playerFacingH, HitPart hitPart)
private static Direction getRotatedFacing(Direction originalSide, Direction playerFacingH, PositionUtils.HitPart hitPart)
{
if (originalSide.getAxis().isVertical())
{
Expand Down
Loading

0 comments on commit 9582eab

Please sign in to comment.