net.minecraft.util.BlockPos Java Examples

The following examples show how to use net.minecraft.util.BlockPos. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MixinBlockLadder.java    From LiquidBounce with GNU General Public License v3.0 6 votes vote down vote up
/**
 * @author CCBlueX
 */
@Overwrite
public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos) {
    final IBlockState iblockstate = worldIn.getBlockState(pos);

    if(iblockstate.getBlock() instanceof BlockLadder) {
        final FastClimb fastClimb = (FastClimb) LiquidBounce.moduleManager.getModule(FastClimb.class);
        final float f = fastClimb.getState() && fastClimb.getModeValue().get().equalsIgnoreCase("AAC3.0.0") ? 0.99f : 0.125f;

        switch(iblockstate.getValue(FACING)) {
            case NORTH:
                this.setBlockBounds(0.0F, 0.0F, 1.0F - f, 1.0F, 1.0F, 1.0F);
                break;
            case SOUTH:
                this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, f);
                break;
            case WEST:
                this.setBlockBounds(1.0F - f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
                break;
            case EAST:
            default:
                this.setBlockBounds(0.0F, 0.0F, 0.0F, f, 1.0F, 1.0F);
        }
    }
}
 
Example #2
Source File: ProphuntESP.java    From LiquidBounce with GNU General Public License v3.0 6 votes vote down vote up
@EventTarget
public void onRender3D(final Render3DEvent event) {
    final Color color = colorRainbow.get() ? ColorUtils.rainbow() : new Color(colorRedValue.get(), colorGreenValue.get(), colorBlueValue.get());

    for(final Entity entity : mc.theWorld.loadedEntityList) {
        if(!(entity instanceof EntityFallingBlock))
            continue;

        RenderUtils.drawEntityBox(entity, color, true);
    }

    synchronized(blocks) {
        final Iterator<Map.Entry<BlockPos, Long>> iterator = blocks.entrySet().iterator();

        while(iterator.hasNext()) {
            final Map.Entry<BlockPos, Long> entry = iterator.next();

            if(System.currentTimeMillis() - entry.getValue() > 2000L) {
                iterator.remove();
                continue;
            }

            RenderUtils.drawBlockBox(entry.getKey(), color, true);
        }
    }
}
 
Example #3
Source File: AACPort.java    From LiquidBounce with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onUpdate() {
    if(!MovementUtils.isMoving())
        return;

    final float f = mc.thePlayer.rotationYaw * 0.017453292F;
    for (double d = 0.2; d <= ((Speed) LiquidBounce.moduleManager.getModule(Speed.class)).portMax.get(); d += 0.2) {
        final double x = mc.thePlayer.posX - MathHelper.sin(f) * d;
        final double z = mc.thePlayer.posZ + MathHelper.cos(f) * d;

        if(mc.thePlayer.posY < (int) mc.thePlayer.posY + 0.5 && !(BlockUtils.getBlock(new BlockPos(x, mc.thePlayer.posY, z)) instanceof BlockAir))
            break;

        mc.thePlayer.sendQueue.addToSendQueue(new C03PacketPlayer.C04PacketPlayerPosition(x, mc.thePlayer.posY, z, true));
    }
}
 
Example #4
Source File: BuildContainerCommands.java    From mobycraft with Apache License 2.0 6 votes vote down vote up
public BlockPos getAverageContainerPosition() {
	double x = 0;
	double y = 0;
	int z = configurationCommands.getStartPos().getZ();

	for (BoxContainer container : boxContainers) {
		BlockPos containerPos = container.getPosition();
		x += containerPos.getX();
		y += containerPos.getY();
	}

	x /= boxContainers.size();
	y /= boxContainers.size();

	return new BlockPos(Math.floor(x), Math.floor(y), z);
}
 
Example #5
Source File: BlockCoordTransporter.java    From ModdingTutorials with GNU General Public License v2.0 6 votes vote down vote up
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
{
	ItemStack stack = playerIn.getCurrentEquippedItem();
	if(stack != null)
	{
		if(stack.getItem() instanceof ItemCoordinateCache)
		{
			if(stack.getItem().hasEffect(stack))
			{
				TileEntityCoordTransporter tect = (TileEntityCoordTransporter) worldIn.getTileEntity(pos);
				stack.stackSize--;
				playerIn.addChatMessage(new ChatComponentText("Added cordinate cache to tile entity"));
			}
		}
	}
	return true;
}
 
Example #6
Source File: ItemCoordinateCache.java    From ModdingTutorials with GNU General Public License v2.0 6 votes vote down vote up
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
{
	if(!playerIn.isSneaking())
	{
		if(stack.getTagCompound() == null)
		{
			stack.setTagCompound(new NBTTagCompound());
		}
		NBTTagCompound nbt = new NBTTagCompound();
		nbt.setInteger("dim", playerIn.dimension);
		nbt.setInteger("posX", pos.getX());
		nbt.setInteger("posY", pos.getY());
		nbt.setInteger("posZ", pos.getZ());
		stack.getTagCompound().setTag("coords", nbt);
		stack.setStackDisplayName(EnumChatFormatting.DARK_PURPLE + "Coordinate Cache");
	}
	return false;
}
 
Example #7
Source File: FWBlock.java    From NOVA-Core with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
	Block blockInstance;

	// see onBlockHarvested for why the harvestedBlocks hack exists
	// this method will be called exactly once after destroying the block
	BlockPosition position = new BlockPosition((World) world, pos.getX(), pos.getY(), pos.getZ());
	if (harvestedBlocks.containsKey(position)) {
		blockInstance = harvestedBlocks.remove(position);
	} else {
		blockInstance = getBlockInstance(world, VectorConverter.instance().toNova(pos));
	}

	Block.DropEvent event = new Block.DropEvent(blockInstance);
	blockInstance.events.publish(event);

	return event.drops
		.stream()
		.map(ItemConverter.instance()::toNative)
		.collect(Collectors.toCollection(ArrayList::new));
}
 
Example #8
Source File: BasicDockerCommands.java    From mobycraft with Apache License 2.0 6 votes vote down vote up
public void showDetailedInfo() throws InterruptedException {
	listCommands.refreshContainerIDMap();

	if (listCommands.getBoxContainerWithID(arg1).equals(null)) {
		return;
	}

	BlockPos senderPos = sender.getPosition();
	sender = sender.getEntityWorld().getClosestPlayer(senderPos.getX(),
			senderPos.getY(), senderPos.getZ(), -1);

	if (listCommands.isStopped(listCommands.getBoxContainerWithID(arg1).getName())) {
		BoxContainer boxContainer = listCommands.getBoxContainerWithID(arg1);
		Container container = listCommands.getFromAllWithName(boxContainer.getName());
		printContainerInfo(boxContainer, container);
		return;
	}

	listCommands.execStatsCommand(arg1, true);
}
 
Example #9
Source File: BlockESP.java    From LiquidBounce with GNU General Public License v3.0 6 votes vote down vote up
@EventTarget
public void onRender3D(Render3DEvent event) {
    synchronized(posList) {
        final Color color = colorRainbow.get() ? ColorUtils.rainbow() : new Color(colorRedValue.get(), colorGreenValue.get(), colorBlueValue.get());

        for(final BlockPos blockPos : posList) {
            switch(modeValue.get().toLowerCase()) {
                case "box":
                    RenderUtils.drawBlockBox(blockPos, color, true);
                    break;
                case "2d":
                    RenderUtils.draw2D(blockPos, color.getRGB(), Color.BLACK.getRGB());
                    break;
            }
        }
    }
}
 
Example #10
Source File: HighJump.java    From LiquidBounce with GNU General Public License v3.0 6 votes vote down vote up
@EventTarget
public void onUpdate(final UpdateEvent event) {
    if(glassValue.get() && !(BlockUtils.getBlock(new BlockPos(mc.thePlayer.posX, mc.thePlayer.posY, mc.thePlayer.posZ)) instanceof BlockPane))
        return;

    switch(modeValue.get().toLowerCase()) {
        case "damage":
            if(mc.thePlayer.hurtTime > 0 && mc.thePlayer.onGround)
                mc.thePlayer.motionY += 0.42F * heightValue.get();
            break;
        case "aacv3":
            if(!mc.thePlayer.onGround) mc.thePlayer.motionY += 0.059D;
            break;
        case "dac":
            if(!mc.thePlayer.onGround) mc.thePlayer.motionY += 0.049999;
            break;
        case "mineplex":
            if(!mc.thePlayer.onGround) MovementUtils.strafe(0.35F);
            break;
    }
}
 
Example #11
Source File: BWBlockTransform.java    From NOVA-Core with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void setWorld(World world) {
	BlockPos pos = blockPos();
	net.minecraft.world.World oldWorld = (net.minecraft.world.World) WorldConverter.instance().toNative(this.world);
	net.minecraft.world.World newWorld = (net.minecraft.world.World) WorldConverter.instance().toNative(world);
	Optional<TileEntity> tileEntity = Optional.ofNullable(oldWorld.getTileEntity(pos));
	Optional<NBTTagCompound> nbt = Optional.empty();
	if (tileEntity.isPresent()) {
		NBTTagCompound compound = new NBTTagCompound();
		tileEntity.get().writeToNBT(compound);
		nbt = Optional.of(compound);
	}
	newWorld.setBlockState(pos, block.blockState());
	oldWorld.removeTileEntity(pos);
	oldWorld.setBlockToAir(pos);
	Optional<TileEntity> newTileEntity = Optional.ofNullable(newWorld.getTileEntity(pos));
	if (newTileEntity.isPresent() && nbt.isPresent()) {
		newTileEntity.get().readFromNBT(nbt.get());
	}
	this.world = world;
}
 
Example #12
Source File: StructureBuilder.java    From mobycraft with Apache License 2.0 6 votes vote down vote up
public static void room(World world, BlockPos start, BlockPos end,
		Block material) {
	fill(world, start, end, material);

	int airStartX = -(start.getX() - end.getX())
			/ Math.abs(start.getX() - end.getX());
	int airEndX = -(end.getX() - start.getX())
			/ Math.abs(end.getX() - start.getX());
	int airStartY = -(start.getY() - end.getY())
			/ Math.abs(start.getY() - end.getY());
	int airEndY = -(end.getY() - start.getY())
			/ Math.abs(end.getY() - start.getY());
	int airStartZ = -(start.getZ() - end.getZ())
			/ Math.abs(start.getZ() - end.getZ());
	int airEndZ = -(end.getZ() - start.getZ())
			/ Math.abs(end.getZ() - start.getZ());

	fill(world, start.add(airStartX, airStartY, airStartZ),
			end.add(airEndX, airEndY, airEndZ), Blocks.air);
}
 
Example #13
Source File: FWBlock.java    From NOVA-Core with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
@SuppressWarnings({"unchecked", "rawtypes"})
public void addCollisionBoxesToList(World world, BlockPos pos, IBlockState state, AxisAlignedBB mask, List list, Entity entity) {
	Block blockInstance = getBlockInstance(world, VectorConverter.instance().toNova(pos));
	blockInstance.components.getOp(Collider.class).ifPresent(
		collider -> {
			Set<Cuboid> boxes = collider.occlusionBoxes.apply(Optional.ofNullable(entity != null ? EntityConverter.instance().toNova(entity) : null));

			list.addAll(
				boxes
					.stream()
					.map(c -> c.add(VectorConverter.instance().toNova(pos)))
					.filter(c -> c.intersects(CuboidConverter.instance().toNova(mask)))
					.map(CuboidConverter.instance()::toNative)
					.collect(Collectors.toList())
			);
		}
	);
}
 
Example #14
Source File: SkyblockAddonsCommand.java    From SkyblockAddons with MIT License 6 votes vote down vote up
public List<String> addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos) {
    if (args.length == 1) {
        if (main.isDevMode()) {
            return getListOfStringsMatchingLastWord(args, "set", "edit", "folder", "dev", "sidebar", "brand");
        } else {
            return getListOfStringsMatchingLastWord(args, "set", "edit", "folder", "dev");
        }

    } else if (args.length == 2) {
        if (main.isDevMode() && args[1].equalsIgnoreCase("sidebar")) {
            return getListOfStringsMatchingLastWord(args, "formatted");
        } else if (args[1].equalsIgnoreCase("set")) {
            return getListOfStringsMatchingLastWord(args, "total", "zealots", "eyes");
        }
    }

    return null;
}
 
Example #15
Source File: MixinBlockLadder.java    From LiquidBounce with GNU General Public License v3.0 6 votes vote down vote up
/**
 * @author CCBlueX
 */
@Overwrite
public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos) {
    final IBlockState iblockstate = worldIn.getBlockState(pos);

    if(iblockstate.getBlock() instanceof BlockLadder) {
        final FastClimb fastClimb = (FastClimb) LiquidBounce.moduleManager.getModule(FastClimb.class);
        final float f = fastClimb.getState() && fastClimb.getModeValue().get().equalsIgnoreCase("AAC3.0.0") ? 0.99f : 0.125f;

        switch(iblockstate.getValue(FACING)) {
            case NORTH:
                this.setBlockBounds(0.0F, 0.0F, 1.0F - f, 1.0F, 1.0F, 1.0F);
                break;
            case SOUTH:
                this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, f);
                break;
            case WEST:
                this.setBlockBounds(1.0F - f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
                break;
            case EAST:
            default:
                this.setBlockBounds(0.0F, 0.0F, 0.0F, f, 1.0F, 1.0F);
        }
    }
}
 
Example #16
Source File: EntityChaosMonkey.java    From mobycraft with Apache License 2.0 6 votes vote down vote up
/**
 * Checks if the entity's current position is a valid location to spawn this
 * entity.
 */
public boolean getCanSpawnHere() {
	BlockPos blockpos = new BlockPos(this.posX,
			this.getEntityBoundingBox().minY, this.posZ);

	if (blockpos.getY() >= this.worldObj.getSeaLevel()) {
		return false;
	} else {
		int i = this.worldObj.getLightFromNeighbors(blockpos);
		int j = 4;

		if (this.isDateAroundHalloween(this.worldObj.getCurrentDate())) {
			j = 7;
		} else if (this.rand.nextBoolean()) {
			return false;
		}

		return i <= this.rand.nextInt(j) && super.getCanSpawnHere();
	}
}
 
Example #17
Source File: AnimationHandler.java    From Hyperium with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void setPosition(RenderChunk rc, BlockPos bp) {
    if (!ChunkAnimatorConfig.enabled) return;
    if (Minecraft.getMinecraft().thePlayer != null) {
        boolean flag = true;
        BlockPos zeroedPlayerPosition = Minecraft.getMinecraft().thePlayer.getPosition();
        zeroedPlayerPosition = zeroedPlayerPosition.add(0, -zeroedPlayerPosition.getY(), 0);
        BlockPos zeroedCenteredChunkPos = bp.add(8, -bp.getY(), 8);

        if (ChunkAnimatorConfig.disableAroundPlayer) {
            flag = zeroedPlayerPosition.distanceSq(zeroedCenteredChunkPos) > (64 * 64);
        }

        if (flag) {
            EnumFacing chunkFacing = null;

            if (ChunkAnimatorConfig.mode.equals("From sides")) {
                Vec3i dif = zeroedPlayerPosition.subtract(zeroedCenteredChunkPos);
                int difX = Math.abs(dif.getX());
                int difZ = Math.abs(dif.getZ());
                chunkFacing = getFacing(dif, difX, difZ);
            }

            AnimationData animationData = new AnimationData(-1L, chunkFacing);
            timeStamps.put(rc, animationData);
        }
    }
}
 
Example #18
Source File: WorldExtension.java    From CodeChickenLib with GNU Lesser General Public License v2.1 5 votes vote down vote up
public ChunkExtension getChunkExtension(int chunkXPos, int chunkZPos)
{
    if(!world.isBlockLoaded(new BlockPos(chunkXPos<<4, 128, chunkZPos<<4)))
        return null;
    
    return chunkMap.get(world.getChunkFromChunkCoords(chunkXPos, chunkZPos));
}
 
Example #19
Source File: FWBlock.java    From NOVA-Core with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public int getLightValue(IBlockAccess access, BlockPos pos) {
	Block blockInstance = getBlockInstance(access, VectorConverter.instance().toNova(pos));
	Optional<LightEmitter> opEmitter = blockInstance.components.getOp(LightEmitter.class);

	if (opEmitter.isPresent()) {
		return (int) MathUtil.clamp(Math.round(opEmitter.get().emittedLevel.getAsDouble() * 15), 0, 15);
	} else {
		return 0;
	}
}
 
Example #20
Source File: MixinGuiOverlayDebug.java    From Hyperium with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void renderOldDebugInfoLeft() {
    FontRenderer fontRendererObj = mc.fontRendererObj;

    fontRendererObj.drawStringWithShadow("Minecraft 1.8.9 (" + Minecraft.getDebugFPS() + " fps, " +
        RenderChunk.renderChunksUpdated + " chunk updates)", 2, 2, -1);
    fontRendererObj.drawStringWithShadow(mc.renderGlobal.getDebugInfoRenders(), 2, 12, -1);
    fontRendererObj.drawStringWithShadow(mc.renderGlobal.getDebugInfoEntities(), 2, 22, -1);
    fontRendererObj.drawStringWithShadow("P: " + mc.effectRenderer.getStatistics() + ". T: " + mc.theWorld.getDebugLoadedEntities(), 2, 32, -1);
    fontRendererObj.drawStringWithShadow(mc.theWorld.getProviderName(), 2, 42, -1);

    int posX = MathHelper.floor_double(mc.thePlayer.posX);
    int posY = MathHelper.floor_double(mc.thePlayer.posY);
    int posZ = MathHelper.floor_double(mc.thePlayer.posZ);
    fontRendererObj.drawStringWithShadow(String.format("x: %.5f (%d) // c: %d (%d)", mc.thePlayer.posX, posX, posX >> 4, posX & 15), 2, 64, -1);
    fontRendererObj.drawStringWithShadow(String.format("y: %.3f (feet pos, %.3f eyes pos)",
        mc.thePlayer.getEntityBoundingBox().minY, mc.thePlayer.posY), 2, 72, -1);
    Entity entity = mc.getRenderViewEntity();
    EnumFacing enumfacing = entity.getHorizontalFacing();
    fontRendererObj.drawStringWithShadow(String.format("z: %.5f (%d) // c: %d (%d)", mc.thePlayer.posZ, posZ, posZ >> 4, posZ & 15), 2, 80, -1);
    int yaw = MathHelper.floor_double((double) (mc.thePlayer.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
    fontRendererObj.drawStringWithShadow("f: " + yaw + " (" + enumfacing + ") / " +
        MathHelper.wrapAngleTo180_float(mc.thePlayer.rotationYaw), 2, 88, -1);
    if (mc.theWorld != null && !mc.theWorld.isAirBlock(new BlockPos(posX, posY, posZ))) {
        Chunk chunk = mc.theWorld.getChunkFromBlockCoords(new BlockPos(posX, posY, posZ));
        fontRendererObj.drawStringWithShadow("lc: " + (chunk.getTopFilledSegment() + 15) + " b: " +
                chunk.getBiome(new BlockPos(posX & 15, 64, posZ & 15), mc.theWorld.getWorldChunkManager()).biomeName + " bl: "
                + chunk.getBlockLightOpacity(new BlockPos(posX & 15, posY, posZ & 15)) + " sl: " + chunk.getBlockLightOpacity(
            new BlockPos(posX & 15, posY, posZ & 15)) + " rl: " + chunk.getBlockLightOpacity(new BlockPos(posX & 15, posY, posZ & 15)),
            2, 96, -1);
    }

    fontRendererObj.drawStringWithShadow(String.format("ws: %.3f, fs: %.3f, g: %b, fl: %d", mc.thePlayer.capabilities.getWalkSpeed(),
        mc.thePlayer.capabilities.getFlySpeed(), mc.thePlayer.onGround, mc.theWorld.getHeight()), 2, 104, -1);
    if (mc.entityRenderer != null && mc.entityRenderer.isShaderActive()) {
        fontRendererObj.drawStringWithShadow(String.format("shader: %s", mc.entityRenderer.getShaderGroup().getShaderGroupName()), 2, 112, -1);
    }
}
 
Example #21
Source File: PlayerSwingEvent.java    From Hyperium with GNU Lesser General Public License v3.0 5 votes vote down vote up
public PlayerSwingEvent(@NotNull UUID player, @NotNull Vec3 posVec, @NotNull Vec3 lookVec, @NotNull BlockPos pos) {
    Preconditions.checkNotNull(player, "player");
    Preconditions.checkNotNull(posVec, "posVec");
    Preconditions.checkNotNull(lookVec, "lookVec");
    Preconditions.checkNotNull(pos, "pos");

    this.player = player;
    this.posVec = posVec;
    this.lookVec = lookVec;
    this.pos = pos;
}
 
Example #22
Source File: MixinBlock.java    From LiquidBounce with GNU General Public License v3.0 5 votes vote down vote up
/**
 * @author CCBlueX
 */
@Overwrite
public void addCollisionBoxesToList(World worldIn, BlockPos pos, IBlockState state, AxisAlignedBB mask, List<AxisAlignedBB> list, Entity collidingEntity) {
    AxisAlignedBB axisalignedbb = this.getCollisionBoundingBox(worldIn, pos, state);
    BlockBBEvent blockBBEvent = new BlockBBEvent(pos, blockState.getBlock(), axisalignedbb);
    LiquidBounce.eventManager.callEvent(blockBBEvent);
    axisalignedbb = blockBBEvent.getBoundingBox();
    if(axisalignedbb != null && mask.intersectsWith(axisalignedbb))
        list.add(axisalignedbb);
}
 
Example #23
Source File: FWBlock.java    From NOVA-Core with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public boolean isReplaceable(World world, BlockPos pos) {
	return getBlockInstance(world, VectorConverter.instance().toNova(pos))
		.components.getOp(BlockProperty.Replaceable.class)
		.filter(BlockProperty.Replaceable::isReplaceable)
		.isPresent();
}
 
Example #24
Source File: EntityChaosMonkey.java    From mobycraft with Apache License 2.0 5 votes vote down vote up
protected void updateAITasks() {
	super.updateAITasks();
	{
		if (this.spawnPosition != null
				&& (!this.worldObj.isAirBlock(this.spawnPosition) || this.spawnPosition
						.getY() < 1)) {
			this.spawnPosition = null;
		}

		if (this.spawnPosition == null
				|| this.rand.nextInt(30) == 0
				|| this.spawnPosition.distanceSq(
						(double) ((int) this.posX),
						(double) ((int) this.posY),
						(double) ((int) this.posZ)) < 4.0D) {
			this.spawnPosition = new BlockPos((int) this.posX
					+ this.rand.nextInt(7) - this.rand.nextInt(7),
					(int) this.posY + this.rand.nextInt(6) - 2,
					(int) this.posZ + this.rand.nextInt(7)
							- this.rand.nextInt(7));
		}

		double d0 = (double) this.spawnPosition.getX() + 0.5D - this.posX;
		double d1 = (double) this.spawnPosition.getY() + 0.1D - this.posY;
		double d2 = (double) this.spawnPosition.getZ() + 0.5D - this.posZ;
		this.motionX += (Math.signum(d0) * 0.5D - this.motionX) * 0.10000000149011612D;
		this.motionY += (Math.signum(d1) * 0.699999988079071D - this.motionY) * 0.10000000149011612D;
		this.motionZ += (Math.signum(d2) * 0.5D - this.motionZ) * 0.10000000149011612D;
		float f = (float) (MathHelper.atan2(this.motionZ, this.motionX) * 180.0D / Math.PI) - 90.0F;
		float f1 = MathHelper.wrapAngleTo180_float(f - this.rotationYaw);
		this.moveForward = 0.5F;
		this.rotationYaw += f1;
	}
}
 
Example #25
Source File: ConfigurationCommands.java    From mobycraft with Apache License 2.0 5 votes vote down vote up
public void setStartPos() {
	BlockPos position = sender.getPosition();
	configProperties.getStartPosProperty().setValue((int) Math.floor(position.getX()) + ", "
			+ (int) Math.floor(position.getY()) + ", " + (int) Math.floor(position.getZ()));
	Mobycraft.config.save();
	sendConfirmMessage("Set start position for building containers to ("
			+ getConfigProperties().getStartPosProperty().getString() + ").");
	buildCommands.updateContainers(false);
}
 
Example #26
Source File: RayTracer.java    From CodeChickenLib with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static MovingObjectPosition retraceBlock(World world, EntityPlayer player, BlockPos pos) {
    IBlockState b = world.getBlockState(pos);
    Vec3 headVec = getCorrectedHeadVec(player);
    Vec3 lookVec = player.getLook(1.0F);
    double reach = getBlockReachDistance(player);
    Vec3 endVec = headVec.addVector(lookVec.xCoord * reach, lookVec.yCoord * reach, lookVec.zCoord * reach);
    return b.getBlock().collisionRayTrace(world, pos, headVec, endVec);
}
 
Example #27
Source File: VectorConverterTest.java    From NOVA-Core with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Test
public void testToNova() {
	for (int x = -1; x <= 1; x++)
		for (int y = -1; y <= 1; y++)
			for (int z = -1; z <= 1; z++)
				assertThat(converter.toNova(new BlockPos(x, y, z))).isEqualTo(new Vector3D(x, y, z));

	for (int x = -1; x <= 1; x++)
		for (int y = -1; y <= 1; y++)
			for (int z = -1; z <= 1; z++)
				assertThat(converter.toNova(new Vec3(x, y, z))).isEqualTo(new Vector3D(x, y, z));
}
 
Example #28
Source File: MixinBlockModelRenderer.java    From LiquidBounce with GNU General Public License v3.0 5 votes vote down vote up
@Inject(method = "renderModelStandard", at = @At("HEAD"), cancellable = true)
private void renderModelStandard(IBlockAccess blockAccessIn, IBakedModel modelIn, Block blockIn, BlockPos blockPosIn, WorldRenderer worldRendererIn, boolean checkSides, final CallbackInfoReturnable<Boolean> booleanCallbackInfoReturnable) {
    final XRay xray = (XRay) LiquidBounce.moduleManager.getModule(XRay.class);

    if (xray.getState() && !xray.getXrayBlocks().contains(blockIn))
        booleanCallbackInfoReturnable.setReturnValue(false);
}
 
Example #29
Source File: MixinBlockAnvil.java    From LiquidBounce with GNU General Public License v3.0 5 votes vote down vote up
@Inject(method = "onBlockPlaced", cancellable = true, at = @At("HEAD"))
private void injectAnvilCrashFix(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer, CallbackInfoReturnable<IBlockState> cir) {
    if (((meta >> 2) & ~0x3) != 0) {
        cir.setReturnValue(super.onBlockPlaced(worldIn, pos, facing, hitX, hitY, hitZ, meta, placer).withProperty(BlockAnvil.FACING, placer.getHorizontalFacing().rotateY()).withProperty(BlockAnvil.DAMAGE, 2));
        cir.cancel();
    }
}
 
Example #30
Source File: FWBlock.java    From NOVA-Core with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void setBlockBoundsBasedOnState(IBlockAccess access, BlockPos pos) {
	Block blockInstance = getBlockInstance(access, VectorConverter.instance().toNova(pos));
	if (blockInstance.components.has(Collider.class)) {
		Cuboid cuboid = blockInstance.components.get(Collider.class).boundingBox.get();
		setBlockBounds((float) cuboid.min.getX(), (float) cuboid.min.getY(), (float) cuboid.min.getZ(), (float) cuboid.max.getX(), (float) cuboid.max.getY(), (float) cuboid.max.getZ());
	}
}