Skip to content

Commit

Permalink
Add active_hands to /record clean (and also python_case fallDistance)…
Browse files Browse the repository at this point in the history
… and adjust sleeping swipe
  • Loading branch information
mchorse committed Sep 27, 2018
1 parent e463612 commit f3a7d13
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/
public class SubCommandRecordClean extends SubCommandRecordBase
{
public static final Set<String> PROPERTIES = ImmutableSet.of("x", "y", "z", "yaw", "yaw_head", "pitch", "fallDistance", "sprinting", "sneaking");
public static final Set<String> PROPERTIES = ImmutableSet.of("x", "y", "z", "yaw", "yaw_head", "pitch", "fall_distance", "sprinting", "sneaking", "active_hands");

@Override
public int getRequiredArgs()
Expand Down Expand Up @@ -113,7 +113,7 @@ else if (property.equals("pitch"))
{
return (float) frame.pitch;
}
else if (property.equals("fallDistance"))
else if (property.equals("fall_distance"))
{
return frame.fallDistance;
}
Expand All @@ -125,6 +125,10 @@ else if (property.equals("sneaking"))
{
return frame.isSneaking ? 1 : 0;
}
else if (property.equals("active_hands"))
{
return frame.activeHands;
}

return 0;
}
Expand Down Expand Up @@ -155,7 +159,7 @@ else if (property.equals("pitch"))
{
frame.pitch = value;
}
else if (property.equals("fallDistance"))
else if (property.equals("fall_distance"))
{
frame.fallDistance = value;
}
Expand All @@ -167,6 +171,10 @@ else if (property.equals("sneaking"))
{
frame.isSneaking = value == 1;
}
else if (property.equals("active_hands"))
{
frame.activeHands = (int) value;
}
}

@Override
Expand Down
22 changes: 10 additions & 12 deletions src/main/java/mchorse/blockbuster/recording/PlayerTracker.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import mchorse.blockbuster.recording.actions.AttackAction;
import mchorse.blockbuster.recording.actions.EquipAction;
import mchorse.blockbuster.recording.actions.SwipeAction;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;

Expand All @@ -24,14 +23,6 @@ public class PlayerTracker
/* Items to track */
private ItemStack[] items = new ItemStack[6];

/**
* Track player swing progress, apparently, during player sleep,
* {@link EntityLivingBase#isSwingInProgress} is true, however, its value
* doesn't change over time. So gotta track that so it wouldn't look like
* Steve is beating his meat.
*/
private float lastSwing;

public PlayerTracker(RecordRecorder recorder)
{
this.recorder = recorder;
Expand Down Expand Up @@ -104,7 +95,16 @@ else if (this.items[slot] != null)
*/
private void trackSwing(EntityPlayer player)
{
if (player.isSwingInProgress && player.swingProgress == 0 && player.swingProgress != this.lastSwing)
/**
* player.isPlayerSleeping() is necessary since for some reason when
* player is falling asleep, the isSwingInProgress is true, while
* player.swingProgress is equals to 0 which makes player swipe every
* tick in bed.
*
* So gotta check that so it wouldn't look like Steve is beating his
* meat.
*/
if (player.isSwingInProgress && player.swingProgress == 0 && !player.isPlayerSleeping())
{
this.recorder.actions.add(new SwipeAction());

Expand All @@ -113,7 +113,5 @@ private void trackSwing(EntityPlayer player)
this.recorder.actions.add(new AttackAction());
}
}

this.lastSwing = player.swingProgress;
}
}

0 comments on commit f3a7d13

Please sign in to comment.