Skip to content

Commit

Permalink
Merge branch '1.19' into 1.19.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Siphalor committed Jul 30, 2023
2 parents 735c266 + 6f3020f commit bb4abdc
Show file tree
Hide file tree
Showing 31 changed files with 822 additions and 325 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.11
# Mod Properties
mod_id=mousewheelie
mod_version=1.11.1
mod_version=1.12.0
mod_release=release
mod_mc_version_specifier=1.19.3+
mod_mc_versions=1.19.3
maven_group=de.siphalor
archives_base_name=mousewheelie
# Dependencies
amecs_version=1.4.0+mc1.19.3
lombok_version=1.18.28
# Mod Dependencies
amecs_version=1.5.0+mc1.19.3
coat_version=1.0.0-beta.20+mc1.19.3
fabric_api_version=0.68.1+1.19.3
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
Original file line number Diff line number Diff line change
Expand Up @@ -233,12 +233,9 @@ public int getScope(Slot slot, boolean preferSmallerScopes) {
} else {
if (slot.inventory instanceof PlayerInventory) {
if (isHotbarSlot(slot)) {
if (MWConfig.general.hotbarScoping == MWConfig.General.HotbarScoping.HARD) {
if (MWConfig.general.hotbarScoping == MWConfig.General.HotbarScoping.HARD
|| MWConfig.general.hotbarScoping == MWConfig.General.HotbarScoping.SOFT && preferSmallerScopes) {
return -1;
} else if (MWConfig.general.hotbarScoping == MWConfig.General.HotbarScoping.SOFT) {
if (preferSmallerScopes) {
return -1;
}
}
}
return 0;
Expand Down Expand Up @@ -338,10 +335,9 @@ public void depositAllFrom(int scope) {
});

runInScope(scope, slot -> {
if (slot.hasStack()) {
if (itemKinds.contains(ItemKind.of(slot.getStack()))) {
sendStackLocked(slot);
}
if (slot.hasStack() && itemKinds.contains(ItemKind.of(slot.getStack()))) {
sendStackLocked(slot);

}
});
}
Expand Down Expand Up @@ -424,7 +420,7 @@ public void restockAll(int scope) {
int complementaryScope = getComplementaryScope(scope);

slotsByItemKind.asMap().forEach((itemKind, slots) ->
restockAllOfAKind(slots.iterator(), complementaryScope)
restockAllOfAKind(slots.iterator(), complementaryScope)
);
}

Expand Down
Loading

0 comments on commit bb4abdc

Please sign in to comment.