moved rest of the stuff. mixins needed still
This commit is contained in:
1 parent
ecced620a4
commit
f985678517
16 files changed
+417
-184
No files matched your search
@@ -8,14 +8,12 @@ import carpet.commands.DrawCommand;
|
||||
//import carpet.commands.ScriptCommand;
|
||||
//import carpet.commands.InfoCommand;
|
||||
import carpet.commands.PerimeterInfoCommand;
|
||||
//import carpet.commands.PlayerCommand;
|
||||
//import carpet.commands.SpawnCommand;
|
||||
import carpet.commands.PlayerCommand;
|
||||
import carpet.commands.SpawnCommand;
|
||||
import carpet.commands.LogCommand;
|
||||
import carpet.commands.TestCommand;
|
||||
//import carpet.commands.TickCommand;
|
||||
//import carpet.logging.LoggerRegistry;
|
||||
import carpet.commands.TickCommand;
|
||||
//import carpet.script.ExpressionInspector;
|
||||
//import carpet.utils.HUDController;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
@@ -53,11 +51,11 @@ public class CarpetServer // static for now - easier to handle all around the co
|
||||
public static void registerCarpetCommands(CommandDispatcher<ServerCommandSource> dispatcher)
|
||||
{
|
||||
CarpetCommand.register(dispatcher);
|
||||
//TickCommand.register(dispatcher);
|
||||
TickCommand.register(dispatcher);
|
||||
CounterCommand.register(dispatcher);
|
||||
LogCommand.register(dispatcher);
|
||||
//SpawnCommand.register(dispatcher);
|
||||
//PlayerCommand.register(dispatcher);
|
||||
SpawnCommand.register(dispatcher);
|
||||
PlayerCommand.register(dispatcher);
|
||||
CameraModeCommand.register(dispatcher);
|
||||
//InfoCommand.register(dispatcher);
|
||||
//DistanceCommand.register(dispatcher);
|
||||
|
||||
+62
-59
@@ -1,6 +1,7 @@
|
||||
package carpet.commands;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import carpet.fakes.ServerPlayerEntityInterface;
|
||||
import carpet.patches.EntityPlayerMPFake;
|
||||
import carpet.utils.Messenger;
|
||||
import com.google.common.collect.Sets;
|
||||
@@ -8,14 +9,16 @@ import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import net.minecraft.command.suggestion.SuggestionProviders;
|
||||
import net.minecraft.command.arguments.DimensionArgumentType;
|
||||
import net.minecraft.command.arguments.RotationArgumentType;
|
||||
import net.minecraft.command.arguments.Vec3ArgumentType;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.util.math.Vec2f;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.GameType;
|
||||
import net.minecraft.world.GameMode;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -28,16 +31,16 @@ import static com.mojang.brigadier.arguments.StringArgumentType.getString;
|
||||
import static com.mojang.brigadier.arguments.StringArgumentType.word;
|
||||
import static net.minecraft.server.command.CommandManager.argument;
|
||||
import static net.minecraft.server.command.CommandManager.literal;
|
||||
import static net.minecraft.server.command.CommandSource.suggestMatching;
|
||||
|
||||
public class PlayerCommand
|
||||
{
|
||||
ServerPlayerEntity
|
||||
public static void register(CommandDispatcher<ServerCommandSource> dispatcher)
|
||||
{
|
||||
LiteralArgumentBuilder<ServerCommandSource> literalargumentbuilder = literal("player").
|
||||
requires((player) -> CarpetSettings.getBool("commandPlayer")).
|
||||
then(argument("player", word()).
|
||||
suggests( (c, b) -> SuggestionProviders.suggest(getPlayers(c.getSource()), b)).
|
||||
suggests( (c, b) -> suggestMatching(getPlayers(c.getSource()), b)).
|
||||
then(literal("stop").
|
||||
executes(PlayerCommand::stop)).
|
||||
then(literal("use").
|
||||
@@ -96,7 +99,7 @@ public class PlayerCommand
|
||||
executes(PlayerCommand::lookUp)).
|
||||
then(literal("down").
|
||||
executes(PlayerCommand::lookDown)).
|
||||
then(argument("direction",RotationArgument.rotation()).
|
||||
then(argument("direction", RotationArgumentType.create()).
|
||||
executes(PlayerCommand::lookAround))).
|
||||
then(literal("turn").
|
||||
then(literal("left").
|
||||
@@ -105,7 +108,7 @@ public class PlayerCommand
|
||||
executes(PlayerCommand::turnRight)).
|
||||
then(literal("back").
|
||||
executes(PlayerCommand::turnBack)).
|
||||
then(argument("direction",RotationArgument.rotation()).
|
||||
then(argument("direction",RotationArgumentType.create()).
|
||||
executes(PlayerCommand::turn))).
|
||||
then(literal("move").
|
||||
then(literal("forward").
|
||||
@@ -119,13 +122,13 @@ public class PlayerCommand
|
||||
then(literal("spawn").
|
||||
executes(PlayerCommand::spawn).
|
||||
then(literal("at").
|
||||
then(argument("position", Vec3Argument.vec3()).
|
||||
then(argument("position", Vec3ArgumentType.create()).
|
||||
executes(PlayerCommand::spawn).
|
||||
then(literal("facing").
|
||||
then(argument("direction",RotationArgument.rotation()).
|
||||
then(argument("direction",RotationArgumentType.create()).
|
||||
executes(PlayerCommand::spawn).
|
||||
then(literal("in").
|
||||
then(argument("dimension",DimensionArgument.getDimension()).
|
||||
then(argument("dimension", DimensionArgumentType.create()).
|
||||
executes(PlayerCommand::spawn)))))))));
|
||||
|
||||
dispatcher.register(literalargumentbuilder);
|
||||
@@ -137,17 +140,17 @@ public class PlayerCommand
|
||||
return players;
|
||||
}
|
||||
|
||||
private static ServerPlayerEntityy getPlayer(CommandContext<ServerCommandSource> context)
|
||||
private static ServerPlayerEntity getPlayer(CommandContext<ServerCommandSource> context)
|
||||
{
|
||||
String playerName = getString(context,"player");
|
||||
MinecraftServer server = context.getSource().getServer();
|
||||
return (ServerPlayerEntityy) server.getPlayerList().getPlayerByUsername(playerName);
|
||||
MinecraftServer server = context.getSource().getMinecraftServer();
|
||||
return server.getPlayerManager().getPlayer(playerName);
|
||||
}
|
||||
|
||||
private static boolean cantSpawn(CommandContext<ServerCommandSource> context)
|
||||
{
|
||||
String playerName = getString(context,"player");
|
||||
PlayerEntity player = context.getSource().getServer().getPlayerList().getPlayerByUsername(playerName);
|
||||
PlayerEntity player = context.getSource().getMinecraftServer().getPlayerManager().getPlayer(playerName);
|
||||
if (player != null)
|
||||
{
|
||||
Messenger.m(context.getSource(), "r Player ", "rb "+playerName, "r is already logged on");
|
||||
@@ -167,14 +170,14 @@ public class PlayerCommand
|
||||
PlayerEntity sendingPlayer;
|
||||
try
|
||||
{
|
||||
sendingPlayer = context.getSource().asPlayer();
|
||||
sendingPlayer = context.getSource().getPlayer();
|
||||
}
|
||||
catch (CommandSyntaxException e)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!(context.getSource().getServer().getPlayerList().canSendCommands(sendingPlayer.getGameProfile())))
|
||||
if (!(context.getSource().getMinecraftServer().getPlayerManager().isOperator(sendingPlayer.getGameProfile())))
|
||||
{
|
||||
if (!(sendingPlayer == player || player instanceof EntityPlayerMPFake))
|
||||
{
|
||||
@@ -214,208 +217,208 @@ public class PlayerCommand
|
||||
private static int stop(CommandContext<ServerCommandSource> context)
|
||||
{
|
||||
if (cantManipulate(context)) return 0;
|
||||
getPlayer(context).actionPack.stop();
|
||||
((ServerPlayerEntityInterface)getPlayer(context)).getActionPack().stop();
|
||||
return 1;
|
||||
}
|
||||
private static int useOnce(CommandContext<ServerCommandSource> context)
|
||||
{
|
||||
if (cantManipulate(context)) return 0;
|
||||
getPlayer(context).actionPack.useOnce();
|
||||
((ServerPlayerEntityInterface)getPlayer(context)).getActionPack().useOnce();
|
||||
return 1;
|
||||
}
|
||||
private static int useContinuous(CommandContext<ServerCommandSource> context)
|
||||
{
|
||||
if (cantManipulate(context)) return 0;
|
||||
getPlayer(context).actionPack.setUseForever();
|
||||
((ServerPlayerEntityInterface)getPlayer(context)).getActionPack().setUseForever();
|
||||
return 1;
|
||||
}
|
||||
private static int useInterval(CommandContext<ServerCommandSource> context)
|
||||
{
|
||||
if (cantManipulate(context)) return 0;
|
||||
int ticks = getInteger(context, "ticks");
|
||||
getPlayer(context).actionPack.setUse(ticks, 0);
|
||||
((ServerPlayerEntityInterface)getPlayer(context)).getActionPack().setUse(ticks, 0);
|
||||
return 1;
|
||||
}
|
||||
private static int jumpOnce(CommandContext<ServerCommandSource> context)
|
||||
{
|
||||
if (cantManipulate(context)) return 0;
|
||||
getPlayer(context).actionPack.jumpOnce();
|
||||
((ServerPlayerEntityInterface)getPlayer(context)).getActionPack().jumpOnce();
|
||||
return 1;
|
||||
}
|
||||
private static int jumpContinuous(CommandContext<ServerCommandSource> context)
|
||||
{
|
||||
if (cantManipulate(context)) return 0;
|
||||
getPlayer(context).actionPack.setJumpForever();
|
||||
((ServerPlayerEntityInterface)getPlayer(context)).getActionPack().setJumpForever();
|
||||
return 1;
|
||||
}
|
||||
private static int jumpInterval(CommandContext<ServerCommandSource> context)
|
||||
{
|
||||
if (cantManipulate(context)) return 0;
|
||||
int ticks = getInteger(context, "ticks");
|
||||
getPlayer(context).actionPack.setJump(ticks, 0);
|
||||
((ServerPlayerEntityInterface)getPlayer(context)).getActionPack().setJump(ticks, 0);
|
||||
return 1;
|
||||
}
|
||||
private static int attackOnce(CommandContext<ServerCommandSource> context)
|
||||
{
|
||||
if (cantManipulate(context)) return 0;
|
||||
getPlayer(context).actionPack.attackOnce();
|
||||
getPlayer(context).actionPack.resetBlockRemoving(true);
|
||||
((ServerPlayerEntityInterface)getPlayer(context)).getActionPack().attackOnce();
|
||||
//((ServerPlayerEntityInterface)getPlayer(context)).getActionPack().resetBlockRemoving(true);
|
||||
|
||||
return 1;
|
||||
}
|
||||
private static int attackContinuous(CommandContext<ServerCommandSource> context)
|
||||
{
|
||||
if (cantManipulate(context)) return 0;
|
||||
getPlayer(context).actionPack.setAttackForever();
|
||||
((ServerPlayerEntityInterface)getPlayer(context)).getActionPack().setAttackForever();
|
||||
return 1;
|
||||
}
|
||||
private static int attackInterval(CommandContext<ServerCommandSource> context)
|
||||
{
|
||||
if (cantManipulate(context)) return 0;
|
||||
int ticks = getInteger(context, "ticks");
|
||||
getPlayer(context).actionPack.setAttack(ticks, 0);
|
||||
((ServerPlayerEntityInterface)getPlayer(context)).getActionPack().setAttack(ticks, 0);
|
||||
return 1;
|
||||
}
|
||||
private static int dropItem(CommandContext<ServerCommandSource> context)
|
||||
{
|
||||
if (cantManipulate(context)) return 0;
|
||||
getPlayer(context).actionPack.dropItem();
|
||||
((ServerPlayerEntityInterface)getPlayer(context)).getActionPack().dropItem();
|
||||
return 1;
|
||||
}
|
||||
private static int swapHands(CommandContext<ServerCommandSource> context)
|
||||
{
|
||||
if (cantManipulate(context)) return 0;
|
||||
getPlayer(context).actionPack.swapHands();
|
||||
((ServerPlayerEntityInterface)getPlayer(context)).getActionPack().swapHands();
|
||||
return 1;
|
||||
}
|
||||
private static int kill(CommandContext<ServerCommandSource> context)
|
||||
{
|
||||
if (cantReMove(context)) return 0;
|
||||
getPlayer(context).onKillCommand();
|
||||
getPlayer(context).kill();
|
||||
return 1;
|
||||
}
|
||||
private static int shadow(CommandContext<ServerCommandSource> context)
|
||||
{
|
||||
if (cantShadow(context)) return 0;
|
||||
EntityPlayerMPFake.createShadow(
|
||||
context.getSource().getServer(),
|
||||
context.getSource().getMinecraftServer(),
|
||||
getPlayer(context));
|
||||
return 1;
|
||||
}
|
||||
private static int mount(CommandContext<ServerCommandSource> context)
|
||||
{
|
||||
if (cantManipulate(context)) return 0;
|
||||
getPlayer(context).actionPack.mount();
|
||||
((ServerPlayerEntityInterface)getPlayer(context)).getActionPack().mount();
|
||||
return 1;
|
||||
}
|
||||
private static int dismount(CommandContext<ServerCommandSource> context)
|
||||
{
|
||||
if (cantManipulate(context)) return 0;
|
||||
getPlayer(context).actionPack.dismount();
|
||||
((ServerPlayerEntityInterface)getPlayer(context)).getActionPack().dismount();
|
||||
return 1;
|
||||
}
|
||||
private static int sneak(CommandContext<ServerCommandSource> context)
|
||||
{
|
||||
if (cantReMove(context)) return 0;
|
||||
getPlayer(context).actionPack.setSneaking(true);
|
||||
((ServerPlayerEntityInterface)getPlayer(context)).getActionPack().setSneaking(true);
|
||||
return 1;
|
||||
}
|
||||
private static int sprint(CommandContext<ServerCommandSource> context)
|
||||
{
|
||||
if (cantReMove(context)) return 0;
|
||||
getPlayer(context).actionPack.setSprinting(true);
|
||||
((ServerPlayerEntityInterface)getPlayer(context)).getActionPack().setSprinting(true);
|
||||
return 1;
|
||||
}
|
||||
private static int lookNorth(CommandContext<ServerCommandSource> context)
|
||||
{
|
||||
if (cantReMove(context)) return 0;
|
||||
getPlayer(context).actionPack.look("north");
|
||||
((ServerPlayerEntityInterface)getPlayer(context)).getActionPack().look("north");
|
||||
return 1;
|
||||
}
|
||||
private static int lookSouth(CommandContext<ServerCommandSource> context)
|
||||
{
|
||||
if (cantReMove(context)) return 0;
|
||||
getPlayer(context).actionPack.look("south");
|
||||
((ServerPlayerEntityInterface)getPlayer(context)).getActionPack().look("south");
|
||||
return 1;
|
||||
}
|
||||
private static int lookEast(CommandContext<ServerCommandSource> context)
|
||||
{
|
||||
if (cantReMove(context)) return 0;
|
||||
getPlayer(context).actionPack.look("east");
|
||||
((ServerPlayerEntityInterface)getPlayer(context)).getActionPack().look("east");
|
||||
return 1;
|
||||
}
|
||||
private static int lookWest(CommandContext<ServerCommandSource> context)
|
||||
{
|
||||
if (cantReMove(context)) return 0;
|
||||
getPlayer(context).actionPack.look("west");
|
||||
((ServerPlayerEntityInterface)getPlayer(context)).getActionPack().look("west");
|
||||
return 1;
|
||||
}
|
||||
private static int lookUp(CommandContext<ServerCommandSource> context)
|
||||
{
|
||||
if (cantReMove(context)) return 0;
|
||||
getPlayer(context).actionPack.look("up");
|
||||
((ServerPlayerEntityInterface)getPlayer(context)).getActionPack().look("up");
|
||||
return 1;
|
||||
}
|
||||
private static int lookDown(CommandContext<ServerCommandSource> context)
|
||||
{
|
||||
if (cantReMove(context)) return 0;
|
||||
getPlayer(context).actionPack.look("down");
|
||||
((ServerPlayerEntityInterface)getPlayer(context)).getActionPack().look("down");
|
||||
return 1;
|
||||
}
|
||||
private static int lookAround(CommandContext<ServerCommandSource> context)
|
||||
{
|
||||
if (cantReMove(context)) return 0;
|
||||
Vec2f vec2f = RotationArgument.getRotation(context, "direction").getRotation(context.getSource());
|
||||
getPlayer(context).actionPack.look(vec2f.y,vec2f.x);
|
||||
Vec2f vec2f = RotationArgumentType.getRotation(context, "direction").toAbsoluteRotation(context.getSource());
|
||||
((ServerPlayerEntityInterface)getPlayer(context)).getActionPack().look(vec2f.y,vec2f.x);
|
||||
return 1;
|
||||
}
|
||||
private static int turnRight(CommandContext<ServerCommandSource> context)
|
||||
{
|
||||
if (cantReMove(context)) return 0;
|
||||
getPlayer(context).actionPack.turn("right");
|
||||
((ServerPlayerEntityInterface)getPlayer(context)).getActionPack().turn("right");
|
||||
return 1;
|
||||
}
|
||||
private static int turnLeft(CommandContext<ServerCommandSource> context)
|
||||
{
|
||||
if (cantReMove(context)) return 0;
|
||||
getPlayer(context).actionPack.turn("left");
|
||||
((ServerPlayerEntityInterface)getPlayer(context)).getActionPack().turn("left");
|
||||
return 1;
|
||||
}
|
||||
private static int turnBack(CommandContext<ServerCommandSource> context)
|
||||
{
|
||||
if (cantReMove(context)) return 0;
|
||||
getPlayer(context).actionPack.turn("back");
|
||||
((ServerPlayerEntityInterface)getPlayer(context)).getActionPack().turn("back");
|
||||
return 1;
|
||||
}
|
||||
private static int turn(CommandContext<ServerCommandSource> context)
|
||||
{
|
||||
if (cantReMove(context)) return 0;
|
||||
Vec2f vec2f = RotationArgument.getRotation(context, "direction").getRotation(context.getSource());
|
||||
getPlayer(context).actionPack.turn(vec2f.y,vec2f.x);
|
||||
Vec2f vec2f = RotationArgumentType.getRotation(context, "direction").toAbsoluteRotation(context.getSource());
|
||||
((ServerPlayerEntityInterface)getPlayer(context)).getActionPack().turn(vec2f.y,vec2f.x);
|
||||
return 1;
|
||||
}
|
||||
private static int moveForward(CommandContext<ServerCommandSource> context)
|
||||
{
|
||||
if (cantReMove(context)) return 0;
|
||||
getPlayer(context).actionPack.setForward(1.0F);
|
||||
((ServerPlayerEntityInterface)getPlayer(context)).getActionPack().setForward(1.0F);
|
||||
return 1;
|
||||
}
|
||||
private static int moveBackward(CommandContext<ServerCommandSource> context)
|
||||
{
|
||||
if (cantReMove(context)) return 0;
|
||||
getPlayer(context).actionPack.setForward(-1.0F);
|
||||
((ServerPlayerEntityInterface)getPlayer(context)).getActionPack().setForward(-1.0F);
|
||||
return 1;
|
||||
}
|
||||
private static int strafeLeft(CommandContext<ServerCommandSource> context)
|
||||
{
|
||||
if (cantReMove(context)) return 0;
|
||||
getPlayer(context).actionPack.setStrafing(-1.0F);
|
||||
((ServerPlayerEntityInterface)getPlayer(context)).getActionPack().setStrafing(-1.0F);
|
||||
return 1;
|
||||
}
|
||||
private static int strafeRight(CommandContext<ServerCommandSource> context)
|
||||
{
|
||||
if (cantReMove(context)) return 0;
|
||||
getPlayer(context).actionPack.setStrafing(1.0F);
|
||||
((ServerPlayerEntityInterface)getPlayer(context)).getActionPack().setStrafing(1.0F);
|
||||
return 1;
|
||||
}
|
||||
private static int spawn(CommandContext<ServerCommandSource> context) throws CommandSyntaxException
|
||||
@@ -426,15 +429,15 @@ public class PlayerCommand
|
||||
DimensionType dim;
|
||||
try
|
||||
{
|
||||
pos = Vec3Argument.getVec3(context, "position");
|
||||
pos = Vec3ArgumentType.getVec3(context, "position");
|
||||
}
|
||||
catch (IllegalArgumentException e)
|
||||
{
|
||||
pos = context.getSource().getPos();
|
||||
pos = context.getSource().getPosition();
|
||||
}
|
||||
try
|
||||
{
|
||||
facing = RotationArgument.getRotation(context, "direction").getRotation(context.getSource());
|
||||
facing = RotationArgumentType.getRotation(context, "direction").toAbsoluteRotation(context.getSource());
|
||||
}
|
||||
catch (IllegalArgumentException e)
|
||||
{
|
||||
@@ -442,24 +445,24 @@ public class PlayerCommand
|
||||
}
|
||||
try
|
||||
{
|
||||
dim = DimensionArgument.func_212592_a(context, "dimension");
|
||||
dim = DimensionArgumentType.getDimensionArgument(context, "dimension");
|
||||
}
|
||||
catch (IllegalArgumentException e)
|
||||
{
|
||||
dim = context.getSource().getWorld().dimension.getType();
|
||||
}
|
||||
GameType mode = GameType.CREATIVE;
|
||||
GameMode mode = GameMode.CREATIVE;
|
||||
try
|
||||
{
|
||||
ServerPlayerEntityy player = context.getSource().asPlayer();
|
||||
mode = player.interactionManager.getGameType();
|
||||
ServerPlayerEntity player = context.getSource().getPlayer();
|
||||
mode = player.interactionManager.getGameMode();
|
||||
}
|
||||
catch (CommandSyntaxException ignored)
|
||||
{
|
||||
}
|
||||
PlayerEntity p = EntityPlayerMPFake.createFake(
|
||||
getString(context,"player"),
|
||||
context.getSource().getServer(),
|
||||
context.getSource().getMinecraftServer(),
|
||||
pos.x, pos.y, pos.z,
|
||||
facing.y, facing.x,
|
||||
dim,
|
||||
@@ -0,0 +1,8 @@
|
||||
package carpet.fakes;
|
||||
|
||||
import carpet.helpers.EntityPlayerActionPack;
|
||||
|
||||
public interface ServerPlayerEntityInterface
|
||||
{
|
||||
EntityPlayerActionPack getActionPack();
|
||||
}
|
||||
+64
-71
@@ -1,37 +1,18 @@
|
||||
package carpet.helpers;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import com.google.common.base.Predicate;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockCommandBlock;
|
||||
import net.minecraft.block.BlockStructure;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.BlockWorldState;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import carpet.mixins.PlayerActionC2SPacketMixin;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.fluid.IFluidState;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemSword;
|
||||
import net.minecraft.network.play.client.CPacketPlayerDigging;
|
||||
import net.minecraft.util.EntitySelectors;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.server.network.packet.PlayerActionC2SPacket;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.RayTraceFluidMode;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.GameType;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class EntityPlayerActionPack
|
||||
{
|
||||
private EntityPlayerMP player;
|
||||
private ServerPlayerEntity player;
|
||||
|
||||
private boolean doesAttack;
|
||||
private int attackInterval;
|
||||
@@ -55,7 +36,7 @@ public class EntityPlayerActionPack
|
||||
private float forward;
|
||||
private float strafing;
|
||||
|
||||
public EntityPlayerActionPack(EntityPlayerMP playerIn)
|
||||
public EntityPlayerActionPack(ServerPlayerEntity playerIn)
|
||||
{
|
||||
player = playerIn;
|
||||
stop();
|
||||
@@ -183,9 +164,9 @@ public class EntityPlayerActionPack
|
||||
case "west":
|
||||
look(90.0F, 0.0F); return true;
|
||||
case "up":
|
||||
look(player.rotationYaw, -90.0F); return true;
|
||||
look(player.yaw, -90.0F); return true;
|
||||
case "down":
|
||||
look(player.rotationYaw, 90.0F); return true;
|
||||
look(player.yaw, 90.0F); return true;
|
||||
case "left":
|
||||
case "right":
|
||||
return turn(where);
|
||||
@@ -194,7 +175,7 @@ public class EntityPlayerActionPack
|
||||
}
|
||||
public EntityPlayerActionPack look(float yaw, float pitch)
|
||||
{
|
||||
player.setPositionAndRotation(player.posX, player.posY, player.posZ, yaw, MathHelper.clamp(pitch,-90.0F, 90.0F));
|
||||
player.setPositionAndAngles(player.x, player.y, player.z, yaw, MathHelper.clamp(pitch,-90.0F, 90.0F));
|
||||
return this;
|
||||
}
|
||||
public boolean turn(String where)
|
||||
@@ -216,7 +197,7 @@ public class EntityPlayerActionPack
|
||||
}
|
||||
public EntityPlayerActionPack turn(float yaw, float pitch)
|
||||
{
|
||||
player.setPositionAndRotation(player.posX, player.posY, player.posZ, player.rotationYaw+yaw,MathHelper.clamp(player.rotationPitch+pitch,-90.0F, 90.0F));
|
||||
player.setPositionAndAngles(player.x, player.y, player.z, player.yaw+yaw,MathHelper.clamp(player.pitch+pitch,-90.0F, 90.0F));
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -227,7 +208,7 @@ public class EntityPlayerActionPack
|
||||
this.doesUse = false;
|
||||
this.doesAttack = false;
|
||||
this.doesJump = false;
|
||||
resetBlockRemoving(false);
|
||||
//resetBlockRemoving(false);
|
||||
setSneaking(false);
|
||||
setSprinting(false);
|
||||
forward = 0.0F;
|
||||
@@ -240,25 +221,29 @@ public class EntityPlayerActionPack
|
||||
|
||||
public void swapHands()
|
||||
{
|
||||
player.connection.processPlayerDigging(new CPacketPlayerDigging(null, null, CPacketPlayerDigging.Action.SWAP_HELD_ITEMS));
|
||||
PlayerActionC2SPacket packet = new PlayerActionC2SPacket();
|
||||
((PlayerActionC2SPacketMixin)packet).setAction(PlayerActionC2SPacket.Action.SWAP_HELD_ITEMS);
|
||||
player.networkHandler.onPlayerAction(packet);
|
||||
}
|
||||
|
||||
public void dropItem()
|
||||
{
|
||||
player.connection.processPlayerDigging(new CPacketPlayerDigging(null, null, CPacketPlayerDigging.Action.DROP_ITEM));
|
||||
PlayerActionC2SPacket packet = new PlayerActionC2SPacket();
|
||||
((PlayerActionC2SPacketMixin)packet).setAction(PlayerActionC2SPacket.Action.DROP_ITEM);
|
||||
player.networkHandler.onPlayerAction(packet);
|
||||
}
|
||||
public void mount()
|
||||
{
|
||||
List<Entity> entities = player.world.getEntitiesWithinAABBExcludingEntity(player,player.getBoundingBox().expand(3.0D, 1.0D, 3.0D));
|
||||
List<Entity> entities = player.world.getEntities(player,player.getBoundingBox().expand(3.0D, 1.0D, 3.0D));
|
||||
if (entities.size()==0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Entity closest = entities.get(0);
|
||||
double distance = player.getDistanceSq(closest);
|
||||
double distance = player.squaredDistanceTo(closest);
|
||||
for (Entity e: entities)
|
||||
{
|
||||
double dd = player.getDistanceSq(e);
|
||||
double dd = player.squaredDistanceTo(e);
|
||||
if (dd<distance)
|
||||
{
|
||||
distance = dd;
|
||||
@@ -305,11 +290,11 @@ public class EntityPlayerActionPack
|
||||
}
|
||||
if (forward != 0.0F)
|
||||
{
|
||||
player.moveForward = forward*(sneaking?0.3F:1.0F);
|
||||
player.forwardSpeed = forward*(sneaking?0.3F:1.0F);
|
||||
}
|
||||
if (strafing != 0.0F)
|
||||
{
|
||||
player.moveStrafing = strafing*(sneaking?0.3F:1.0F);
|
||||
player.sidewaysSpeed = strafing*(sneaking?0.3F:1.0F);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -321,12 +306,15 @@ public class EntityPlayerActionPack
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void attackOnce()
|
||||
{
|
||||
RayTraceResult raytraceresult = mouseOver();
|
||||
/* needs rework due to 1.14 changes
|
||||
HitResult raytraceresult = mouseOver();
|
||||
if(raytraceresult == null) return;
|
||||
|
||||
switch (raytraceresult.type)
|
||||
switch (raytraceresult.getType())
|
||||
{
|
||||
case ENTITY:
|
||||
player.attackTargetEntityWithCurrentItem(raytraceresult.entity);
|
||||
@@ -348,11 +336,13 @@ public class EntityPlayerActionPack
|
||||
break;
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
public boolean useOnce()
|
||||
{
|
||||
RayTraceResult raytraceresult = mouseOver();
|
||||
/*needs rework due to 1.14 changes
|
||||
BlockHitResult raytraceresult = mouseOver();
|
||||
for (EnumHand enumhand : EnumHand.values())
|
||||
{
|
||||
ItemStack itemstack = this.player.getHeldItem(enumhand);
|
||||
@@ -412,10 +402,12 @@ public class EntityPlayerActionPack
|
||||
return true;
|
||||
}
|
||||
}
|
||||
*/
|
||||
return false;
|
||||
}
|
||||
|
||||
private RayTraceResult rayTraceBlocks(double blockReachDistance)
|
||||
/*needs rework due to 1.14 changes
|
||||
private BlockHitResult rayTraceBlocks(double blockReachDistance)
|
||||
{
|
||||
Vec3d eyeVec = player.getEyePosition(1.0F);
|
||||
Vec3d lookVec = player.getLook(1.0F);
|
||||
@@ -423,10 +415,10 @@ public class EntityPlayerActionPack
|
||||
return player.getEntityWorld().rayTraceBlocks(eyeVec, pointVec, RayTraceFluidMode.NEVER, false, true);
|
||||
}
|
||||
|
||||
private RayTraceResult mouseOver()
|
||||
private BlockHitResult mouseOver()
|
||||
{
|
||||
World world = player.getEntityWorld();
|
||||
RayTraceResult result = null;
|
||||
BlockHitResult result = null;
|
||||
|
||||
Entity pointedEntity = null;
|
||||
double reach = player.isCreative() ? 5.0D : 4.5D;
|
||||
@@ -456,8 +448,8 @@ public class EntityPlayerActionPack
|
||||
for (int j = 0; j < list.size(); ++j)
|
||||
{
|
||||
Entity entity1 = list.get(j);
|
||||
AxisAlignedBB axisalignedbb = entity1.getBoundingBox().grow((double) entity1.getCollisionBorderSize());
|
||||
RayTraceResult raytraceresult = axisalignedbb.calculateIntercept(eyeVec, pointVec);
|
||||
BoundingBox axisalignedbb = entity1.getBoundingBox().grow((double) entity1.getCollisionBorderSize());
|
||||
BlockHitResult raytraceresult = axisalignedbb.calculateIntercept(eyeVec, pointVec);
|
||||
|
||||
if (axisalignedbb.contains(eyeVec))
|
||||
{
|
||||
@@ -495,23 +487,23 @@ public class EntityPlayerActionPack
|
||||
if (pointedEntity != null && flag && eyeVec.distanceTo(hitVec) > 3.0D)
|
||||
{
|
||||
pointedEntity = null;
|
||||
result = new RayTraceResult(RayTraceResult.Type.MISS, hitVec, (EnumFacing) null, new BlockPos(hitVec));
|
||||
result = new BlockHitResult(BlockHitResult.Type.MISS, hitVec, (Direction) null, new BlockPos(hitVec));
|
||||
}
|
||||
|
||||
if (pointedEntity != null && (d2 < extendedReach || result == null))
|
||||
{
|
||||
result = new RayTraceResult(pointedEntity, hitVec);
|
||||
result = new BlockHitResult(pointedEntity, hitVec);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public boolean clickBlock(BlockPos loc, EnumFacing face) // don't call this one
|
||||
public boolean clickBlock(BlockPos loc, Direction face) // don't call this one
|
||||
{
|
||||
World world = player.getEntityWorld();
|
||||
if (player.interactionManager.getGameType()!=GameType.ADVENTURE)
|
||||
if (player.interactionManager.getGameType()!=GameMode.ADVENTURE)
|
||||
{
|
||||
if (player.interactionManager.getGameType() == GameType.SPECTATOR)
|
||||
if (player.interactionManager.getGameType() == GameMode.SPECTATOR)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -540,7 +532,7 @@ public class EntityPlayerActionPack
|
||||
}
|
||||
else
|
||||
{
|
||||
if (player.interactionManager.getGameType()==GameType.CREATIVE)
|
||||
if (player.interactionManager.getGameType()==GameMode.CREATIVE)
|
||||
{
|
||||
player.connection.processPlayerDigging(new CPacketPlayerDigging(loc, face, CPacketPlayerDigging.Action.START_DESTROY_BLOCK));
|
||||
clickBlockCreative(world, loc, face);
|
||||
@@ -553,7 +545,7 @@ public class EntityPlayerActionPack
|
||||
player.connection.processPlayerDigging(new CPacketPlayerDigging(this.currentBlock, face, CPacketPlayerDigging.Action.ABORT_DESTROY_BLOCK));
|
||||
}
|
||||
|
||||
IBlockState iblockstate = world.getBlockState(loc);
|
||||
BlockState iblockstate = world.getBlockState(loc);
|
||||
player.connection.processPlayerDigging(new CPacketPlayerDigging(loc, face, CPacketPlayerDigging.Action.START_DESTROY_BLOCK));
|
||||
boolean flag = iblockstate.getMaterial() != Material.AIR;
|
||||
|
||||
@@ -579,7 +571,7 @@ public class EntityPlayerActionPack
|
||||
}
|
||||
}
|
||||
|
||||
private void clickBlockCreative(World world, BlockPos pos, EnumFacing facing)
|
||||
private void clickBlockCreative(World world, BlockPos pos, Direction facing)
|
||||
{
|
||||
if (!world.extinguishFire(player, pos, facing))
|
||||
{
|
||||
@@ -587,7 +579,7 @@ public class EntityPlayerActionPack
|
||||
}
|
||||
}
|
||||
|
||||
public boolean onPlayerDamageBlock(BlockPos posBlock, EnumFacing directionFacing) //continue clicking - one to call
|
||||
public boolean onPlayerDamageBlock(BlockPos posBlock, Direction directionFacing) //continue clicking - one to call
|
||||
{
|
||||
if (this.blockHitDelay > 0)
|
||||
{
|
||||
@@ -595,7 +587,7 @@ public class EntityPlayerActionPack
|
||||
return true;
|
||||
}
|
||||
World world = player.getEntityWorld();
|
||||
if (player.interactionManager.getGameType()==GameType.CREATIVE && world.getWorldBorder().contains(posBlock))
|
||||
if (player.interactionManager.getGameType()==GameMode.CREATIVE && world.getWorldBorder().contains(posBlock))
|
||||
{
|
||||
this.blockHitDelay = 5;
|
||||
player.connection.processPlayerDigging(new CPacketPlayerDigging(posBlock, directionFacing, CPacketPlayerDigging.Action.START_DESTROY_BLOCK));
|
||||
@@ -604,7 +596,7 @@ public class EntityPlayerActionPack
|
||||
}
|
||||
else if (posBlock.equals(currentBlock))
|
||||
{
|
||||
IBlockState iblockstate = world.getBlockState(posBlock);
|
||||
BlockState iblockstate = world.getBlockState(posBlock);
|
||||
|
||||
if (iblockstate.getMaterial() == Material.AIR)
|
||||
{
|
||||
@@ -638,9 +630,9 @@ public class EntityPlayerActionPack
|
||||
private boolean onPlayerDestroyBlock(BlockPos pos)
|
||||
{
|
||||
World world = player.getEntityWorld();
|
||||
if (player.interactionManager.getGameType()!=GameType.ADVENTURE)
|
||||
if (player.interactionManager.getGameType()!=GameMode.ADVENTURE)
|
||||
{
|
||||
if (player.interactionManager.getGameType() == GameType.SPECTATOR)
|
||||
if (player.interactionManager.getGameType() == GameMode.SPECTATOR)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -663,13 +655,13 @@ public class EntityPlayerActionPack
|
||||
}
|
||||
}
|
||||
|
||||
if (player.interactionManager.getGameType()==GameType.CREATIVE && !player.getHeldItemMainhand().isEmpty() && player.getHeldItemMainhand().getItem() instanceof ItemSword)
|
||||
if (player.interactionManager.getGameType()==GameMode.CREATIVE && !player.getHeldItemMainhand().isEmpty() && player.getHeldItemMainhand().getItem() instanceof ItemSword)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
IBlockState iblockstate = world.getBlockState(pos);
|
||||
BlockState iblockstate = world.getBlockState(pos);
|
||||
Block block = iblockstate.getBlock();
|
||||
|
||||
if ((block instanceof BlockCommandBlock || block instanceof BlockStructure) && !player.canUseCommandBlock())
|
||||
@@ -684,7 +676,7 @@ public class EntityPlayerActionPack
|
||||
{
|
||||
world.playEvent(2001, pos, Block.getStateId(iblockstate));
|
||||
block.onBlockHarvested(world, pos, iblockstate, player);
|
||||
IFluidState ifluidstate = world.getFluidState(pos);
|
||||
FluidState ifluidstate = world.getFluidState(pos);
|
||||
boolean flag = world.setBlockState(pos, ifluidstate.getBlockState(), 11);
|
||||
|
||||
if (flag)
|
||||
@@ -694,7 +686,7 @@ public class EntityPlayerActionPack
|
||||
|
||||
this.currentBlock = new BlockPos(this.currentBlock.getX(), -1, this.currentBlock.getZ());
|
||||
|
||||
if (!(player.interactionManager.getGameType()==GameType.CREATIVE))
|
||||
if (!(player.interactionManager.getGameType()==GameMode.CREATIVE))
|
||||
{
|
||||
ItemStack itemstack1 = player.getHeldItemMainhand();
|
||||
|
||||
@@ -718,7 +710,7 @@ public class EntityPlayerActionPack
|
||||
{
|
||||
if (this.isHittingBlock || force)
|
||||
{
|
||||
player.connection.processPlayerDigging(new CPacketPlayerDigging(this.currentBlock, EnumFacing.DOWN, CPacketPlayerDigging.Action.ABORT_DESTROY_BLOCK));
|
||||
player.connection.processPlayerDigging(new CPacketPlayerDigging(this.currentBlock, Direction.DOWN, CPacketPlayerDigging.Action.ABORT_DESTROY_BLOCK));
|
||||
this.isHittingBlock = false;
|
||||
this.curBlockDamageMP = 0.0F;
|
||||
player.getEntityWorld().sendBlockBreakProgress(player.getEntityId(), this.currentBlock, -1);
|
||||
@@ -730,7 +722,7 @@ public class EntityPlayerActionPack
|
||||
|
||||
|
||||
/*
|
||||
public EnumActionResult processRightClickBlock(EntityPlayerSP player, WorldClient worldIn, BlockPos stack, EnumFacing pos, Vec3d facing, EnumHand vec)
|
||||
public EnumActionResult processRightClickBlock(EntityPlayerSP player, WorldClient worldIn, BlockPos stack, Direction pos, Vec3d facing, EnumHand vec)
|
||||
{
|
||||
this.syncCurrentPlayItem();
|
||||
ItemStack itemstack = player.getHeldItem(vec);
|
||||
@@ -745,9 +737,9 @@ public class EntityPlayerActionPack
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.currentGameType != GameType.SPECTATOR)
|
||||
if (this.currentGameType != GameMode.SPECTATOR)
|
||||
{
|
||||
IBlockState iblockstate = worldIn.getBlockState(stack);
|
||||
BlockState iblockstate = worldIn.getBlockState(stack);
|
||||
|
||||
if ((!player.isSneaking() || player.getHeldItemMainhand().func_190926_b() && player.getHeldItemOffhand().func_190926_b()) && iblockstate.getBlock().onBlockActivated(worldIn, stack, iblockstate, player, vec, pos, f, f1, f2))
|
||||
{
|
||||
@@ -767,7 +759,7 @@ public class EntityPlayerActionPack
|
||||
|
||||
this.connection.sendPacket(new CPacketPlayerTryUseItemOnBlock(stack, pos, vec, f, f1, f2));
|
||||
|
||||
if (!flag && this.currentGameType != GameType.SPECTATOR)
|
||||
if (!flag && this.currentGameType != GameMode.SPECTATOR)
|
||||
{
|
||||
if (itemstack.func_190926_b())
|
||||
{
|
||||
@@ -813,7 +805,7 @@ public class EntityPlayerActionPack
|
||||
|
||||
public EnumActionResult processRightClick(EntityPlayer player, World worldIn, EnumHand stack)
|
||||
{
|
||||
if (this.currentGameType == GameType.SPECTATOR)
|
||||
if (this.currentGameType == GameMode.SPECTATOR)
|
||||
{
|
||||
return EnumActionResult.PASS;
|
||||
}
|
||||
@@ -847,18 +839,19 @@ public class EntityPlayerActionPack
|
||||
{
|
||||
this.syncCurrentPlayItem();
|
||||
this.connection.sendPacket(new CPacketUseEntity(target, heldItem));
|
||||
return this.currentGameType == GameType.SPECTATOR ? EnumActionResult.PASS : player.func_190775_a(target, heldItem);
|
||||
return this.currentGameType == GameMode.SPECTATOR ? EnumActionResult.PASS : player.func_190775_a(target, heldItem);
|
||||
}
|
||||
*/
|
||||
|
||||
/
|
||||
/*
|
||||
* Handles right clicking an entity from the entities side, sends a packet to the server.
|
||||
*
|
||||
public EnumActionResult interactWithEntity(EntityPlayer player, Entity target, RayTraceResult raytrace, EnumHand heldItem)
|
||||
public EnumActionResult interactWithEntity(EntityPlayer player, Entity target, BlockHitResult raytrace, EnumHand heldItem)
|
||||
{
|
||||
this.syncCurrentPlayItem();
|
||||
Vec3d vec3d = new Vec3d(raytrace.hitVec.xCoord - target.posX, raytrace.hitVec.yCoord - target.posY, raytrace.hitVec.zCoord - target.posZ);
|
||||
this.connection.sendPacket(new CPacketUseEntity(target, heldItem, vec3d));
|
||||
return this.currentGameType == GameType.SPECTATOR ? EnumActionResult.PASS : target.applyPlayerInteraction(player, vec3d, heldItem);
|
||||
return this.currentGameType == GameMode.SPECTATOR ? EnumActionResult.PASS : target.applyPlayerInteraction(player, vec3d, heldItem);
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -3,6 +3,7 @@ package carpet.helpers;
|
||||
import carpet.CarpetSettings;
|
||||
import net.minecraft.init.Biomes;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.structure.Structure;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
@@ -13,11 +14,12 @@ import net.minecraft.world.gen.ChunkGeneratorOverworld;
|
||||
import net.minecraft.world.gen.IChunkGenerator;
|
||||
import net.minecraft.world.gen.OverworldGenSettings;
|
||||
import net.minecraft.world.gen.feature.BlockBlobConfig;
|
||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
import net.minecraft.world.gen.feature.Feature;
|
||||
import net.minecraft.world.gen.feature.IFeatureConfig;
|
||||
import net.minecraft.world.gen.feature.FeatureConfig;
|
||||
import net.minecraft.world.gen.feature.IcebergConfig;
|
||||
import net.minecraft.world.gen.feature.LakesConfig;
|
||||
import net.minecraft.world.gen.feature.NoFeatureConfig;
|
||||
import net.minecraft.world.gen.feature.OceanRuinFeature;
|
||||
import net.minecraft.world.gen.feature.SeaGrassConfig;
|
||||
import net.minecraft.world.gen.feature.ShrubFeature;
|
||||
import net.minecraft.world.gen.feature.TallGrassConfig;
|
||||
@@ -25,9 +27,10 @@ import net.minecraft.world.gen.feature.TallGrassFeature;
|
||||
import net.minecraft.world.gen.feature.structure.MineshaftConfig;
|
||||
import net.minecraft.world.gen.feature.structure.MineshaftStructure;
|
||||
import net.minecraft.world.gen.feature.structure.OceanRuinConfig;
|
||||
import net.minecraft.world.gen.feature.structure.OceanRuinStructure;
|
||||
import net.minecraft.structure.OceanRuinGenerator;
|
||||
import net.minecraft.world.gen.feature.structure.ShipwreckConfig;
|
||||
import net.minecraft.world.gen.feature.structure.Structure;
|
||||
|
||||
import net.minecraft.structure.Structure;
|
||||
import net.minecraft.world.gen.feature.structure.VillageConfig;
|
||||
import net.minecraft.world.gen.feature.structure.VillagePieces;
|
||||
import net.minecraft.world.gen.placement.CountConfig;
|
||||
@@ -43,29 +46,29 @@ public class FeatureGenerator
|
||||
{
|
||||
Boolean plop(World world, BlockPos pos);
|
||||
}
|
||||
private static Thing simplePlop(Feature<NoFeatureConfig> feature)
|
||||
private static Thing simplePlop(Feature<DefaultFeatureConfig> feature)
|
||||
{
|
||||
return simplePlop(feature, IFeatureConfig.NO_FEATURE_CONFIG);
|
||||
return simplePlop(feature, FeatureConfig.DEFAULT);
|
||||
}
|
||||
private static Thing simplePlop(Feature feature, IFeatureConfig config)
|
||||
private static Thing simplePlop(Feature feature, FeatureConfig config)
|
||||
{
|
||||
return (w, p) -> {
|
||||
CarpetSettings.skipGenerationChecks=true;
|
||||
boolean res = feature.place(w, w.getChunkProvider().getChunkGenerator(), w.rand, p, config);
|
||||
boolean res = feature.generate(w, w.getChunkManager().getChunkGenerator(), w.random, p, config);
|
||||
CarpetSettings.skipGenerationChecks=false;
|
||||
return res;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
private static Thing spawnCustomStructure(Structure structure, IFeatureConfig config)
|
||||
private static Thing spawnCustomStructure(Structure structure, FeatureConfig config)
|
||||
{
|
||||
return (w, p) -> {
|
||||
IChunkGenerator chunkgen = new ChunkGeneratorOverworld(w, null, new OverworldGenSettings())
|
||||
{
|
||||
@Nullable
|
||||
@Override
|
||||
public IFeatureConfig getStructureConfig(Biome biomeIn, Structure<? extends IFeatureConfig> structureIn)
|
||||
public FeatureConfig getStructureConfig(Biome biomeIn, Structure<? extends FeatureConfig> structureIn)
|
||||
{
|
||||
return config;
|
||||
}
|
||||
@@ -173,17 +176,17 @@ public class FeatureGenerator
|
||||
put("stronghold", Feature.STRONGHOLD::plopAnywhere);
|
||||
|
||||
put("oceanruin_small", spawnCustomStructure(Feature.OCEAN_RUIN,
|
||||
new OceanRuinConfig(OceanRuinStructure.Type.COLD, 0.0F, 0.5F)));
|
||||
new OceanRuinConfig(OceanRuinGenerator.Type.COLD, 0.0F, 0.5F)));
|
||||
put("oceanruin_warm_small", spawnCustomStructure(Feature.OCEAN_RUIN,
|
||||
new OceanRuinConfig(OceanRuinStructure.Type.WARM, 0.0F, 0.5F)));
|
||||
new OceanRuinConfig(OceanRuinGenerator.Type.WARM, 0.0F, 0.5F)));
|
||||
put("oceanruin_tall", spawnCustomStructure(Feature.OCEAN_RUIN,
|
||||
new OceanRuinConfig(OceanRuinStructure.Type.COLD, 1.0F, 0.0F)));
|
||||
new OceanRuinConfig(OceanRuinGenerator.Type.COLD, 1.0F, 0.0F)));
|
||||
put("oceanruin_warm_tall", spawnCustomStructure(Feature.OCEAN_RUIN,
|
||||
new OceanRuinConfig(OceanRuinStructure.Type.WARM, 1.0F, 0.0F)));
|
||||
new OceanRuinConfig(OceanRuinGenerator.Type.WARM, 1.0F, 0.0F)));
|
||||
put("oceanruin", spawnCustomStructure(Feature.OCEAN_RUIN,
|
||||
new OceanRuinConfig(OceanRuinStructure.Type.COLD, 1.0F, 1.0F)));
|
||||
new OceanRuinConfig(OceanRuinGenerator.Type.COLD, 1.0F, 1.0F)));
|
||||
put("oceanruin_warm", spawnCustomStructure(Feature.OCEAN_RUIN,
|
||||
new OceanRuinConfig(OceanRuinStructure.Type.WARM, 1.0F, 1.0F)));
|
||||
new OceanRuinConfig(OceanRuinGenerator.Type.WARM, 1.0F, 1.0F)));
|
||||
put("treasure", Feature.BURIED_TREASURE::plopAnywhere);
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package carpet.helpers;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.item.BlockItem;
|
||||
|
||||
public class PortalHelper
|
||||
{
|
||||
public static boolean player_holds_obsidian(PlayerEntity playerIn)
|
||||
{
|
||||
if ( (!playerIn.getMainHandStack().isEmpty()
|
||||
&& playerIn.getMainHandStack().getItem() instanceof BlockItem &&
|
||||
((BlockItem)(playerIn.getMainHandStack().getItem())).getBlock() == Blocks.OBSIDIAN ))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package carpet.helpers;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
|
||||
public class PortalHelper
|
||||
{
|
||||
public static boolean player_holds_obsidian(EntityPlayer playerIn)
|
||||
{
|
||||
if ( (!playerIn.getHeldItemMainhand().isEmpty()
|
||||
&& playerIn.getHeldItemMainhand().getItem() instanceof ItemBlock &&
|
||||
((ItemBlock)(playerIn.getHeldItemMainhand().getItem())).getBlock() == Blocks.OBSIDIAN ))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -2,17 +2,9 @@ package carpet.helpers;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import carpet.fakes.ExperienceOrbInterface;
|
||||
import carpet.mixins.ExperienceOrbEntityMixin;
|
||||
import net.minecraft.client.network.packet.PlaySoundFromEntityS2CPacket;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.ExperienceOrbEntity;
|
||||
import net.minecraft.entity.ai.TargetPredicate;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.sound.SoundCategory;
|
||||
import net.minecraft.sound.SoundEvent;
|
||||
import net.minecraft.sound.SoundEvents;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import net.minecraft.server.network.packet.PlayerActionC2SPacket;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
@Mixin(PlayerActionC2SPacket.class)
|
||||
public interface PlayerActionC2SPacketMixin
|
||||
{
|
||||
@Accessor("pos")
|
||||
void setPos(BlockPos pos);
|
||||
|
||||
@Accessor("direction")
|
||||
void setDirection(Direction direction);
|
||||
|
||||
@Accessor("action")
|
||||
void setAction(PlayerActionC2SPacket.Action action);
|
||||
}
|
||||
@@ -6,7 +6,8 @@ import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
@Mixin(PlayerListHeaderS2CPacket.class)
|
||||
public interface PlayerListHeaderS2CPacketMixin {
|
||||
public interface PlayerListHeaderS2CPacketMixin
|
||||
{
|
||||
@Accessor("header")
|
||||
void setHeader(Component header);
|
||||
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.fakes.ServerPlayerEntityInterface;
|
||||
import carpet.helpers.EntityPlayerActionPack;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.server.network.ServerPlayerInteractionManager;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(ServerPlayerEntity.class)
|
||||
public abstract class ServerPlayerEntityMixin implements ServerPlayerEntityInterface
|
||||
{
|
||||
public EntityPlayerActionPack actionPack;
|
||||
public EntityPlayerActionPack getActionPack()
|
||||
{
|
||||
return actionPack;
|
||||
}
|
||||
|
||||
@Inject(method = "<init>", at = @At(value = "RETURN"))
|
||||
private void onServerPlayerEntityContructor(
|
||||
MinecraftServer minecraftServer_1,
|
||||
ServerWorld serverWorld_1,
|
||||
GameProfile gameProfile_1,
|
||||
ServerPlayerInteractionManager serverPlayerInteractionManager_1,
|
||||
CallbackInfo ci)
|
||||
{
|
||||
this.actionPack = new EntityPlayerActionPack((ServerPlayerEntity) (Object) this);
|
||||
}
|
||||
|
||||
@Inject(method = "tick", at = @At(value = "HEAD"))
|
||||
private void onTick(CallbackInfo ci)
|
||||
{
|
||||
actionPack.onUpdate();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
package carpet.patches;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.block.entity.SkullBlockEntity;
|
||||
import net.minecraft.client.network.packet.EntityPositionS2CPacket;
|
||||
import net.minecraft.client.network.packet.EntitySetHeadYawS2CPacket;
|
||||
import net.minecraft.client.network.packet.PlayerListS2CPacket;
|
||||
import net.minecraft.entity.damage.DamageSource;
|
||||
import net.minecraft.network.NetworkSide;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.ServerTask;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.server.network.ServerPlayerInteractionManager;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.world.GameMode;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
import carpet.fakes.ServerPlayerEntityInterface;
|
||||
import carpet.utils.Messenger;
|
||||
|
||||
public class EntityPlayerMPFake extends ServerPlayerEntity
|
||||
{
|
||||
public Runnable fixStartingPosition = () -> {};
|
||||
|
||||
public static EntityPlayerMPFake createFake(String username, MinecraftServer server, double d0, double d1, double d2, double yaw, double pitch, DimensionType dimension, GameMode gamemode)
|
||||
{
|
||||
//prolly half of that crap is not necessary, but it works
|
||||
ServerWorld worldIn = server.getWorld(dimension);
|
||||
ServerPlayerInteractionManager interactionManagerIn = new ServerPlayerInteractionManager(worldIn);
|
||||
GameProfile gameprofile = server.getUserCache().findByName(username);
|
||||
if (gameprofile == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (gameprofile.getProperties().containsKey("textures"))
|
||||
{
|
||||
gameprofile = SkullBlockEntity.loadProperties(gameprofile);
|
||||
}
|
||||
EntityPlayerMPFake instance = new EntityPlayerMPFake(server, worldIn, gameprofile, interactionManagerIn);
|
||||
instance.fixStartingPosition = () -> instance.setPositionAndAngles(d0, d1, d2, (float) yaw, (float) pitch);
|
||||
server.getPlayerManager().onPlayerConnect(new NetworkManagerFake(NetworkSide.SERVERBOUND), instance);
|
||||
if (instance.dimension != dimension) //player was logged in in a different dimension
|
||||
{
|
||||
ServerWorld old_world = server.getWorld(instance.dimension);
|
||||
instance.dimension = dimension;
|
||||
old_world.removePlayer(instance);
|
||||
instance.removed = false;
|
||||
worldIn.spawnEntity(instance);
|
||||
instance.setWorld(worldIn);
|
||||
server.getPlayerManager().sendWorldInfo(instance, old_world);
|
||||
instance.networkHandler.requestTeleport(d0, d1, d2, (float) yaw, (float) pitch);
|
||||
instance.interactionManager.setWorld(worldIn);
|
||||
}
|
||||
instance.setHealth(20.0F);
|
||||
instance.removed = false;
|
||||
instance.networkHandler.requestTeleport(d0, d1, d2, (float) yaw, (float) pitch);
|
||||
instance.stepHeight = 0.6F;
|
||||
interactionManagerIn.setGameMode(gamemode);
|
||||
server.getPlayerManager().sendToDimension(new EntitySetHeadYawS2CPacket(instance, (byte) (instance.headYaw * 256 / 360)), instance.dimension);
|
||||
server.getPlayerManager().sendToDimension(new EntityPositionS2CPacket(instance), instance.dimension);
|
||||
instance.getServerWorld().method_14178().updateCameraPosition(instance);
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static EntityPlayerMPFake createShadow(MinecraftServer server, ServerPlayerEntity player)
|
||||
{
|
||||
player.getServer().getPlayerManager().remove(player);
|
||||
player.networkHandler.disconnect(new TranslatableComponent("multiplayer.disconnect.duplicate_login"));
|
||||
ServerWorld worldIn = server.getWorld(player.dimension);
|
||||
ServerPlayerInteractionManager interactionManagerIn = new ServerPlayerInteractionManager(worldIn);
|
||||
GameProfile gameprofile = player.getGameProfile();
|
||||
EntityPlayerMPFake playerShadow = new EntityPlayerMPFake(server, worldIn, gameprofile, interactionManagerIn);
|
||||
server.getPlayerManager().onPlayerConnect(new NetworkManagerFake(NetworkSide.SERVERBOUND), playerShadow);
|
||||
|
||||
playerShadow.setHealth(player.getHealth());
|
||||
playerShadow.networkHandler.requestTeleport(player.x, player.y, player.z, player.yaw, player.pitch);
|
||||
interactionManagerIn.setGameMode(player.interactionManager.getGameMode());
|
||||
((ServerPlayerEntityInterface) playerShadow).getActionPack().copyFrom(((ServerPlayerEntityInterface) player).getActionPack());
|
||||
playerShadow.stepHeight = 0.6F;
|
||||
|
||||
server.getPlayerManager().sendToDimension(new EntitySetHeadYawS2CPacket(playerShadow, (byte) (player.headYaw * 256 / 360)), playerShadow.dimension);
|
||||
server.getPlayerManager().sendToAll(new PlayerListS2CPacket(PlayerListS2CPacket.Action.ADD_PLAYER, playerShadow));
|
||||
player.getServerWorld().method_14178().updateCameraPosition(playerShadow);
|
||||
return playerShadow;
|
||||
}
|
||||
|
||||
private EntityPlayerMPFake(MinecraftServer server, ServerWorld worldIn, GameProfile profile, ServerPlayerInteractionManager interactionManagerIn)
|
||||
{
|
||||
super(server, worldIn, profile, interactionManagerIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void kill()
|
||||
{
|
||||
this.server.method_18858(new ServerTask(this.server.getTicks(), () -> {
|
||||
this.networkHandler.onDisconnected(Messenger.s("Killed"));
|
||||
}));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick()
|
||||
{
|
||||
if (this.getServer().getTicks() % 10 == 0)
|
||||
{
|
||||
this.networkHandler.syncWithPlayerPosition();
|
||||
this.getServerWorld().method_14178().updateCameraPosition(this);
|
||||
}
|
||||
super.tick();
|
||||
this.method_14226();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeath(DamageSource cause)
|
||||
{
|
||||
super.onDeath(cause);
|
||||
setHealth(20);
|
||||
kill();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package carpet.patches;
|
||||
|
||||
import net.minecraft.network.ClientConnection;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.network.ServerPlayNetworkHandler;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
|
||||
public class NetHandlerPlayServerFake extends ServerPlayNetworkHandler
|
||||
{
|
||||
public NetHandlerPlayServerFake(MinecraftServer server, ClientConnection cc, ServerPlayerEntity playerIn)
|
||||
{
|
||||
super(server, cc, playerIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPacket(final Packet<?> packetIn)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disconnect(Component message)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package carpet.patches;
|
||||
|
||||
import net.minecraft.network.ClientConnection;
|
||||
import net.minecraft.network.NetworkSide;
|
||||
|
||||
public class NetworkManagerFake extends ClientConnection
|
||||
{
|
||||
public NetworkManagerFake(NetworkSide p)
|
||||
{
|
||||
super(p);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disableAutoRead()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleDisconnection()
|
||||
{
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user