Java Code Examples for net.minecraft.entity.player.EntityPlayer#openGui()

The following examples show how to use net.minecraft.entity.player.EntityPlayer#openGui() . These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
private boolean openGui(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn)
{
    Optional<ContentGuiBase> gui = getGui(state);

    if (gui.isPresent())
    {
        if (worldIn.isRemote)
        {
            return true;
        } else
        {
            playerIn.openGui(CustomStuff4.INSTANCE, gui.get().getGuiId(), worldIn, pos.getX(), pos.getY(), pos.getZ());

            return true;
        }
    }

    return false;
}
 
Example 2
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) {
    if (!world.isRemote) {
        player.openGui(ProductionLine.getInstance(), GuiHandler.EnumGui.FluidKineticGenerator.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
    }
    return true;
}
 
Example 3
Source Project: TFC2   File: EntityCart.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean processInitialInteract(EntityPlayer player, EnumHand hand)
{
	if (this.isBeingRidden() && getPassengers().get(0) instanceof EntityPlayer && getPassengers().get(0) != player)
	{
		return true;
	}
	else
	{
		double angle = Helper.normalizeAngle(getAngleToEntity(player));
		double fAngle = Helper.normalizeAngle(getFacingAngle());
		double revAngle =Helper.normalizeAngle(fAngle + 180);
		System.out.println(angle+"/"+fAngle);
		if(pullEntity == null && (angle > (fAngle - 25) && angle < (fAngle + 25)))
		{
			setPullEntity(player);
		}
		else if(this.getPassengers().size() < 1 && (angle > revAngle - 25 && angle < revAngle + 25))
		{
			player.startRiding(this);
			this.noClip = true;
		}
		else
		{
			PlayerManagerTFC.getInstance().getPlayerInfoFromPlayer(player).entityForInventory = this;
			if(!world.isRemote)
			{
				player.openGui(TFC.instance, 1, world, player.getPosition().getX(), player.getPosition().getY(), player.getPosition().getZ());
			}
		}

		return true;
	}
}
 
Example 4
@SideOnly(Side.CLIENT)
@SubscribeEvent
public static void onKey(InputEvent.KeyInputEvent event) {
	if (!Keyboard.isCreated()) return;

	EntityPlayer player = Minecraft.getMinecraft().player;
	if (player == null) return;

	if (pearlSwapping.isKeyDown() && player.getHeldItemMainhand().getItem() instanceof IPearlSwappable && !BaublesSupport.getItem(player, IPearlStorageHolder.class).isEmpty()) {
		player.openGui(Wizardry.instance, 1, player.world, (int) player.posX, (int) player.posY, (int) player.posZ);
	}
}
 
Example 5
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
{
    if (world.isRemote == false)
    {
        player.openGui(EnderUtilities.instance, ReferenceGuiIds.GUI_ID_QUICK_STACKER, world,
                (int)player.posX, (int)player.posY, (int)player.posZ);
    }

    return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, player.getHeldItem(hand));
}
 
Example 6
Source Project: ExtraCells1   File: BlockLevelEmitterFluid.java    License: 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 offsetX, float offsetY, float offsetZ)
{
	if (!world.isRemote)
	{
		if (world.getBlockTileEntity(x, y, z) == null || player.isSneaking())
		{
			return false;
		}
		PacketDispatcher.sendPacketToPlayer(world.getBlockTileEntity(x, y, z).getDescriptionPacket(), (Player) player);
		player.openGui(Extracells.instance, 6, world, x, y, z);
	}
	return true;
}
 
Example 7
Source Project: EmergingTechnology   File: Cooker.java    License: MIT License 5 votes vote down vote up
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn,
        EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {

    if (worldIn.isRemote) {
        return true;
    }

    playerIn.openGui(EmergingTechnology.instance, Reference.GUI_COOKER, worldIn, pos.getX(), pos.getY(),
            pos.getZ());

    return true;
}
 
Example 8
Source Project: AgriCraft   File: ItemJournal.java    License: MIT License 5 votes vote down vote up
@Override
@Nonnull
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
    if (world.isRemote) {
        player.openGui(AgriCraft.instance, GuiHandler.JOURNAL_GUI_ID, world, player.getPosition().getX(), player.getPosition().getY(), player.getPosition().getZ());
    }
    return new ActionResult<>(EnumActionResult.PASS, player.getHeldItem(hand));
}
 
Example 9
Source Project: EmergingTechnology   File: Shredder.java    License: MIT License 5 votes vote down vote up
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn,
        EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {

    if (worldIn.isRemote) {
        return true;
    }

    playerIn.openGui(EmergingTechnology.instance, Reference.GUI_SHREDDER, worldIn, pos.getX(), pos.getY(),
            pos.getZ());

    return true;
}
 
Example 10
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int hitX, float hitY, float hitZ, float p_149727_9_) {
	if (!world.isSideSolid(x, y + 1, z, ForgeDirection.DOWN)) {
		player.openGui(Chisel.instance, 2, world, x, y, z);
		return true;
	}
	return false;
}
 
Example 11
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) {
    if (!world.isRemote && world.getTileEntity(x, y, z) instanceof TileEntityIndustrialWandRecharge) {
        player.openGui(ElectroMagicTools.instance, 0, world, x, y, z);
    } else if (!world.isRemote && world.getTileEntity(x, y, z) instanceof TileEntityEtherealMacerator) {
        player.openGui(ElectroMagicTools.instance, 1, world, x, y, z);
    }
    return true;
}
 
Example 12
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
    if (worldIn.getTileEntity(pos) != null && getGuiBlueprint((TileRoutiduct) worldIn.getTileEntity(pos)) != null) {
        playerIn.openGui(CommunityMod.INSTANCE, 0, worldIn, pos.getX(), pos.getY(), pos.getZ());
        return true;
    }
    return super.onBlockActivated(worldIn, pos, state, playerIn, hand, side, hitX, hitY, hitZ);
}
 
Example 13
@Override
public ActionResult<ItemStack> onItemRightClick(final World world, final EntityPlayer player, final EnumHand hand) {
  if (world.isRemote) {
    player.openGui(Minecoprocessors.INSTANCE, MinecoprocessorGuiHandler.MINECOPROCESSOR_BOOK_GUI, world, 0, 0, 0);
  }
  return super.onItemRightClick(world, player, hand);
}
 
Example 14
Source Project: EmergingTechnology   File: Battery.java    License: MIT License 5 votes vote down vote up
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn,
        EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {

    if (worldIn.isRemote) {
        return true;
    }

    playerIn.openGui(EmergingTechnology.instance, Reference.GUI_BATTERY, worldIn, pos.getX(), pos.getY(),
            pos.getZ());

    return true;
}
 
Example 15
/**
 * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
 */
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player){
    if(!world.isRemote) {
        player.openGui(PneumaticCraft.instance, ((SemiBlockLogistics)getSemiBlock(world, 0, 0, 0, stack)).getGuiID().ordinal(), world, 0, 0, 0);
    }
    return stack;
}
 
Example 16
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9){
    if(player.isSneaking()) return false;
    TileEntity te = world.getTileEntity(x, y, z);
    if(!world.isRemote && te instanceof TileEntityPressureChamberValve) {
        if(((TileEntityPressureChamberValve)te).multiBlockSize > 0) {
            player.openGui(PneumaticCraft.instance, EnumGuiId.PRESSURE_CHAMBER.ordinal(), world, x, y, z);
        } else if(((TileEntityPressureChamberValve)te).accessoryValves.size() > 0) { // when
                                                                                     // this
                                                                                     // isn't
                                                                                     // the
                                                                                     // core
                                                                                     // Valve,
                                                                                     // track
                                                                                     // down
                                                                                     // the
                                                                                     // core
                                                                                     // Valve.
            //  System.out.println("size: " + ((TileEntityPressureChamberValve)te).accessoryValves.size());
            for(TileEntityPressureChamberValve valve : ((TileEntityPressureChamberValve)te).accessoryValves) {
                if(valve.multiBlockSize > 0) {
                    player.openGui(PneumaticCraft.instance, EnumGuiId.PRESSURE_CHAMBER.ordinal(), world, valve.xCoord, valve.yCoord, valve.zCoord);
                    break;
                }
            }
        } else {
            return false;
        }
        return true;
    }
    return true;
}
 
Example 17
Source Project: EmergingTechnology   File: Bioreactor.java    License: MIT License 5 votes vote down vote up
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn,
        EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {

    if (worldIn.isRemote) {
        return true;
    }

    playerIn.openGui(EmergingTechnology.instance, Reference.GUI_SCAFFOLDER, worldIn, pos.getX(), pos.getY(),
            pos.getZ());

    return true;
}
 
Example 18
Source Project: EmergingTechnology   File: Collector.java    License: MIT License 5 votes vote down vote up
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn,
        EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {

    if (worldIn.isRemote) {
        return true;
    }

    playerIn.openGui(EmergingTechnology.instance, Reference.GUI_COLLECTOR, worldIn, pos.getX(), pos.getY(),
            pos.getZ());

    return true;
}
 
Example 19
Source Project: GardenCollection   File: ItemTrowel.java    License: MIT License 4 votes vote down vote up
@Override
public boolean onItemUse (ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
    if (!player.canPlayerEdit(x, y, z, side, itemStack))
        return false;

    UseTrowelEvent event = new UseTrowelEvent(player, itemStack, world, x, y, z);
    if (MinecraftForge.EVENT_BUS.post(event))
        return false;

    if (event.getResult() == Event.Result.ALLOW) {
        itemStack.damageItem(1, player);
        return true;
    }

    if (side == 0)
        return false;

    Block block = world.getBlock(x, y, z);

    if (block instanceof BlockGarden) {
        player.openGui(GardenCore.instance, GuiHandler.gardenLayoutGuiID, world, x, y, z);
        return true;
    }
    else if (block instanceof IPlantProxy) {
        IPlantProxy proxy = (IPlantProxy) block;
        TileEntityGarden te = proxy.getGardenEntity(world, x, y, z);

        if (te != null) {
            player.openGui(GardenCore.instance, GuiHandler.gardenLayoutGuiID, world, te.xCoord, te.yCoord, te.zCoord);
            return true;
        }
    }

    /*if (world.getBlock(x, y + 1, z).isAir(world, x, y + 1, z) && (block == Blocks.grass || block == Blocks.dirt)) {
        Block.SoundType stepSound = ModBlocks.gardenSoil.stepSound;
        world.playSoundEffect( + .5f, y + .5f, z + .5f, stepSound.getStepResourcePath(), (stepSound.getVolume() + .5f) / 2, stepSound.getPitch() * .8f);

        if (!world.isRemote) {
            world.setBlock(x, y, z, ModBlocks.gardenSoil);
            itemStack.damageItem(1, player);
        }

        return true;
    }*/

    return false;
}
 
Example 20
Source Project: OpenModsLib   File: OpenBlock.java    License: MIT License 4 votes vote down vote up
public void openGui(EntityPlayer player, World world, BlockPos blockPos) {
	player.openGui(modInstance, OPEN_MODS_TE_GUI, world, blockPos.getX(), blockPos.getY(), blockPos.getZ());
}