draft
This commit is contained in:
1 parent
aacc1dcb3e
commit
a690e477ae
3 files changed
+40
No files matched your search
@@ -427,6 +427,18 @@ public class Inventories {
|
|||||||
return new ScreenValue(player,type,name,function,c);
|
return new ScreenValue(player,type,name,function,c);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
expression.addContextFunction("get_current_screen",-1, (c, t, lv) ->
|
||||||
|
{
|
||||||
|
if(lv.size() < 1) throw new InternalExpressionException("'get_current_screen' requires at least 1 argument");
|
||||||
|
Value playerValue = lv.get(0);
|
||||||
|
ServerPlayer player = EntityValue.getPlayerByValue(((CarpetContext) c).s.getServer(), playerValue);
|
||||||
|
if(player == null) throw new InternalExpressionException("'get_current_screen' requires a valid online player as the first argument.");
|
||||||
|
FunctionValue function = null;
|
||||||
|
if(lv.size() > 1)
|
||||||
|
function = FunctionArgument.findIn(c, expression.module, lv, 1, true, false).function;
|
||||||
|
|
||||||
|
return new ScreenValue(player,player.containerMenu,function,c);
|
||||||
|
});
|
||||||
expression.addContextFunction("close_screen",1, (c, t, lv) ->
|
expression.addContextFunction("close_screen",1, (c, t, lv) ->
|
||||||
{
|
{
|
||||||
Value value = lv.get(0);
|
Value value = lv.get(0);
|
||||||
@@ -454,6 +466,9 @@ public class Inventories {
|
|||||||
|
|
||||||
private static void syncPlayerInventory(NBTSerializableValue.InventoryLocator inventory, int int_1)
|
private static void syncPlayerInventory(NBTSerializableValue.InventoryLocator inventory, int int_1)
|
||||||
{
|
{
|
||||||
|
if (inventory.owner() instanceof ServerPlayer player && inventory.inventory() instanceof ScreenValue.ScreenHandlerInventory && (inventory.inventory().getContainerSize()-1)==int_1){
|
||||||
|
player.containerMenu.broadcastFullState();
|
||||||
|
}//not sure. if you think that is wrong, please tell me.
|
||||||
if (inventory.owner() instanceof ServerPlayer player && !inventory.isEnder() && !(inventory.inventory() instanceof ScreenValue.ScreenHandlerInventory))
|
if (inventory.owner() instanceof ServerPlayer player && !inventory.isEnder() && !(inventory.inventory() instanceof ScreenValue.ScreenHandlerInventory))
|
||||||
{
|
{
|
||||||
player.connection.send(new ClientboundContainerSetSlotPacket(
|
player.connection.send(new ClientboundContainerSetSlotPacket(
|
||||||
|
|||||||
@@ -525,12 +525,14 @@ public class EntityValue extends Value
|
|||||||
put("breeding_age", (e, a) -> e instanceof AgeableMob?new NumericValue(((AgeableMob) e).getAge()):Value.NULL);
|
put("breeding_age", (e, a) -> e instanceof AgeableMob?new NumericValue(((AgeableMob) e).getAge()):Value.NULL);
|
||||||
put("despawn_timer", (e, a) -> e instanceof LivingEntity?new NumericValue(((LivingEntity) e).getNoActionTime()):Value.NULL);
|
put("despawn_timer", (e, a) -> e instanceof LivingEntity?new NumericValue(((LivingEntity) e).getNoActionTime()):Value.NULL);
|
||||||
//getter of ironman flower, blueness of skull, carryingitem
|
//getter of ironman flower, blueness of skull, carryingitem
|
||||||
|
/*
|
||||||
put("carrying_item",(e,a)->{
|
put("carrying_item",(e,a)->{
|
||||||
if (e instanceof ServerPlayer){
|
if (e instanceof ServerPlayer){
|
||||||
return ValueConversions.of(((ServerPlayer) e).containerMenu.getCarried());
|
return ValueConversions.of(((ServerPlayer) e).containerMenu.getCarried());
|
||||||
}
|
}
|
||||||
return Value.NULL;
|
return Value.NULL;
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
put("skull_dangerous",(e,a)->{
|
put("skull_dangerous",(e,a)->{
|
||||||
if (e instanceof WitherSkull w){
|
if (e instanceof WitherSkull w){
|
||||||
return BooleanValue.of(w.isDangerous());
|
return BooleanValue.of(w.isDangerous());
|
||||||
@@ -1696,6 +1698,7 @@ public class EntityValue extends Value
|
|||||||
});
|
});
|
||||||
|
|
||||||
//setter of ironman flower, blueness of skull, carryingitem
|
//setter of ironman flower, blueness of skull, carryingitem
|
||||||
|
/*
|
||||||
put("carrying_item",(e,v)->{
|
put("carrying_item",(e,v)->{
|
||||||
if (e instanceof ServerPlayer pl){
|
if (e instanceof ServerPlayer pl){
|
||||||
ItemStack item=getItemStackFromValue(v);
|
ItemStack item=getItemStackFromValue(v);
|
||||||
@@ -1707,6 +1710,7 @@ public class EntityValue extends Value
|
|||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
put("skull_dangerous",(e,v)->{
|
put("skull_dangerous",(e,v)->{
|
||||||
if (e instanceof WitherSkull w){
|
if (e instanceof WitherSkull w){
|
||||||
w.setDangerous(v.getBoolean());
|
w.setDangerous(v.getBoolean());
|
||||||
|
|||||||
@@ -111,6 +111,27 @@ public class ScreenValue extends Value {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public ScreenValue(ServerPlayer player, AbstractContainerMenu screenHandler, FunctionValue callback, Context c) {
|
||||||
|
this.screenHandler=screenHandler;
|
||||||
|
this.inventory = new ScreenHandlerInventory(this.screenHandler);
|
||||||
|
this.hostname = c.host.getName();
|
||||||
|
this.player=player;
|
||||||
|
name=null;//TO DO...
|
||||||
|
net.minecraft.resources.ResourceLocation menuname=null;
|
||||||
|
try {
|
||||||
|
menuname=net.minecraft.core.Registry.MENU.getKey(screenHandler.getType());
|
||||||
|
}catch(Exception e){}
|
||||||
|
if (menuname==null){
|
||||||
|
typestring=screenHandler != this.player.inventoryMenu?"__unknown":"inv";
|
||||||
|
}else if(menuname.getNamespace().equals("minecraft")){
|
||||||
|
typestring=menuname.getPath();
|
||||||
|
}else{
|
||||||
|
typestring=menuname.getNamespace();
|
||||||
|
}
|
||||||
|
if(callback != null) callback.checkArgs(4);
|
||||||
|
this.callback=callback;
|
||||||
|
addListenerCallback(screenHandler);
|
||||||
|
}
|
||||||
public ScreenValue(ServerPlayer player, String type, Component name, FunctionValue callback, Context c) {
|
public ScreenValue(ServerPlayer player, String type, Component name, FunctionValue callback, Context c) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.typestring = type.toLowerCase();
|
this.typestring = type.toLowerCase();
|
||||||
|
|||||||
Reference in new issue
Block a user