Merge branch 'master' into 1.16
This commit is contained in:
commit
359b89b46f
13 files changed
+295
-2
No files matched your search
@@ -538,6 +538,14 @@ public class CarpetEventServer
|
||||
}, player::getCommandSource);
|
||||
}
|
||||
},
|
||||
PLAYER_SWAPS_HANDS("player_swaps_hands", 1, false)
|
||||
{
|
||||
@Override
|
||||
public void onPlayerEvent(ServerPlayerEntity player)
|
||||
{
|
||||
handler.call( () -> Collections.singletonList(((c, t) -> new EntityValue(player))), player::getCommandSource);
|
||||
}
|
||||
},
|
||||
PLAYER_TAKES_DAMAGE("player_takes_damage", 4, false)
|
||||
{
|
||||
@Override
|
||||
|
||||
@@ -7,6 +7,7 @@ import carpet.fakes.LivingEntityInterface;
|
||||
import carpet.fakes.MemoryInterface;
|
||||
import carpet.fakes.MobEntityInterface;
|
||||
import carpet.fakes.HungerManagerInterface;
|
||||
import carpet.fakes.ServerPlayerInteractionManagerInterface;
|
||||
import carpet.helpers.Tracer;
|
||||
import carpet.patches.EntityPlayerMPFake;
|
||||
import carpet.script.CarpetContext;
|
||||
@@ -471,9 +472,32 @@ public class EntityValue extends Value
|
||||
put("selected_slot", (e, a) -> {
|
||||
if (e instanceof PlayerEntity)
|
||||
return new NumericValue(((PlayerEntity) e).inventory.selectedSlot);
|
||||
return null;
|
||||
return Value.NULL;
|
||||
});
|
||||
|
||||
put("active_block", (e, a) -> {
|
||||
if (e instanceof ServerPlayerEntity)
|
||||
{
|
||||
ServerPlayerInteractionManagerInterface manager = (ServerPlayerInteractionManagerInterface) (((ServerPlayerEntity) e).interactionManager);
|
||||
BlockPos pos = manager.getCurrentBreakingBlock();
|
||||
if (pos == null) return Value.NULL;
|
||||
return new BlockValue(null, ((ServerPlayerEntity) e).getServerWorld(), pos);
|
||||
}
|
||||
return Value.NULL;
|
||||
});
|
||||
|
||||
put("breaking_progress", (e, a) -> {
|
||||
if (e instanceof ServerPlayerEntity)
|
||||
{
|
||||
ServerPlayerInteractionManagerInterface manager = (ServerPlayerInteractionManagerInterface) (((ServerPlayerEntity) e).interactionManager);
|
||||
int progress = manager.getCurrentBlockBreakingProgress();
|
||||
if (progress < 0) return Value.NULL;
|
||||
return new NumericValue(progress);
|
||||
}
|
||||
return Value.NULL;
|
||||
});
|
||||
|
||||
|
||||
put("facing", (e, a) -> {
|
||||
int index = 0;
|
||||
if (a != null)
|
||||
@@ -1040,6 +1064,15 @@ public class EntityValue extends Value
|
||||
if(e instanceof PlayerEntity) ((PlayerEntity) e).getHungerManager().setSaturationLevelClient((float)NumericValue.asNumber(v).getLong());
|
||||
});
|
||||
|
||||
put("breaking_progress", (e, a) -> {
|
||||
if (e instanceof ServerPlayerEntity)
|
||||
{
|
||||
int progress = (a == null || a == Value.NULL)?-1:NumericValue.asNumber(a).getInt();
|
||||
ServerPlayerInteractionManagerInterface manager = (ServerPlayerInteractionManagerInterface) (((ServerPlayerEntity) e).interactionManager);
|
||||
manager.setBlockBreakingProgress(progress);
|
||||
}
|
||||
});
|
||||
|
||||
put("nbt", (e, v) -> {
|
||||
if (!(e instanceof PlayerEntity))
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user