use of net.minecraft.entity.player.EntityPlayerMP in project SimplyJetpacks by Tonius.
the class Jetpack method flyUser.
public void flyUser(EntityLivingBase user, ItemStack stack, ItemPack item, boolean force) {
if (this.isOn(stack)) {
boolean hoverMode = this.isHoverModeOn(stack);
double hoverSpeed = Config.invertHoverSneakingBehavior == SyncHandler.isDescendKeyDown(user) ? this.speedVerticalHoverSlow : this.speedVerticalHover;
boolean flyKeyDown = force || SyncHandler.isFlyKeyDown(user);
boolean descendKeyDown = SyncHandler.isDescendKeyDown(user);
double currentAccel = this.accelVertical * (user.motionY < 0.3D ? 2.5D : 1.0D);
double currentSpeedVertical = this.speedVertical * (user.isInWater() ? 0.4D : 1.0D);
if (flyKeyDown || hoverMode && !user.onGround) {
if (this.usesFuel) {
item.useFuel(stack, (int) (user.isSprinting() ? Math.round(this.getFuelUsage(stack) * this.sprintFuelModifier) : this.getFuelUsage(stack)), false);
}
if (item.getFuelStored(stack) > 0) {
if (flyKeyDown) {
if (!hoverMode) {
user.motionY = Math.min(user.motionY + currentAccel, currentSpeedVertical);
} else {
if (descendKeyDown) {
user.motionY = Math.min(user.motionY + currentAccel, -this.speedVerticalHoverSlow);
} else {
user.motionY = Math.min(user.motionY + currentAccel, this.speedVerticalHover);
}
}
} else {
user.motionY = Math.min(user.motionY + currentAccel, -hoverSpeed);
}
float speedSideways = (float) (user.isSneaking() ? this.speedSideways * 0.5F : this.speedSideways);
float speedForward = (float) (user.isSprinting() ? speedSideways * this.sprintSpeedModifier : speedSideways);
if (SyncHandler.isForwardKeyDown(user)) {
user.moveFlying(0, speedForward, speedForward);
}
if (SyncHandler.isBackwardKeyDown(user)) {
user.moveFlying(0, -speedSideways, speedSideways * 0.8F);
}
if (SyncHandler.isLeftKeyDown(user)) {
user.moveFlying(speedSideways, 0, speedSideways);
}
if (SyncHandler.isRightKeyDown(user)) {
user.moveFlying(-speedSideways, 0, speedSideways);
}
if (!user.worldObj.isRemote) {
user.fallDistance = 0.0F;
if (user instanceof EntityPlayerMP) {
((EntityPlayerMP) user).playerNetServerHandler.floatingTickCount = 0;
}
if (Config.flammableFluidsExplode) {
if (!(user instanceof EntityPlayer) || !((EntityPlayer) user).capabilities.isCreativeMode) {
int x = Math.round((float) user.posX - 0.5F);
int y = Math.round((float) user.posY);
int z = Math.round((float) user.posZ - 0.5F);
Block fluidBlock = user.worldObj.getBlock(x, y, z);
if (fluidBlock instanceof IFluidBlock && fluidBlock.isFlammable(user.worldObj, x, y, z, ForgeDirection.UNKNOWN)) {
user.worldObj.playSoundAtEntity(user, "mob.ghast.fireball", 2.0F, 1.0F);
user.worldObj.createExplosion(user, user.posX, user.posY, user.posZ, 3.5F, false);
user.attackEntityFrom(new EntityDamageSource("jetpackexplode", user), 100.0F);
}
}
}
}
}
}
}
if (!user.worldObj.isRemote && this.emergencyHoverMode && this.isEHoverOn(stack)) {
if (item.getEnergyStored(stack) > 0 && (!this.isHoverModeOn(stack) || !this.isOn(stack))) {
if (user.posY < -5) {
this.doEHover(stack, user);
} else if (user instanceof EntityPlayer) {
if (!((EntityPlayer) user).capabilities.isCreativeMode && user.fallDistance - 1.2F >= user.getHealth()) {
for (int i = 0; i <= 16; i++) {
int x = Math.round((float) user.posX - 0.5F);
int y = Math.round((float) user.posY) - i;
int z = Math.round((float) user.posZ - 0.5F);
if (!user.worldObj.isAirBlock(x, y, z)) {
this.doEHover(stack, user);
break;
}
}
}
}
}
}
}
use of net.minecraft.entity.player.EntityPlayerMP in project BluePower by Qmunity.
the class ContainerMachineBase method detectAndSendChanges.
/**
* Looks for changes made in the container, sends them to every listener.
*/
@Override
public void detectAndSendChanges() {
super.detectAndSendChanges();
for (Object crafter : crafters) {
ICrafting icrafting = (ICrafting) crafter;
if (backlogSize != machine.getBacklog().size() && icrafting instanceof EntityPlayerMP) {
BPNetworkHandler.INSTANCE.sendTo(new MessageSyncMachineBacklog(machine, machine.getBacklog()), (EntityPlayerMP) icrafting);
}
}
backlogSize = machine.getBacklog().size();
}
use of net.minecraft.entity.player.EntityPlayerMP in project BluePower by Qmunity.
the class TileCircuitDatabase method updateEntity.
@Override
public void updateEntity() {
super.updateEntity();
if (!worldObj.isRemote) {
if (copyInventory.getStackInSlot(0) != null) {
if (curCopyProgress >= 0) {
if (++curCopyProgress > UPLOAD_AND_COPY_TIME) {
curCopyProgress = -1;
if (copy(triggeringPlayer, copyInventory.getStackInSlot(0), copyInventory.getStackInSlot(1), true)) {
copy(triggeringPlayer, copyInventory.getStackInSlot(0), copyInventory.getStackInSlot(1), false);
}
}
}
if (curUploadProgress >= 0) {
if (++curUploadProgress > UPLOAD_AND_COPY_TIME) {
curUploadProgress = -1;
if (selectedShareOption == 1 && triggeringPlayer != null)
BPNetworkHandler.INSTANCE.sendTo(new MessageCircuitDatabaseTemplate(this, copyInventory.getStackInSlot(0)), (EntityPlayerMP) triggeringPlayer);
if (selectedShareOption == 2) {
stackDatabase.saveItemStack(copyInventory.getStackInSlot(0));
BPNetworkHandler.INSTANCE.sendToAll(new MessageSendClientServerTemplates(stackDatabase.loadItemStacks()));
}
selectedShareOption = 0;
}
}
} else {
curCopyProgress = -1;
curUploadProgress = -1;
selectedShareOption = 0;
}
}
}
use of net.minecraft.entity.player.EntityPlayerMP in project LogisticsPipes by RS485.
the class LPChatListener method serverChat.
@SubscribeEvent
public void serverChat(ServerChatEvent event) {
EntityPlayerMP player = event.player;
if (LPChatListener.tasks.containsKey(event.username)) {
if (event.message.startsWith("/")) {
player.addChatComponentMessage(new ChatComponentText(ChatColor.RED + "You need to answer the question, before you can use any other command"));
MainProxy.sendPacketToPlayer(PacketHandler.getPacket(OpenChatGui.class), player);
} else {
if (!event.message.equalsIgnoreCase("true") && !event.message.equalsIgnoreCase("false") && !event.message.equalsIgnoreCase("on") && !event.message.equalsIgnoreCase("off") && !event.message.equalsIgnoreCase("0") && !event.message.equalsIgnoreCase("1") && !event.message.equalsIgnoreCase("no") && !event.message.equalsIgnoreCase("yes")) {
player.addChatComponentMessage(new ChatComponentText(ChatColor.RED + "Not a valid answer."));
player.addChatComponentMessage(new ChatComponentText(ChatColor.AQUA + "Please enter " + ChatColor.RESET + "<" + ChatColor.GREEN + "yes" + ChatColor.RESET + "/" + ChatColor.RED + "no " + ChatColor.RESET + "| " + ChatColor.GREEN + "true" + ChatColor.RESET + "/" + ChatColor.RED + "flase " + ChatColor.RESET + "| " + ChatColor.GREEN + "on" + ChatColor.RESET + "/" + ChatColor.RED + "off " + ChatColor.RESET + "| " + ChatColor.GREEN + "1" + ChatColor.RESET + "/" + ChatColor.RED + "0" + ChatColor.RESET + ">"));
MainProxy.sendPacketToPlayer(PacketHandler.getPacket(OpenChatGui.class), player);
} else {
boolean flag = event.message.equalsIgnoreCase("true") || event.message.equalsIgnoreCase("on") || event.message.equalsIgnoreCase("1") || event.message.equalsIgnoreCase("yes");
if (!handleAnswer(flag, player)) {
player.addChatComponentMessage(new ChatComponentText(ChatColor.RED + "Error: Could not handle answer."));
}
}
}
event.setCanceled(true);
} else if (LPChatListener.morePageDisplays.containsKey(event.username)) {
if (!LPChatListener.morePageDisplays.get(event.username).isTerminated()) {
if (event.message.startsWith("/")) {
player.addChatComponentMessage(new ChatComponentText(ChatColor.RED + "Exit " + ChatColor.AQUA + "PageView" + ChatColor.RED + " first!"));
MainProxy.sendPacketToPlayer(PacketHandler.getPacket(OpenChatGui.class), player);
event.setCanceled(true);
} else {
if (LPChatListener.morePageDisplays.get(event.username).handleChat(event.message, player)) {
event.setCanceled(true);
}
}
}
}
}
use of net.minecraft.entity.player.EntityPlayerMP in project LogisticsPipes by RS485.
the class DummyContainerSlotClick method processPacket.
@Override
public void processPacket(EntityPlayer player) {
if (player instanceof EntityPlayerMP && ((EntityPlayerMP) player).openContainer instanceof DummyContainer) {
DummyContainer container = (DummyContainer) ((EntityPlayerMP) player).openContainer;
Slot slot = (Slot) container.inventorySlots.get(slotId);
if (slot instanceof DummySlot || slot instanceof ColorSlot || slot instanceof FluidSlot) {
container.handleDummyClick(slot, slotId, stack, button, 0, player);
}
}
}
Aggregations