use of ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class ShipPilotingController method getShipPlayerIsPiloting.
public static PhysicsWrapperEntity getShipPlayerIsPiloting(EntityPlayer pilot) {
World playerWorld = pilot.worldObj;
WorldPhysObjectManager worldManager = ValkyrienWarfareMod.physicsManager.getManagerForWorld(playerWorld);
for (PhysicsWrapperEntity wrapperEntity : worldManager.physicsEntities) {
if (wrapperEntity.wrapping.pilotingController.getPilotEntity() == pilot) {
return wrapperEntity;
}
}
return null;
}
use of ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class ItemSystemLinker method onItemUse.
@Override
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
IBlockState state = worldIn.getBlockState(pos);
Block block = state.getBlock();
NBTTagCompound stackCompound = stack.getTagCompound();
if (stackCompound == null) {
stackCompound = new NBTTagCompound();
stack.setTagCompound(stackCompound);
}
if (block instanceof BlockHovercraftController) {
if (!worldIn.isRemote) {
NBTUtils.writeBlockPosToNBT("controllerPos", pos, stackCompound);
playerIn.addChatMessage(new TextComponentString("ControllerPos set <" + pos.getX() + ":" + pos.getY() + ":" + pos.getZ() + ">"));
} else {
return EnumActionResult.SUCCESS;
}
}
if (block instanceof BlockEtherCompressor) {
if (!worldIn.isRemote) {
BlockPos controllerPos = NBTUtils.readBlockPosFromNBT("controllerPos", stackCompound);
if (controllerPos.equals(BlockPos.ORIGIN)) {
playerIn.addChatMessage(new TextComponentString("No selected Controller"));
} else {
PhysicsWrapperEntity controllerWrapper = ValkyrienWarfareMod.physicsManager.getObjectManagingPos(worldIn, controllerPos);
PhysicsWrapperEntity engineWrapper = ValkyrienWarfareMod.physicsManager.getObjectManagingPos(worldIn, pos);
if (controllerWrapper != engineWrapper) {
playerIn.addChatMessage(new TextComponentString("Controller and Engine are on seperate ships"));
return EnumActionResult.SUCCESS;
}
TileEntity worldTile = worldIn.getTileEntity(pos);
if (worldTile instanceof TileEntityEtherCompressor) {
TileEntityEtherCompressor tileEntity = (TileEntityEtherCompressor) worldTile;
BlockPos gravControllerPos = tileEntity.controllerPos;
if (gravControllerPos.equals(BlockPos.ORIGIN)) {
playerIn.addChatMessage(new TextComponentString("Set Controller To " + controllerPos.toString()));
} else {
playerIn.addChatMessage(new TextComponentString("Replaced controller position from: " + gravControllerPos.toString() + " to: " + controllerPos.toString()));
}
tileEntity.setController(controllerPos);
}
}
} else {
return EnumActionResult.SUCCESS;
}
}
return EnumActionResult.PASS;
}
use of ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class EntityFixMessageHandler method onMessage.
@Override
public IMessage onMessage(final EntityFixMessage message, MessageContext ctx) {
IThreadListener mainThread = Minecraft.getMinecraft();
mainThread.addScheduledTask(new Runnable() {
@Override
public void run() {
PhysicsWrapperEntity toFixOn = (PhysicsWrapperEntity) Minecraft.getMinecraft().theWorld.getEntityByID(message.shipId);
if (toFixOn != null) {
if (message.isFixing) {
toFixOn.wrapping.fixEntityUUID(message.entityUUID, message.localPosition);
} else {
toFixOn.wrapping.removeEntityUUID(message.entityUUID);
}
}
}
});
return null;
}
use of ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class BlockBalloonBurner method getTileEntity.
private BalloonBurnerTileEntity getTileEntity(World world, BlockPos pos, IBlockState state, Entity shipEntity) {
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 BalloonBurnerTileEntity) {
BalloonBurnerTileEntity burnerTile = (BalloonBurnerTileEntity) worldTile;
return burnerTile;
}
return null;
}
use of ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class BlockHovercraftController method onBlockActivated.
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) {
PhysicsWrapperEntity wrapper = ValkyrienWarfareMod.physicsManager.getObjectManagingPos(worldIn, pos);
if (heldItem != null && heldItem.getItem() instanceof ItemSystemLinker) {
return false;
}
if (wrapper != null) {
if (!worldIn.isRemote) {
if (playerIn instanceof EntityPlayerMP) {
EntityPlayerMP player = (EntityPlayerMP) playerIn;
int realWindowId = player.currentWindowId;
// TODO: Fix this, I have to reset the window Id's because there is no container on client side, resulting in the client never changing its window id
player.currentWindowId = player.inventoryContainer.windowId - 1;
player.openGui(ValkyrienWarfareControlMod.instance, ControlGUIEnum.HoverCraftController.ordinal(), worldIn, pos.getX(), pos.getY(), pos.getZ());
player.currentWindowId = realWindowId;
// player.openContainer = playerIn.inventoryContainer;
}
// ModContainer mc = FMLCommonHandler.instance().findContainerFor(ValkyrienWarfareControlMod.instance);
// if (playerIn instanceof EntityPlayerMP && !(playerIn instanceof FakePlayer))
// {
// EntityPlayerMP entityPlayerMP = (EntityPlayerMP) playerIn;
// Container remoteGuiContainer = NetworkRegistry.INSTANCE.getRemoteGuiContainer(mc, entityPlayerMP, ControlGUIEnum.HoverCraftController.ordinal(), worldIn, pos.getX(), pos.getY(), pos.getZ());
// if (remoteGuiContainer != null)
// {
// entityPlayerMP.getNextWindowId();
// entityPlayerMP.closeContainer();
// int windowId = entityPlayerMP.currentWindowId;
// entityPlayerMP.openContainer = remoteGuiContainer;
// entityPlayerMP.openContainer = entityPlayerMP.inventoryContainer;
//// entityPlayerMP.openContainer.windowId = windowId;
//// entityPlayerMP.openContainer.addListener(entityPlayerMP);
// net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.player.PlayerContainerEvent.Open(playerIn, playerIn.openContainer));
// }
// }
}
return true;
}
return false;
}
Aggregations