net.minecraft.util.MovingObjectPosition Java Examples

The following examples show how to use net.minecraft.util.MovingObjectPosition. 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: General.java    From Chisel with GNU General Public License v2.0 6 votes vote down vote up
public static MovingObjectPosition getMovingObjectPositionFromPlayer(World par1World, EntityPlayer par2EntityPlayer, boolean par3)
{
    float var4 = 1.0F;
    float var5 = par2EntityPlayer.prevRotationPitch + (par2EntityPlayer.rotationPitch - par2EntityPlayer.prevRotationPitch) * var4;
    float var6 = par2EntityPlayer.prevRotationYaw + (par2EntityPlayer.rotationYaw - par2EntityPlayer.prevRotationYaw) * var4;
    double var7 = par2EntityPlayer.prevPosX + (par2EntityPlayer.posX - par2EntityPlayer.prevPosX) * var4;
    double var9 = par2EntityPlayer.prevPosY + (par2EntityPlayer.posY - par2EntityPlayer.prevPosY) * var4 + 1.62D - par2EntityPlayer.yOffset;
    double var11 = par2EntityPlayer.prevPosZ + (par2EntityPlayer.posZ - par2EntityPlayer.prevPosZ) * var4;
    //TODO- 1.7.10 fix?
    Vec3 var13 = Vec3.createVectorHelper(var7, var9, var11);
    float var14 = MathHelper.cos(-var6 * 0.017453292F - (float) Math.PI);
    float var15 = MathHelper.sin(-var6 * 0.017453292F - (float) Math.PI);
    float var16 = -MathHelper.cos(-var5 * 0.017453292F);
    float var17 = MathHelper.sin(-var5 * 0.017453292F);
    float var18 = var15 * var16;
    float var20 = var14 * var16;
    double var21 = 5.0D;

    if(par2EntityPlayer instanceof EntityPlayerMP)
    {
        var21 = ((EntityPlayerMP) par2EntityPlayer).theItemInWorldManager.getBlockReachDistance();
    }

    Vec3 var23 = var13.addVector(var18 * var21, var17 * var21, var20 * var21);
    return par1World.rayTraceBlocks(var13, var23, par3);
}
 
Example #2
Source File: ReachDisplay.java    From Hyperium with GNU Lesser General Public License v3.0 6 votes vote down vote up
@InvokeEvent
public void attacc(PlayerAttackEntityEvent entityEvent) {
    if (!Settings.SHOW_HIT_DISTANCES) return;
    if (!(entityEvent.getEntity() instanceof EntityLivingBase)) return;
    if (((EntityLivingBase) entityEvent.getEntity()).hurtTime > 0) return;
    if (locked) return;

    locked = true;
    EntityPlayerSP entity = Minecraft.getMinecraft().thePlayer;
    double d0 = 6;
    Vec3 vec3 = entity.getPositionEyes(0.0F);
    Vec3 vec31 = entity.getLook(0.0F);
    Vec3 vec32 = vec3.addVector(vec31.xCoord * d0, vec31.yCoord * d0, vec31.zCoord * d0);
    Entity entity1 = entityEvent.getEntity();
    float f1 = .1F;
    AxisAlignedBB axisalignedbb = entity1.getEntityBoundingBox().expand(f1, f1, f1);
    MovingObjectPosition movingobjectposition = axisalignedbb.calculateIntercept(vec3, vec32);
    if (movingobjectposition == null) return;
    Vec3 vec33 = movingobjectposition.hitVec;
    hits.add(new Hit(vec33, dis));

}
 
Example #3
Source File: MixinMinecraft.java    From LiquidBounce with GNU General Public License v3.0 6 votes vote down vote up
/**
 * @author CCBlueX
 */
@Overwrite
private void sendClickBlockToController(boolean leftClick) {
    if(!leftClick)
        this.leftClickCounter = 0;

    if (this.leftClickCounter <= 0 && (!this.thePlayer.isUsingItem() || LiquidBounce.moduleManager.getModule(MultiActions.class).getState())) {
        if(leftClick && this.objectMouseOver != null && this.objectMouseOver.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
            BlockPos blockPos = this.objectMouseOver.getBlockPos();

            if(this.leftClickCounter == 0)
                LiquidBounce.eventManager.callEvent(new ClickBlockEvent(blockPos, this.objectMouseOver.sideHit));


            if(this.theWorld.getBlockState(blockPos).getBlock().getMaterial() != Material.air && this.playerController.onPlayerDamageBlock(blockPos, this.objectMouseOver.sideHit)) {
                this.effectRenderer.addBlockHitEffects(blockPos, this.objectMouseOver.sideHit);
                this.thePlayer.swingItem();
            }
        } else if (!LiquidBounce.moduleManager.getModule(AbortBreaking.class).getState()) {
            this.playerController.resetBlockRemoving();
        }
    }
}
 
Example #4
Source File: MixinMinecraft.java    From LiquidBounce with GNU General Public License v3.0 6 votes vote down vote up
/**
 * @author CCBlueX
 */
@Overwrite
private void sendClickBlockToController(boolean leftClick) {
    if(!leftClick)
        this.leftClickCounter = 0;

    if (this.leftClickCounter <= 0 && (!this.thePlayer.isUsingItem() || LiquidBounce.moduleManager.getModule(MultiActions.class).getState())) {
        if(leftClick && this.objectMouseOver != null && this.objectMouseOver.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
            BlockPos blockPos = this.objectMouseOver.getBlockPos();

            if(this.leftClickCounter == 0)
                LiquidBounce.eventManager.callEvent(new ClickBlockEvent(blockPos, this.objectMouseOver.sideHit));


            if(this.theWorld.getBlockState(blockPos).getBlock().getMaterial() != Material.air && this.playerController.onPlayerDamageBlock(blockPos, this.objectMouseOver.sideHit)) {
                this.effectRenderer.addBlockHitEffects(blockPos, this.objectMouseOver.sideHit);
                this.thePlayer.swingItem();
            }
        } else if (!LiquidBounce.moduleManager.getModule(AbortBreaking.class).getState()) {
            this.playerController.resetBlockRemoving();
        }
    }
}
 
Example #5
Source File: DragonsFuck.java    From ehacks-pro with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onMouse(MouseEvent event) {
    MovingObjectPosition mop = Wrapper.INSTANCE.mc().objectMouseOver;
    if (mop.sideHit == -1) {
        return;
    }
    if (Mouse.isButtonDown(1)) {
        TileEntity entity = Wrapper.INSTANCE.world().getTileEntity(mop.blockX, mop.blockY, mop.blockZ);
        try {
            if (mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK && entity != null && Class.forName("eu.thesociety.DragonbornSR.DragonsRadioMod.Block.TileEntity.TileEntityRadio").isInstance(entity)) {
                Wrapper.INSTANCE.mc().displayGuiScreen((GuiScreen) Class.forName("eu.thesociety.DragonbornSR.DragonsRadioMod.Block.Gui.NGuiRadio").getConstructor(Class.forName("eu.thesociety.DragonbornSR.DragonsRadioMod.Block.TileEntity.TileEntityRadio")).newInstance(entity));
                InteropUtils.log("Gui opened", this);
                if (event.isCancelable()) {
                    event.setCanceled(true);
                }
            }
        } catch (Exception ex) {
            InteropUtils.log("&cError", this);
        }
    }
}
 
Example #6
Source File: WirelessPart.java    From WirelessRedstone with MIT License 6 votes vote down vote up
@Override
public boolean activate(EntityPlayer player, MovingObjectPosition hit, ItemStack held) {
    if (hit.sideHit == (side() ^ 1) && player.isSneaking()) {
        int r = rotation();
        setRotation((r + 1) % 4);
        if (!tile().canReplacePart(this, this)) {
            setRotation(r);
            return false;
        }

        if (!world().isRemote) {
            updateChange();
            onPartChanged(this);
        } else {
            setRotation(r);
        }
        return true;
    }
    return false;
}
 
Example #7
Source File: ExtendedDestroyer.java    From ehacks-pro with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onMouse(MouseEvent event) {
    try {
        MovingObjectPosition position = Wrapper.INSTANCE.mc().objectMouseOver;
        boolean nowState = Mouse.isButtonDown(0);
        if (position.sideHit != -1 && nowState && !prevState) {
            ByteBuf buf = Unpooled.buffer(0);
            buf.writeByte(14);
            buf.writeInt(position.blockX);
            buf.writeInt(position.blockY);
            buf.writeInt(position.blockZ);
            C17PacketCustomPayload packet = new C17PacketCustomPayload("cfm", buf);
            Wrapper.INSTANCE.player().sendQueue.addToSendQueue(packet);
        }
        prevState = nowState;
    } catch (Exception ignored) {

    }
}
 
Example #8
Source File: ContainerClear.java    From ehacks-pro with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onModuleEnabled() {
    try {
        Class.forName("powercrystals.minefactoryreloaded.net.ServerPacketHandler");
        MovingObjectPosition mop = Wrapper.INSTANCE.mc().objectMouseOver;
        TileEntity entity = Wrapper.INSTANCE.world().getTileEntity(mop.blockX, mop.blockY, mop.blockZ);
        if (entity == null) {
            this.off();
            return;
        }
        if (entity instanceof IInventory) {
            IInventory inv = (IInventory) entity;
            for (int i = 0; i < inv.getSizeInventory(); i++) {
                setSlot(i, mop.blockX, mop.blockY, mop.blockZ);
            }
        }
        InteropUtils.log("Cleared", this);
        this.off();
    } catch (Exception ex) {
        this.off();
    }
}
 
Example #9
Source File: HotGive.java    From ehacks-pro with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onTicks() {
    try {
        boolean newState = Keyboard.isKeyDown(GiveKeybind.getKey());
        if (newState && !prevState) {
            prevState = newState;
            MovingObjectPosition mop = Wrapper.INSTANCE.mc().objectMouseOver;
            TileEntity entity = Wrapper.INSTANCE.world().getTileEntity(mop.blockX, mop.blockY, mop.blockZ);
            if (entity != null && Class.forName("cofh.thermalexpansion.block.cache.TileCache").isInstance(entity)) {
                setSlot(entity, Statics.STATIC_ITEMSTACK);
                InteropUtils.log("Set", this);
            }
        }
        prevState = newState;
    } catch (Exception e) {
    }
}
 
Example #10
Source File: AimAssist.java    From ehacks-pro with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onTicks() {
    Entity entity;
    this.targetlist.clear();
    Wrapper.INSTANCE.world().playerEntities.stream().filter((e) -> !(!this.isAttackable((Entity) e) || (AuraConfiguration.config.friends.contains(((Entity) e).getCommandSenderName())))).forEachOrdered((e) -> {
        this.targetlist.add((EntityPlayer) e);
    });
    if (Wrapper.INSTANCE.mc().objectMouseOver == null) {
        return;
    }
    if (Wrapper.INSTANCE.mc().objectMouseOver.typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY && (entity = Wrapper.INSTANCE.mc().objectMouseOver.entityHit) instanceof EntityPlayer) {
        this.curtarget = (EntityPlayer) entity;
        return;
    }
    if (!this.targetlist.contains(this.curtarget) && this.curtarget != null) {
        this.curtarget = null;
        return;
    }
    Random r = new Random();
    if (this.curtarget == null) {
        return;
    }
    Wrapper.INSTANCE.player().rotationYaw = (float) (Wrapper.INSTANCE.player().rotationYaw - (Wrapper.INSTANCE.player().rotationYaw - this.getAngles(this.curtarget)[0]) * 0.5);
    Wrapper.INSTANCE.player().rotationPitch = (float) (Wrapper.INSTANCE.player().rotationPitch - (Wrapper.INSTANCE.player().rotationPitch - this.getAngles(this.curtarget)[1]) * 0.5);
}
 
Example #11
Source File: ShowContainer.java    From ehacks-pro with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onMouse(MouseEvent event) {
    try {
        boolean nowState = Mouse.isButtonDown(1);
        MovingObjectPosition position = Wrapper.INSTANCE.mc().objectMouseOver;
        if (position.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK && !prevState && nowState) {
            TileEntity tileEntity = Wrapper.INSTANCE.world().getTileEntity(position.blockX, position.blockY, position.blockZ);
            if (tileEntity instanceof IInventory) {
                ItemStack[] stacks = new ItemStack[0];
                Wrapper.INSTANCE.mc().displayGuiScreen(new ShowContainerGui(new ShowContainerContainer(stacks, tileEntity.getClass().getSimpleName())));
                if (event.isCancelable()) {
                    event.setCanceled(true);
                }
            } else {
                InteropUtils.log("Not a container", this);
            }
        }
        prevState = nowState;
    } catch (Exception ignored) {

    }
}
 
Example #12
Source File: Events.java    From ehacks-pro with GNU General Public License v3.0 6 votes vote down vote up
@SubscribeEvent
public void onAttack(AttackEntityEvent event) {
    if (!cheatEnabled) {
        return;
    }
    if (!(KillAura.isActive || MobAura.isActive || ProphuntAura.isActive || Forcefield.isActive || TriggerBot.isActive || !Criticals.isActive || Wrapper.INSTANCE.player().isInWater() || Wrapper.INSTANCE.player().isInsideOfMaterial(Material.lava) || Wrapper.INSTANCE.player().isInsideOfMaterial(Material.web) || !Wrapper.INSTANCE.player().onGround || !Wrapper.INSTANCE.mcSettings().keyBindAttack.getIsKeyPressed() || Wrapper.INSTANCE.mc().objectMouseOver == null || Wrapper.INSTANCE.mc().objectMouseOver.typeOfHit != MovingObjectPosition.MovingObjectType.ENTITY)) {
        event.setCanceled(true);
        Wrapper.INSTANCE.player().motionY = 0.1000000014901161;
        Wrapper.INSTANCE.player().fallDistance = 0.1f;
        Wrapper.INSTANCE.player().onGround = false;
        event.setCanceled(false);
    }
    if (event.target instanceof EntityPlayer) {
        EntityPlayer e = (EntityPlayer) event.target;
        if (SeeHealth.isActive) {
            InteropUtils.log("Health of &e" + e.getCommandSenderName() + "&f: &e" + e.getHealth(), "SeeHealth");
        }
    }
}
 
Example #13
Source File: TileEssentiaCompressor.java    From Gadomancy with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void playVortexEffects() {
    for (int a = 0; a < Thaumcraft.proxy.particleCount(1); a++) {
        int tx = this.xCoord + this.worldObj.rand.nextInt(4) - this.worldObj.rand.nextInt(4);
        int ty = this.yCoord + 1 + this.worldObj.rand.nextInt(4) - this.worldObj.rand.nextInt(4);
        int tz = this.zCoord + this.worldObj.rand.nextInt(4) - this.worldObj.rand.nextInt(4);
        if (ty > this.worldObj.getHeightValue(tx, tz)) {
            ty = this.worldObj.getHeightValue(tx, tz);
        }
        Vec3 v1 = Vec3.createVectorHelper(this.xCoord + 0.5D, this.yCoord + 1.5D, this.zCoord + 0.5D);
        Vec3 v2 = Vec3.createVectorHelper(tx + 0.5D, ty + 0.5D, tz + 0.5D);

        MovingObjectPosition mop = ThaumcraftApiHelper.rayTraceIgnoringSource(this.worldObj, v1, v2, true, false, false);
        if ((mop != null) && (getDistanceFrom(mop.blockX, mop.blockY, mop.blockZ) < 16.0D)) {
            tx = mop.blockX;
            ty = mop.blockY;
            tz = mop.blockZ;
            Block bi = this.worldObj.getBlock(tx, ty, tz);
            int md = this.worldObj.getBlockMetadata(tx, ty, tz);
            if (!bi.isAir(this.worldObj, tx, ty, tz)) {
                Thaumcraft.proxy.hungryNodeFX(this.worldObj, tx, ty, tz, this.xCoord, this.yCoord + 1, this.zCoord, bi, md);
            }
        }
    }
}
 
Example #14
Source File: General.java    From Chisel-2 with GNU General Public License v2.0 6 votes vote down vote up
public static MovingObjectPosition getMovingObjectPositionFromPlayer(World par1World, EntityPlayer par2EntityPlayer, boolean par3) {
	float var4 = 1.0F;
	float var5 = par2EntityPlayer.prevRotationPitch + (par2EntityPlayer.rotationPitch - par2EntityPlayer.prevRotationPitch) * var4;
	float var6 = par2EntityPlayer.prevRotationYaw + (par2EntityPlayer.rotationYaw - par2EntityPlayer.prevRotationYaw) * var4;
	double var7 = par2EntityPlayer.prevPosX + (par2EntityPlayer.posX - par2EntityPlayer.prevPosX) * var4;
	double var9 = par2EntityPlayer.prevPosY + (par2EntityPlayer.posY - par2EntityPlayer.prevPosY) * var4 + 1.62D - par2EntityPlayer.yOffset;
	double var11 = par2EntityPlayer.prevPosZ + (par2EntityPlayer.posZ - par2EntityPlayer.prevPosZ) * var4;
	// TODO- 1.7.10 fix?
	Vec3 var13 = Vec3.createVectorHelper(var7, var9, var11);
	float var14 = MathHelper.cos(-var6 * 0.017453292F - (float) Math.PI);
	float var15 = MathHelper.sin(-var6 * 0.017453292F - (float) Math.PI);
	float var16 = -MathHelper.cos(-var5 * 0.017453292F);
	float var17 = MathHelper.sin(-var5 * 0.017453292F);
	float var18 = var15 * var16;
	float var20 = var14 * var16;
	double var21 = 5.0D;

	if (par2EntityPlayer instanceof EntityPlayerMP) {
		var21 = ((EntityPlayerMP) par2EntityPlayer).theItemInWorldManager.getBlockReachDistance();
	}

	Vec3 var23 = var13.addVector(var18 * var21, var17 * var21, var20 * var21);
	return par1World.rayTraceBlocks(var13, var23, par3);
}
 
Example #15
Source File: ItemInfo.java    From NotEnoughItems with MIT License 5 votes vote down vote up
public static ArrayList<ItemStack> getIdentifierItems(World world, EntityPlayer player, MovingObjectPosition hit) {
    BlockPos pos = hit.getBlockPos();
    IBlockState state = world.getBlockState(pos);
    Block block = state.getBlock();

    ArrayList<ItemStack> items = new ArrayList<ItemStack>();

    ArrayList<IHighlightHandler> handlers = new ArrayList<IHighlightHandler>();
    if (highlightIdentifiers.containsKey(null))
        handlers.addAll(highlightIdentifiers.get(null));
    if (highlightIdentifiers.containsKey(block))
        handlers.addAll(highlightIdentifiers.get(block));
    for (IHighlightHandler ident : handlers) {
        ItemStack item = ident.identifyHighlight(world, player, hit);
        if (item != null)
            items.add(item);
    }

    if (items.size() > 0)
        return items;

    ItemStack pick = block.getPickBlock(hit, world, pos);
    if (pick != null)
        items.add(pick);

    try {
        items.addAll(block.getDrops(world, pos, state, 0));
    } catch (Exception ignored) {}
    if (block instanceof IShearable) {
        IShearable shearable = (IShearable) block;
        if (shearable.isShearable(new ItemStack(Items.shears), world, pos))
            items.addAll(shearable.onSheared(new ItemStack(Items.shears), world, pos, 0));
    }

    if (items.size() == 0)
        items.add(0, new ItemStack(block, 1, block.getMetaFromState(state)));

    return items;
}
 
Example #16
Source File: TileMoving.java    From Framez with GNU General Public License v3.0 5 votes vote down vote up
public ItemStack getPickBlock(MovingObjectPosition target, EntityPlayer player) {

        MovingObjectPosition mop = rayTrace(Framez.proxy.getPlayer());
        if (mop == null)
            return null;
        MovingBlock block = getSelected(mop);
        if (block == null)
            return null;

        return block.getBlock().getPickBlock(mop, FakeWorld.getFakeWorld(block), block.getX(), block.getY(), block.getZ(), player);
    }
 
Example #17
Source File: BlockMoving.java    From Framez with GNU General Public License v3.0 5 votes vote down vote up
@Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player) {

    TileMoving te = get(world, x, y, z);
    if (te == null)
        return null;
    return te.getPickBlock(target, player);
}
 
Example #18
Source File: ItemEntityEgg.java    From Et-Futurum with The Unlicense 5 votes vote down vote up
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
	if (world.isRemote)
		return stack;
	else {
		MovingObjectPosition movingobjectposition = getMovingObjectPositionFromPlayer(world, player, true);

		if (movingobjectposition == null)
			return stack;
		else {
			if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
				int i = movingobjectposition.blockX;
				int j = movingobjectposition.blockY;
				int k = movingobjectposition.blockZ;

				if (!world.canMineBlock(player, i, j, k))
					return stack;

				if (!player.canPlayerEdit(i, j, k, movingobjectposition.sideHit, stack))
					return stack;

				if (world.getBlock(i, j, k) instanceof BlockLiquid) {
					Entity entity = spawnEntity(world, stack.getItemDamage(), i, j, k);

					if (entity != null) {
						if (entity instanceof EntityLivingBase && stack.hasDisplayName())
							((EntityLiving) entity).setCustomNameTag(stack.getDisplayName());

						if (!player.capabilities.isCreativeMode)
							stack.stackSize--;
					}
				}
			}

			return stack;
		}
	}
}
 
Example #19
Source File: BlockCraftingGrid.java    From Translocators with MIT License 5 votes vote down vote up
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
    if (world.isRemote)
        return true;

    MovingObjectPosition hit = RayTracer.retraceBlock(world, player, x, y, z);
    TileCraftingGrid tcraft = (TileCraftingGrid) world.getTileEntity(x, y, z);

    if (hit != null) {
        if (hit.subHit > 0)
            tcraft.activate(hit.subHit - 1, player);
        return true;
    }
    return false;
}
 
Example #20
Source File: CommandEntityName.java    From OmniOcular with Apache License 2.0 5 votes vote down vote up
@Override
public void processCommand(ICommandSender sender, String[] array) {
    EntityPlayer player = (EntityPlayer) sender;
    Minecraft minecraft = Minecraft.getMinecraft();
    MovingObjectPosition objectMouseOver = minecraft.objectMouseOver;
    if (objectMouseOver.typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY) {
        Class pointEntityClass = objectMouseOver.entityHit.getClass();
        if (EntityList.classToStringMapping.containsKey(pointEntityClass)) {
            player.addChatComponentMessage(new ChatComponentText(EntityList.getEntityString(objectMouseOver.entityHit)));
        }
    } else {
        player.addChatComponentMessage(new ChatComponentTranslation("omniocular.info.NotPointing"));
    }
}
 
Example #21
Source File: ItemMorphPickaxe.java    From ForbiddenMagic with Do What The F*ck You Want To Public License 5 votes vote down vote up
@Override
public boolean onBlockStartBreak(ItemStack stack, int x, int y, int z, EntityPlayer player) {
    MovingObjectPosition movingobjectposition = BlockUtils.getTargetBlock(player.worldObj, player, true);
    if(movingobjectposition != null && movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
        this.side = movingobjectposition.sideHit;
    }

    return super.onBlockStartBreak(stack, x, y, z, player);
}
 
Example #22
Source File: BlockBanner.java    From Et-Futurum with The Unlicense 5 votes vote down vote up
@Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player) {
	TileEntityBanner banner = Utils.getTileEntity(world, x, y, z, TileEntityBanner.class);
	if (banner != null)
		return banner.createStack();

	return super.getPickBlock(target, world, x, y, z, player);
}
 
Example #23
Source File: ArmourStandInteractMessage.java    From Et-Futurum with The Unlicense 5 votes vote down vote up
public ArmourStandInteractMessage(int dimID, EntityArmourStand stand, EntityPlayer player) {
	this.dimID = dimID;
	standID = stand.getEntityId();
	playerID = player.getEntityId();
	MovingObjectPosition hit = Minecraft.getMinecraft().objectMouseOver;
	hitPos = Vec3.createVectorHelper(hit.hitVec.xCoord - stand.posX, hit.hitVec.yCoord - stand.posY, hit.hitVec.zCoord - stand.posZ);
}
 
Example #24
Source File: BlockQBlock.java    From qcraft-mod with Apache License 2.0 5 votes vote down vote up
@Override
public ItemStack getPickBlock( MovingObjectPosition target, World world, int x, int y, int z )
{
    TileEntity entity = world.getTileEntity( x, y, z );
    if( entity != null && entity instanceof TileEntityQBlock )
    {
        TileEntityQBlock qblock = (TileEntityQBlock) entity;
        return ItemQBlock.create( qblock.getSubType(), qblock.getTypes(), qblock.getEntanglementFrequency(), 1 );
    }
    return null;
}
 
Example #25
Source File: MinecraftHook.java    From SkyblockAddons with MIT License 5 votes vote down vote up
public static void rightClickMouse(ReturnValue<?> returnValue) {
    SkyblockAddons main = SkyblockAddons.getInstance();
    if (main.getUtils().isOnSkyblock()) {
        Minecraft mc = Minecraft.getMinecraft();
        if (mc.objectMouseOver != null && mc.objectMouseOver.typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY) {
            Entity entityIn = mc.objectMouseOver.entityHit;
            if (main.getConfigValues().isEnabled(Feature.DONT_OPEN_PROFILES_WITH_BOW)) {
                if (entityIn instanceof EntityOtherPlayerMP && !NPCUtils.isNPC(entityIn)) {
                    ItemStack item = mc.thePlayer.inventory.getCurrentItem();
                    ItemStack itemInUse = mc.thePlayer.getItemInUse();
                    if ((isItemBow(item) || isItemBow(itemInUse))) {
                        if (System.currentTimeMillis() - lastProfileMessage > 20000) {
                            lastProfileMessage = System.currentTimeMillis();
                            main.getUtils().sendMessage(main.getConfigValues().getRestrictedColor(Feature.DONT_OPEN_PROFILES_WITH_BOW) +
                                    Message.MESSAGE_STOPPED_OPENING_PROFILE.getMessage());
                        }
                        returnValue.cancel();
                        return;
                    }
                }
            }
            if (main.getConfigValues().isEnabled(Feature.LOCK_SLOTS) && entityIn instanceof EntityItemFrame && ((EntityItemFrame)entityIn).getDisplayedItem() == null) {
                int slot = mc.thePlayer.inventory.currentItem + 36;
                if (main.getConfigValues().getLockedSlots().contains(slot) && slot >= 9) {
                    main.getUtils().playLoudSound("note.bass", 0.5);
                    main.getUtils().sendMessage(main.getConfigValues().getRestrictedColor(Feature.DROP_CONFIRMATION) + Message.MESSAGE_SLOT_LOCKED.getMessage());
                    returnValue.cancel();
                }
            }
        }
    }
}
 
Example #26
Source File: ItemExplosionFocus.java    From Electro-Magic-Tools with GNU General Public License v3.0 5 votes vote down vote up
@Override
public ItemStack onFocusRightClick(ItemStack itemstack, World world, EntityPlayer player, MovingObjectPosition movingobjectposition) {
    ItemWandCasting wand = (ItemWandCasting) itemstack.getItem();
    if (wand.consumeAllVis(itemstack, player, getVisCost(), true, true)) {
        if (!world.isRemote) {
            EntityLaser laser;
            laser = new EntityLaser(world, player, 2);
            world.spawnEntityInWorld(laser);
        }
    }
    return itemstack;
}
 
Example #27
Source File: DrawBlockHighlightEvent.java    From Hyperium with GNU Lesser General Public License v3.0 5 votes vote down vote up
public DrawBlockHighlightEvent(@NotNull EntityPlayer player, @NotNull MovingObjectPosition target, float partialTicks) {
    Preconditions.checkNotNull(player, "player");
    Preconditions.checkNotNull(target, "target");

    this.player = player;
    this.target = target;
    this.partialTicks = partialTicks;
}
 
Example #28
Source File: BlockStoneMachine.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player) {
    int metadata = world.getBlockMetadata(x, y, z);
    if (metadata == 11 || metadata == 15) {
        return new ItemStack(getItemDropped(metadata, null, 0), 1, damageDropped(metadata));
    }

    return super.getPickBlock(target, world, x, y, z, player);
}
 
Example #29
Source File: MusicalCrash.java    From ehacks-pro with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onMouse(MouseEvent event) {
    MovingObjectPosition mop = Wrapper.INSTANCE.mc().objectMouseOver;
    if (mop.sideHit == -1) {
        return;
    }
    boolean nowState = Mouse.isButtonDown(1);
    if (!prevState && nowState) {
        prevState = nowState;
        TileEntity entity = Wrapper.INSTANCE.world().getTileEntity(mop.blockX, mop.blockY, mop.blockZ);
        try {
            if (mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK && entity != null && !Class.forName("eu.thesociety.DragonbornSR.DragonsRadioMod.Block.TileEntity.TileEntityRadio").isInstance(entity)) {
                ByteBuf buf = Unpooled.buffer(0);
                buf.writeByte(0);
                buf.writeInt(0);
                buf.writeDouble(mop.blockX);
                buf.writeDouble(mop.blockY);
                buf.writeDouble(mop.blockZ);
                buf.writeInt(Wrapper.INSTANCE.player().dimension);
                buf.writeInt(0);
                buf.writeBytes(new byte[0]);
                buf.writeBoolean(false);
                buf.writeFloat(0);
                buf.writeDouble(0);
                buf.writeDouble(0);
                buf.writeDouble(0);
                C17PacketCustomPayload packet = new C17PacketCustomPayload("DragonsRadioMod", buf);
                Wrapper.INSTANCE.player().sendQueue.addToSendQueue(packet);
                InteropUtils.log("Crash sent", this);
                if (event.isCancelable()) {
                    event.setCanceled(true);
                }
            }
        } catch (Exception ex) {
            InteropUtils.log("Error happened", this);
        }
    }
    prevState = nowState;
}
 
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 onBlockClicked(World world, int x, int y, int z, EntityPlayer player) {
	Block blockInstance = getBlockInstance(world, new Vector3D(x, y, z));
	MovingObjectPosition mop = player.rayTrace(10, 1);
	Block.LeftClickEvent evt = new Block.LeftClickEvent(EntityConverter.instance().toNova(player), Direction.fromOrdinal(mop.sideHit), new Vector3D(mop.hitVec.xCoord, mop.hitVec.yCoord, mop.hitVec.zCoord));
	blockInstance.events.publish(evt);
}