use of ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class BlockEtherCompressor method getBlockForce.
@Override
public Vector getBlockForce(World world, BlockPos pos, IBlockState state, Entity shipEntity, double secondsToApply) {
PhysicsWrapperEntity wrapper = (PhysicsWrapperEntity) shipEntity;
PhysicsObject obj = wrapper.wrapping;
IBlockState controllerState = obj.VKChunkCache.getBlockState(pos);
TileEntity worldTile = obj.VKChunkCache.getTileEntity(pos);
if (worldTile == null) {
return null;
}
if (worldTile instanceof TileEntityEtherCompressor) {
TileEntityEtherCompressor engineTile = (TileEntityEtherCompressor) worldTile;
return engineTile.getForceOutput(world, pos, state, wrapper, secondsToApply);
}
return null;
}
use of ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class AirshipSettingsCommand method execute.
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
if (!(sender instanceof EntityPlayer)) {
sender.addChatMessage(new TextComponentString("You need to be a player to do that!"));
return;
}
if (args.length == 0) {
sender.addChatMessage(new TextComponentString(TextFormatting.RED + "Usage: " + getCommandUsage(sender)));
return;
}
EntityPlayer p = (EntityPlayer) sender;
//This method has an @SIDE.CLIENT, and it broke all the commands on servers!
// BlockPos pos = p.rayTrace(p.isCreative() ? 5.0 : 4.5, 1).getBlockPos();
BlockPos pos = rayTraceBothSides(p, p.isCreative() ? 5.0 : 4.5, 1).getBlockPos();
PhysicsWrapperEntity wrapper = ValkyrienWarfareMod.physicsManager.getObjectManagingPos(p.getEntityWorld(), pos);
if (wrapper == null) {
sender.addChatMessage(new TextComponentString("You need to be looking at an airship to do that!"));
return;
}
if (p.entityUniqueID.toString().equals(wrapper.wrapping.creator)) {
if (args[0].equals("transfer")) {
if (args.length == 1) {
return;
}
if (!args[1].isEmpty()) {
EntityPlayer target = server.getPlayerList().getPlayerByUsername(args[1]);
if (target == null) {
p.addChatMessage(new TextComponentString("That player is not online!"));
return;
}
switch(wrapper.wrapping.changeOwner(target)) {
case ERROR_IMPOSSIBLE_STATUS:
p.addChatMessage(new TextComponentString("An error occured, please report to mod devs"));
break;
case ERROR_NEWOWNER_NOT_ENOUGH:
p.addChatMessage(new TextComponentString("That player doesn't have enough free airship slots!"));
break;
case SUCCESS:
p.addChatMessage(new TextComponentString("Success! " + target.getName() + " is the new owner of this airship!"));
break;
case ALREADY_CLAIMED:
p.addChatMessage(new TextComponentString("Airship already claimed"));
break;
}
return;
}
} else if (args[0].equals("allowPlayer")) {
if (args.length == 1) {
StringBuilder result = new StringBuilder("<");
Iterator<String> iter = wrapper.wrapping.allowedUsers.iterator();
while (iter.hasNext()) {
result.append(iter.next() + (iter.hasNext() ? ", " : ">"));
}
p.addChatMessage(new TextComponentString(result.toString()));
return;
}
if (!args[1].isEmpty()) {
EntityPlayer target = server.getPlayerList().getPlayerByUsername(args[1]);
if (target == null) {
p.addChatMessage(new TextComponentString("That player is not online!"));
return;
}
if (target.entityUniqueID.toString().equals(wrapper.wrapping.creator)) {
p.addChatMessage(new TextComponentString("You can't add yourself to your own airship!"));
return;
}
wrapper.wrapping.allowedUsers.add(target.entityUniqueID.toString());
p.addChatMessage(new TextComponentString("Success! " + target.getName() + " can now interact with this airship!"));
return;
}
}
} else {
if (wrapper.wrapping.creator == null || wrapper.wrapping.creator.trim().isEmpty()) {
if (args.length == 1 && args[0].equals("claim")) {
wrapper.wrapping.creator = p.entityUniqueID.toString();
p.addChatMessage(new TextComponentString("You've successfully claimed an airship!"));
return;
}
}
p.addChatMessage(new TextComponentString("You need to be the owner of an airship to change airship settings!"));
}
if (args[0].equals("help")) {
for (String command : completionOptions) {
sender.addChatMessage(new TextComponentString(command));
}
}
sender.addChatMessage(new TextComponentString(TextFormatting.RED + "Usage: " + getCommandUsage(sender)));
}
use of ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class CallRunner method rayTraceBlocksIgnoreShip.
public static RayTraceResult rayTraceBlocksIgnoreShip(World world, Vec3d vec31, Vec3d vec32, boolean stopOnLiquid, boolean ignoreBlockWithoutBoundingBox, boolean returnLastUncollidableBlock, PhysicsWrapperEntity toIgnore) {
RayTraceResult vanillaTrace = world.rayTraceBlocks(vec31, vec32, stopOnLiquid, ignoreBlockWithoutBoundingBox, returnLastUncollidableBlock);
WorldPhysObjectManager physManager = ValkyrienWarfareMod.physicsManager.getManagerForWorld(world);
if (physManager == null) {
return vanillaTrace;
}
Vec3d playerEyesPos = vec31;
Vec3d playerReachVector = vec32.subtract(vec31);
AxisAlignedBB playerRangeBB = new AxisAlignedBB(vec31.xCoord, vec31.yCoord, vec31.zCoord, vec32.xCoord, vec32.yCoord, vec32.zCoord);
List<PhysicsWrapperEntity> nearbyShips = physManager.getNearbyPhysObjects(playerRangeBB);
//Get rid of the Ship that we're not supposed to be RayTracing for
nearbyShips.remove(toIgnore);
boolean changed = false;
double reachDistance = playerReachVector.lengthVector();
double worldResultDistFromPlayer = 420000000D;
if (vanillaTrace != null && vanillaTrace.hitVec != null) {
worldResultDistFromPlayer = vanillaTrace.hitVec.distanceTo(vec31);
}
for (PhysicsWrapperEntity wrapper : nearbyShips) {
playerEyesPos = vec31;
playerReachVector = vec32.subtract(vec31);
// TODO: Re-enable
if (world.isRemote) {
// ValkyrienWarfareMod.proxy.updateShipPartialTicks(wrapper);
}
// Transform the coordinate system for the player eye pos
playerEyesPos = RotationMatrices.applyTransform(wrapper.wrapping.coordTransform.RwToLTransform, playerEyesPos);
playerReachVector = RotationMatrices.applyTransform(wrapper.wrapping.coordTransform.RwToLRotation, playerReachVector);
Vec3d playerEyesReachAdded = playerEyesPos.addVector(playerReachVector.xCoord * reachDistance, playerReachVector.yCoord * reachDistance, playerReachVector.zCoord * reachDistance);
RayTraceResult resultInShip = world.rayTraceBlocks(playerEyesPos, playerEyesReachAdded, stopOnLiquid, ignoreBlockWithoutBoundingBox, returnLastUncollidableBlock);
if (resultInShip != null && resultInShip.hitVec != null && resultInShip.typeOfHit == Type.BLOCK) {
double shipResultDistFromPlayer = resultInShip.hitVec.distanceTo(playerEyesPos);
if (shipResultDistFromPlayer < worldResultDistFromPlayer) {
worldResultDistFromPlayer = shipResultDistFromPlayer;
resultInShip.hitVec = RotationMatrices.applyTransform(wrapper.wrapping.coordTransform.RlToWTransform, resultInShip.hitVec);
vanillaTrace = resultInShip;
}
}
}
return vanillaTrace;
}
use of ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class CallRunner method onGetDistanceSq.
public static double onGetDistanceSq(Entity entity, BlockPos pos) {
double vanilla = entity.getDistanceSq(pos);
if (vanilla < 64.0D) {
return vanilla;
} else {
PhysicsWrapperEntity wrapper = ValkyrienWarfareMod.physicsManager.getObjectManagingPos(entity.worldObj, pos);
if (wrapper != null) {
Vector posVec = new Vector(pos.getX() + .5D, pos.getY() + .5D, pos.getZ() + .5D);
wrapper.wrapping.coordTransform.fromLocalToGlobal(posVec);
posVec.X -= entity.posX;
posVec.Y -= entity.posY;
posVec.Z -= entity.posZ;
if (vanilla > posVec.lengthSq()) {
return posVec.lengthSq();
}
}
}
return vanilla;
}
use of ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class SetShipPilotMessageHandler method onMessage.
@Override
public IMessage onMessage(final SetShipPilotMessage message, final MessageContext ctx) {
IThreadListener mainThread = Minecraft.getMinecraft();
mainThread.addScheduledTask(new Runnable() {
@Override
public void run() {
UUID entityId = message.entityUniqueID;
if (entityId.getLeastSignificantBits() == 0L && entityId.getMostSignificantBits() == 0L) {
ClientPilotingManager.setPilotedWrapperEntity(null);
// System.out.println("got set to null");
} else {
Entity foundEntity = null;
for (Entity entity : Minecraft.getMinecraft().theWorld.getLoadedEntityList()) {
if (entity.entityUniqueID.equals(entityId)) {
ClientPilotingManager.setPilotedWrapperEntity((PhysicsWrapperEntity) entity);
// System.out.println("Found the Pilot on client side");
foundEntity = entity;
}
}
if (foundEntity == null) {
ClientPilotingManager.setPilotedWrapperEntity(null);
}
}
}
});
return null;
}
Aggregations