Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert reload changes from #460 #462

Merged
merged 2 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -240,27 +240,22 @@ public boolean startReloadWithoutTrigger(EntityWrapper entityWrapper, String wea
// This is necessary for events to be used correctly
handData.setReloadData(weaponTitle, weaponStack);

ItemStack oldWeaponStack = weaponStack.clone();
ChainTask reloadTask = new ChainTask(reloadDuration) {

private int unloadedAmount;

@Override
public void task() {
// Check if the slot is still the same
ItemStack currentItem = mainhand ? entityWrapper.getEntity().getEquipment().getItemInMainHand() : entityWrapper.getEntity().getEquipment().getItemInOffHand();
if (!currentItem.isSimilar(weaponStack)) {
ItemStack taskReference = mainhand ? entityWrapper.getEntity().getEquipment().getItemInMainHand() : entityWrapper.getEntity().getEquipment().getItemInOffHand();
String newWeaponTitle = taskReference.hasItemMeta() ? CustomTag.WEAPON_TITLE.getString(taskReference) : null;
if (!taskReference.hasItemMeta() || !weaponTitle.equals(newWeaponTitle)) {
// if weapon changes, it stops the task
handData.stopReloadingTasks();
return;
}

ItemStack taskReference = mainhand ? entityWrapper.getEntity().getEquipment().getItemInMainHand() : entityWrapper.getEntity().getEquipment().getItemInOffHand();
if (!taskReference.hasItemMeta()) {
handData.stopReloadingTasks();
return;
}
handData.setReloadData(weaponTitle, taskReference);

int ammoLeft = getAmmoLeft(taskReference, weaponTitle);

// Here creating this again since this may change if there isn't enough ammo...
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Versions of the 2 plugins stored in this repo.
mechanicsCoreVersion=3.4.11
weaponMechanicsVersion=3.4.12
mechanicsCoreVersion=3.4.13
weaponMechanicsVersion=3.4.14

# Version of the resource pack
resourcePackVersion=2.1.2
Expand Down
Loading