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

The following examples show how to use net.minecraft.entity.player.EntityPlayer#openGui() . 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: BlockMixin.java    From customstuff4 with GNU General Public License v3.0 6 votes vote down vote up
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
Source File: BlockPresent.java    From Chisel-2 with GNU General Public License v2.0 5 votes vote down vote up
@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 3
Source File: Collector.java    From EmergingTechnology with 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 4
Source File: Bioreactor.java    From EmergingTechnology with 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 5
Source File: BlockPressureChamberValve.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@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 6
Source File: ItemLogisticsFrame.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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 7
Source File: Battery.java    From EmergingTechnology with 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 8
Source File: ItemBookCode.java    From Minecoprocessors with GNU General Public License v3.0 5 votes vote down vote up
@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 9
Source File: BlockRD.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
@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 10
Source File: BlockEMTMachines.java    From Electro-Magic-Tools with GNU General Public License v3.0 5 votes vote down vote up
@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 11
Source File: BlockFluidKineticGenerator.java    From Production-Line with MIT License 5 votes vote down vote up
@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 12
Source File: Shredder.java    From EmergingTechnology with 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 13
Source File: ItemJournal.java    From AgriCraft with 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 14
Source File: Cooker.java    From EmergingTechnology with 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 15
Source File: BlockLevelEmitterFluid.java    From ExtraCells1 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 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 16
Source File: ItemQuickStacker.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
@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 17
Source File: ModKeybinds.java    From Wizardry with GNU Lesser General Public License v3.0 5 votes vote down vote up
@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 18
Source File: EntityCart.java    From TFC2 with 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 19
Source File: OpenBlock.java    From OpenModsLib with 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());
}
 
Example 20
Source File: ItemTrowel.java    From GardenCollection with 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;
}