Merge branch 'master' into 1.16

This commit is contained in:
gnembon committed 2020-02-08 15:20:35 -04:00
commit 2f517f93eb
4 files changed
+37 -4

No files matched your search

@@ -24,7 +24,7 @@ public abstract class GuardianEntityMixin extends HostileEntity
@Override @Override
public void onStruckByLightning(LightningEntity lightning) public void onStruckByLightning(LightningEntity lightning)
{ {
if (!this.world.isClient && !this.removed && CarpetSettings.renewableSponges) if (!this.world.isClient && !this.removed && CarpetSettings.renewableSponges && !((Object)this instanceof ElderGuardianEntity))
{ {
ElderGuardianEntity elderGuardian = new ElderGuardianEntity(EntityType.ELDER_GUARDIAN ,this.world); ElderGuardianEntity elderGuardian = new ElderGuardianEntity(EntityType.ELDER_GUARDIAN ,this.world);
elderGuardian.refreshPositionAndAngles(this.getX(), this.getY(), this.getZ(), this.yaw, this.pitch); elderGuardian.refreshPositionAndAngles(this.getX(), this.getY(), this.getZ(), this.yaw, this.pitch);
@@ -23,6 +23,7 @@ import carpet.utils.Messenger;
public class EntityPlayerMPFake extends ServerPlayerEntity public class EntityPlayerMPFake extends ServerPlayerEntity
{ {
public Runnable fixStartingPosition = () -> {}; public Runnable fixStartingPosition = () -> {};
public boolean isAShadow;
public static EntityPlayerMPFake createFake(String username, MinecraftServer server, double d0, double d1, double d2, double yaw, double pitch, DimensionType dimension, GameMode gamemode) public static EntityPlayerMPFake createFake(String username, MinecraftServer server, double d0, double d1, double d2, double yaw, double pitch, DimensionType dimension, GameMode gamemode)
{ {
@@ -38,7 +39,7 @@ public class EntityPlayerMPFake extends ServerPlayerEntity
{ {
gameprofile = SkullBlockEntity.loadProperties(gameprofile); gameprofile = SkullBlockEntity.loadProperties(gameprofile);
} }
EntityPlayerMPFake instance = new EntityPlayerMPFake(server, worldIn, gameprofile, interactionManagerIn); EntityPlayerMPFake instance = new EntityPlayerMPFake(server, worldIn, gameprofile, interactionManagerIn, false);
instance.fixStartingPosition = () -> instance.refreshPositionAndAngles(d0, d1, d2, (float) yaw, (float) pitch); instance.fixStartingPosition = () -> instance.refreshPositionAndAngles(d0, d1, d2, (float) yaw, (float) pitch);
server.getPlayerManager().onPlayerConnect(new NetworkManagerFake(NetworkSide.SERVERBOUND), instance); server.getPlayerManager().onPlayerConnect(new NetworkManagerFake(NetworkSide.SERVERBOUND), instance);
if (instance.dimension != dimension) //player was logged in in a different dimension if (instance.dimension != dimension) //player was logged in in a different dimension
@@ -73,7 +74,7 @@ public class EntityPlayerMPFake extends ServerPlayerEntity
ServerWorld worldIn = server.getWorld(player.dimension); ServerWorld worldIn = server.getWorld(player.dimension);
ServerPlayerInteractionManager interactionManagerIn = new ServerPlayerInteractionManager(worldIn); ServerPlayerInteractionManager interactionManagerIn = new ServerPlayerInteractionManager(worldIn);
GameProfile gameprofile = player.getGameProfile(); GameProfile gameprofile = player.getGameProfile();
EntityPlayerMPFake playerShadow = new EntityPlayerMPFake(server, worldIn, gameprofile, interactionManagerIn); EntityPlayerMPFake playerShadow = new EntityPlayerMPFake(server, worldIn, gameprofile, interactionManagerIn, true);
server.getPlayerManager().onPlayerConnect(new NetworkManagerFake(NetworkSide.SERVERBOUND), playerShadow); server.getPlayerManager().onPlayerConnect(new NetworkManagerFake(NetworkSide.SERVERBOUND), playerShadow);
playerShadow.setHealth(player.getHealth()); playerShadow.setHealth(player.getHealth());
@@ -90,9 +91,10 @@ public class EntityPlayerMPFake extends ServerPlayerEntity
return playerShadow; return playerShadow;
} }
private EntityPlayerMPFake(MinecraftServer server, ServerWorld worldIn, GameProfile profile, ServerPlayerInteractionManager interactionManagerIn) private EntityPlayerMPFake(MinecraftServer server, ServerWorld worldIn, GameProfile profile, ServerPlayerInteractionManager interactionManagerIn, boolean shadow)
{ {
super(server, worldIn, profile, interactionManagerIn); super(server, worldIn, profile, interactionManagerIn);
isAShadow = shadow;
} }
@@ -155,6 +155,7 @@ public class CarpetExpression
private final Expression expr; private final Expression expr;
Expression getExpr() {return expr;} Expression getExpr() {return expr;}
private static long tickStart = 0L; private static long tickStart = 0L;
// dummy entity for dummy requirements in the loot tables (see snowball)
private static FallingBlockEntity DUMMY_ENTITY = new FallingBlockEntity(EntityType.FALLING_BLOCK, null); private static FallingBlockEntity DUMMY_ENTITY = new FallingBlockEntity(EntityType.FALLING_BLOCK, null);
private static boolean stopAll = false; private static boolean stopAll = false;
@@ -2157,6 +2158,17 @@ public class CarpetExpression
* <p>String with gamemode, or <code>null</code> if not a player.</p> * <p>String with gamemode, or <code>null</code> if not a player.</p>
* <h3><code>query(e,'gamemode_id')</code></h3> * <h3><code>query(e,'gamemode_id')</code></h3>
* <p>Good'ol gamemode id, or null if not a player.</p> * <p>Good'ol gamemode id, or null if not a player.</p>
* <h3><code>query(e,'player_type')</code></h3>
* <p>Returns <code>null</code> if the argument is not a player, otherwise:</p>
* <ul>
* <li><code>singleplayer</code>: for singleplayer game</li>
* <li><code>multiplayer</code>: for players on a dedicated server</li>
* <li><code>lan_host</code>: for singleplayer owner that opened the game to LAN</li>
* <li><code>lan_player</code>: for all other players that connected to a LAN host</li>
* <li><code>fake</code>: any carpet-spanwed fake player</li>
* <li><code>shadow</code>: any carpet-shadowed real player</li>
* <li><code>realms</code>: ?</li>
* </ul>
* <h3><code>query(e,'permission_level')</code></h3> * <h3><code>query(e,'permission_level')</code></h3>
* <p>Player's permission level, or <code>null</code> if not applicable for this entity.</p> * <p>Player's permission level, or <code>null</code> if not applicable for this entity.</p>
* *
@@ -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.patches.EntityPlayerMPFake;
import carpet.script.CarpetContext; import carpet.script.CarpetContext;
import carpet.script.EntityEventsGroup; import carpet.script.EntityEventsGroup;
import carpet.script.exception.InternalExpressionException; import carpet.script.exception.InternalExpressionException;
@@ -32,6 +33,7 @@ import net.minecraft.nbt.CompoundTag;
import net.minecraft.predicate.entity.EntityPredicates; import net.minecraft.predicate.entity.EntityPredicates;
import net.minecraft.server.MinecraftServer; import net.minecraft.server.MinecraftServer;
import net.minecraft.server.command.ServerCommandSource; import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.server.integrated.IntegratedServer;
import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld; import net.minecraft.server.world.ServerWorld;
import net.minecraft.text.LiteralText; import net.minecraft.text.LiteralText;
@@ -311,6 +313,23 @@ public class EntityValue extends Value
return Value.NULL; return Value.NULL;
}); });
put("player_type", (e, a) -> {
if (e instanceof PlayerEntity)
{
if (e instanceof EntityPlayerMPFake) return new StringValue(((EntityPlayerMPFake) e).isAShadow?"shadow":"fake");
PlayerEntity p = (PlayerEntity)e;
MinecraftServer server = p.getEntityWorld().getServer();
if (server.isDedicated()) return new StringValue("multiplayer");
boolean runningLan = server.isRemote();
if (!runningLan) return new StringValue("singleplayer");
boolean isowner = server.isOwner(p.getGameProfile());
if (isowner) return new StringValue("lan_host");
return new StringValue("lan player");
// realms?
}
return Value.NULL;
});
//spectating_entity //spectating_entity
// isGlowing // isGlowing
put("effect", (e, a) -> put("effect", (e, a) ->