Skip to content

Commit

Permalink
Merge branch '1.19.3' into 1.19.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Siphalor committed Aug 5, 2023
2 parents 018544f + 6818320 commit 6553e3b
Show file tree
Hide file tree
Showing 33 changed files with 983 additions and 413 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
on:
push:
pull_request:

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 17
- name: Set Gradle execution rights
run: chmod +x ./gradlew
- name: Build
uses: gradle/gradle-build-action@v2
with:
arguments: assemble
- name: Check
uses: gradle/gradle-build-action@v2
with:
arguments: check
27 changes: 27 additions & 0 deletions .github/workflows/push-main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
on:
push:
branches:
- "1.16"


jobs:
auto-fix:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Fix language file names
run: |
for lang in src/main/resources/assets/*/lang/*.json
do
rename=$(echo "$lang" | sed -e 's/\b\w\+\.json$/\L\0/' -e 's/\b\([a-z]\+\)\.json$/\/\1_\1.json/')
mv "$lang" "$rename" || true
done
- name: Commit
uses: EndBug/add-and-commit@v9
with:
add: 'src/main/resources/assets'
default_author: github_actions
message: Fix language file names
2 changes: 1 addition & 1 deletion .giup
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"merge-paths": [
"1.16",
"1.16->1.15->1.14",
"1.16->1.17->1.18.2->1.19->1.19.3->unstable"
"1.16->1.17->1.18.2->1.19->1.19.3->1.19.4->unstable"
],
"commands": [
{
Expand Down
3 changes: 3 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ dependencies {
mappings "net.fabricmc:yarn:${project.minecraft_version}+build.${project.yarn_build}"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"

compileOnly(annotationProcessor("org.projectlombok:lombok:$lombok_version"))
testCompileOnly(testAnnotationProcessor("org.projectlombok:lombok:$lombok_version"))

def fabric_deps = [
'fabric-api-base',
'fabric-events-interaction-v0',
Expand Down
6 changes: 4 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@ yarn_build=2:v2
loader_version=0.14.19
# Mod Properties
mod_id=mousewheelie
mod_version=1.11.1
mod_version=1.12.1
mod_release=release
mod_mc_version_specifier=1.19.4
mod_mc_versions=1.19.4
maven_group=de.siphalor
archives_base_name=mousewheelie
# Dependencies
amecs_version=1.4.0+mc1.19.4
lombok_version=1.18.28
# Mod Dependencies
amecs_version=1.5.1+mc1.19.4
coat_version=1.0.0-beta.20+mc1.19.4
fabric_api_version=0.80.0+1.19.4
tweed_version=1.3.0+mc1.19.4
1 change: 1 addition & 0 deletions src/lombok.config
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lombok.log.custom.declaration = org.apache.logging.log4j.Logger org.apache.logging.log4j.LogManager.getLogger(TYPE)
3 changes: 3 additions & 0 deletions src/main/java/de/siphalor/mousewheelie/MWConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ public static class Sort {
public SortMode primarySort = SortMode.CREATIVE;
public SortMode shiftSort = SortMode.QUANTITY;
public SortMode controlSort = SortMode.ALPHABET;
public boolean serverAcceleratedSorting = true;

@AConfigEntry(scope = ConfigScope.SMALLEST)
public boolean optimizeCreativeSearchSort = true;
Expand All @@ -120,6 +121,8 @@ public static class Refill {
public boolean offHand = true;
public boolean restoreSelectedSlot = false;

public boolean itemChanges = true;

public boolean eat = true;
public boolean drop = true;
public boolean use = true;
Expand Down
37 changes: 23 additions & 14 deletions src/main/java/de/siphalor/mousewheelie/MouseWheelie.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,33 +17,42 @@

package de.siphalor.mousewheelie;

import de.siphalor.mousewheelie.common.network.MWLogicalServerNetworking;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.event.player.UseItemCallback;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.entity.mob.MobEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Hand;
import net.minecraft.util.TypedActionResult;
import net.minecraft.world.World;

public class MouseWheelie implements ModInitializer {
public static final String MOD_ID = "mousewheelie";
public static final String MOD_NAME = "Mouse Wheelie";

@Override
public void onInitialize() {
UseItemCallback.EVENT.register((player, world, hand) -> {
ItemStack stack = player.getStackInHand(hand);
if (MWConfig.general.enableQuickArmorSwapping && !world.isClient()) {
EquipmentSlot equipmentSlot = MobEntity.getPreferredEquipmentSlot(stack);
if (equipmentSlot.getType() == EquipmentSlot.Type.ARMOR) {
ItemStack equipmentStack = player.getEquippedStack(equipmentSlot);
int index = 5 + (3 - equipmentSlot.getEntitySlotId());
if (!equipmentStack.isEmpty() && player.playerScreenHandler.getSlot(index).canTakeItems(player)) {
player.setStackInHand(hand, equipmentStack);
player.equipStack(equipmentSlot, stack);
return TypedActionResult.consume(equipmentStack);
}
UseItemCallback.EVENT.register(this::onPlayerUseItem);

MWLogicalServerNetworking.setup();
}

private TypedActionResult<ItemStack> onPlayerUseItem(PlayerEntity player, World world, Hand hand) {
ItemStack stack = player.getStackInHand(hand);
if (MWConfig.general.enableQuickArmorSwapping && !world.isClient()) {
EquipmentSlot equipmentSlot = MobEntity.getPreferredEquipmentSlot(stack);
if (equipmentSlot.getType() == EquipmentSlot.Type.ARMOR) {
ItemStack equipmentStack = player.getEquippedStack(equipmentSlot);
int index = 5 + (3 - equipmentSlot.getEntitySlotId());
if (!equipmentStack.isEmpty() && player.playerScreenHandler.getSlot(index).canTakeItems(player)) {
player.setStackInHand(hand, equipmentStack);
player.equipStack(equipmentSlot, stack);
return TypedActionResult.consume(equipmentStack);
}
}
return TypedActionResult.pass(stack);
});
}
return TypedActionResult.pass(stack);
}
}
30 changes: 28 additions & 2 deletions src/main/java/de/siphalor/mousewheelie/client/MWClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,35 @@ public void onInitializeClient() {
});
}

public static void scheduleRefill(Hand hand, PlayerInventory inventory, ItemStack stack) {
/**
* Schedules a refill if a refill scenario is encountered.
* @param hand the hand to potentially refill
* @param inventory the player inventory
* @param oldStack the old stack in the hand
* @param newStack the new stack in the hand
* @return whether a refill has been scheduled
*/
public static boolean scheduleRefillChecked(Hand hand, PlayerInventory inventory, ItemStack oldStack, ItemStack newStack) {
if (MinecraftClient.getInstance().currentScreen != null) {
return false;
}

if (!oldStack.isEmpty() && (newStack.isEmpty() || (MWConfig.refill.itemChanges && oldStack.getItem() != newStack.getItem()))) {
scheduleRefillUnchecked(hand, inventory, oldStack.copy());
return true;
}
return false;
}

/**
* Unconditionally schedules a refill.
* @param hand the hand to refill
* @param inventory the player inventory
* @param referenceStack the stack to decide the refilling by
*/
public static void scheduleRefillUnchecked(Hand hand, PlayerInventory inventory, ItemStack referenceStack) {
refillHand = hand;
SlotRefiller.set(inventory, stack);
SlotRefiller.set(inventory, referenceStack);
}

public static boolean performRefill() {
Expand Down
Loading

0 comments on commit 6553e3b

Please sign in to comment.