use of net.minecraft.entity.player.EntityPlayer in project LogisticsPipes by RS485.
the class RenderTickHandler method renderWorldLast.
//private static final ResourceLocation TEXTURE = new ResourceLocation("logisticspipes", "textures/blocks/pipes/White.png");
@SubscribeEvent
public void renderWorldLast(RenderWorldLastEvent worldEvent) {
if (LogisticsRenderPipe.config.isUseNewRenderer()) {
if (displayPipeGhost()) {
Minecraft mc = Minecraft.getMinecraft();
EntityPlayer player = mc.thePlayer;
MovingObjectPosition box = mc.objectMouseOver;
if (box != null && box.typeOfHit == MovingObjectType.BLOCK) {
ItemStack stack = FMLClientHandler.instance().getClient().thePlayer.inventory.mainInventory[FMLClientHandler.instance().getClient().thePlayer.inventory.currentItem];
CoreUnroutedPipe pipe = ((ItemLogisticsPipe) stack.getItem()).getDummyPipe();
int i = box.blockX;
int j = box.blockY;
int k = box.blockZ;
World world = player.getEntityWorld();
int side = box.sideHit;
Block worldBlock = world.getBlock(i, j, k);
if (worldBlock == Blocks.snow) {
side = 1;
} else if (worldBlock != Blocks.vine && worldBlock != Blocks.tallgrass && worldBlock != Blocks.deadbush && (worldBlock == null || !worldBlock.isReplaceable(world, i, j, k))) {
if (side == 0) {
j--;
}
if (side == 1) {
j++;
}
if (side == 2) {
k--;
}
if (side == 3) {
k++;
}
if (side == 4) {
i--;
}
if (side == 5) {
i++;
}
}
double xCoord = i;
double yCoord = j;
double zCoord = k;
boolean isFreeSpace = true;
ITubeOrientation orientation = null;
if (pipe instanceof CoreMultiBlockPipe) {
CoreMultiBlockPipe multipipe = (CoreMultiBlockPipe) pipe;
DoubleCoordinates placeAt = new DoubleCoordinates(xCoord, yCoord, zCoord);
LPPositionSet<DoubleCoordinatesType<CoreMultiBlockPipe.SubBlockTypeForShare>> globalPos = new LPPositionSet<>(DoubleCoordinatesType.class);
globalPos.add(new DoubleCoordinatesType<>(placeAt, CoreMultiBlockPipe.SubBlockTypeForShare.NON_SHARE));
LPPositionSet<DoubleCoordinatesType<CoreMultiBlockPipe.SubBlockTypeForShare>> positions = multipipe.getSubBlocks();
orientation = multipipe.getTubeOrientation(player, (int) xCoord, (int) zCoord);
if (orientation != null) {
orientation.rotatePositions(positions);
positions.stream().map(pos -> pos.add(placeAt)).forEach(globalPos::add);
globalPos.addToAll(orientation.getOffset());
for (DoubleCoordinatesType<CoreMultiBlockPipe.SubBlockTypeForShare> pos : globalPos) {
if (!player.getEntityWorld().canPlaceEntityOnSide(LogisticsPipes.LogisticsPipeBlock, pos.getXInt(), pos.getYInt(), pos.getZInt(), false, side, player, stack)) {
TileEntity tile = player.getEntityWorld().getTileEntity(pos.getXInt(), pos.getYInt(), pos.getZInt());
boolean canPlace = false;
if (tile instanceof LogisticsTileGenericSubMultiBlock) {
if (CoreMultiBlockPipe.canShare(((LogisticsTileGenericSubMultiBlock) tile).getSubTypes(), pos.getType())) {
canPlace = true;
}
}
if (!canPlace) {
isFreeSpace = false;
break;
}
}
}
} else {
return;
}
} else {
if (!player.getEntityWorld().canPlaceEntityOnSide(LogisticsPipes.LogisticsPipeBlock, i, j, k, false, side, player, stack)) {
isFreeSpace = false;
}
}
if (isFreeSpace) {
GL11.glPushMatrix();
double x;
double y;
double z;
if (orientation != null) {
x = xCoord + orientation.getOffset().getXInt() - player.prevPosX - ((player.posX - player.prevPosX) * worldEvent.partialTicks);
y = yCoord + orientation.getOffset().getYInt() - player.prevPosY - ((player.posY - player.prevPosY) * worldEvent.partialTicks);
z = zCoord + orientation.getOffset().getZInt() - player.prevPosZ - ((player.posZ - player.prevPosZ) * worldEvent.partialTicks);
} else {
x = xCoord - player.prevPosX - ((player.posX - player.prevPosX) * worldEvent.partialTicks);
y = yCoord - player.prevPosY - ((player.posY - player.prevPosY) * worldEvent.partialTicks);
z = zCoord - player.prevPosZ - ((player.posZ - player.prevPosZ) * worldEvent.partialTicks);
}
GL11.glTranslated(x + 0.001, y + 0.001, z + 0.001);
GL11.glEnable(GL11.GL_BLEND);
//GL11.glDepthMask(false);
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
mc.renderEngine.bindTexture(new ResourceLocation("logisticspipes", "textures/blocks/pipes/White.png"));
Tessellator tess = Tessellator.instance;
CCRenderState.reset();
CCRenderState.useNormals = true;
CCRenderState.alphaOverride = 0xff;
GL11.glEnable(GL11.GL_TEXTURE_2D);
CCRenderState.alphaOverride = 0x50;
CCRenderState.useNormals = true;
CCRenderState.hasBrightness = false;
CCRenderState.startDrawing();
pipe.getHighlightRenderer().renderHighlight(orientation);
tess.draw();
CCRenderState.alphaOverride = 0xff;
GL11.glDisable(GL11.GL_BLEND);
GL11.glDepthMask(true);
GL11.glPopMatrix();
}
}
}
}
}
use of net.minecraft.entity.player.EntityPlayer in project SimplyJetpacks by Tonius.
the class RenderUtils method getArmorModel.
public static ModelBiped getArmorModel(PackBase pack, EntityLivingBase entity) {
ModelBiped model = null;
switch(pack.armorModel) {
case JETPACK:
model = ModelJetpack.INSTANCE;
break;
case FLUX_PACK:
model = ModelFluxPack.INSTANCE;
default:
}
if (model == null) {
return null;
}
model.isSneak = entity.isSneaking();
model.isRiding = entity.isRiding();
model.isChild = entity.isChild();
model.heldItemRight = entity.getEquipmentInSlot(0) != null ? 1 : 0;
if (entity instanceof EntityPlayer) {
model.aimedBow = ((EntityPlayer) entity).getItemInUseDuration() > 2;
}
return model;
}
use of net.minecraft.entity.player.EntityPlayer 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.EntityPlayer in project SimplyJetpacks by Tonius.
the class JetpackPotato method flyUser.
@Override
public void flyUser(EntityLivingBase user, ItemStack stack, ItemPack item, boolean force) {
if (this.isFired(stack)) {
super.flyUser(user, stack, item, true);
user.rotationYawHead += 37.5F;
if (item.getFuelStored(stack) <= 0) {
user.setCurrentItemOrArmor(3, null);
if (!user.worldObj.isRemote) {
user.worldObj.createExplosion(user, user.posX, user.posY, user.posZ, 4.0F, false);
for (int i = 0; i <= MathHelper.RANDOM.nextInt(3) + 4; i++) {
ItemStack firework = FireworksHelper.getRandomFireworks(0, 1, MathHelper.RANDOM.nextInt(6) + 1, 1);
user.worldObj.spawnEntityInWorld(new EntityFireworkRocket(user.worldObj, user.posX + MathHelper.RANDOM.nextDouble() * 6.0D - 3.0D, user.posY, user.posZ + MathHelper.RANDOM.nextDouble() * 6.0D - 3.0D, firework));
}
user.attackEntityFrom(new EntityDamageSource("jetpackpotato", user), 100.0F);
if (user instanceof EntityPlayer) {
user.dropItem(Items.baked_potato, 1);
}
}
}
} else {
if (force || SyncHandler.isFlyKeyDown(user)) {
if (this.isTimerSet(stack)) {
this.decrementTimer(stack, user);
} else {
this.setTimer(stack, 50);
}
}
}
}
use of net.minecraft.entity.player.EntityPlayer in project malmo by Microsoft.
the class MovingTargetDecoratorImplementation method pinchedByPlayer.
private boolean pinchedByPlayer(World world) {
for (BlockPos bp : this.path) {
//Block b = world.getBlockState(bp).getBlock();
//AxisAlignedBB aabb = b.getCollisionBoundingBox(world, bp, b.getDefaultState());
//aabb.expand(0, 1, 0);
BlockPos bp2 = new BlockPos(bp.getX() + 1, bp.getY() + 2, bp.getZ() + 1);
AxisAlignedBB aabb = new AxisAlignedBB(bp, bp2);
List<Entity> entities = world.getEntitiesWithinAABBExcludingEntity(null, aabb);
for (Entity ent : entities) if (ent instanceof EntityPlayer)
return true;
}
return false;
}
Aggregations