This commit is contained in:
gnembon committed 2021-03-26 22:29:06 -03:00
1 parent 1ef764b9b1
commit c5f666b95c
2 files changed
+18

No files matched your search

+4
View File
@@ -722,6 +722,10 @@ Requires a living entity as an argument.
Will make the entity jump once.
### `modify(e, 'swing')` `modify(e, 'swing', 'offhand')`
Makes the living entity swing their required limb.
### `modify(e, 'silent', boolean)`
Silences or unsilences the entity.
@@ -56,6 +56,7 @@ import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.text.LiteralText;
import net.minecraft.util.Hand;
import net.minecraft.util.Identifier;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.hit.EntityHitResult;
@@ -1376,6 +1377,19 @@ public class EntityValue extends Value
}
});
put("swing", (e, v) -> {
if (e instanceof LivingEntity)
{
Hand hand = Hand.MAIN_HAND;
if (v != null)
{
String handString = v.getString().toLowerCase(Locale.ROOT);
if (handString.equals("offhand") || handString.equals("off_hand")) hand = Hand.OFF_HAND;
}
((LivingEntity)e).swingHand(hand, true);
}
});
put("silent",(e,v)-> e.setSilent(v.getBoolean()));
put("gravity",(e,v)-> e.setNoGravity(!v.getBoolean()));