added gamemode_id and jump modifications
This commit is contained in:
1 parent
f5316a1e2d
commit
2b6a1bf1c5
1 file changed
+47
-15
@@ -4,6 +4,7 @@ import carpet.fakes.EntityInterface;
|
|||||||
import carpet.fakes.ItemEntityInterface;
|
import carpet.fakes.ItemEntityInterface;
|
||||||
import carpet.fakes.MobEntityInterface;
|
import carpet.fakes.MobEntityInterface;
|
||||||
import carpet.helpers.Tracer;
|
import carpet.helpers.Tracer;
|
||||||
|
import carpet.helpers.EntityPlayerActionPack;
|
||||||
import carpet.patches.EntityPlayerMPFake;
|
import carpet.patches.EntityPlayerMPFake;
|
||||||
import carpet.script.CarpetContext;
|
import carpet.script.CarpetContext;
|
||||||
import carpet.script.EntityEventsGroup;
|
import carpet.script.EntityEventsGroup;
|
||||||
@@ -45,6 +46,7 @@ import net.minecraft.util.math.Direction;
|
|||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
import net.minecraft.util.registry.Registry;
|
import net.minecraft.util.registry.Registry;
|
||||||
|
import net.minecraft.world.GameMode;
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -891,21 +893,51 @@ public class EntityValue extends Value
|
|||||||
throw new InternalExpressionException("'effect' needs either no arguments (clear) or effect name, duration, and optional amplifier, show particles and show icon");
|
throw new InternalExpressionException("'effect' needs either no arguments (clear) or effect name, duration, and optional amplifier, show particles and show icon");
|
||||||
});
|
});
|
||||||
|
|
||||||
// gamemode
|
put("gamemode", (e,v)->{
|
||||||
// spectate
|
if(!(e instanceof ServerPlayerEntity)){
|
||||||
// "fire"
|
throw new InternalExpressionException("Cannot change the gamemode of non-player entities");
|
||||||
// "extinguish"
|
}
|
||||||
// "silent"
|
if(v.readInteger()==0){
|
||||||
// "gravity"
|
((ServerPlayerEntity) e).setGameMode(GameMode.SURVIVAL);
|
||||||
// "invulnerable"
|
return;
|
||||||
// "dimension"
|
}
|
||||||
// "item"
|
if(v.getString()=="creative"){
|
||||||
// "count",
|
((ServerPlayerEntity) e).setGameMode(GameMode.CREATIVE);
|
||||||
// "age",
|
return;
|
||||||
// "effect_"name
|
}
|
||||||
// "hold"
|
if(v.getString()=="spectator"){
|
||||||
// "hold_offhand"
|
((ServerPlayerEntity) e).setGameMode(GameMode.SPECTATOR);
|
||||||
// "jump"
|
return;
|
||||||
|
}
|
||||||
|
if(v.getString()=="adventure"){
|
||||||
|
((ServerPlayerEntity) e).setGameMode(GameMode.ADVENTURE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
throw new InternalExpressionException("s"+v.getString()+"s is an invalid gamemode type");
|
||||||
|
});
|
||||||
|
|
||||||
|
put("jump",(e,v)->{
|
||||||
|
if(!(e instanceof ServerPlayerEntity)){
|
||||||
|
throw new InternalExpressionException("Non-player entities can't jump");
|
||||||
|
}
|
||||||
|
((PlayerEntity) e).jump();
|
||||||
|
});
|
||||||
|
|
||||||
|
// gamemode_id [check](gamemode just wont read string)
|
||||||
|
// spectate [check]
|
||||||
|
// "fire" []
|
||||||
|
// "extinguish" []
|
||||||
|
// "silent" []
|
||||||
|
// "gravity" []
|
||||||
|
// "invulnerable" []
|
||||||
|
// "dimension" []
|
||||||
|
// "item" []
|
||||||
|
// "count", []
|
||||||
|
// "age", []
|
||||||
|
// "effect_"name []
|
||||||
|
// "hold" [inventory_set?]
|
||||||
|
// "hold_offhand" [inventory_set?]
|
||||||
|
// "jump" [check]
|
||||||
// "nbt" <-big one, for now use run('data merge entity ...
|
// "nbt" <-big one, for now use run('data merge entity ...
|
||||||
}};
|
}};
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user