Skip to content

Commit

Permalink
Port to 25w06a
Browse files Browse the repository at this point in the history
  • Loading branch information
sakura-ryoko committed Feb 6, 2025
1 parent 1d4afea commit 3062d4e
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 34 deletions.
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ mod_file_name = tweakeroo-fabric
mod_version = 0.23.999-dev

# Required malilib version
malilib_version = d9dceacbfb
malilib_version = eef4b1b932

# Minecraft, Fabric Loader and API and mappings versions
minecraft_version_out = 25w05a
minecraft_version = 25w05a
mappings_version = 25w05a+build.4
minecraft_version_out = 25w06a
minecraft_version = 25w06a
mappings_version = 25w06a+build.2

fabric_loader_version = 0.16.10
mod_menu_version = 13.0.1
# fabric_api_version = 0.115.2+1.21.5
# fabric_api_version = 0.115.3+1.21.5
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ public Inventory getEntityInventory(World world, int entityId, boolean useNbt)
}
else if (entity instanceof PlayerEntity player)
{
inv = new SimpleInventory(player.getInventory().main.toArray(new ItemStack[36]));
inv = new SimpleInventory(player.getInventory().getMainStacks().toArray(new ItemStack[36]));
}
else if (entity instanceof VillagerEntity)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ else if (this.lastEntityContext != null && this.lastEntityContext.getLeft() == e
}
else if (entity instanceof PlayerEntity player)
{
inv = new SimpleInventory(player.getInventory().main.toArray(new ItemStack[36]));
inv = new SimpleInventory(player.getInventory().getMainStacks().toArray(new ItemStack[36]));
}
else if (entity instanceof VillagerEntity)
{
Expand Down
26 changes: 25 additions & 1 deletion src/main/java/fi/dy/masa/tweakeroo/renderer/RenderUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import net.minecraft.block.entity.CrafterBlockEntity;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gl.GlUsage;
import net.minecraft.client.gl.VertexBuffer;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.ingame.HandledScreen;
import net.minecraft.client.render.Camera;
Expand Down Expand Up @@ -376,12 +378,34 @@ public static void renderDirectionsCursor(DrawContext drawContext)
matrix4fStack.rotateX(fi.dy.masa.malilib.render.RenderUtils.matrix4fRotateFix(-pitch));
matrix4fStack.rotateY(fi.dy.masa.malilib.render.RenderUtils.matrix4fRotateFix(yaw));
matrix4fStack.scale(-1.0F, -1.0F, -1.0F);
RenderSystem.renderCrosshair(10);
//RenderSystem.renderCrosshair(10);
mc.getDebugHud().method_67545();

matrix4fStack.popMatrix();
//RenderSystem.applyModelViewMatrix();
RenderSystem.disableBlend();
}

/*
public void method_67545()
{
GlStateManager._depthMask(false);
GlStateManager._disableCull();
RenderSystem.setShader(ShaderProgramKeys.RENDERTYPE_LINES);
this.field_56578.bind();
RenderSystem.lineWidth(4.0F);
RenderSystem.setShaderColor(0.0F, 0.0F, 0.0F, 1.0F);
this.field_56578.draw(RenderSystem.getModelViewMatrix(), RenderSystem.getProjectionMatrix(), RenderSystem.getShader());
RenderSystem.lineWidth(2.0F);
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
this.field_56578.draw(RenderSystem.getModelViewMatrix(), RenderSystem.getProjectionMatrix(), RenderSystem.getShader());
VertexBuffer.unbind();
RenderSystem.lineWidth(1.0F);
GlStateManager._enableCull();
GlStateManager._depthMask(true);
}
*/

public static void notifyRotationChanged()
{
lastRotationChangeTime = System.currentTimeMillis();
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/fi/dy/masa/tweakeroo/tweaks/PlacementTweaks.java
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public static void cacheStackInHand(Hand hand)
canUseItemWithRestriction(HAND_RESTOCK_RESTRICTION, stackOriginal))
{
stackBeforeUse[hand.ordinal()] = stackOriginal.copy();
hotbarSlot = player.getInventory().selectedSlot;
hotbarSlot = player.getInventory().getSelectedSlot();
}
}

Expand Down Expand Up @@ -682,7 +682,7 @@ public static void tryRestockHand(PlayerEntity player, Hand hand, ItemStack stac
{
ItemStack stackCurrent = player.getStackInHand(hand);

if (stackOriginal.isEmpty() == false && player.getInventory().selectedSlot == hotbarSlot &&
if (stackOriginal.isEmpty() == false && player.getInventory().getSelectedSlot() == hotbarSlot &&
(stackCurrent.isEmpty() || ItemStack.areItemsEqual(stackCurrent, stackOriginal) == false))
{
// Don't allow taking stacks from elsewhere in the hotbar, if the cycle tweak is on
Expand Down Expand Up @@ -871,18 +871,18 @@ else if (flexible && rotation && accurate == false &&

if (FeatureToggle.TWEAK_HOTBAR_SLOT_CYCLE.getBooleanValue())
{
int newSlot = inv.selectedSlot + 1;
int newSlot = inv.getSelectedSlot() + 1;

if (newSlot >= 9 || newSlot >= Configs.Generic.HOTBAR_SLOT_CYCLE_MAX.getIntegerValue())
{
newSlot = 0;
}

inv.selectedSlot = newSlot;
inv.setSelectedSlot(newSlot);
}
else if (FeatureToggle.TWEAK_HOTBAR_SLOT_RANDOMIZER.getBooleanValue())
{
inv.selectedSlot = player.getRandom().nextInt(Configs.Generic.HOTBAR_SLOT_RANDOMIZER_MAX.getIntegerValue());
inv.setSelectedSlot(player.getRandom().nextInt(Configs.Generic.HOTBAR_SLOT_RANDOMIZER_MAX.getIntegerValue()));
}
}

Expand Down Expand Up @@ -1208,7 +1208,7 @@ public static boolean shouldSkipSlotSync(int slotNumber, ItemStack newStack)
if (Configs.Generic.SLOT_SYNC_WORKAROUND.getBooleanValue() &&
FeatureToggle.TWEAK_PICK_BEFORE_PLACE.getBooleanValue() == false &&
container != null && container == player.playerScreenHandler &&
(slotNumber == 45 || (slotNumber - 36) == player.getInventory().selectedSlot))
(slotNumber == 45 || (slotNumber - 36) == player.getInventory().getSelectedSlot()))
{
if (mc.options.useKey.isPressed() &&
(Configs.Generic.SLOT_SYNC_WORKAROUND_ALWAYS.getBooleanValue() ||
Expand Down
40 changes: 20 additions & 20 deletions src/main/java/fi/dy/masa/tweakeroo/util/InventoryUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ public static void setWeaponMapping(List<String> mappings)
}
catch (Exception ignore) {}

Tweakeroo.logger.warn("Unable to find entity: '{}'", entity_id);
Tweakeroo.LOGGER.warn("Unable to find entity: '{}'", entity_id);
}
}
}
Expand All @@ -249,7 +249,7 @@ public static void setWeaponMapping(List<String> mappings)
private static boolean isConfiguredRepairSlot(int slotNum, PlayerEntity player)
{
if (REPAIR_MODE_SLOTS.contains(EquipmentSlot.MAINHAND) &&
(slotNum - 36) == player.getInventory().selectedSlot)
(slotNum - 36) == player.getInventory().getSelectedSlot())
{
return true;
}
Expand All @@ -265,7 +265,7 @@ private static boolean isConfiguredRepairSlot(int slotNum, PlayerEntity player)
private static EquipmentSlot getEquipmentTypeForSlot(int slotNum, PlayerEntity player)
{
if (REPAIR_MODE_SLOTS.contains(EquipmentSlot.MAINHAND) &&
(slotNum - 36) == player.getInventory().selectedSlot)
(slotNum - 36) == player.getInventory().getSelectedSlot())
{
return EquipmentSlot.MAINHAND;
}
Expand All @@ -290,7 +290,7 @@ private static int getSlotNumberForEquipmentType(EquipmentSlot type, @Nullable P
{
switch (type)
{
case MAINHAND: return player != null ? player.getInventory().selectedSlot + 36 : -1;
case MAINHAND: return player != null ? player.getInventory().getSelectedSlot() + 36 : -1;
case OFFHAND: return 45;
case HEAD: return 5;
case CHEST: return 6;
Expand Down Expand Up @@ -350,7 +350,7 @@ public static void preRestockHand(PlayerEntity player, Hand hand, boolean allowH
MinecraftClient mc = MinecraftClient.getInstance();
ScreenHandler container = player.playerScreenHandler;
int endSlot = allowHotbar ? 44 : 35;
int currentMainHandSlot = player.getInventory().selectedSlot + 36;
int currentMainHandSlot = player.getInventory().getSelectedSlot() + 36;
int currentSlot = hand == Hand.MAIN_HAND ? currentMainHandSlot : 45;

for (int slotNum = 9; slotNum <= endSlot; ++slotNum)
Expand Down Expand Up @@ -410,7 +410,7 @@ public static void trySwitchToWeapon(Entity entity)
PlayerEntity player = mc.player;

if (player != null && mc.world != null &&
TOOL_SWITCH_IGNORED_SLOTS.contains(player.getInventory().selectedSlot) == false)
TOOL_SWITCH_IGNORED_SLOTS.contains(player.getInventory().getSelectedSlot()) == false)
{
ScreenHandler container = player.playerScreenHandler;
ItemPickerTest test;
Expand All @@ -426,7 +426,7 @@ public static void trySwitchToWeapon(Entity entity)

int slotNumber = findSlotWithBestItemMatch(container, test, UniformIntProvider.create(36, 44), UniformIntProvider.create(9, 35));

if (slotNumber != -1 && (slotNumber - 36) != player.getInventory().selectedSlot)
if (slotNumber != -1 && (slotNumber - 36) != player.getInventory().getSelectedSlot())
{
swapToolToHand(slotNumber, mc);
PlacementTweaks.cacheStackInHand(Hand.MAIN_HAND);
Expand Down Expand Up @@ -522,7 +522,7 @@ public static void trySwitchToEffectiveTool(BlockPos pos)
PlayerEntity player = mc.player;

if (player != null && mc.world != null &&
TOOL_SWITCH_IGNORED_SLOTS.contains(player.getInventory().selectedSlot) == false)
TOOL_SWITCH_IGNORED_SLOTS.contains(player.getInventory().getSelectedSlot()) == false)
{
BlockState state = mc.world.getBlockState(pos);
ScreenHandler container = player.playerScreenHandler;
Expand All @@ -539,7 +539,7 @@ public static void trySwitchToEffectiveTool(BlockPos pos)

int slotNumber = findSlotWithBestItemMatch(container, test, UniformIntProvider.create(36, 44), UniformIntProvider.create(9, 35));

if (slotNumber != -1 && (slotNumber - 36) != player.getInventory().selectedSlot)
if (slotNumber != -1 && (slotNumber - 36) != player.getInventory().getSelectedSlot())
{
swapToolToHand(slotNumber, mc);
}
Expand Down Expand Up @@ -906,7 +906,7 @@ private static int findRepairableItemNotInRepairableSlot(Slot targetSlot, Player
ItemStack stack = slot.getStack();

// Don't take items from the current hotbar slot
if ((slot.id - 36) != player.getInventory().selectedSlot &&
if ((slot.id - 36) != player.getInventory().getSelectedSlot() &&
stack.isDamageable() && stack.isDamaged() && targetSlot.canInsert(stack) &&
EquipmentUtils.getEnchantmentLevel(stack, Enchantments.MENDING) > 0)
{
Expand Down Expand Up @@ -1078,12 +1078,12 @@ private static void swapItemToHand(PlayerEntity player, Hand hand, int slotNumbe

if (hand == Hand.MAIN_HAND)
{
int currentHotbarSlot = inventory.selectedSlot;
int currentHotbarSlot = inventory.getSelectedSlot();

if (isHotbarSlot(slotNumber))
{
inventory.selectedSlot = slotNumber - 36;
mc.getNetworkHandler().sendPacket(new UpdateSelectedSlotC2SPacket(inventory.selectedSlot));
inventory.setSelectedSlot(slotNumber - 36);
mc.getNetworkHandler().sendPacket(new UpdateSelectedSlotC2SPacket(inventory.getSelectedSlot()));
}
else
{
Expand Down Expand Up @@ -1126,20 +1126,20 @@ private static void swapToolToHand(int slotNumber, MinecraftClient mc)

if (isHotbarSlot(slotNumber))
{
inventory.selectedSlot = slotNumber - 36;
mc.getNetworkHandler().sendPacket(new UpdateSelectedSlotC2SPacket(inventory.selectedSlot));
inventory.setSelectedSlot(slotNumber - 36);
mc.getNetworkHandler().sendPacket(new UpdateSelectedSlotC2SPacket(inventory.getSelectedSlot()));
}
else
{
int selectedSlot = inventory.selectedSlot;
int selectedSlot = inventory.getSelectedSlot();
int hotbarSlot = getUsableHotbarSlotForTool(selectedSlot, TOOL_SWITCHABLE_SLOTS, container);

if (PlayerInventory.isValidHotbarIndex(hotbarSlot))
{
if (hotbarSlot != selectedSlot)
{
inventory.selectedSlot = hotbarSlot;
mc.getNetworkHandler().sendPacket(new UpdateSelectedSlotC2SPacket(inventory.selectedSlot));
inventory.setSelectedSlot(hotbarSlot);
mc.getNetworkHandler().sendPacket(new UpdateSelectedSlotC2SPacket(inventory.getSelectedSlot()));
}

mc.interactionManager.clickSlot(container.syncId, slotNumber, hotbarSlot, SlotActionType.SWAP, mc.player);
Expand Down Expand Up @@ -1315,7 +1315,7 @@ private static void tryCombineStacksInInventory(PlayerEntity player, ItemStack s
mc.interactionManager.clickSlot(container.syncId, slot2.id, 0, SlotActionType.PICKUP, player);

// If the items didn't all fit, return the rest
if (player.getInventory().getMainHandStack().isEmpty() == false)
if (player.getInventory().getSelectedStack().isEmpty() == false)
{
mc.interactionManager.clickSlot(container.syncId, slot1.id, 0, SlotActionType.PICKUP, player);
}
Expand Down Expand Up @@ -1393,7 +1393,7 @@ public static void switchToPickedBlock()
if (isCreative)
{
inventory.swapStackWithHotbar(stack);
mc.interactionManager.clickCreativeStack(player.getStackInHand(Hand.MAIN_HAND), 36 + inventory.selectedSlot);
mc.interactionManager.clickCreativeStack(player.getStackInHand(Hand.MAIN_HAND), 36 + inventory.getSelectedSlot());
}
else
{
Expand Down

0 comments on commit 3062d4e

Please sign in to comment.