Skip to content

Commit

Permalink
Revert reload changes from #460 (#462)
Browse files Browse the repository at this point in the history
* Revert reload changes from #460

* increment version
  • Loading branch information
CJCrafter authored Sep 18, 2024
1 parent 13c3e80 commit 2450267
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
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

0 comments on commit 2450267

Please sign in to comment.